archlinux-s390x/patches/pkgbuild/pacman.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

55 lines
2.7 KiB
Bash
Executable file

#!/usr/bin/env bash
# pacman: bare meson takes its libdir from the Debian host.
#
# The build host is Ubuntu, so meson's default_libdir() asks
# dpkg-architecture for the multiarch tuple and hands back
#
# lib/s390x-linux-gnu
#
# devtools' arch-meson would override that, but this PKGBUILD calls BARE
# `meson`, so nothing does. The build then succeeds, makepkg exits 0, and the
# package ships
#
# usr/lib/s390x-linux-gnu/libalpm.so.16
#
# where Arch's ld.so never looks -- it reads /usr/lib. libalpm is pacman's
# OWN library, so a target installed from this package has a package manager
# that cannot start, and no way to pacman -U the fix. Nothing in the build log
# says a word about it. This is the single most expensive instance of the
# libdir slip in the port, which is why it gets its own hook rather than
# waiting for the arch-meson stand-in to cover it.
#
# The same slip poisons two things downstream of the library file:
# - .../pkgconfig/libalpm.pc, whose `libdir=${prefix}/lib/s390x-linux-gnu`
# then aims every consumer at the same dead directory;
# - makepkg's own autodep. /etc/makepkg.conf sets
# LIB_DIRS=('lib:usr/lib' 'lib32:usr/lib32') and library_provides.sh runs
# `find "$pkgdir/$dir" -maxdepth 1`, so it never descends into the
# multiarch directory. .PKGINFO recorded a bare `provides = libalpm.so`
# with no version, where it should read libalpm.so=16-64 -- so every
# `libalpm.so=16-64` dependency in the port would go unsatisfiable, and
# the error would name the package that wanted it, never pacman.
#
# Only the configure call takes a libdir. The other four `meson` words in the
# file -- makedepends, compile, test, install -- take none and are left alone.
# The count is asserted rather than assumed.
#
# libdir only. sbindir and libexecdir also keep non-Arch defaults here, but
# pacman installs nothing into either -- the manifest is /usr/{bin,include,
# lib,share} and /etc, nothing else. Setting them would be a change with no
# artefact behind it, and if upstream ever does add an sbin binary we want to
# see it rather than have it silently absorbed.
set -euo pipefail
python3 - <<'PY'
import io
s = io.open("PKGBUILD", encoding="utf-8").read()
old = " meson --prefix=/usr \\\n"
n = s.count(old)
assert n == 1, "pacman: expected 1 meson configure call, found %d" % n
assert "libdir" not in s, "pacman: PKGBUILD already sets a libdir, re-read it"
s = s.replace(old, old + " --libdir=lib \\\n", 1)
io.open("PKGBUILD", "w", encoding="utf-8").write(s)
PY
[ "$(grep -c -- '--libdir=lib' PKGBUILD)" = 1 ] || {
echo "pacman: libdir not forced to lib exactly once" >&2; exit 1; }
echo "pacman: libdir forced to /usr/lib (Debian host defaults it to multiarch)"