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
102 lines
5 KiB
Bash
Executable file
102 lines
5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# libgcrypt: the first package the host is too OLD for, rather than missing
|
|
# something.
|
|
#
|
|
# configure: Use gpgrt-config with /usr/lib/s390x-linux-gnu as gpg-error-config
|
|
# checking for GPG Error - version >= 1.56... no
|
|
# configure: error: libgpg-error is needed.
|
|
#
|
|
# libgcrypt 1.12.2 wants libgpg-error >= 1.56. Ubuntu ships 1.51. Installing a
|
|
# -dev package cannot fix a version floor, and every earlier failure in this
|
|
# port was an absence -- this one is an age.
|
|
#
|
|
# THE TRAP is the first line. configure DID find gpgrt-config and DID pick a
|
|
# libdir, so the message reads like a path problem and sends you checking
|
|
# multiarch directories. The path was right all along; only the version was
|
|
# wrong. config.log is where it says so, four lines further down, and the
|
|
# summary on stderr never mentions a version at all.
|
|
#
|
|
# WE ALREADY BUILT WHAT IS NEEDED. repo/s390x holds libgpg-error 1.61,
|
|
# complete with usr/bin/gpgrt-config and usr/lib/pkgconfig/gpg-error.pc.
|
|
#
|
|
# SO THIS HOOK CROSSES A LINE, DELIBERATELY, AND IT IS WORTH NAMING. Stage 1
|
|
# builds against the HOST's libraries; consuming stage 1's own output is the
|
|
# property that defines stage 2. Here the host cannot supply a new enough
|
|
# library at all, so the choice was between using our own package and
|
|
# deferring libgcrypt -- which gnupg and systemd both declare, so the
|
|
# repository would not resolve. Using our own is also what a bootstrap does:
|
|
# each package built becomes an input available to the next. And stage 2
|
|
# rebuilds everything inside the chroot regardless, so this host-versus-ours
|
|
# distinction is erased there rather than inherited.
|
|
#
|
|
# Expect the precedent to recur at the next version floor.
|
|
#
|
|
# HOW, rather than --with-libgpg-error-prefix. That flag looks like the
|
|
# answer and is not: it sets GPG_ERROR_CONFIG to "$prefix/bin/gpg-error-config",
|
|
# a program modern libgpg-error no longer ships -- 1.61 has only gpgrt-config,
|
|
# invoked as `gpgrt-config gpg-error ...`. Pointing the flag at our prefix
|
|
# would name a file that does not exist, configure would fall back to the PATH
|
|
# and find the host's 1.51 again, and the error would not move.
|
|
#
|
|
# GPGRT_CONFIG is the variable configure actually consults. From its location
|
|
# it derives a prefix, then looks for pkgconfig/gpg-error.pc under
|
|
# <prefix>/lib -- which our extracted tree has. Verified by running the real
|
|
# configure on a copy:
|
|
#
|
|
# checking for gpgrt-config... .../stage1-prefix/usr/bin/gpgrt-config
|
|
# configure: Use gpgrt-config with .../stage1-prefix/usr/lib as gpg-error-config
|
|
# checking for GPG Error - version >= 1.56... yes (1.61-unknown)
|
|
# configure rc=0
|
|
#
|
|
# The export goes INTO build(). This hook runs in its own bash process, so an
|
|
# export here would never reach makepkg -- the same reason gcc.sh puts its
|
|
# MAKEFLAGS bound inside build() rather than at hook level.
|
|
set -euo pipefail
|
|
|
|
# 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 "libgcrypt: nothing to do at stage 2 -- our libgpg-error is installed in the chroot"
|
|
exit 0
|
|
fi
|
|
|
|
WORK="${WORK:-$HOME/work/arch-s390x}"
|
|
PREFIX="$WORK/stage1-prefix"
|
|
|
|
# Refreshed on every run rather than cached: if libgpg-error is rebuilt, a
|
|
# stale prefix would silently keep feeding the old one -- the same class of
|
|
# invisible staleness as the arch-meson copy left in /usr/local.
|
|
shopt -s nullglob
|
|
_gpe=("$WORK"/repo/s390x/libgpg-error-*.pkg.tar.*)
|
|
shopt -u nullglob
|
|
[ "${#_gpe[@]}" -ge 1 ] || {
|
|
echo "libgcrypt: no libgpg-error package in $WORK/repo/s390x" >&2; exit 1; }
|
|
rm -rf "$PREFIX"
|
|
mkdir -p "$PREFIX"
|
|
bsdtar -xf "${_gpe[0]}" -C "$PREFIX" usr || {
|
|
echo "libgcrypt: could not extract ${_gpe[0]}" >&2; exit 1; }
|
|
[ -x "$PREFIX/usr/bin/gpgrt-config" ] || {
|
|
echo "libgcrypt: extracted prefix has no gpgrt-config" >&2; exit 1; }
|
|
[ -f "$PREFIX/usr/lib/pkgconfig/gpg-error.pc" ] || {
|
|
echo "libgcrypt: extracted prefix has no gpg-error.pc" >&2; exit 1; }
|
|
_ver=$("$PREFIX/usr/bin/gpgrt-config" gpg-error --version 2>/dev/null || true)
|
|
echo "libgcrypt: stage-1 prefix holds libgpg-error ${_ver:-unknown}"
|
|
|
|
PREFIX="$PREFIX" python3 - <<'PY'
|
|
import io, os
|
|
s = io.open("PKGBUILD", encoding="utf-8").read()
|
|
assert "GPGRT_CONFIG" not in s, "libgcrypt: GPGRT_CONFIG already set, hook ran twice"
|
|
anchor = "build() {\n"
|
|
assert s.count(anchor) == 1, "libgcrypt: expected exactly one build()"
|
|
prefix = os.environ.get("PREFIX")
|
|
inject = anchor + (
|
|
" # Our own libgpg-error 1.61: the host's 1.51 is below the 1.56 floor.\n"
|
|
" export GPGRT_CONFIG=%s/usr/bin/gpgrt-config\n" % prefix)
|
|
s = s.replace(anchor, inject, 1)
|
|
io.open("PKGBUILD", "w", encoding="utf-8").write(s)
|
|
PY
|
|
grep -q "export GPGRT_CONFIG=$PREFIX/usr/bin/gpgrt-config" PKGBUILD || {
|
|
echo "libgcrypt: GPGRT_CONFIG not injected into build()" >&2; exit 1; }
|
|
echo "libgcrypt: build() points at our gpgrt-config (host libgpg-error is 1.51)"
|