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

52 lines
2.6 KiB
Bash
Executable file

#!/usr/bin/env bash
# zstd: bare cmake, so nobody passes -DCMAKE_INSTALL_LIBDIR.
#
# This PKGBUILD calls plain `cmake`, not the arch-cmake stand-in, so the
# -DCMAKE_INSTALL_LIBDIR=lib that stand-in supplies never arrives. zstd's own
# build/cmake/CMakeLists.txt does include(GNUInstallDirs), and GNUInstallDirs
# on this build host walks into its Debian branch:
#
# elseif (EXISTS "/etc/arch-release") <- absent here
# elseif (EXISTS "/etc/debian_version") <- present here
#
# and sets CMAKE_INSTALL_LIBDIR=lib/s390x-linux-gnu. The build then exits 0
# and ships the library where Arch's ld.so and pkgconf will never look:
#
# usr/lib/s390x-linux-gnu/libzstd.so.1.5.7
# usr/lib/ <- empty
#
# Note what is NOT the trap here. zstd looks like it might also run a plain
# `make` next to the cmake tree; it does not. There is exactly one configure
# (`cmake -S build/cmake -B build`), `cmake --build build` drives that same
# build dir, and `cmake --install build` installs from it. One insertion
# covers the whole package.
#
# It has to, because CMAKE_INSTALL_LIBDIR is the single root of four separate
# poisoned paths -- fixing only the .so would have left three:
#
# lib/CMakeLists.txt:279 LIBRARY DESTINATION -> libzstd.so*
# lib/CMakeLists.txt:270 pkgconfig -> libzstd.pc location
# lib/CMakeLists.txt:264 join_paths(LIBDIR) -> libdir= INSIDE libzstd.pc
# CMakeLists.txt:212 ConfigPackageLocation -> cmake/zstd/*.cmake
#
# The third is why this package is worse than it looks. The shipped
# libzstd.pc reads libdir=${exec_prefix}/lib/s390x-linux-gnu, so the poison
# does not stop at zstd: every downstream package that finds zstd through
# pkg-config inherits -L/usr/lib/s390x-linux-gnu and hardcodes a path that
# does not exist on the target. And zstd is a pacman dependency -- pacman
# links libzstd.so.1 -- so the current artefact yields a system that cannot
# run its own package manager to repair itself.
set -euo pipefail
python3 - <<'PY'
import io
s = io.open("PKGBUILD", encoding="utf-8").read()
assert "CMAKE_INSTALL_LIBDIR" not in s, "zstd: libdir already pinned, hook ran twice"
old = " -DCMAKE_INSTALL_PREFIX=/usr \\\n"
n = s.count(old)
assert n == 1, "zstd: expected 1 cmake configure, found %d" % n
s = s.replace(old, old + " -DCMAKE_INSTALL_LIBDIR=lib \\\n", 1)
io.open("PKGBUILD", "w", encoding="utf-8").write(s)
PY
[ "$(grep -c -- '-DCMAKE_INSTALL_LIBDIR=lib' PKGBUILD)" = 1 ] || {
echo "zstd: libdir not pinned exactly once" >&2; exit 1; }
echo "zstd: CMAKE_INSTALL_LIBDIR=lib (GNUInstallDirs would say multiarch)"