From a75acd5f9c5dd6b4f89492adf1af9adef2ded34a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 24 Oct 2023 19:12:52 +0000 Subject: [PATCH] _dl.sh: implement fix for broken ftp.openbsd.org server config [ci skip] Add a way to pass per-dependency custom curl options for bump checking and downloads. This became necessary for ftp.openbsd.org. The name resolves to IPv6, but there is no HTTPS configured under IPv6. Our fix is to force IPv4 when contacting this server. --- _dl.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/_dl.sh b/_dl.sh index ca928dbd9..fa3625243 100755 --- a/_dl.sh +++ b/_dl.sh @@ -153,6 +153,7 @@ cat <&2 echo "mask|${mask}|" - res="$(my_curl "${urldir}" | hxclean | hxselect -i -c -s '\n' 'a::attr(href)' \ + res="$(my_curl "${options[@]}" "${urldir}" | hxclean | hxselect -i -c -s '\n' 'a::attr(href)' \ | grep -a -o -E -- "${mask}" | "${latest}" -1)" # >&2 echo "res|${res}|" if [[ "${res}" =~ ${mask} ]]; then @@ -360,13 +364,15 @@ check_update() { } check_dl() { - local name url keys sig sha options key ok hash_calc hash_got + local name url keys sig sha options key ok hash_calc hash_got curlopt name="$1" url="$2" sig="$3" sha="$4" keys="$6" + curlopt="$7" options=() + [ -n "${curlopt}" ] && options+=("${curlopt}") [ "$5" = 'redir' ] && options+=(--location --proto-redir '=https') options+=(--output pkg.bin "${url}") if [ -n "${sig}" ]; then @@ -463,6 +469,7 @@ bump() { ref_url="$( printf '%s' "${jp}" | jq --raw-output '.ref_url' | sed 's/^null$//')" ref_expr="$(printf '%s' "${jp}" | jq --raw-output '.ref_expr' | sed 's/^null$//')" ref_mask="$(printf '%s' "${jp}" | jq --raw-output '.ref_mask' | sed 's/^null$//')" + curlopt="$( printf '%s' "${jp}" | jq --raw-output '.curlopt' | sed 's/^null$//')" if [ "${pin}" = 'true' ]; then >&2 echo "! ${name}: Version pinned. Skipping." @@ -474,7 +481,7 @@ bump() { newver="$(check_update "${name}" "${ourvern}" "${urlver}" "${desc}" \ "${tag}" \ "${hasfile}" \ - "${ref_url}" "${ref_expr}" "${ref_mask}")" + "${ref_url}" "${ref_expr}" "${ref_mask}" "${curlopt}")" if [ -n "${newver}" ]; then >&2 echo "! ${name}: New version found: |${newver}|" @@ -486,7 +493,7 @@ bump() { urlver="$(printf '%s' "${url}" | expandver "${newver}")" sigver="$(printf '%s' "${sig}" | expandver "${newver}")" - newhash="$(check_dl "${name}" "${urlver}" "${sigver}" "${sha}" "${redir}" "${keys}")" + newhash="$(check_dl "${name}" "${urlver}" "${sigver}" "${sha}" "${redir}" "${keys}" "${curlopt}")" else newhash='-' fi @@ -586,13 +593,15 @@ live_dl() { jp="$(dependencies_json | jq \ ".[] | select(.name == \"${name}\")")" - url="$( printf '%s' "${jp}" | jq --raw-output '.url' | expandver "${ver}")" - mirror="$(printf '%s' "${jp}" | jq --raw-output '.mirror' | sed 's/^null$//' | expandver "${ver}")" - sigraw="$(printf '%s' "${jp}" | jq --raw-output '.sig' | sed 's/^null$//' | expandver "${ver}")" - redir="$( printf '%s' "${jp}" | jq --raw-output '.redir')" - keys="$( printf '%s' "${jp}" | jq --raw-output '.keys' | sed 's/^null$//')" + url="$( printf '%s' "${jp}" | jq --raw-output '.url' | expandver "${ver}")" + mirror="$( printf '%s' "${jp}" | jq --raw-output '.mirror' | sed 's/^null$//' | expandver "${ver}")" + sigraw="$( printf '%s' "${jp}" | jq --raw-output '.sig' | sed 's/^null$//' | expandver "${ver}")" + redir="$( printf '%s' "${jp}" | jq --raw-output '.redir')" + keys="$( printf '%s' "${jp}" | jq --raw-output '.keys' | sed 's/^null$//')" + curlopt="$(printf '%s' "${jp}" | jq --raw-output '.curlopt' | sed 's/^null$//')" options=() + [ -n "${curlopt}" ] && options+=("${curlopt}") [ "${redir}" = 'redir' ] && options+=(--location --proto-redir '=https') options+=(--output pkg.bin "${url}") sig="${sigraw}"