summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2017-05-12 23:22:52 -0700
committerJosh Stone <jistone@redhat.com>2017-05-12 23:22:52 -0700
commiteda1fc85cc369656443a2e17680253ca367456d6 (patch)
tree72ad4993e2f1cc7a95debc49c00bf8af52376e40
parentdaff0798e43cc2cd44b3528aab2bf363d8bf212d (diff)
downloadrust-installer-eda1fc85cc369656443a2e17680253ca367456d6.tar.gz
Revert "Move the combined components instead of copying"
This reverts commit 4f6e020b179ef79a3e3717f80132ad1a4875a669. We need to leave the unpacked input packages intact for rustbuild to reuse in OS-specific installers on macOS and Windows. Add a test to make sure the components are still present.
-rw-r--r--src/combiner.rs9
-rw-r--r--src/util.rs7
-rwxr-xr-xtest.sh32
3 files changed, 38 insertions, 10 deletions
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<P: AsRef<Path>>(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<P: AsRef<Path>, Q: AsRef<Path>>(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() {