archlinux-s390x/patches/pkgbuild/libarchive.sh

81 lines
3.7 KiB
Bash
Raw Normal View History

[FIX] stage 2: produce its first package Stage 2 could build and could not deliver. Four obstacles, all in the tail of package(), after a compile that had already succeeded. Our meson ships arch-meson and it passes --auto-features enabled, so each of the nine documentation tools this chroot lacks was a hard error, not a skipped feature. A wrapper appends --auto-features auto; meson honours the last one. Building those tools was the alternative and it is not close -- doxygen alone wants clang, fmt, spdlog, llvm-libs. Then bsdtar would not start: stage-1 libxml2 asks for the host's libicuuc.so.76, our icu ships 78, and bsdtar is what writes the package. The package that would fix it was the one being built. libarchive only links libxml2 for xar, which nothing here reads, so stage 1 drops it. Verified: libxml2 rebuilt against libicuuc.so.78, provides libxml2.so=16-64, zero multiarch paths. --- FR --- L'étage 2 savait bâtir et ne savait pas livrer. Quatre obstacles, tous dans la queue de package(), après une compilation déjà réussie. Notre meson livre arch-meson, qui passe --auto-features enabled : chacun des neuf outils de documentation absents de ce chroot devenait une erreur franche au lieu d'une option écartée. Une enveloppe ajoute --auto-features auto, meson retenant la dernière occurrence. Bâtir ces outils était l'autre voie et l'écart est net -- doxygen seul réclame clang, fmt, spdlog, llvm-libs. Puis bsdtar ne démarrait plus : le libxml2 de l'étage 1 réclame le libicuuc.so.76 de l'hôte, notre icu livre le 78, et bsdtar est ce qui écrit le paquet. Le paquet qui corrigeait cela était celui qu'on bâtissait. libarchive ne lie libxml2 que pour xar, que rien ici ne lit : l'étage 1 l'abandonne. Vérifié : libxml2 rebâti sur libicuuc.so.78, fournit libxml2.so=16-64, aucun chemin multiarch. Assisted-by: Claude Opus 5
2026-08-20 01:12:14 -04:00
#!/usr/bin/env bash
# libarchive: no xar during the bootstrap. STAGE 1 ONLY.
#
# THE CYCLE, exactly as it presented itself. Stage 2 reached its very first
# packaging step and stopped on
#
# bsdtar: error while loading shared libraries: libicuuc.so.76
# ==> ERROR: Failed to create package file.
#
# after libxml2 had compiled and installed perfectly. The chain:
#
# bsdtar -> libarchive.so.13 -> libxml2.so.16 -> libicuuc.so.76
#
# The libxml2 in the chroot is our own stage-1 build, and stage 1 builds
# against the HOST, whose ICU is 76. Our icu package ships 78. So bsdtar
# cannot start -- and bsdtar is what makepkg uses to write the package. The
# package that would fix it is the one being built. Nothing can come out of
# the chroot until this is broken from outside.
#
# WHY NOT SUPPLY libicuuc.so.76. Copying the host's ICU into the chroot is the
# obvious move and it is the wrong one: it puts untracked host binaries in
# /usr/lib, which is precisely what test-chroot.sh's ARTEFACT check exists to
# catch. A symlink to 78 does not work either -- ICU version-suffixes every
# symbol, so libicuuc.so.78 does not define u_strlen_76.
#
# THE ROOT is that libarchive links libxml2 at all. It wants it for the xar
# format, which is an Apple installer container. Nothing in this bootstrap
# reads one: makepkg writes .pkg.tar.gz, pacman reads it. Dropping xar removes
# the entire ICU chain rather than papering over its version.
#
# STAGE 1 ONLY -- build-stage2.sh lists libarchive in STAGE2_SKIP_HOOKS. Stage
# 2 builds it as Arch does, with xar, against our own libxml2 and icu, where
# the versions agree. The divergence lives exactly as long as the cycle does.
#
# BOTH depends ARRAYS. libxml2 is declared twice: once at the top and once as
# libxml2.so in the depends+= inside package(). Removing only the visible one
# leaves the package uninstallable for a reason the diff appears to fix -- the
# fifth place, and the one that has cost the most time in this port.
set -euo pipefail
[FIX] a hook's scope belongs to its sections, not to its filename git and meson kept failing in stage 2 on exactly what their own hooks fix, while the log said hook skipped (stage-1 only) Both were named in STAGE2_SKIP_HOOKS, correctly, when their whole content was a host workaround: git dropped ZLIB_NG because the host had no zlib-ng headers, meson moved a wheel out of /usr/local. Then each grew a second section that BOTH stages need -- git's asciidoc man pages, meson's hotdoc reference manual -- and the list skips the whole FILE, so the new sections never ran. Two hooks that were by then two thirds relevant, silently ignored. A list of filenames cannot say why a hook is listed, and cannot notice when that reason stops covering the file. The hooks now read EL_STAGE and decide per section, with the reason written beside each guard; the list is gone. libgcrypt and libarchive keep a whole-file guard, which now states its reason instead of being an entry somewhere else. Verified at both stages: git drops its man pages in each, and keeps ZLIB_NG in the chroot where zlib-ng exists. --- FR --- git et meson échouaient à l'étage 2 sur précisément ce que leurs propres hooks corrigent, pendant que le journal disait hook skipped (stage-1 only) Tous deux étaient nommés dans STAGE2_SKIP_HOOKS, à juste titre quand tout leur contenu était un contournement de l'hôte : git abandonnait ZLIB_NG faute d'en-têtes zlib-ng, meson déplaçait une roue hors de /usr/local. Puis chacun a gagné une seconde section utile aux DEUX étages — les pages asciidoc de git, le manuel hotdoc de meson — et la liste saute le FICHIER entier : ces sections n'ont jamais tourné. Deux hooks devenus pertinents aux deux tiers, ignorés en silence. Une liste de noms de fichiers ne peut pas dire pourquoi un hook y figure, ni remarquer que cette raison a cessé de couvrir le fichier. Les hooks lisent désormais EL_STAGE et tranchent par section, la raison écrite à côté de chaque garde ; la liste disparaît. libgcrypt et libarchive gardent une garde de fichier entier, qui énonce sa raison au lieu d'être une entrée ailleurs. Vérifié aux deux étages : git abandonne ses pages de manuel dans les deux, et conserve ZLIB_NG dans le chroot, où zlib-ng existe. Assisted-by: Claude Opus 5
2026-08-23 17:23:30 -04:00
# STAGE 1 ONLY, the whole file. Expressed here rather than in a list kept by the
# driver: a list of file names cannot say WHY, and when a hook later grows a
# section that both stages need, the list silently skips that too. That happened
# to git and meson.
if [ "${EL_STAGE:-1}" != 1 ]; then
echo "libarchive: nothing to do at stage 2 -- our libxml2 and icu agree in the chroot"
exit 0
fi
[FIX] stage 2: produce its first package Stage 2 could build and could not deliver. Four obstacles, all in the tail of package(), after a compile that had already succeeded. Our meson ships arch-meson and it passes --auto-features enabled, so each of the nine documentation tools this chroot lacks was a hard error, not a skipped feature. A wrapper appends --auto-features auto; meson honours the last one. Building those tools was the alternative and it is not close -- doxygen alone wants clang, fmt, spdlog, llvm-libs. Then bsdtar would not start: stage-1 libxml2 asks for the host's libicuuc.so.76, our icu ships 78, and bsdtar is what writes the package. The package that would fix it was the one being built. libarchive only links libxml2 for xar, which nothing here reads, so stage 1 drops it. Verified: libxml2 rebuilt against libicuuc.so.78, provides libxml2.so=16-64, zero multiarch paths. --- FR --- L'étage 2 savait bâtir et ne savait pas livrer. Quatre obstacles, tous dans la queue de package(), après une compilation déjà réussie. Notre meson livre arch-meson, qui passe --auto-features enabled : chacun des neuf outils de documentation absents de ce chroot devenait une erreur franche au lieu d'une option écartée. Une enveloppe ajoute --auto-features auto, meson retenant la dernière occurrence. Bâtir ces outils était l'autre voie et l'écart est net -- doxygen seul réclame clang, fmt, spdlog, llvm-libs. Puis bsdtar ne démarrait plus : le libxml2 de l'étage 1 réclame le libicuuc.so.76 de l'hôte, notre icu livre le 78, et bsdtar est ce qui écrit le paquet. Le paquet qui corrigeait cela était celui qu'on bâtissait. libarchive ne lie libxml2 que pour xar, que rien ici ne lit : l'étage 1 l'abandonne. Vérifié : libxml2 rebâti sur libicuuc.so.78, fournit libxml2.so=16-64, aucun chemin multiarch. Assisted-by: Claude Opus 5
2026-08-20 01:12:14 -04:00
python3 - <<'ZZPY'
import io, re
s = io.open("PKGBUILD", encoding="utf-8").read()
# ./configure: refuse xar outright. libarchive probes for BOTH libxml2 and
# expat and uses whichever it finds, so declining only one leaves the other
# to reintroduce the dependency the day the host installs it.
old = " --without-nettle \\\n"
assert s.count(old) == 1, "libarchive: --without-nettle is not where expected"
s = s.replace(old, old + " --without-xml2 \\\n --without-expat \\\n", 1)
# depends=(...): the top-level array.
old = " 'libxml2'\n"
assert s.count(old) == 1, "libarchive: 'libxml2' not in depends as expected"
s = s.replace(old, "", 1)
# depends+=(...) inside package(): the soname form.
old = " 'libxml2.so'\n"
assert s.count(old) == 1, "libarchive: 'libxml2.so' not in package() depends"
s = s.replace(old, "", 1)
io.open("PKGBUILD", "w", encoding="utf-8").write(s)
ZZPY
grep -q -- '--without-xml2' PKGBUILD || { echo "libarchive: xar not disabled" >&2; exit 1; }
# Nothing named libxml2 may remain in ANY depends array -- checked by counting
# rather than by eye, because there were two and both looked like the only one.
if grep -nE "^\s*'?libxml2" PKGBUILD | grep -q .; then
echo "libarchive: a libxml2 dependency survived:" >&2
grep -nE "^\s*'?libxml2" PKGBUILD >&2
exit 1
fi
echo "libarchive: xar disabled, libxml2 dropped from both depends arrays"