-
Couldn't load subscription status.
- Fork 13.9k
rustbuild: canonicalize prefix install_sh
#49778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/bootstrap/install.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might have to be more careful about sysconfdir here. If it's an absolute path, then canonicalizing it is fine, but if it's relative, it'll be relative to prefix per the documentation, which makes this code (I believe) do the wrong thing.
I think I'd probably branch on is_absolute/is_relative on the path after mapping it to the default to determine if we need to canonicalize it (though it might be true that like all of the other paths, there's never a need to do so?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you're absolutely right. I was confused by the default value being "/etc" rather than "etc". Fixed.
1f1a16e to
cb9d219
Compare
install_shinstall_sh
src/bootstrap/install.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er, no, the previous default was correct I think? In that normally you want to have the sysconfdir be /etc and the rest of the dirs be relative to /usr/local. The confusing part of this is that Path::new("/usr/local").join("/etc") evaluates to /etc which is somewhat unexpected, though correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, wow - that is very surprising, but of course, you are right. https://play.rust-lang.org/?gist=9fca8ef12a8ac532ceaa12383983c62f&version=stable
Fixed again!
Testing: ``` $ git diff diff --git a/config.toml.example b/config.toml.example index 9dd3002..b47bc490cd 100644 --- a/config.toml.example +++ b/config.toml.example @@ -196,7 +196,7 @@ [install] # Instead of installing to /usr/local, install to this path instead. -#prefix = "/usr/local" +prefix = "install-prefix" # Where to install system configuration files # If this is a relative path, it will get installed in `prefix` above $ mkdir install-prefix $ ./x.py install -i --stage 0 --config config.toml.example ... $ ls install-prefix/ bin lib share ``` Closes rust-lang#36989.
cb9d219 to
9487902
Compare
|
@bors r+ rollup (can't fail because, well, not tested...) |
|
📌 Commit 9487902 has been approved by |
rustbuild: canonicalize prefix `install_sh` Testing: ``` $ git diff diff --git a/config.toml.example b/config.toml.example index 9dd3002..b47bc490cd 100644 --- a/config.toml.example +++ b/config.toml.example @@ -196,7 +196,7 @@ [install] # Instead of installing to /usr/local, install to this path instead. -#prefix = "/usr/local" +prefix = "install-prefix" # Where to install system configuration files # If this is a relative path, it will get installed in `prefix` above $ mkdir install-prefix $ ./x.py install -i --stage 0 --config config.toml.example ... $ ls install-prefix/ bin lib share ``` Closes #36989. r? @Mark-Simulacrum
|
☀️ Test successful - status-appveyor, status-travis |
PR rust-lang#49778 introduced fs::canonicalize() which fails for a nonexistent path. This is a surprise for someone used to GNU Autotools' configure which can create any necessary intermediate directories in prefix. This change makes it run fs::create_dir_all() before canonicalize().
…ent-prefix, r=Mark-Simulacrum bootstrap/install.rs: support a nonexistent `prefix` in `x.py install` PR rust-lang#49778 introduced fs::canonicalize() which fails for a nonexistent path. This is a surprise for someone used to GNU Autotools' configure which can create any necessary intermediate directories in prefix. This change makes it run fs::create_dir_all() before canonicalize().
…ent-prefix, r=Mark-Simulacrum bootstrap/install.rs: support a nonexistent `prefix` in `x.py install` PR rust-lang#49778 introduced fs::canonicalize() which fails for a nonexistent path. This is a surprise for someone used to GNU Autotools' configure which can create any necessary intermediate directories in prefix. This change makes it run fs::create_dir_all() before canonicalize().
…ent-prefix, r=Mark-Simulacrum bootstrap/install.rs: support a nonexistent `prefix` in `x.py install` PR rust-lang#49778 introduced fs::canonicalize() which fails for a nonexistent path. This is a surprise for someone used to GNU Autotools' configure which can create any necessary intermediate directories in prefix. This change makes it run fs::create_dir_all() before canonicalize().
Testing:
Closes #36989.
r? @Mark-Simulacrum