archlinux-s390x/patches/pkgbuild/pacman.sh
Mathieu Benoit 07486af2fa [FIX] systemd without BPF, pacman without asciidoc
Two more documentation-and-toolchain cuts, both using the project's own switch.

systemd asked for libbpf, which this port does not package -- and packaging it
means clang and llvm, an entire second compiler toolchain for unit features
nothing here uses yet. pacman asked for asciidoc, the same Python documentation
stack already declined for doxygen, asciidoctor and a2x.

pacman is worth naming out loud: it is the package manager, so its man pages are
the ones a user reaches for first. This is the most visible of the documentation
cuts and the strongest single argument for restoring them at stage 3.

--- FR ---

Deux coupes de plus, documentation et chaîne d'outils, chacune par l'interrupteur
prévu par le projet lui-même.

systemd réclamait libbpf, que ce portage ne paquette pas — et le paqueter suppose
clang et llvm, soit une seconde chaîne de compilation entière pour des fonctions
d'unité dont rien ici ne se sert encore. pacman réclamait asciidoc, la même pile
Python déjà écartée pour doxygen, asciidoctor et a2x.

pacman mérite d'être nommé : c'est le gestionnaire de paquets, donc ses pages de
manuel sont les premières qu'un utilisateur cherche. C'est la plus visible de ces
coupes, et le meilleur argument pour les restaurer à l'étage 3.

Assisted-by: Claude Opus 5
2026-08-21 21:25:20 -04:00

81 lines
3.8 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)"
# --- no asciidoc documentation ------------------------------------------------
#
# ERROR: Program 'asciidoc' not found or not executable
#
# pacman's man pages come from asciidoc, a Python toolchain this port declined
# along with doxygen, asciidoctor and a2x -- each of them a language runtime
# whose only job is rendering documentation. -Ddoc=disabled is meson's own
# switch.
#
# Worth noting where this one lands: pacman IS the package manager, so its man
# pages are the ones a user reaches for first. This is the most visible of the
# documentation cuts and the strongest argument for restoring them at stage 3,
# where the tools can be built against a self-hosted toolchain.
set -euo pipefail
python3 - <<'ZZPY'
import io
s = io.open("PKGBUILD", encoding="utf-8").read()
old = "-Ddoc=enabled"
assert s.count(old) == 1, "pacman: expected one doc option, got %d" % s.count(old)
s = s.replace(old, "-Ddoc=disabled", 1)
io.open("PKGBUILD", "w", encoding="utf-8").write(s)
ZZPY
grep -q -- "-Ddoc=disabled" PKGBUILD || {
echo "pacman: doc was not disabled" >&2; exit 1; }
echo "pacman: man pages disabled (no asciidoc)"