Skip to content

Commit eda1fc8

Browse files
committed
Revert "Move the combined components instead of copying"
This reverts commit 4f6e020. 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.
1 parent daff079 commit eda1fc8

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

src/combiner.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,18 @@ impl Combiner {
8383
bail!("incorrect installer version in {}", input_tarball);
8484
}
8585

86-
// Move components to the new combined installer
86+
// Copy components to the new combined installer
8787
let mut pkg_components = String::new();
8888
open_file(pkg_dir.join("components"))
8989
.and_then(|mut file| file.read_to_string(&mut pkg_components).map_err(Error::from))
9090
.chain_err(|| format!("failed to read components in '{}'", input_tarball))?;
9191
for component in pkg_components.split_whitespace() {
92-
// All we need to do is move the component directory
92+
// All we need to do is copy the component directory. We could
93+
// move it, but rustbuild wants to reuse the unpacked package
94+
// dir for OS-specific installers on macOS and Windows.
9395
let component_dir = package_dir.join(&component);
94-
rename(&pkg_dir.join(&component), component_dir)?;
96+
create_dir(&component_dir)?;
97+
copy_recursive(&pkg_dir.join(&component), &component_dir)?;
9598

9699
// Merge the component name
97100
writeln!(&components, "{}", component)

src/util.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> Result<()> {
7979
.chain_err(|| format!("failed to remove file '{}'", path.as_ref().display()))
8080
}
8181

82-
/// Wrap `fs::rename` with a nicer error message
83-
pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<()> {
84-
fs::rename(&from, &to)
85-
.chain_err(|| format!("failed to rename '{}' to '{}'",
86-
from.as_ref().display(), to.as_ref().display()))
87-
}
88-
8982
/// Copies the `src` directory recursively to `dst`. Both are assumed to exist
9083
/// when this function is called.
9184
pub fn copy_recursive(src: &Path, dst: &Path) -> Result<()> {

test.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,38 @@ list_components() {
946946
}
947947
runtest list_components
948948

949+
combined_remains() {
950+
try sh "$S/gen-installer.sh" \
951+
--image-dir="$TEST_DIR/image1" \
952+
--work-dir="$WORK_DIR" \
953+
--output-dir="$OUT_DIR" \
954+
--package-name=rustc \
955+
--component-name=rustc
956+
try sh "$S/gen-installer.sh" \
957+
--image-dir="$TEST_DIR/image3" \
958+
--work-dir="$WORK_DIR" \
959+
--output-dir="$OUT_DIR" \
960+
--package-name=cargo \
961+
--component-name=cargo
962+
try sh "$S/gen-installer.sh" \
963+
--image-dir="$TEST_DIR/image4" \
964+
--work-dir="$WORK_DIR" \
965+
--output-dir="$OUT_DIR" \
966+
--package-name=rust-docs \
967+
--component-name=rust-docs
968+
try sh "$S/combine-installers.sh" \
969+
--work-dir="$WORK_DIR" \
970+
--output-dir="$OUT_DIR" \
971+
--package-name=rust \
972+
--input-tarballs="$OUT_DIR/rustc.tar.gz,$OUT_DIR/cargo.tar.gz,$OUT_DIR/rust-docs.tar.gz"
973+
for component in rustc cargo rust-docs; do
974+
# rustbuild wants the original extracted package intact too
975+
try test -d "$WORK_DIR/$component/$component"
976+
try test -d "$WORK_DIR/rust/$component"
977+
done
978+
}
979+
runtest combined_remains
980+
949981
# Upgrade tests
950982

951983
upgrade_from_v1() {

0 commit comments

Comments
 (0)