From 413c14ea3b85f6af4bb4f73c5d6e6f96a3694fd5 Mon Sep 17 00:00:00 2001 From: fkDead Date: Thu, 26 Nov 2026 11:52:04 +0100 Subject: [PATCH] feat(build): take the FWS packages from the remote fws repository A build no longer needs a prior setup-aur.sh run nor a local-repo directory: mkarchiso resolves the FWS packages through the [fws] repository declared in the profile, and the build stops early when its database cannot be read. The pre-flight check derives what [fws] must provide from what [core] and [extra] do not, so it no longer depends on a packaging tree. The Broadcom driver is checked against the SHA-256 of the database, the only integrity check an unsigned repository gives. --- build.sh | 152 +++++++++++++++++++++++++++---------------------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/build.sh b/build.sh index fe25780..430b8ca 100755 --- a/build.sh +++ b/build.sh @@ -162,7 +162,7 @@ if [ -z "$FWS_IN_CONTAINER" ] && ! host_is_arch; then # On les rend au propriétaire du dépôt pour confort côté hôte. OWNER="$(stat -c '%u:%g' "$REPO_DIR" 2>/dev/null || true)" if [ -n "$OWNER" ]; then - for d in out local-repo; do + for d in out; do [ -e "$REPO_DIR/$d" ] && "${SUDO[@]}" chown -R "$OWNER" "$REPO_DIR/$d" 2>/dev/null || true done fi @@ -305,84 +305,74 @@ echo "==> Vérification des services systemd..." ls "$SDDIR" 2>/dev/null | head -25 || echo " (aucun service)" ls "$SDDIR/multi-user.target.wants/" 2>/dev/null || echo " (aucun symlink)" -# Copie le repo local (fws-pacmanage + fws-dnd + deps Anaconda packagées) -# « ls glob » renvoie un statut d'échec dès qu'une entrée FANTÔME traîne dans -# local-repo (nom refusé par NTFS, laissé à moitié créé par un cp raté) : on -# testait alors « aucun repo » et l'ISO partait sans les paquets FWS. On sonde -# donc un fichier réellement stat-able, et on copie de même, un par un. -_localrepo_has=0 -for _f in "$WORK_DIR/local-repo/"*.pkg.tar.*; do - if [ -e "$_f" ]; then _localrepo_has=1; break; fi -done -if [ "$_localrepo_has" = 1 ]; then - echo "==> Copie du repo local fws-local..." - mkdir -p /tmp/fws-build/local-repo - for _f in "$WORK_DIR/local-repo/"*; do - if [ -e "$_f" ]; then cp -a "$_f" /tmp/fws-build/local-repo/; fi - done - - echo "==> Injection [fws-local] dans pacman.conf..." - sed -i '/^\[fws-local\]/,/^$/d' /tmp/fws-build/releng/pacman.conf - PACMAN_TMP=$(mktemp) - printf '[fws-local]\nSigLevel = Optional TrustAll\nServer = file:///tmp/fws-build/local-repo\n\n' \ - > "$PACMAN_TMP" - cat /tmp/fws-build/releng/pacman.conf >> "$PACMAN_TMP" - mv "$PACMAN_TMP" /tmp/fws-build/releng/pacman.conf - - echo "==> Vérification pacman.conf :" - head -5 /tmp/fws-build/releng/pacman.conf -else - echo "==> Aucun repo local détecté." +# ============================================================ +# Dépôt distant [fws] : source des paquets FWS +# +# fws-pacmanage, fws-dnd, anaconda and its python deps come from the [fws] +# repo declared in the profile's pacman.conf, which mkarchiso uses as is: +# the build needs neither local-repo/ nor a prior setup-aur.sh run. Its +# database is read once here, for the check and the Broadcom driver below. +# ============================================================ +_PROFILE_CONF=/tmp/fws-build/releng/pacman.conf +# dos2unix only runs further down: strip a possible CR from a Windows clone. +FWS_REPO_URL="$(awk '/^\[/{f=/^\[fws\]/} f && /^[[:space:]]*Server[[:space:]]*=/{ + gsub(/\r/, ""); sub(/^[^=]*=[[:space:]]*/, ""); sub(/[[:space:]]+$/, ""); print; exit }' "$_PROFILE_CONF")" +FWS_REPO_URL="${FWS_REPO_URL//\$repo/fws}" +FWS_REPO_URL="${FWS_REPO_URL//\$arch/x86_64}" +if [ -z "$FWS_REPO_URL" ]; then + echo -e "\e[31m[ERR] Aucun dépôt [fws] (Server = …) dans le pacman.conf du profil.\e[0m" >&2 + exit 1 fi +echo "==> Lecture du dépôt [fws] ($FWS_REPO_URL)..." +FWS_DB_DIR="$(mktemp -d)" +if ! curl -fsSL --retry 3 --connect-timeout 20 -o "$FWS_DB_DIR/fws.db" "$FWS_REPO_URL/fws.db" \ + || ! tar -xzf "$FWS_DB_DIR/fws.db" -C "$FWS_DB_DIR" 2>/dev/null; then + echo -e "\e[31m[ERR] Base du dépôt [fws] illisible : $FWS_REPO_URL/fws.db\e[0m" >&2 + echo " Vérifie l'accès à ce serveur, puis relance." >&2 + exit 1 +fi +# One directory per package in the database: "--". +mapfile -t _fws_pkgs < <(find "$FWS_DB_DIR" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' \ + | sed -E 's/-[^-]+-[^-]+$//') + # ============================================================ -# Garde-fou : les paquets FWS doivent EXISTER dans local-repo +# Garde-fou : les paquets FWS doivent EXISTER dans le dépôt [fws] # -# packages.x86_64 liste des paquets que seul le dépôt local fournit (fws-*, -# anaconda, fws-pacmanage, deps python…). S'ils n'ont pas encore été construits, +# packages.x86_64 liste des paquets que seul le dépôt FWS fournit (fws-*, +# anaconda, fws-pacmanage, deps python…). S'ils n'y sont pas publiés, # pacman ne le découvre qu'à la toute fin — après le -Syu, les miroirs et # toute la préparation de mkarchiso — avec un « target not found » sec et # plusieurs minutes de perdues. On vérifie donc AVANT de lancer quoi que ce # soit de long, et on dit quoi faire. # ============================================================ -echo "==> Vérification des paquets fournis par local-repo..." -_missing=() -# Paquets construits depuis les PKGBUILD du dépôt (le nom du dossier est le -# pkgname), plus la liste AUR lue dans setup-aur.sh — sa seule source de vérité. -_local_pkgs=() -for _d in "$WORK_DIR"/pkgbuilds/*/; do - [ -f "$_d/PKGBUILD" ] || continue - _local_pkgs+=("$(basename "$_d")") -done -# Liste AUR lue dans setup-aur.sh, sa seule source de vérité. L'extraction -# passe par bash : la déclaration est un tableau entre parenthèses, qu'un sed -# ramenait en UN SEUL mot — la comparaison ci-dessous ne matchait donc jamais -# packages.x86_64, et ce garde-fou ne vérifiait rien, en silence. -_aur_decl="$(awk '/^AUR_PACKAGES=\(/{f=1} f{print} f && /\)/{exit}' "$WORK_DIR/setup-aur.sh" 2>/dev/null)" -if [ -n "$_aur_decl" ]; then - # shellcheck disable=SC2207 - _local_pkgs+=($(bash -c 'eval "$1"; printf "%s\n" "${AUR_PACKAGES[@]}"' _ "$_aur_decl" 2>/dev/null)) -fi -# Présence testée par stat : « ls glob » renvoie un statut d'échec dès qu'une -# entrée fantôme traîne dans local-repo, et déclarerait absents des paquets -# pourtant présents. -for _p in "${_local_pkgs[@]}"; do - grep -qx "$_p" /tmp/fws-build/releng/packages.x86_64 || continue - _found=0 - for _f in "$WORK_DIR/local-repo/$_p"-[0-9]*.pkg.tar.*; do - if [ -e "$_f" ]; then _found=1; break; fi - done - [ "$_found" = 1 ] || _missing+=("$_p") -done -if [ "${#_missing[@]}" -gt 0 ]; then - echo -e "\e[31m[ERR] Ces paquets sont demandés par packages.x86_64 mais absents de local-repo :\e[0m" >&2 - printf ' - %s\n' "${_missing[@]}" >&2 - echo "" >&2 - echo " Construis-les d'abord : ./setup-aur.sh" >&2 - echo " (incrémental : il saute ce qui est déjà à jour dans local-repo/)" >&2 +echo "==> Vérification des paquets fournis par le dépôt [fws]..." +# What [core]/[extra] do not provide can only come from [fws]. Deriving that +# list here keeps the check free of any packaging tree. The host sync +# databases are fresh: the "pacman -Syu" above has just refreshed them. +mapfile -t _official < <(pacman -Slq core extra 2>/dev/null | sort -u) +if [ "${#_official[@]}" -eq 0 ]; then + echo -e "\e[31m[ERR] Bases pacman [core]/[extra] illisibles sur la machine de build.\e[0m" >&2 exit 1 fi -echo " ${#_local_pkgs[@]} paquets locaux attendus, tous présents ✔" +_expected=() _missing=() +# [[:space:]] also strips the CR of a Windows clone (dos2unix runs later). +for _p in $(comm -23 \ + <(sed -e 's/#.*//' -e 's/[[:space:]]//g' -e '/^$/d' /tmp/fws-build/releng/packages.x86_64 | sort -u) \ + <(printf '%s\n' "${_official[@]}")); do + # An official group (xorg, …) is no package name, yet pacman resolves it. + if pacman -Sgq "$_p" >/dev/null 2>&1; then continue; fi + _expected+=("$_p") + printf '%s\n' "${_fws_pkgs[@]}" | grep -qxF -- "$_p" || _missing+=("$_p") +done +if [ "${#_missing[@]}" -gt 0 ]; then + echo -e "\e[31m[ERR] Ces paquets sont demandés par packages.x86_64 mais absents de [core], [extra] et [fws] :\e[0m" >&2 + printf ' - %s\n' "${_missing[@]}" >&2 + echo "" >&2 + echo " Publie-les sur $FWS_REPO_URL (ou corrige leur nom dans packages.x86_64), puis relance." >&2 + exit 1 +fi +echo " Attendus de [fws] : ${_expected[*]:-aucun} — tous présents ✔" # ============================================================ # Pilote Wi-Fi Broadcom : embarqué, installé seulement SI DÉTECTÉ @@ -390,19 +380,29 @@ echo " ${#_local_pkgs[@]} paquets locaux attendus, tous présents ✔" # Volontairement absent de packages.x86_64 : broadcom-wl-dkms blackliste b43, # bcma, ssb et brcmsmac pour tout le système — l'imposer à chaque machine # couperait le Wi-Fi de celles que ces modules font justement fonctionner. -# Il vient de l'AUR, donc aucun dépôt ne le fournira sur la cible : on le +# Une machine qui en a besoin n'a, par définition, pas de réseau : on le # dépose dans l'airootfs et fws-setup-hardware fait « pacman -U » UNIQUEMENT # s'il voit une Broadcom sans interface sans fil, puis supprime le fichier. # ============================================================ -_WL_PKG="$(ls "$WORK_DIR/local-repo"/broadcom-wl-dkms-[0-9]*.pkg.tar.* 2>/dev/null | head -1)" -if [ -n "$_WL_PKG" ]; then - install -Dm644 "$_WL_PKG" \ - "/tmp/fws-build/releng/airootfs/usr/local/share/fws/drivers/$(basename "$_WL_PKG")" - echo "==> Pilote Wi-Fi Broadcom embarqué : $(basename "$_WL_PKG")" +# Taken from [fws] (our build) and checked against the database checksum: +# the repo is unsigned, so this is the only integrity check it gets. +_WL_FILE="" _WL_SHA="" +for _desc in "$FWS_DB_DIR"/broadcom-wl-dkms-[0-9]*/desc; do + [ -f "$_desc" ] || continue + _WL_FILE="$(awk '/^%FILENAME%$/{getline; print; exit}' "$_desc")" + _WL_SHA="$(awk '/^%SHA256SUM%$/{getline; print; exit}' "$_desc")" +done +_WL_DIR=/tmp/fws-build/releng/airootfs/usr/local/share/fws/drivers +if [ -n "$_WL_FILE" ] && mkdir -p "$_WL_DIR" \ + && curl -fsSL --retry 3 --connect-timeout 20 -o "$_WL_DIR/$_WL_FILE" "$FWS_REPO_URL/$_WL_FILE" \ + && echo "$_WL_SHA $_WL_DIR/$_WL_FILE" | sha256sum -c --status -; then + echo "==> Pilote Wi-Fi Broadcom embarqué : $_WL_FILE" else - echo -e "\e[33m[!] broadcom-wl-dkms absent de local-repo — les portables Broadcom\e[0m" >&2 - echo " resteront sans Wi-Fi. Lance ./setup-aur.sh pour le construire." >&2 + if [ -n "$_WL_FILE" ]; then rm -f "$_WL_DIR/$_WL_FILE"; fi + echo -e "\e[33m[!] broadcom-wl-dkms introuvable ou corrompu dans [fws] — les portables Broadcom\e[0m" >&2 + echo " resteront sans Wi-Fi. Publie-le sur $FWS_REPO_URL (./setup-aur.sh puis ./prepare-remote-repo.sh)." >&2 fi +rm -rf "$FWS_DB_DIR" echo "==> Correction des retours à la ligne Windows (dos2unix)..." pacman -S --needed --noconfirm dos2unix