-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
rewrite rustup to protect against truncation errors #19170
Conversation
then | ||
MAYBE_PREFIX="--prefix=${CFG_PREFIX}" | ||
CFG_NIGHTLY=`date "+%Y-%m-%d"` |
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 should still default to downloading from rust-nightly-...
because we're not always guaranteed to have nightlies for each date (they could fail to sync).
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.
or... I may not know how to read bash. So let me confirm instead! This doesn't download from a specific date with no flags specified, right?
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.
Yes, when no flag is specified it downloads the current nightly, which does not include the date in the url.
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 this sets the cache dir based on the local system's date? If so, won't it fail to update if a new nightly is available on the server, but the date hasn't yet changed on my computer (e.g. if I'm in a different timezone)?
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 agree with this comment. It is very likely the dates will get out of sync. I'd suggest that if a specific date isn't provided that either a) --save has no effect, b) it is stored directly in the .rustup
folder and the .sha256
file (which exists for all tarballs) is d/l'd and used to determine if it is fresh before using.
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.
Alternately, it could be stored in the dated folder, but all cached installs could be checksummed from the network before installing. Might be a slightly simpler arrangement.
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, hm. It looks like because of https://github.com/erickt/rust/blob/9afe5de38d279a0cc127b038c072e849adaffe18/src/etc/rustup.sh#L495, if --save
is selected then the script tries to download from the archives using today's date. That solves the problem of the dates being out of sync, but adds the problem that today may not have a nightly yet. I at least like this better since --save
is not the default, but it's a bit wonky.
(My original comment may have been confusing since I didn't notice this).
Just confirming, but you've run this multiple times in a few flavorful configurations, to make sure it works, right? |
also otherwise looks good to me, r? @brson (good to have two sets of eyes on shell scripts) |
Hm I checked this out locally and got this error:
|
This change appears to ignore the The old script did all downloading before all installing, which seems appropriate to me: get the fallable network business done first. I think I'd prefer to preserve that behavior. What does it mean to 'protect against truncation'? Is it that everything is wrapped in a function call, so the entire function has to be downloaded before anything in the script can be run? If so please spell that out in comments so I don't forget. I presume the use-case for In anticipation of release channels we might want to futureproof the name of the |
shell can be confusing to read, so I refactored the code into a bunch of small, incremental changes. I've also pulled out the caching behavior for a future PR so that we can land a safer |
7b02098
to
76fbf57
Compare
@erickt hm I still get an odd error locally, maybe a different one?
|
This closes rust-lang#19168. It's possible that if the downloading of `rustup.sh` is interrupted, bad things could happen, such as running a naked "rm -rf /" instead of "rm -rf /path/to/tmpdir". This wraps rustup.sh's functionality in a function that gets called at the last time that should protect us from these truncation errors.
|
It should have GPG signatures for nightlies just as it does for the tagged releases. |
There can be a separate key for whatever automated builder is responsible for making them. |
Nightlies do have a .sha256 hash file along side of the tar balls. I've got a patch queued up that checks the hash, I just had enough trouble with this PR I wanted land this first before I do the next round of patches. |
This closes #19168. Please be careful reviewing this since this gets used all over the place. I've tested all the options and everything appears to be working though.
minor: Update lockfile
This closes #19168.
Please be careful reviewing this since this gets used all over the place. I've tested all the options and everything appears to be working though.