Files
FWS-ISO/configs/releng/airootfs/usr/local/bin/fws-install-step
T
nocode dadd46fe3c feat(installer): show the real sub-steps of GRUB, initramfs, desktop and drivers
The progress screen only knew twelve coarse phases: "Installing GRUB" then
nothing until "Keyboard and language", and a bar stuck for minutes while
pacman pulled a whole desktop. Nobody could tell a slow mirror from a hang,
and a failure (no ESP, no initramfs) only existed in the log.

Every real action now publishes a line: kernel copy, mkinitcpio and its
result, each GRUB step (ESP found and mounted or missing, UEFI entry with
the VMD no-NVRAM note, EFI/BOOT fallback, BIOS MBR, menu generation,
first-boot check), desktop activation. For pacman, fws-install-step gains a
--pacman filter that reads the transaction output and turns it into
"download i/N — package", "install i/N — package", hooks, download size and
errors, moving the bar per package. fws-setup-hardware uses the same filter
when the kickstart hands it a FWS_PROGRESS range, and stays silent when run
from fws-drivers or a terminal.

The duplicated Wi-Fi profile copy left by the Main merge is folded into one.
2026-11-03 21:07:18 +01:00

115 lines
5.9 KiB
Bash

#!/bin/sh
# FWS — publie l'avancement de l'installation pour l'écran de progression
# d'Anaconda (pyanaconda/modules/runtime/scripts/runtime.py lit ce fichier et
# le transforme en « Script 2/3 · Installation du bureau — 62 % »).
#
# Usage : fws-install-step <pourcentage 0-100> "<ce qui est en cours>"
# <commande pacman> 2>&1 | fws-install-step --pacman <de> <à> "<préfixe>"
#
# Le mode « --pacman » lit la sortie d'une transaction pacman, la REcopie telle
# quelle sur stdout (le journal d'installation ne perd rien) et publie ce qui
# se passe vraiment : « <préfixe> : téléchargement 123/345 — plasma-desktop »,
# puis « installation 200/345 — konsole », puis les hooks. Le pourcentage
# avance de <de> à <à> au fil des paquets. Sans ça, l'installation du bureau
# (plusieurs minutes, des centaines de paquets) restait une barre immobile
# sous un libellé fixe, et l'utilisateur ne pouvait pas distinguer « ça
# télécharge » de « c'est planté ». Le code retour de pacman reste à lire via
# PIPESTATUS côté appelant : ce filtre sort toujours en 0.
#
# Le fichier est toujours écrit dans le rootfs COURANT (/var/log/…) : dans le
# %post chrooté c'est le système installé (que l'installeur lit via
# /mnt/sysroot), dans les %post --nochroot c'est le live. Écriture atomique
# (fichier temporaire + mv) pour que l'installeur ne lise jamais une ligne à
# moitié écrite.
#
# Best-effort : le code retour est toujours 0 — un souci de progression ne doit
# jamais faire échouer l'installation (les %post sont en `set -x`, pas en
# `set -e`, mais autant ne pas tenter le diable).
set -u
FILE=/var/log/fws-install-progress
publish() {
_pct="$1"; shift
case "$_pct" in
''|*[!0-9]*) return 0 ;;
esac
[ "$_pct" -le 100 ] || _pct=100
mkdir -p "${FILE%/*}" 2>/dev/null || return 0
if printf '%s|%s\n' "$_pct" "$*" > "$FILE.tmp" 2>/dev/null; then
mv -f "$FILE.tmp" "$FILE" 2>/dev/null || rm -f "$FILE.tmp" 2>/dev/null
fi
return 0
}
# ── Mode filtre : la sortie de pacman, ligne par ligne ──────────────────────
# pacman sans terminal (c'est le cas dans un %post) n'affiche aucune barre :
# il écrit une ligne par événement, et c'est ce qu'on lit ici.
# Packages (345) foo-1.0-1 bar-2.0-1 … → le total, N
# foo-1.0-1-x86_64 downloading... → téléchargement i/N (moitié de la plage)
# installing foo... → installation i/N (jusqu'à 95 %)
# (3/12) Creating system user accounts... → hooks (les 5 % restants)
# Les totaux sont des bornes : avec « --needed » les paquets déjà présents ne
# sont pas retéléchargés, donc le compteur peut s'arrêter avant N — la barre
# saute alors à l'étape suivante, elle ne recule jamais.
if [ "${1:-}" = "--pacman" ]; then
FROM="${2:-0}"; TO="${3:-100}"; PREFIX="${4:-pacman}"
case "$FROM$TO" in *[!0-9]*) FROM=0; TO=100 ;; esac
[ "$TO" -gt "$FROM" ] || TO=$((FROM + 1))
SPAN=$((TO - FROM))
total=0; dl=0; inst=0
publish "$FROM" "$PREFIX : résolution des dépendances"
while IFS= read -r line; do
printf '%s\n' "$line"
case "$line" in
":: Synchronizing package databases"*)
publish "$FROM" "$PREFIX : synchronisation des dépôts" ;;
"Packages ("*")"*)
total="${line#Packages (}"; total="${total%%)*}"
case "$total" in ''|*[!0-9]*) total=0 ;; esac
dl=0 # les « downloading... » vus jusqu'ici étaient les bases de dépôts
publish "$FROM" "$PREFIX : $total paquets à installer" ;;
"Total Download Size:"*)
size="${line#Total Download Size:}"; size="${size#"${size%%[! ]*}"}"
publish "$FROM" "$PREFIX : $size à télécharger" ;;
*" downloading...")
dl=$((dl + 1)); name="${line# }"; name="${name% downloading...}"
if [ "$total" -gt 0 ]; then
pct=$((FROM + SPAN * dl / (2 * total)))
publish "$pct" "$PREFIX : téléchargement $dl/$total — $name"
else
publish "$FROM" "$PREFIX : téléchargement — $name"
fi ;;
"checking keyring"*) publish $((FROM + SPAN / 2)) "$PREFIX : vérification des signatures" ;;
"checking package integrity"*) publish $((FROM + SPAN / 2)) "$PREFIX : vérification de l'intégrité des paquets" ;;
"loading package files"*) publish $((FROM + SPAN / 2)) "$PREFIX : lecture des paquets" ;;
"checking for file conflicts"*) publish $((FROM + SPAN / 2)) "$PREFIX : recherche de conflits de fichiers" ;;
"checking available disk space"*) publish $((FROM + SPAN / 2)) "$PREFIX : vérification de l'espace disque" ;;
installing\ *...|upgrading\ *...|reinstalling\ *...)
inst=$((inst + 1)); name="${line#* }"; name="${name%...}"
if [ "$total" -gt 0 ]; then
pct=$((FROM + SPAN / 2 + SPAN * 45 * inst / (100 * total)))
publish "$pct" "$PREFIX : installation $inst/$total — $name"
else
publish $((FROM + SPAN / 2)) "$PREFIX : installation — $name"
fi ;;
":: Running post-transaction hooks"*)
publish $((FROM + SPAN * 95 / 100)) "$PREFIX : exécution des hooks" ;;
"("*"/"*") "*)
h="${line#(}"; hi="${h%%/*}"; hn="${h#*/}"; hn="${hn%%)*}"; what="${line#*) }"
case "$hi$hn" in *[!0-9]*) ;; *)
[ "$hn" -gt 0 ] && publish $((FROM + SPAN * 95 / 100 + SPAN * 5 * hi / (100 * hn))) "$PREFIX : hook $hi/$hn — ${what%...}" ;;
esac ;;
"error:"*)
publish "$FROM" "$PREFIX : ERREUR — ${line#error: }" ;;
esac
done
exit 0
fi
[ "$#" -ge 2 ] || exit 0
PERCENT="$1"
shift
publish "$PERCENT" "$*"
exit 0