Skip to content

Commit a7f515b

Browse files
committed
docker: use update-toolchain in entrypoint
using update-toolchain instead of add-essential files installs the toolchain first if it doesn't exist. This still keeps the `add-essential-files` command in case someone needs to update the essential files without updating the toolchain version.
1 parent e58ee86 commit a7f515b

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

docker-entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ if ! [ -d "${CRATESFYI_PREFIX}/crates.io-index/.git" ]; then
3636
git --git-dir="$CRATESFYI_PREFIX/crates.io-index/.git" branch crates-index-diff_last-seen
3737
fi
3838

39-
cratesfyi build add-essential-files --only-first-time
39+
cratesfyi build update-toolchain --only-first-time
4040

4141
cratesfyi "$@"

src/bin/cratesfyi.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ pub fn main() {
6565
.takes_value(true)
6666
.conflicts_with_all(&["CRATE_NAME", "CRATE_VERSION"])
6767
.help("Build a crate at a specific path")))
68-
.subcommand(SubCommand::with_name("add-essential-files")
69-
.about("Adds essential files for rustc")
68+
.subcommand(SubCommand::with_name("update-toolchain")
69+
.about("update the curretntly installed rustup toolchain")
7070
.arg(Arg::with_name("ONLY_FIRST_TIME")
7171
.long("only-first-time")
72-
.help("add essential files only if no essential files are present")))
72+
.help("update toolchain only if no toolchain is currently installed")))
73+
.subcommand(SubCommand::with_name("add-essential-files")
74+
.about("Adds essential files for the installed version of rustc"))
7375
.subcommand(SubCommand::with_name("lock").about("Locks cratesfyi daemon to stop \
7476
building new crates"))
7577
.subcommand(SubCommand::with_name("unlock")
@@ -171,18 +173,20 @@ pub fn main() {
171173
matches.value_of("CRATE_NAME").unwrap(), matches.value_of("CRATE_VERSION").unwrap(), None),
172174
}.expect("Building documentation failed");
173175
docbuilder.save_cache().expect("Failed to save cache");
174-
} else if let Some(m) = matches.subcommand_matches("add-essential-files") {
176+
} else if let Some(m) = matches.subcommand_matches("update-toolchain") {
175177
if m.is_present("ONLY_FIRST_TIME") {
176178
let conn = db::connect_db().unwrap();
177179
let res = conn.query("SELECT * FROM config WHERE name = 'rustc_version';", &[]).unwrap();
178180
if !res.is_empty() {
179-
println!("add-essential files was already called in the past, exiting");
181+
println!("update-toolchain was already called in the past, exiting");
180182
return;
181183
}
182184
}
183-
184185
let mut builder = RustwideBuilder::init().unwrap();
185-
builder.update_toolchain().expect("failed to add essential files");
186+
builder.update_toolchain().expect("failed to update toolchain");
187+
} else if matches.subcommand_matches("add-essential-files").is_some() {
188+
let mut builder = RustwideBuilder::init().unwrap();
189+
builder.add_essential_files().expect("failed to add essential files");
186190
} else if let Some(_) = matches.subcommand_matches("lock") {
187191
docbuilder.lock().expect("Failed to lock");
188192
} else if let Some(_) = matches.subcommand_matches("unlock") {

src/docbuilder/rustwide_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl RustwideBuilder {
127127
}
128128
}
129129

130-
fn add_essential_files(&mut self) -> Result<()> {
130+
pub fn add_essential_files(&mut self) -> Result<()> {
131131
self.rustc_version = self.detect_rustc_version()?;
132132
let rustc_version = parse_rustc_version(&self.rustc_version)?;
133133

0 commit comments

Comments
 (0)