From b116f341fe2dedcc2831b69a1e4fd51a2bce7892 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Mon, 8 Feb 2016 12:27:46 +0000 Subject: [PATCH 1/5] Use `aria2c` as the download if available (#534) --- plugins/python-build/bin/python-build | 18 ++++++++++- plugins/python-build/test/build.bats | 2 +- plugins/python-build/test/cache.bats | 22 +++++++------- plugins/python-build/test/checksum.bats | 33 ++++++++++---------- plugins/python-build/test/fetch.bats | 2 +- plugins/python-build/test/mirror.bats | 38 ++++++++++++------------ plugins/python-build/test/pyenv_ext.bats | 2 +- 7 files changed, 67 insertions(+), 50 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index fef4260a..a866a017 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -323,7 +323,9 @@ http() { local file="$3" [ -n "$url" ] || return 1 - if type curl &>/dev/null; then + if type aria2c &>/dev/null; then + "http_${method}_aria2c" "$url" "$file" + elif type curl &>/dev/null; then "http_${method}_curl" "$url" "$file" elif type wget &>/dev/null; then "http_${method}_wget" "$url" "$file" @@ -333,6 +335,20 @@ http() { fi } +http_head_aria2c() { + options="" + [ -n "${IPV4}" ] && options="--disable-ipv6=true" + [ -n "${IPV6}" ] && options="--disable-ipv6=false" + aria2c -q --dry-run ${options} "$1" >&4 2>&1 +} + +http_get_aria2c() { + options="" + [ -n "${IPV4}" ] && options="--disable-ipv6=true" + [ -n "${IPV6}" ] && options="--disable-ipv6=false" + aria2c -q -o "${2:--}" ${options} "$1" +} + http_head_curl() { options="" [ -n "${IPV4}" ] && options="--ipv4" diff --git a/plugins/python-build/test/build.bats b/plugins/python-build/test/build.bats index b8aa3acd..fbf104c8 100644 --- a/plugins/python-build/test/build.bats +++ b/plugins/python-build/test/build.bats @@ -10,7 +10,7 @@ export -n PYTHON_CONFIGURE_OPTS setup() { mkdir -p "$INSTALL_ROOT" stub md5 false - stub curl false + stub aria2c false } executable() { diff --git a/plugins/python-build/test/cache.bats b/plugins/python-build/test/cache.bats index d3ccc226..4795f80c 100644 --- a/plugins/python-build/test/cache.bats +++ b/plugins/python-build/test/cache.bats @@ -10,19 +10,19 @@ setup() { @test "packages are saved to download cache" { - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/without-checksum assert_success assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] - unstub curl + unstub aria2c } @test "cached package without checksum" { - stub curl + stub aria2c cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_CACHE_PATH" @@ -31,13 +31,13 @@ setup() { assert_success assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] - unstub curl + unstub aria2c } @test "cached package with valid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" - stub curl + stub aria2c cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_CACHE_PATH" @@ -47,7 +47,7 @@ setup() { assert [ -x "${INSTALL_ROOT}/bin/package" ] assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] - unstub curl + unstub aria2c unstub shasum } @@ -57,8 +57,8 @@ setup() { local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo invalid" "echo $checksum" - stub curl "-*I* : true" \ - "-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" + stub aria2c "-q --dry-run * : true" \ + "-q -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" touch "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" @@ -69,13 +69,13 @@ setup() { assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ] assert diff -q "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz" - unstub curl + unstub aria2c unstub shasum } @test "nonexistent cache directory is ignored" { - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" export PYTHON_BUILD_CACHE_PATH="${TMP}/nonexistent" @@ -85,5 +85,5 @@ setup() { assert [ -x "${INSTALL_ROOT}/bin/package" ] refute [ -d "$PYTHON_BUILD_CACHE_PATH" ] - unstub curl + unstub aria2c } diff --git a/plugins/python-build/test/checksum.bats b/plugins/python-build/test/checksum.bats index 62d46312..bca47a8a 100644 --- a/plugins/python-build/test/checksum.bats +++ b/plugins/python-build/test/checksum.bats @@ -6,102 +6,103 @@ export PYTHON_BUILD_CACHE_PATH= @test "package URL without checksum" { - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/without-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c } @test "package URL with valid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub shasum } @test "package URL with invalid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/with-invalid-checksum assert_failure refute [ -f "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub shasum } @test "package URL with checksum but no shasum support" { stub shasum false - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub shasum } @test "package URL with valid md5 checksum" { stub md5 true "echo 83e6d7725e20166024a1eb74cde80677" - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/with-md5-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub md5 } @test "package URL with md5 checksum but no md5 support" { stub md5 false - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/with-md5-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub md5 } @test "package with invalid checksum" { stub shasum true "echo invalid" - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/with-checksum assert_failure refute [ -f "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub shasum } @test "existing tarball in build location is reused" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" + stub aria2c false stub curl false stub wget false @@ -125,7 +126,7 @@ DEF stub shasum true \ "echo invalid" \ "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" export -n PYTHON_BUILD_CACHE_PATH export PYTHON_BUILD_BUILD_PATH="${TMP}/build" @@ -144,7 +145,7 @@ DEF } @test "package URL with checksum of unexpected length" { - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" run_inline_definition <&2 @@ -16,21 +16,21 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub shasum } @test "package URL with checksum but no shasum support bypasses mirror" { stub shasum false - stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub shasum } @@ -40,15 +40,15 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum" stub shasum true "echo $checksum" - stub curl "-*I* $mirror_url : true" \ - "-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" + stub aria2c "-q --dry-run $mirror_url : true" \ + "-q -o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub shasum } @@ -58,15 +58,15 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum" stub shasum true "echo $checksum" - stub curl "-*I* $mirror_url : false" \ - "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q --dry-run $mirror_url : false" \ + "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub shasum } @@ -76,9 +76,9 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum" stub shasum true "echo invalid" "echo $checksum" - stub curl "-*I* $mirror_url : true" \ - "-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ - "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q --dry-run $mirror_url : true" \ + "-q -o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ + "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" install_fixture definitions/with-checksum echo "$output" >&2 @@ -86,7 +86,7 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub shasum } @@ -96,15 +96,15 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo $checksum" - stub curl "-*I* : true" \ - "-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ + stub aria2c "-q --dry-run : true" \ + "-q -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] - unstub curl + unstub aria2c unstub shasum } @@ -114,7 +114,7 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo $checksum" - stub curl "-q -o * -*S* https://www.python.org/* : cp $FIXTURE_ROOT/\${5##*/} \$3" + stub aria2c "-q -o * https://www.python.org/* : cp $FIXTURE_ROOT/\${4##*/} \$3" run_inline_definition < Date: Fri, 12 Feb 2016 07:08:59 +0000 Subject: [PATCH 2/5] Increased verbosity of `aria2c` downloader (#534) --- plugins/python-build/bin/python-build | 4 ++-- plugins/python-build/test/cache.bats | 8 ++++---- plugins/python-build/test/checksum.bats | 18 +++++++++--------- plugins/python-build/test/mirror.bats | 24 ++++++++++++------------ 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index a866a017..3f325ecd 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -339,14 +339,14 @@ http_head_aria2c() { options="" [ -n "${IPV4}" ] && options="--disable-ipv6=true" [ -n "${IPV6}" ] && options="--disable-ipv6=false" - aria2c -q --dry-run ${options} "$1" >&4 2>&1 + aria2c --dry-run ${options} "$1" >&4 2>&1 } http_get_aria2c() { options="" [ -n "${IPV4}" ] && options="--disable-ipv6=true" [ -n "${IPV6}" ] && options="--disable-ipv6=false" - aria2c -q -o "${2:--}" ${options} "$1" + aria2c -o "${2:--}" ${options} "$1" } http_head_curl() { diff --git a/plugins/python-build/test/cache.bats b/plugins/python-build/test/cache.bats index 4795f80c..c810903f 100644 --- a/plugins/python-build/test/cache.bats +++ b/plugins/python-build/test/cache.bats @@ -10,7 +10,7 @@ setup() { @test "packages are saved to download cache" { - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/without-checksum @@ -57,8 +57,8 @@ setup() { local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo invalid" "echo $checksum" - stub aria2c "-q --dry-run * : true" \ - "-q -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" + stub aria2c "--dry-run * : true" \ + "-o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$2" touch "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" @@ -75,7 +75,7 @@ setup() { @test "nonexistent cache directory is ignored" { - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" export PYTHON_BUILD_CACHE_PATH="${TMP}/nonexistent" diff --git a/plugins/python-build/test/checksum.bats b/plugins/python-build/test/checksum.bats index bca47a8a..a9b0ca25 100644 --- a/plugins/python-build/test/checksum.bats +++ b/plugins/python-build/test/checksum.bats @@ -6,7 +6,7 @@ export PYTHON_BUILD_CACHE_PATH= @test "package URL without checksum" { - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/without-checksum @@ -19,7 +19,7 @@ export PYTHON_BUILD_CACHE_PATH= @test "package URL with valid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum @@ -33,7 +33,7 @@ export PYTHON_BUILD_CACHE_PATH= @test "package URL with invalid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-invalid-checksum @@ -47,7 +47,7 @@ export PYTHON_BUILD_CACHE_PATH= @test "package URL with checksum but no shasum support" { stub shasum false - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum @@ -61,7 +61,7 @@ export PYTHON_BUILD_CACHE_PATH= @test "package URL with valid md5 checksum" { stub md5 true "echo 83e6d7725e20166024a1eb74cde80677" - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-md5-checksum @@ -75,7 +75,7 @@ export PYTHON_BUILD_CACHE_PATH= @test "package URL with md5 checksum but no md5 support" { stub md5 false - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-md5-checksum @@ -89,7 +89,7 @@ export PYTHON_BUILD_CACHE_PATH= @test "package with invalid checksum" { stub shasum true "echo invalid" - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum @@ -126,7 +126,7 @@ DEF stub shasum true \ "echo invalid" \ "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" export -n PYTHON_BUILD_CACHE_PATH export PYTHON_BUILD_BUILD_PATH="${TMP}/build" @@ -145,7 +145,7 @@ DEF } @test "package URL with checksum of unexpected length" { - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" run_inline_definition <&2 @@ -23,7 +23,7 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com @test "package URL with checksum but no shasum support bypasses mirror" { stub shasum false - stub aria2c "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum @@ -40,8 +40,8 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum" stub shasum true "echo $checksum" - stub aria2c "-q --dry-run $mirror_url : true" \ - "-q -o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" + stub aria2c "--dry-run $mirror_url : true" \ + "-o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$2" install_fixture definitions/with-checksum @@ -58,8 +58,8 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum" stub shasum true "echo $checksum" - stub aria2c "-q --dry-run $mirror_url : false" \ - "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "--dry-run $mirror_url : false" \ + "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum @@ -76,9 +76,9 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum" stub shasum true "echo invalid" "echo $checksum" - stub aria2c "-q --dry-run $mirror_url : true" \ - "-q -o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ - "-q -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "--dry-run $mirror_url : true" \ + "-o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$2" \ + "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2" install_fixture definitions/with-checksum echo "$output" >&2 @@ -96,8 +96,8 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo $checksum" - stub aria2c "-q --dry-run : true" \ - "-q -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \ + stub aria2c "--dry-run : true" \ + "-o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$2" \ install_fixture definitions/with-checksum @@ -114,7 +114,7 @@ export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub shasum true "echo $checksum" - stub aria2c "-q -o * https://www.python.org/* : cp $FIXTURE_ROOT/\${4##*/} \$3" + stub aria2c "-o * https://www.python.org/* : cp $FIXTURE_ROOT/\${3##*/} \$2" run_inline_definition < Date: Sat, 13 Feb 2016 02:50:51 +0000 Subject: [PATCH 3/5] Allow overriding aria2c/curl/wget via environment variable (#534) --- plugins/python-build/bin/python-build | 34 ++++++++----------------- plugins/python-build/test/cache.bats | 1 + plugins/python-build/test/checksum.bats | 1 + plugins/python-build/test/mirror.bats | 1 + 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 3f325ecd..6250d907 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -336,45 +336,27 @@ http() { } http_head_aria2c() { - options="" - [ -n "${IPV4}" ] && options="--disable-ipv6=true" - [ -n "${IPV6}" ] && options="--disable-ipv6=false" - aria2c --dry-run ${options} "$1" >&4 2>&1 + aria2c --dry-run ${ARIA2_OPTS} "$1" >&4 2>&1 } http_get_aria2c() { - options="" - [ -n "${IPV4}" ] && options="--disable-ipv6=true" - [ -n "${IPV6}" ] && options="--disable-ipv6=false" - aria2c -o "${2:--}" ${options} "$1" + aria2c -o "${2:--}" ${ARIA2_OPTS} "$1" } http_head_curl() { - options="" - [ -n "${IPV4}" ] && options="--ipv4" - [ -n "${IPV6}" ] && options="--ipv6" - curl -qsILf ${options} "$1" >&4 2>&1 + curl -qsILf ${CURL_OPTS} "$1" >&4 2>&1 } http_get_curl() { - options="" - [ -n "${IPV4}" ] && options="--ipv4" - [ -n "${IPV6}" ] && options="--ipv6" - curl -q -o "${2:--}" -sSLf ${options} "$1" + curl -q -o "${2:--}" -sSLf ${CURL_OPTS} "$1" } http_head_wget() { - options="" - [ -n "${IPV4}" ] && options="--inet4-only" - [ -n "${IPV6}" ] && options="--inet6-only" - wget -q --spider ${options} "$1" >&4 2>&1 + wget -q --spider ${WGET_OPTS} "$1" >&4 2>&1 } http_get_wget() { - options="" - [ -n "${IPV4}" ] && options="--inet4-only" - [ -n "${IPV6}" ] && options="--inet6-only" - wget -nv ${options} -O "${2:--}" "$1" + wget -nv ${WGET_OPTS} -O "${2:--}" "$1" } fetch_tarball() { @@ -1816,6 +1798,10 @@ if [ -n "$PYTHON_BUILD_SKIP_MIRROR" ] || ! has_checksum_support compute_sha2; th unset PYTHON_BUILD_MIRROR_URL fi +ARIA2_OPTS="${PYTHON_BUILD_ARIA2_OPTS} ${IPV4+--disable-ipv6=true} ${IPV6+--disable-ipv6=false}" +CURL_OPTS="${PYTHON_BUILD_CURL_OPTS} ${IPV4+--ipv4} ${IPV6+--ipv6}" +WGET_OPTS="${PYTHON_BUILD_WGET_OPTS} ${IPV4+--inet4-only} ${IPV6+--inet6-only}" + # Add an option to build a debug version of Python (#11) if [ -n "$DEBUG" ]; then package_option python configure --with-pydebug diff --git a/plugins/python-build/test/cache.bats b/plugins/python-build/test/cache.bats index c810903f..d8f8662b 100644 --- a/plugins/python-build/test/cache.bats +++ b/plugins/python-build/test/cache.bats @@ -3,6 +3,7 @@ load test_helper export PYTHON_BUILD_SKIP_MIRROR=1 export PYTHON_BUILD_CACHE_PATH="$TMP/cache" +unset PYTHON_BUILD_ARIA2_OPTS setup() { mkdir "$PYTHON_BUILD_CACHE_PATH" diff --git a/plugins/python-build/test/checksum.bats b/plugins/python-build/test/checksum.bats index a9b0ca25..1af9c722 100644 --- a/plugins/python-build/test/checksum.bats +++ b/plugins/python-build/test/checksum.bats @@ -3,6 +3,7 @@ load test_helper export PYTHON_BUILD_SKIP_MIRROR=1 export PYTHON_BUILD_CACHE_PATH= +unset PYTHON_BUILD_ARIA2_OPTS @test "package URL without checksum" { diff --git a/plugins/python-build/test/mirror.bats b/plugins/python-build/test/mirror.bats index 3310728d..fbffaf7c 100644 --- a/plugins/python-build/test/mirror.bats +++ b/plugins/python-build/test/mirror.bats @@ -4,6 +4,7 @@ load test_helper export PYTHON_BUILD_SKIP_MIRROR= export PYTHON_BUILD_CACHE_PATH= export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com +unset PYTHON_BUILD_ARIA2_OPTS @test "package URL without checksum bypasses mirror" { From a0e0f1637a341d876e172f1539b58a0ebfaf20c8 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Sat, 13 Feb 2016 03:49:28 +0000 Subject: [PATCH 4/5] Just a style issue; use `export` instead of `unset` like other variables --- plugins/python-build/test/cache.bats | 2 +- plugins/python-build/test/checksum.bats | 2 +- plugins/python-build/test/mirror.bats | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/python-build/test/cache.bats b/plugins/python-build/test/cache.bats index d8f8662b..1dca44b0 100644 --- a/plugins/python-build/test/cache.bats +++ b/plugins/python-build/test/cache.bats @@ -3,7 +3,7 @@ load test_helper export PYTHON_BUILD_SKIP_MIRROR=1 export PYTHON_BUILD_CACHE_PATH="$TMP/cache" -unset PYTHON_BUILD_ARIA2_OPTS +export PYTHON_BUILD_ARIA2_OPTS= setup() { mkdir "$PYTHON_BUILD_CACHE_PATH" diff --git a/plugins/python-build/test/checksum.bats b/plugins/python-build/test/checksum.bats index 1af9c722..ffb7d32b 100644 --- a/plugins/python-build/test/checksum.bats +++ b/plugins/python-build/test/checksum.bats @@ -3,7 +3,7 @@ load test_helper export PYTHON_BUILD_SKIP_MIRROR=1 export PYTHON_BUILD_CACHE_PATH= -unset PYTHON_BUILD_ARIA2_OPTS +export PYTHON_BUILD_ARIA2_OPTS= @test "package URL without checksum" { diff --git a/plugins/python-build/test/mirror.bats b/plugins/python-build/test/mirror.bats index fbffaf7c..ddc009dd 100644 --- a/plugins/python-build/test/mirror.bats +++ b/plugins/python-build/test/mirror.bats @@ -4,7 +4,7 @@ load test_helper export PYTHON_BUILD_SKIP_MIRROR= export PYTHON_BUILD_CACHE_PATH= export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com -unset PYTHON_BUILD_ARIA2_OPTS +export PYTHON_BUILD_ARIA2_OPTS= @test "package URL without checksum bypasses mirror" { From 8ea88dee1cedc8dd3d428523172b5a27855a684b Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Thu, 26 May 2016 00:22:54 +0000 Subject: [PATCH 5/5] Trivial fixes --- plugins/python-build/bin/python-build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 6250d907..f226a035 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -330,13 +330,13 @@ http() { elif type wget &>/dev/null; then "http_${method}_wget" "$url" "$file" else - echo "error: please install \`curl\` or \`wget\` and try again" >&2 + echo "error: please install \`aria2c\`, \`curl\` or \`wget\` and try again" >&2 exit 1 fi } http_head_aria2c() { - aria2c --dry-run ${ARIA2_OPTS} "$1" >&4 2>&1 + aria2c --dry-run ${ARIA2_OPTS} "$1" >&4 2>&1 } http_get_aria2c() {