diff --git a/src/combiner.rs b/src/combiner.rs index d084a85..3b827a3 100644 --- a/src/combiner.rs +++ b/src/combiner.rs @@ -83,15 +83,18 @@ impl Combiner { bail!("incorrect installer version in {}", input_tarball); } - // Move components to the new combined installer + // Copy components to the new combined installer let mut pkg_components = String::new(); open_file(pkg_dir.join("components")) .and_then(|mut file| file.read_to_string(&mut pkg_components).map_err(Error::from)) .chain_err(|| format!("failed to read components in '{}'", input_tarball))?; for component in pkg_components.split_whitespace() { - // All we need to do is move the component directory + // All we need to do is copy the component directory. We could + // move it, but rustbuild wants to reuse the unpacked package + // dir for OS-specific installers on macOS and Windows. let component_dir = package_dir.join(&component); - rename(&pkg_dir.join(&component), component_dir)?; + create_dir(&component_dir)?; + copy_recursive(&pkg_dir.join(&component), &component_dir)?; // Merge the component name writeln!(&components, "{}", component) diff --git a/src/util.rs b/src/util.rs index acc269a..d5beed1 100644 --- a/src/util.rs +++ b/src/util.rs @@ -79,13 +79,6 @@ pub fn remove_file>(path: P) -> Result<()> { .chain_err(|| format!("failed to remove file '{}'", path.as_ref().display())) } -/// Wrap `fs::rename` with a nicer error message -pub fn rename, Q: AsRef>(from: P, to: Q) -> Result<()> { - fs::rename(&from, &to) - .chain_err(|| format!("failed to rename '{}' to '{}'", - from.as_ref().display(), to.as_ref().display())) -} - /// Copies the `src` directory recursively to `dst`. Both are assumed to exist /// when this function is called. pub fn copy_recursive(src: &Path, dst: &Path) -> Result<()> { diff --git a/test.sh b/test.sh index 1012dd8..c85e4d3 100755 --- a/test.sh +++ b/test.sh @@ -946,6 +946,38 @@ list_components() { } runtest list_components +combined_remains() { + try sh "$S/gen-installer.sh" \ + --image-dir="$TEST_DIR/image1" \ + --work-dir="$WORK_DIR" \ + --output-dir="$OUT_DIR" \ + --package-name=rustc \ + --component-name=rustc + try sh "$S/gen-installer.sh" \ + --image-dir="$TEST_DIR/image3" \ + --work-dir="$WORK_DIR" \ + --output-dir="$OUT_DIR" \ + --package-name=cargo \ + --component-name=cargo + try sh "$S/gen-installer.sh" \ + --image-dir="$TEST_DIR/image4" \ + --work-dir="$WORK_DIR" \ + --output-dir="$OUT_DIR" \ + --package-name=rust-docs \ + --component-name=rust-docs + try sh "$S/combine-installers.sh" \ + --work-dir="$WORK_DIR" \ + --output-dir="$OUT_DIR" \ + --package-name=rust \ + --input-tarballs="$OUT_DIR/rustc.tar.gz,$OUT_DIR/cargo.tar.gz,$OUT_DIR/rust-docs.tar.gz" + for component in rustc cargo rust-docs; do + # rustbuild wants the original extracted package intact too + try test -d "$WORK_DIR/$component/$component" + try test -d "$WORK_DIR/rust/$component" + done +} +runtest combined_remains + # Upgrade tests upgrade_from_v1() {