|
14 | 14 | # host costs minutes of TLS timeouts per package -- a 20-minute |
15 | 15 | # prepare step died exactly that way. Never fail the VM start: if |
16 | 16 | # nothing answers, leave the file alone. |
| 17 | +# |
| 18 | +# ASK EACH MIRROR FOR THE NEWEST QUARTERLY IT ACTUALLY HAS, rather than |
| 19 | +# using the rolling <release>/ alias. Those aliases are unreliable, and |
| 20 | +# on riscv64 they are what broke this action (netbsd-vm run 33459640344, |
| 21 | +# 12 red legs). Measured 2026-09-01 for riscv64/11.0: |
| 22 | +# |
| 23 | +# mirror <rel>/ <rel>_2026Q2/ |
| 24 | +# cdn.NetBSD.org 302 200 |
| 25 | +# ftp.NetBSD.org 302 200 |
| 26 | +# ftp.fr.NetBSD.org 404 200 |
| 27 | +# ftp.jaist.ac.jp 403 200 |
| 28 | +# ftp.allbsd.org 200 404 <- only survivor, a 2025 tree |
| 29 | +# |
| 30 | +# So every good mirror failed the probe and PKG_PATH ended up holding |
| 31 | +# only allbsd's stale set: rsync 3.4.1 where the image ships 3.4.4 (so |
| 32 | +# `pkg_add rsync` refused with "A different version ... is already |
| 33 | +# installed"), and a dependency set that could not satisfy curl |
| 34 | +# ("no pkg found for 'libidn2>=2.3.3nb1'"), which failed the prepare |
| 35 | +# step and with it the job. The real 2026Q2 tree has 21562 packages |
| 36 | +# including the matching rsync; the alias tree had 13264. x86_64 was |
| 37 | +# unaffected only because its alias still answers 200 there. |
| 38 | +# |
| 39 | +# netbsd-builder learned the same lesson in 2026-08 and its |
| 40 | +# hooks/vm_postBuild.sh already bakes PKG_PATH this way -- listings do |
| 41 | +# not lie about which directories exist, aliases do. The alias is kept |
| 42 | +# only as a per-mirror fallback, so a mirror that publishes just the |
| 43 | +# alias (allbsd) still contributes instead of being dropped. |
17 | 44 |
|
18 | 45 | arch=$(uname -p) |
19 | 46 | rel=$(uname -r) |
20 | 47 |
|
21 | 48 | candidates="https://cdn.NetBSD.org https://ftp.NetBSD.org http://ftp.fr.NetBSD.org http://ftp.jaist.ac.jp https://ftp.allbsd.org" |
22 | 49 |
|
23 | | -alive="" |
| 50 | +# Newest "<rel>_YYYYQn" directory this mirror actually lists, else empty. |
| 51 | +# base ftp(1) speaks plain http/https on every release this action runs. |
| 52 | +newest_quarterly() { |
| 53 | + ftp -o - -q 20 "$1/pub/pkgsrc/packages/NetBSD/$arch/" 2>/dev/null \ |
| 54 | + | grep -oE "${rel}_[0-9][0-9][0-9][0-9]Q[0-9]" \ |
| 55 | + | sort \ |
| 56 | + | tail -n 1 |
| 57 | +} |
| 58 | + |
| 59 | +pkgpath="" |
| 60 | +used="" |
24 | 61 | for base in $candidates; do |
25 | | - if ftp -o /dev/null -q 15 "$base/pub/pkgsrc/packages/NetBSD/$arch/$rel/" >/dev/null 2>&1; then |
26 | | - alive="$alive $base" |
| 62 | + dir=$(newest_quarterly "$base") |
| 63 | + [ -n "$dir" ] || dir="$rel" # no quarterly listed; try the alias |
| 64 | + url="$base/pub/pkgsrc/packages/NetBSD/$arch/$dir" |
| 65 | + ftp -o /dev/null -q 15 "$url/" >/dev/null 2>&1 || continue |
| 66 | + if [ -z "$pkgpath" ]; then |
| 67 | + pkgpath="$url/All" |
| 68 | + else |
| 69 | + pkgpath="$pkgpath;$url/All" |
27 | 70 | fi |
| 71 | + used="$used $base($dir)" |
28 | 72 | done |
29 | 73 |
|
30 | | -if [ -z "$alive" ]; then |
| 74 | +if [ -z "$pkgpath" ]; then |
31 | 75 | echo "onStarted: no NetBSD package mirror answered; keeping the default /etc/pkg_install.conf" >&2 |
32 | 76 | exit 0 |
33 | 77 | fi |
34 | 78 |
|
35 | | -pkgpath="" |
36 | | -for base in $alive; do |
37 | | - entry="$base/pub/pkgsrc/packages/NetBSD/$arch/$rel/All" |
38 | | - if [ -z "$pkgpath" ]; then |
39 | | - pkgpath="$entry" |
40 | | - else |
41 | | - pkgpath="$pkgpath;$entry" |
42 | | - fi |
43 | | -done |
44 | | - |
45 | 79 | echo "PKG_PATH=$pkgpath" > /etc/pkg_install.conf |
46 | | -echo "onStarted: live package mirrors:$alive (release $rel, $arch)" |
| 80 | +echo "onStarted: live package mirrors:$used (release $rel, $arch)" |
47 | 81 | exit 0 |
0 commit comments