Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uprustbuild: Verify sha256 of downloaded tarballs #32926
Conversation
rust-highfive
assigned
aturon
Apr 13, 2016
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
rust-highfive
assigned
alexcrichton
and unassigned
aturon
Apr 13, 2016
mitaa
reviewed
Apr 13, 2016
| if sys.platform == 'win32': | ||
| run(["PowerShell.exe", "/nologo", "-Command", | ||
| "(New-Object System.Net.WebClient).DownloadFile('" + url + | ||
| "', '" + path + "')"], verbose=verbose) |
This comment has been minimized.
This comment has been minimized.
mitaa
Apr 13, 2016
Contributor
While you're here I think this would be much more readable as
"(New-Object System.Net.WebClient).DownloadFile('{}', '{}')".format(url, path)(I think .format is more idiomatic than str + foo anyway)
This comment has been minimized.
This comment has been minimized.
|
Thanks @caipre! Your thoughts on #32902 (comment) were actually spot on, I was thinking of committing the hash into the source tree itself (e.g. a line in |
This comment has been minimized.
This comment has been minimized.
|
Also while you're at it, wanna take care of #32834 as well? It would basically involve downloading into |
mitaa
reviewed
Apr 13, 2016
| with open(path, "rb") as f: | ||
| found = hashlib.sha256(f.read()).hexdigest() | ||
| if found != expected: | ||
| if not verbose: |
This comment has been minimized.
This comment has been minimized.
mitaa
Apr 13, 2016
Contributor
if verbose:? Or just put it in raise RuntimeError("invalid checksum: {}".format(local_sum))?
Where is local_sum defined? Should probably be found?
This comment has been minimized.
This comment has been minimized.
caipre
Apr 13, 2016
Author
Contributor
Good eye, thanks. I must've missed renaming this one.
I think it makes sense to put this RuntimeError and the one in run() behind the verbose flag.
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton: Okay, I can do it that way. It's a bit ugly though, since we'll have to put the shas of all the different build triples for the various tarballs into the How is the snapshot build decided upon? Is there a parameter set as part of some build script when a new snapshot is selected? Regarding #32834, looks like @cyplo is actively working on it, so I'll let them run with it for now. |
This comment has been minimized.
This comment has been minimized.
|
Hi @caipre ! Shall we sync the development here in some way ? e.g. me branching off these changes instead of master or waiting for the sha check first ? Or the other way round, shall I try to make the change quickly so you can add the sha check there ? Let me know how would you like for this to work. Thanks ! |
This comment has been minimized.
This comment has been minimized.
|
If there are merge conflicts they shouldn't be too hairy, so I don't think we need to coordinate our work too much. If mine lands first, I'm happy to help you resolve conflicts if necessary. Don't branch off this commit as I won't be using it per the comments from Alex. |
This comment has been minimized.
This comment has been minimized.
|
Gah right, sorry @cyplo and @caipre! Disregard me :) I agree though that the merge conflicts here, although they'll probably exist, should be easy to fix. This is essentially just verifying after the download, so whatever logic we have for downloading will fit well above it.
Hm yeah, that's a good point. @brson do you have thoughts on this? Should we check the sha256 in the repo or just download it like rustup and verify both downloads?
Right now it's just the date in |
This comment has been minimized.
This comment has been minimized.
|
I was more asking why/how the date is chosen. Why Maybe I'll take a look at the logic for which stage0 compiler is downloaded. |
This comment has been minimized.
This comment has been minimized.
|
Oh that's actually relatively arbitrary right now. Starting very soon though it will become the previous release. (e.g. 1.10 will bootstrap from 1.9) |
This comment has been minimized.
This comment has been minimized.
|
Ok, checked in with @brson on IRC and he thinks we should just download the sha256, so let's stick with that strategy |
This comment has been minimized.
This comment has been minimized.
|
Ok, apart from the comments by @mitaa, could you also fold this directly into the |
This comment has been minimized.
This comment has been minimized.
|
I originally had it folded into |
This comment has been minimized.
This comment has been minimized.
|
Oh sorry that was just intended for the in-transit file. Once we've downloaded and verified there's no need to verify it again I believe |
caipre
added some commits
Apr 14, 2016
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton: Okay, I've pushed new commits that address the comments so far. Thanks! |
This comment has been minimized.
This comment has been minimized.
alexcrichton
referenced this pull request
Apr 14, 2016
Closed
Tracking issue for rustbuild, the alternate build system for rustc #31590
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Apr 14, 2016
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors: retry On Thu, Apr 14, 2016 at 12:24 PM, bors notifications@github.com wrote:
|
caipre commentedApr 13, 2016
Here's a quick first pass at this.
I don't use Python often enough to claim that this is totally Pythonic. I've left off some (almost certainly unnecessary) error handling regarding opening and processing files. The whole tarball is read into memory to calculate the hash, but the file isn't so large so that should be fine. I don't care for the output from
raise RuntimeError, but that's howrun()does it so I'm following precedent.Tested by manually changing the value of
expected, and by modifying the tarball then forcingrustc_out_of_date(). Both cases tripped the error.Closes #32902