Skip to content

Commit a75acd5

Browse files
committed
_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.
1 parent 74c57e9 commit a75acd5

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

_dl.sh

+20-11
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ cat <<EOF
153153
{
154154
"name": "libressl",
155155
"url": "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-{ver}.tar.gz",
156+
"curlopt": "--ipv4",
156157
"sig": ".asc",
157158
"keys": "A1EB079B8D3EB92B4EBD3139663AF51BD5E4D8D5"
158159
},
@@ -265,11 +266,14 @@ to8digit() {
265266
}
266267

267268
check_update() {
268-
local pkg url ourvern newver newvern slug mask urldir res
269+
local pkg url ourvern newver newvern slug mask urldir res curlopt
269270
pkg="$1"
270271
ourvern="${2:-000000}"
271272
url="$3"
272273
newver=''
274+
curlopt="${10}"
275+
options=()
276+
[ -n "${curlopt}" ] && options+=("${curlopt}")
273277
if [[ "${url}" =~ ^https://github.com/([a-zA-Z0-9-]+/[a-zA-Z0-9-]+)/ ]]; then
274278
slug="${BASH_REMATCH[1]}"
275279
if [ -n "$7" ]; then
@@ -325,7 +329,7 @@ check_update() {
325329
# a separate subdirectory.
326330
if [ "${pkg}" = 'libssh' ]; then
327331
# ugly hack: repurpose 'ref_url' for this case:
328-
res="$(my_curl "$7" | hxclean | hxselect -i -c -s '\n' 'a::attr(href)' \
332+
res="$(my_curl "${options[@]}" "$7" | hxclean | hxselect -i -c -s '\n' 'a::attr(href)' \
329333
| grep -a -o -E -- '[0-9.]+' | "${latest}" -1)"
330334
url="$7${res}"
331335
urldir="${url}/"
@@ -338,7 +342,7 @@ check_update() {
338342
mask="${pkg}[._-]v?([0-9]+(\.[0-9]+)+)\.t"
339343
[ -n "$9" ] && mask="$9"
340344
# >&2 echo "mask|${mask}|"
341-
res="$(my_curl "${urldir}" | hxclean | hxselect -i -c -s '\n' 'a::attr(href)' \
345+
res="$(my_curl "${options[@]}" "${urldir}" | hxclean | hxselect -i -c -s '\n' 'a::attr(href)' \
342346
| grep -a -o -E -- "${mask}" | "${latest}" -1)"
343347
# >&2 echo "res|${res}|"
344348
if [[ "${res}" =~ ${mask} ]]; then
@@ -360,13 +364,15 @@ check_update() {
360364
}
361365

362366
check_dl() {
363-
local name url keys sig sha options key ok hash_calc hash_got
367+
local name url keys sig sha options key ok hash_calc hash_got curlopt
364368
name="$1"
365369
url="$2"
366370
sig="$3"
367371
sha="$4"
368372
keys="$6"
373+
curlopt="$7"
369374
options=()
375+
[ -n "${curlopt}" ] && options+=("${curlopt}")
370376
[ "$5" = 'redir' ] && options+=(--location --proto-redir '=https')
371377
options+=(--output pkg.bin "${url}")
372378
if [ -n "${sig}" ]; then
@@ -463,6 +469,7 @@ bump() {
463469
ref_url="$( printf '%s' "${jp}" | jq --raw-output '.ref_url' | sed 's/^null$//')"
464470
ref_expr="$(printf '%s' "${jp}" | jq --raw-output '.ref_expr' | sed 's/^null$//')"
465471
ref_mask="$(printf '%s' "${jp}" | jq --raw-output '.ref_mask' | sed 's/^null$//')"
472+
curlopt="$( printf '%s' "${jp}" | jq --raw-output '.curlopt' | sed 's/^null$//')"
466473

467474
if [ "${pin}" = 'true' ]; then
468475
>&2 echo "! ${name}: Version pinned. Skipping."
@@ -474,7 +481,7 @@ bump() {
474481
newver="$(check_update "${name}" "${ourvern}" "${urlver}" "${desc}" \
475482
"${tag}" \
476483
"${hasfile}" \
477-
"${ref_url}" "${ref_expr}" "${ref_mask}")"
484+
"${ref_url}" "${ref_expr}" "${ref_mask}" "${curlopt}")"
478485
if [ -n "${newver}" ]; then
479486
>&2 echo "! ${name}: New version found: |${newver}|"
480487

@@ -486,7 +493,7 @@ bump() {
486493

487494
urlver="$(printf '%s' "${url}" | expandver "${newver}")"
488495
sigver="$(printf '%s' "${sig}" | expandver "${newver}")"
489-
newhash="$(check_dl "${name}" "${urlver}" "${sigver}" "${sha}" "${redir}" "${keys}")"
496+
newhash="$(check_dl "${name}" "${urlver}" "${sigver}" "${sha}" "${redir}" "${keys}" "${curlopt}")"
490497
else
491498
newhash='-'
492499
fi
@@ -586,13 +593,15 @@ live_dl() {
586593
jp="$(dependencies_json | jq \
587594
".[] | select(.name == \"${name}\")")"
588595

589-
url="$( printf '%s' "${jp}" | jq --raw-output '.url' | expandver "${ver}")"
590-
mirror="$(printf '%s' "${jp}" | jq --raw-output '.mirror' | sed 's/^null$//' | expandver "${ver}")"
591-
sigraw="$(printf '%s' "${jp}" | jq --raw-output '.sig' | sed 's/^null$//' | expandver "${ver}")"
592-
redir="$( printf '%s' "${jp}" | jq --raw-output '.redir')"
593-
keys="$( printf '%s' "${jp}" | jq --raw-output '.keys' | sed 's/^null$//')"
596+
url="$( printf '%s' "${jp}" | jq --raw-output '.url' | expandver "${ver}")"
597+
mirror="$( printf '%s' "${jp}" | jq --raw-output '.mirror' | sed 's/^null$//' | expandver "${ver}")"
598+
sigraw="$( printf '%s' "${jp}" | jq --raw-output '.sig' | sed 's/^null$//' | expandver "${ver}")"
599+
redir="$( printf '%s' "${jp}" | jq --raw-output '.redir')"
600+
keys="$( printf '%s' "${jp}" | jq --raw-output '.keys' | sed 's/^null$//')"
601+
curlopt="$(printf '%s' "${jp}" | jq --raw-output '.curlopt' | sed 's/^null$//')"
594602

595603
options=()
604+
[ -n "${curlopt}" ] && options+=("${curlopt}")
596605
[ "${redir}" = 'redir' ] && options+=(--location --proto-redir '=https')
597606
options+=(--output pkg.bin "${url}")
598607
sig="${sigraw}"

0 commit comments

Comments
 (0)