archlinux-s390x/patches/pkgbuild/expat.sh
Mathieu Benoit ddbf91108f [FIX] libdir: the Debian host hid the libraries from Arch
meson and cmake both ask the HOST where libraries go. On Ubuntu the
answer is lib/s390x-linux-gnu, so five packages already in the repository
ship theirs where Arch's ld.so and pkgconf never look. Measured:

  expat 12  lz4 6  pacman 6  pkgconf 6  zstd 12   entries

Nothing failed. util-linux is where it finally shouted, and even there
the rm was the first victim, not the cause.

pacman is the one that matters: libalpm.so.16 landed where pacman's own
binary cannot load it, and a target installed from that package has no
working package manager left to repair itself with.

arch-meson now states the libdir devtools has no need to state, and is
reinstalled on every run -- editing the copy here changed nothing while
/usr/local/bin held a stale one. Four packages call bare meson or cmake
and get their own hook. util-linux's old hook chased lib64, which never
existed here; it is deleted.

--- FR ---

meson et cmake demandent tous deux à l'HÔTE où vont les bibliothèques.
Sous Ubuntu la réponse est lib/s390x-linux-gnu : cinq paquets déjà dans
le dépôt livrent donc les leurs là où ld.so et pkgconf d'Arch ne
regarderont jamais. Mesuré :

  expat 12  lz4 6  pacman 6  pkgconf 6  zstd 12   entrées

Rien n'a échoué. util-linux est l'endroit où cela a fini par crier, et
même là le rm était la première victime, pas la cause.

pacman est celui qui compte : libalpm.so.16 atterrissait là où le binaire
de pacman ne peut pas la charger, et une cible installée depuis ce paquet
n'a plus de gestionnaire de paquets pour se réparer.

arch-meson énonce désormais le libdir que devtools n'a pas besoin
d'énoncer, et se réinstalle à chaque exécution : éditer la copie du dépôt
ne changeait rien tant que /usr/local/bin en gardait une périmée. Quatre
paquets appellent meson ou cmake nu et reçoivent leur crochet. L'ancien
crochet util-linux poursuivait un lib64 qui n'a jamais existé ici : il
est supprimé.

Assisted-by: Claude Opus 5
2026-08-17 01:33:41 -04:00

43 lines
2.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# expat: bare cmake picks up the Debian multiarch libdir.
#
# The PKGBUILD calls cmake directly -- NOT arch-cmake -- so the devtools
# stand-in that already passes -DCMAKE_INSTALL_LIBDIR=lib never runs. The
# option array only pins the prefix.
#
# expat's CMakeLists include(GNUInstallDirs), and GNUInstallDirs picks its
# default LIBDIR by sniffing the HOST: it sees /etc/debian_version, finds no
# /etc/arch-release, and sets lib/<multiarch> = lib/s390x-linux-gnu. Because
# CMAKE_INSTALL_LIBDIR was never given, that default wins and is cached.
#
# The build then exits 0 and the package installs cleanly. It is the ARTEFACT
# that is wrong -- everything LIBDIR-derived lands off Arch's search paths:
#
# usr/lib/s390x-linux-gnu/libexpat.so.1.12.3 ld.so reads /usr/lib only
# usr/lib/s390x-linux-gnu/pkgconfig/expat.pc pkgconf reads /usr/lib only
# usr/lib/s390x-linux-gnu/cmake/expat-2.8.3/ find_package(EXPAT) misses
#
# and usr/lib itself holds nothing but that subdirectory. expat is a
# dependency of cmake, python, gdb and fontconfig, so this does not fail
# loudly here -- it fails later, in whatever links against -lexpat.
#
# The fix is to state the libdir the stand-in would have stated. Passing it on
# the command line makes it a cache entry BEFORE GNUInstallDirs runs, and
# GNUInstallDirs only fills in defaults for variables that are still unset.
#
# One configure call, so exactly one insertion: assert the count rather than
# rewriting every -D.
set -euo pipefail
python3 - <<'PY'
import io
s = io.open("PKGBUILD", encoding="utf-8").read()
assert "CMAKE_INSTALL_LIBDIR" not in s, "expat: libdir already set, hook ran twice"
anchor = " -D CMAKE_INSTALL_PREFIX=/usr\n"
n = s.count(anchor)
assert n == 1, "expat: expected 1 cmake option block, found %d" % n
s = s.replace(anchor, anchor + " -D CMAKE_INSTALL_LIBDIR=lib\n", 1)
io.open("PKGBUILD", "w", encoding="utf-8").write(s)
PY
[ "$(grep -c 'CMAKE_INSTALL_LIBDIR=lib' PKGBUILD)" = 1 ] || {
echo "expat: libdir not pinned exactly once" >&2; exit 1; }
echo "expat: CMAKE_INSTALL_LIBDIR=lib (bare cmake bypasses arch-cmake)"