@@ -47,19 +47,19 @@ jobs:
4747
4848 # --- Ubuntu: collect possible keyring packages (ports is optional) ---
4949 declare -a UB_PKGS=(ubuntu-keyring ubuntu-keyring-ports)
50- declare -A UB_URLS=()
50+ declare -A PKG_URLS=() # pkg -> url
51+ declare -A PKG_FILES=() # pkg -> filename we downloaded
5152
5253 for p in "${UB_PKGS[@]}"; do
5354 UB_PAGE_URL="https://packages.ubuntu.com/${NEWEST_SUITE}/all/${p}/download"
54- # Try to parse an archive.ubuntu.com link and drop cc/ccN prefix (use rotation)
5555 if page="$(retry_curl "$UB_PAGE_URL" 2>/dev/null || true)"; then
5656 url="$(printf '%s' "$page" \
5757 | grep -oP 'https?://\S+archive\.ubuntu\.com/ubuntu/pool/main/u/\S+\.deb' \
5858 | tail -n 1 \
5959 | sed -E 's#://[a-z][a-z][0-9]?\.#://#' || true)"
6060 if [[ -n "${url:-}" ]]; then
61- UB_URLS ["$p"]="$url"
62- echo "Ubuntu $p URL: ${UB_URLS [$p]}"
61+ PKG_URLS ["$p"]="$url"
62+ echo "Ubuntu $p URL: ${PKG_URLS [$p]}"
6363 else
6464 echo "Ubuntu package not found on page for $p (may not exist in ${NEWEST_SUITE}), skipping."
6565 fi
@@ -69,51 +69,34 @@ jobs:
6969 done
7070
7171 # Ensure we found at least ubuntu-keyring
72- [[ -n "${UB_URLS [ubuntu-keyring]:-}" ]] || { echo "ERROR: ubuntu-keyring URL not found"; exit 1; }
72+ [[ -n "${PKG_URLS [ubuntu-keyring]:-}" ]] || { echo "ERROR: ubuntu-keyring URL not found"; exit 1; }
7373
7474 # --- Debian keyrings (sid pages list the latest available versions) ---
7575 declare -a DEB_PKGS=(debian-archive-keyring debian-ports-archive-keyring)
76- declare -A DEB_URLS=()
77-
7876 for p in "${DEB_PKGS[@]}"; do
7977 DEB_PAGE_URL="https://packages.debian.org/sid/all/${p}/download"
80- # Prefer deb.debian.org or ftp.debian.org
81- if ! page=$(retry_curl "$DEB_PAGE_URL" 2>/dev/null); then
82- echo "ERROR: Unable to fetch Debian page for ${p}" >&2
83- exit 1
84- fi
85- url=$(printf '%s' "$page" \
78+ page="$(retry_curl "$DEB_PAGE_URL")"
79+ url="$(printf '%s' "$page" \
8680 | grep -oP 'https?://(deb|ftp)\.debian\.org/debian/pool/main/d/[^/]+/[^"]+\.deb' \
87- | head -n 1 || true)
81+ | head -n 1 || true)"
8882 [[ -z "${url:-}" ]] && { echo "ERROR: Unable to find ${p} package URL from $DEB_PAGE_URL" >&2; exit 1; }
89- DEB_URLS ["$p"]="$url"
90- echo "Debian $p URL: ${DEB_URLS [$p]}"
83+ PKG_URLS ["$p"]="$url"
84+ echo "Debian $p URL: ${PKG_URLS [$p]}"
9185 done
9286
93- # --- Download all files to the temp workdir ---
94- declare -a DOWNLOADED=()
95-
96- # Ubuntu downloads
97- for p in "${UB_PKGS[@]}"; do
98- url="${UB_URLS[$p]:-}"
99- [[ -z "${url:-}" ]] && continue
100- f="$(basename "$url")"
101- retry_curl "$url" "$workdir/$f"
102- DOWNLOADED+=("$workdir/$f")
103- done
104-
105- # Debian downloads
106- for p in "${DEB_PKGS[@]}"; do
107- url="${DEB_URLS[$p]}"
87+ # --- Download all files to the temp workdir (track filenames per package) ---
88+ for p in "${!PKG_URLS[@]}"; do
89+ url="${PKG_URLS[$p]}"
10890 f="$(basename "$url")"
10991 retry_curl "$url" "$workdir/$f"
110- DOWNLOADED+=("$workdir/$f")
92+ PKG_FILES["$p"]="$f"
93+ echo "Downloaded $p -> $f"
11194 done
11295
11396 # --- Stage into repo folder armbian.github.io/data/keyrings ---
11497 pushd armbian.github.io >/dev/null
11598
116- # Make sure we are on the 'data' branch (fetch if not present locally)
99+ # Ensure we're on the 'data' branch
117100 if ! git rev-parse --verify data >/dev/null 2>&1; then
118101 git fetch origin data || true
119102 fi
@@ -122,34 +105,31 @@ jobs:
122105 mkdir -p data/keyrings
123106
124107 # Move files in (overwrite existing versions)
125- for f in "${DOWNLOADED [@]}"; do
126- base ="$(basename "$f") "
127- mv -f "$f" "data/keyrings/$base "
108+ for p in "${!PKG_FILES [@]}"; do
109+ f ="${PKG_FILES[$p]} "
110+ mv -f "$workdir/$ f" "data/keyrings/$f "
128111 done
129112
130- # --- Create/update per-variant symlinks only ---
131- # Helper: ensure symlink target exists in data/keyrings before linking
132- make_link() {
113+ # --- Create/update per-variant symlinks using the just-downloaded filenames ---
114+ link_if_present() {
133115 local pkg="$1"
134- local pattern="$2" # e.g. 'ubuntu-keyring_*.deb'
135- local linkname="$3" # e.g. 'latest-ubuntu-keyring.deb'
136- local cand
137- cand="$(ls -1 data/keyrings/${pattern} 2>/dev/null | sort | tail -n 1 || true)"
138- if [[ -n "$cand" ]]; then
139- ln -sfn "$(basename "$cand")" "data/keyrings/${linkname}"
140- echo "Linked ${linkname} -> $(basename "$cand")"
116+ local linkname="$2"
117+ local f="${PKG_FILES[$pkg]:-}"
118+ if [[ -n "$f" ]]; then
119+ ln -sfn "$f" "data/keyrings/$linkname"
120+ echo "Linked ${linkname} -> ${f}"
141121 else
142- echo "No match for ${pattern }; not creating ${linkname}"
122+ echo "No fresh download for ${pkg }; skipping ${linkname}"
143123 fi
144124 }
145125
146- # Ubuntu: main + ports (ports only if present )
147- make_link "ubuntu-keyring" "ubuntu-keyring_*.deb " "latest-ubuntu-keyring.deb"
148- make_link "ubuntu-keyring-ports" "ubuntu-keyring-ports_*.deb " "latest-ubuntu-keyring-ports.deb"
126+ # Ubuntu: main + ports (ports only if fetched )
127+ link_if_present "ubuntu-keyring" "latest-ubuntu-keyring.deb"
128+ link_if_present "ubuntu-keyring-ports" "latest-ubuntu-keyring-ports.deb"
149129
150130 # Debian: archive + ports
151- make_link "debian-archive-keyring" "debian-archive-keyring_*.deb" "latest-debian-archive-keyring.deb"
152- make_link "debian-ports-archive-keyring" "debian-ports-archive-keyring_*.deb" "latest-debian-ports-archive-keyring.deb"
131+ link_if_present "debian-archive-keyring" "latest-debian-archive-keyring.deb"
132+ link_if_present "debian-ports-archive-keyring" "latest-debian-ports-archive-keyring.deb"
153133
154134 popd >/dev/null
155135
@@ -165,7 +145,7 @@ jobs:
165145 git add data/keyrings/
166146
167147 if ! git diff --cached --quiet; then
168- git commit -m "Update keyrings: latest per-variant and downloads under data/keyrings/"
148+ git commit -m "Update keyrings: downloaded and linked per-variant under data/keyrings/"
169149 git push
170150 else
171151 echo "No changes to commit."
0 commit comments