Skip to content

Commit

Permalink
make sure installer only creates directories in DESTDIR
Browse files Browse the repository at this point in the history
Fixes #80238

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Dec 20, 2020
1 parent 2ad5292 commit fbc9d50
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,7 @@ fn install_sh(
let docdir_default = datadir_default.join("doc/rust");
let libdir_default = PathBuf::from("lib");
let mandir_default = datadir_default.join("man");
let prefix = builder.config.prefix.as_ref().map_or(prefix_default, |p| {
fs::create_dir_all(p)
.unwrap_or_else(|err| panic!("could not create {}: {}", p.display(), err));
fs::canonicalize(p)
.unwrap_or_else(|err| panic!("could not canonicalize {}: {}", p.display(), err))
});
let prefix = builder.config.prefix.as_ref().unwrap_or(&prefix_default);
let sysconfdir = builder.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default);
let datadir = builder.config.datadir.as_ref().unwrap_or(&datadir_default);
let docdir = builder.config.docdir.as_ref().unwrap_or(&docdir_default);
Expand All @@ -103,6 +98,13 @@ fn install_sh(
let libdir = add_destdir(&libdir, &destdir);
let mandir = add_destdir(&mandir, &destdir);

let prefix = {
fs::create_dir_all(&prefix)
.unwrap_or_else(|err| panic!("could not create {}: {}", prefix.display(), err));
fs::canonicalize(&prefix)
.unwrap_or_else(|err| panic!("could not canonicalize {}: {}", prefix.display(), err))
};

let empty_dir = builder.out.join("tmp/empty_dir");

t!(fs::create_dir_all(&empty_dir));
Expand Down

0 comments on commit fbc9d50

Please sign in to comment.