Skip to content

rustup: Add option to skip download #21138

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

Merged
merged 1 commit into from
Jan 22, 2015
Merged

rustup: Add option to skip download #21138

merged 1 commit into from
Jan 22, 2015

Conversation

mkpankov
Copy link
Contributor

When combined with '--save' and '--date', it uses previously saved
tarball, making possible to re-install in offline mode.
r?

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (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. 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 CONTRIBUTING.md for more information.

@flaper87 flaper87 assigned brson and unassigned pcwalton Jan 14, 2015
download_package \
"${RUST_URL}/${RUST_TARBALL_NAME}" \
"${RUST_LOCAL_TARBALL}"
if [ "${CFG_SKIP_DOWNLOAD}" != 1 ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you change this to:

if [ -z "${CFG_SKIP_DOWNLOAD}" ]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@flaper87
Copy link
Contributor

@mkpankov thanks a lot for your patch. is rustup actually re-downloading things even when the tarball is present?

The download_package function already checks if the tarball exists before downloading it. https://github.com/mkpankov/rust/blob/master/src/etc/rustup.sh#L506

@mkpankov
Copy link
Contributor Author

@flaper87 the actual problem is verify_hash.
Call: https://github.com/mkpankov/rust/blob/master/src/etc/rustup.sh#L519
Definition: https://github.com/mkpankov/rust/blob/master/src/etc/rustup.sh#L457
Here it unconditionally downloads the remote SHA256, making it impossible to run the installation w/o Internet.

Should I check if rust-nightly-x86_64-unknown-linux-gnu.tar.gz.sha256 is present and treat it as a remote SHA256? Then I'd save a local one to something like rust-nightly-x86_64-unknown-linux-gnu.tar.gz.sha256.local and compare that.

@mkpankov
Copy link
Contributor Author

Should be fine now.

I now check if --save is specified and previously saved SHA is available. I then use it if possible for verification of whatever archive there happens to be.

I tested it in offline mode, specifying both --save and --date or just --date. Installer attempts to download stuff when it should.

local_file="$2"
local_sha_file="${local_file}.sha256"

if [ -n "${CFG_SAVE}" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since download_hash already checks on "${CFG_SAVE}" I believe this could become:

if [ -f "${local_sha_file}" ]; then
    ....
else
    download_hash
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, currently download_hash can be called when ${CFG_SAVE} is both specified or not specified.
In case of specified, if file exists, we use that. If file doesn't exist, we download it to compare with, and save for future use.
In case ${CFG_SAVE} is specified, we download the file anyway and don't save it since it's not requested.
Simplifying to suggested variant would mean we check existence of saved file when ${CFG_SAVE} wasn't specified at all. I believe we shouldn't look at local files when saving wasn't requested.

@flaper87
Copy link
Contributor

@mkpankov thanks for updating the patch. Would you mind squashing these commits into 1?

This way installer can work fully in offline mode.

Put pre-downloaded files
(rust-nightly-x86_64-unknown-linux-gnu.tar.gz and
 rust-nightly-x86_64-unknown-linux-gnu.tar.gz.sha256)
into the $HOME/.rustup/YYYY-MM-DD directory
as it would be done by script itself.

Specify --save and --date=YYYY-MM-DD when running.
Files will be picked up and used to install in offline mode.
@mkpankov
Copy link
Contributor Author

@flaper87 I squashed everything, fixing stuff you pointed out but leaving the two calls to download_hash. I explained it in line comment above :)

@brson
Copy link
Contributor

brson commented Jan 20, 2015

@bors: r+ 785176b

@flaper87
Copy link
Contributor

@mkpankov awesome, thanks for contributing!

@alexcrichton
Copy link
Member

@bors: rollup

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jan 21, 2015
When combined with '--save' and '--date', it uses previously saved
tarball, making possible to re-install in offline mode.
r?
@bors bors merged commit 785176b into rust-lang:master Jan 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants