[ADD] driver: refuse to build below 8 GiB free

A full disk does not say so. gcc's bootstrap reported

  genattrtab: cannot close file tmp-attrtab.cc: No space left on device

seventeen thousand lines into its log, behind two hundred lines of make
recursion. Everything visible pointed at gcc, and the first grep for
"error:" matched cpp_error() -- a function name in gcc's own source, the
documented trap of grepping a whole file instead of the right part.

df would have said it in one line, before the forty minutes.

This host is shared, and the free margin is not stable, so it is checked per
package rather than assumed once. 8 GiB clears gcc, the largest build here;
smaller packages never trip it. The message names the reclaim command,
because the answer is not obvious either: the src trees are regenerable,
makepkg -C wipes them anyway.

--- FR ---

Un disque plein ne le dit pas. L'amorçage de gcc a signalé

  genattrtab: cannot close file tmp-attrtab.cc: No space left on device

dix-sept mille lignes plus bas dans son journal, derrière deux cents lignes
de récursion make. Tout ce qui était visible accusait gcc, et le premier
grep sur « error: » est tombé sur cpp_error() — un nom de fonction dans les
sources de gcc, précisément le piège documenté qui consiste à grep un
fichier entier plutôt que le bon endroit.

df l'aurait dit en une ligne, avant les quarante minutes.

Cet hôte est partagé et la marge libre n'est pas stable : la vérification se
fait donc par paquet, sans rien supposer. 8 GiB suffisent à gcc, le plus
gros build ici ; les petits paquets ne la déclencheront jamais. Le message
nomme la commande de récupération, car la réponse n'est pas évidente non
plus : les arbres src se régénèrent, makepkg -C les efface de toute façon.

Assisted-by: Claude Opus 5
This commit is contained in:
Mathieu Benoit 2026-08-17 03:14:40 -04:00
parent d427ea7bd1
commit 549b5650f5

View file

@ -205,6 +205,26 @@ configure_makepkg() {
build_package() {
local name="$1"
log "Building $name"
# Free space, checked before the build rather than discovered inside it.
#
# A full disk does not say so. gcc's stage-2 bootstrap reported
#
# genattrtab: cannot close file tmp-attrtab.cc: No space left on device
#
# seventeen thousand lines into its log, behind two hundred lines of make
# recursion -- and the first grep for "error:" matched cpp_error(), a
# function name in gcc's own source. Every symptom pointed at gcc.
#
# This host is shared with running VMs whose disk images grow, so the
# margin is not stable and cannot be assumed. 8 GiB clears gcc, the
# largest build here; a smaller package will simply never trip it.
local free_mb
free_mb=$(df -Pm "$WORK" | awk 'NR==2 {print $4}')
if [ "${free_mb:-0}" -lt 8192 ]; then
echo "only ${free_mb} MiB free under $WORK; need 8192" >&2
echo "reclaim with: rm -rf $WORK/pkg/*/src (makepkg -C re-extracts)" >&2
return 1
fi
mkdir -p "$WORK/pkg"
# Both guards are load-bearing, and their absence cost a whole run.
#