mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-07 20:31:01 -05:00
Support aria2c
being a snap (#2528)
Likely in Ubuntu where it's only available as a snap
This commit is contained in:
parent
c162dcd932
commit
31355676f0
2 changed files with 29 additions and 3 deletions
|
@ -360,12 +360,38 @@ http_head_aria2c() {
|
|||
}
|
||||
|
||||
http_get_aria2c() {
|
||||
local out="${2:-$(mktemp "out.XXXXXX")}"
|
||||
if aria2c --allow-overwrite=true --no-conf=true -o "${out}" ${ARIA2_OPTS} "$1" >&4; then
|
||||
# aria2c always treats -o argument as a relative path
|
||||
local out dir_out;
|
||||
if [[ -n "$2" ]]; then
|
||||
out="$(basename $2)";
|
||||
dir_out="$(dirname $2)";
|
||||
else
|
||||
out="$(mktemp "out.XXXXXX")";
|
||||
dir_out="$TMPDIR";
|
||||
fi
|
||||
|
||||
# In Ubuntu, aria2c is only available as a snap. Snaps cannot read or write /tmp
|
||||
# (files cannot be found, any write result is silently discarded).
|
||||
local aria2c_is_snap;
|
||||
if [[ $(command -v aria2c) == "/snap/"* ]]; then aria2c_is_snap=1; fi
|
||||
|
||||
if [[ -n $aria2c_is_snap ]]; then
|
||||
local real_dir_out="$dir_out"
|
||||
# presumably, snaps can always write to under $HOME
|
||||
dir_out="$HOME"
|
||||
fi
|
||||
|
||||
if aria2c --allow-overwrite=true --no-conf=true -d "${dir_out}" -o "${out}" ${ARIA2_OPTS} "$1" >&4; then
|
||||
[ -n "$2" ] || cat "${out}"
|
||||
else
|
||||
false
|
||||
fi
|
||||
ret=$?
|
||||
|
||||
if [[ -n "$2" && -n $aria2c_is_snap ]]; then
|
||||
mv "$dir_out/$out" "$real_dir_out/$out"
|
||||
fi
|
||||
return "$ret"
|
||||
}
|
||||
|
||||
http_head_curl() {
|
||||
|
|
|
@ -21,7 +21,7 @@ setup() {
|
|||
@test "using aria2c if available" {
|
||||
export PYTHON_BUILD_ARIA2_OPTS=
|
||||
export -n PYTHON_BUILD_HTTP_CLIENT
|
||||
stub aria2c "--allow-overwrite=true --no-conf=true -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
|
||||
stub aria2c "--allow-overwrite=true --no-conf=true -d * -o * http://example.com/* : cp $FIXTURE_ROOT/\${7##*/} \$6"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
assert_success
|
||||
|
|
Loading…
Reference in a new issue