diff --git a/src/main.rs b/src/main.rs index 305b8a1..6f43342 100644 --- a/src/main.rs +++ b/src/main.rs @@ -508,17 +508,30 @@ impl Context { // Construct the path that contains the documentation inside the tarball. let tarball_dir = format!("{tarball_prefix}/rustc-docs/share/doc/rust/html"); - let tarball_dir_new = format!("{tarball_dir}/rustc"); - - if Command::new("tar") - .arg("tf") - .arg(&tarball) - .arg(&tarball_dir_new) - .current_dir(&rustc_docs) - .output()? - .status - .success() - { + + // NOTE: The following logic is to accommodate 3 different `rustc-docs` structures that + // have existed over time, in the chronological order: + // - No subdirectory: `share/doc/rust/html/...` + // - With `rustc/` subdirectory: `share/doc/rust/html/rustc/...` + // - With `rustc-docs/` subdirectory: `share/doc/rust/html/rustc-docs/...` + let mut tarball_dir_new = None; + for subdir in ["rustc-docs", "rustc"] { + let candidate = format!("{tarball_dir}/{subdir}"); + if Command::new("tar") + .arg("tf") + .arg(&tarball) + .arg(&candidate) + .current_dir(&rustc_docs) + .output()? + .status + .success() + { + // The candidate directory exists in the tarball. + tarball_dir_new = Some(candidate); + break; + } + } + if let Some(tarball_dir_new) = tarball_dir_new { // Unpack the rustc documentation into the new directory. // // Touch all files as well (see above for why). run(Command::new("tar")