-
Notifications
You must be signed in to change notification settings - Fork 785
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
Simplify truffleruby+graalvm-dev
build definition re: download redirect
#2361
Conversation
…rect The `http get <url> <destfile>` utility had a bug with aria2c downloader where it couldn't properly save to destfile if it was an absolute path. I have tried having `http get <url> -` output the downloaded file to stdout, but this conflicted with the output of `log_command` (which is also to stdout) so for now let's keep using the temporary file to resolve manual URL redirects.
@@ -1,26 +1,24 @@ | |||
platform="$(uname -s)-$(uname -m)" | |||
case $platform in | |||
Linux-x86_64) | |||
url="https://raw.githubusercontent.com/graalvm/graal-languages-ea-builds/main/truffleruby/versions/latest-jvm-linux-amd64.url" | |||
url="https://github.com/graalvm/graal-languages-ea-builds/raw/HEAD/truffleruby/versions/latest-jvm-linux-amd64.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.
Let's stick to using github.com
URLs instead of raw.githubusercontent.com
since the latter is an implementation detail of GitHub which might change in the future.
popd | ||
|
||
install_package "truffleruby+graalvm-dev" "$url" truffleruby | ||
urlfile="$(mktemp "${TMP}/truffleruby.XXXXXX")" |
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.
We still save the download to a temporary file, but now we don't have to change the directory to work around aria2c limitation.
local destfile="$2" | ||
if [[ $destfile == /* ]]; then | ||
# the "-o" option to aria2c cannot be an absolute path, but we can achieve that with "--dir" | ||
# shellcheck disable=SC2086 | ||
log_command aria2c --allow-overwrite=true --no-conf=true --console-log-level=warn --stderr $ARIA2_OPTS --dir "${destfile%/*}" -o "${destfile##*/}" "$1" 2>&3 | ||
else | ||
# shellcheck disable=SC2086 | ||
log_command aria2c --allow-overwrite=true --no-conf=true --console-log-level=warn --stderr $ARIA2_OPTS -o "$destfile" "$1" 2>&3 | ||
fi |
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.
Makes sense to me, and I confirmed it works with "file", "subdir/file" and "/abs/path".
You could reduce a bit of duplication:
local destfile="$2" | |
if [[ $destfile == /* ]]; then | |
# the "-o" option to aria2c cannot be an absolute path, but we can achieve that with "--dir" | |
# shellcheck disable=SC2086 | |
log_command aria2c --allow-overwrite=true --no-conf=true --console-log-level=warn --stderr $ARIA2_OPTS --dir "${destfile%/*}" -o "${destfile##*/}" "$1" 2>&3 | |
else | |
# shellcheck disable=SC2086 | |
log_command aria2c --allow-overwrite=true --no-conf=true --console-log-level=warn --stderr $ARIA2_OPTS -o "$destfile" "$1" 2>&3 | |
fi | |
local destfile="$2" | |
local args=() | |
if [[ $destfile == /* ]]; then | |
# the "-o" option to aria2c cannot be an absolute path, but we can achieve that with "--dir" | |
args+=(--dir "${destfile%/*}" -o "${destfile##*/}") | |
else | |
args+=(-o "$destfile") | |
fi | |
# shellcheck disable=SC2086 | |
log_command aria2c --allow-overwrite=true --no-conf=true --console-log-level=warn --stderr $ARIA2_OPTS "${args[@]}" "$1" 2>&3 |
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.
@rwstauner Thanks for the deduplication suggestion, but I find that I prefer seeing the full aria2c
invocation line in both instances even if there is a little duplication, mostly for the ease of reading.
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.
LGTM, I checked locally and it works with aria2c
.
I don't know well temp files in Bash so I was happy with my solution in #2356.
This looks fine too. It might not delete the tempfile until repeat if the installation fails but that seems OK.
FWIW I also tried to pass -
as the file but aria2c creates a file named -
, unlike wget/curl which behave as expected and print to stdout, oh well.
Yeah, that inconsistency worries me. I think a future change to our |
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.
2024-05-01T13:48:16.3879451Z Cleaning up orphan processes
The
http get <url> <destfile>
utility had a bug with aria2c downloader where it couldn't properly save to destfile if it was an absolute path.I have tried having
http get <url> -
consistently print the downloaded file to stdout, but this conflicted with the output oflog_command
(which is also to stdout) so for now let's keep using the temporary file to resolve manual URL redirects.Followup to #2356 /cc @rwstauner