archlinux-s390x/patches/pkgbuild/p11-kit.sh
Mathieu Benoit c375f994fe [FIX] tpm2-tss without integration tests, p11-kit's doc sub-package
tpm2-tss had three obstacles, each hidden by the one before: a missing AX_* macro
(fixed by autoconf-archive), then cmocka, now

  configure: error: Missing required program 'ss': ensure it is installed

`ss` comes from iproute2, and adding iproute2 was the first idea -- it is in
Arch's base group and belongs here eventually. Measured first: it depends on
libbpf, iptables and linux-atm, none of them present, and libbpf is the
dependency systemd was already spared for the same reason. Three packages to
satisfy a test-suite prerequisite, or --disable-integration. The tests are not
run; --nocheck covers the whole first pass.

p11-kit is the thirteenth instance of this shape and the third layer of the same
package: the build flag, the _pick that staged the docs, and now the sub-package
function that moves what _pick staged. Five of these thirteen have been mine, so
the rule is worth writing down: disabling a documentation build means following it
through the entire package() chain, not just switching it off.

--- FR ---

tpm2-tss avait trois obstacles, chacun masqué par le précédent : une macro AX_*
absente (réglée par autoconf-archive), puis cmocka, et maintenant

  configure: error: Missing required program 'ss': ensure it is installed

`ss` vient d'iproute2, et l'ajouter fut la première idée — il est dans le groupe
base d'Arch et y a sa place à terme. Mesuré d'abord : il dépend de libbpf,
iptables et linux-atm, aucun présent, et libbpf est la dépendance dont systemd
avait déjà été dispensé pour la même raison. Trois paquets pour satisfaire un
prérequis de suite de tests, ou --disable-integration. Les tests ne tournent pas :
--nocheck couvre toute la première passe.

p11-kit est la treizième occurrence de cette forme et la troisième couche du même
paquet : le drapeau de construction, le _pick qui préparait la documentation, et
maintenant la fonction de sous-paquet qui déplace ce que _pick préparait. Cinq de
ces treize sont de ma main : la règle mérite d'être écrite — désactiver une
documentation, c'est la suivre dans toute la chaîne package(), pas seulement
l'éteindre.

Assisted-by: Claude Opus 5
2026-08-23 23:33:38 -04:00

106 lines
5.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# p11-kit: no gtk-doc manual.
#
# meson.build:65:18: ERROR: Dependency "glib-2.0" not found (tried pkgconfig)
#
# THIS ONE WAS NEARLY A SUB-PROJECT. glib-2.0 is not in this port, and adding it
# is not one package: Arch's glib2 wants gobject-introspection (which itself
# needs glib2 -- a cycle to bootstrap), libsysprof-capture, dconf and gi-docgen.
# Several packages and a circular dependency, for one entry in one build.
#
# Reading where the requirement actually comes from changed the answer entirely.
# The file is doc/manual/meson.build, and the line is
#
# glib_prefix = dependency('glib-2.0').get_variable(pkgconfig : 'prefix')
#
# glib is consulted to find where gtk-doc keeps its cross-reference files. It is
# not linked, not called, and nothing in p11-kit's code touches it. -D gtk_doc
# is already in the PKGBUILD's option list, set to true; turning it false drops
# the whole doc/manual subdirectory and the dependency with it.
#
# The lesson is the one this port keeps relearning: the error names glib, and
# glib is not the subject. Six lines of context said so.
set -euo pipefail
python3 - <<'ZZPY'
import io, re
lines = io.open("PKGBUILD", encoding="utf-8").read().split("\n")
hit = [i for i, l in enumerate(lines) if re.match(r"^[ \t]*-D gtk_doc=true[ \t]*$", l)]
assert len(hit) == 1, "p11-kit: expected one -D gtk_doc=true, got %d" % len(hit)
lines[hit[0]] = lines[hit[0]].replace("gtk_doc=true", "gtk_doc=false")
io.open("PKGBUILD", "w", encoding="utf-8").write("\n".join(lines))
ZZPY
grep -q -- "-D gtk_doc=false" PKGBUILD || { echo "p11-kit: gtk_doc not disabled" >&2; exit 1; }
echo "p11-kit: gtk-doc manual disabled (glib was only locating its xrefs)"
# --- and no man pages either --------------------------------------------------
#
# With gtk_doc off, the next line was
#
# meson.build:94:4: ERROR: Problem encountered: Docbook stylesheet for man
# pages not found
#
# The stylesheets, not xsltproc -- which our libxslt supplies. Third package to
# stop on exactly this: pam validates DocBook sources it cannot fetch, shadow
# renders man pages from them. Shipping docbook-xsl would be a package that only
# documentation needs; -D man is already in the option list.
python3 - <<'ZZPY'
import io, re
lines = io.open("PKGBUILD", encoding="utf-8").read().split("\n")
hit = [i for i, l in enumerate(lines) if re.match(r"^[ \t]*-D man=true[ \t]*$", l)]
assert len(hit) == 1, "p11-kit: expected one -D man=true, got %d" % len(hit)
lines[hit[0]] = lines[hit[0]].replace("man=true", "man=false")
io.open("PKGBUILD", "w", encoding="utf-8").write("\n".join(lines))
ZZPY
grep -q -- "-D man=false" PKGBUILD || { echo "p11-kit: man not disabled" >&2; exit 1; }
echo "p11-kit: man pages disabled (DocBook stylesheets absent, not xsltproc)"
# --- and the gtk-doc split ----------------------------------------------------
#
# mv: cannot stat '<pkgdir>/usr/share/gtk-doc': No such file or directory
#
# TWELFTH time. -D gtk_doc=false above stopped the documentation being built and
# left package() splitting it out:
#
# _pick doc "$pkgdir"/usr/share/gtk-doc
#
# _pick is Arch's helper for moving a path into a sub-package, and it is as fatal
# on a missing path as a bare mv.
python3 - <<'ZZPY'
import io, re
lines = io.open("PKGBUILD", encoding="utf-8").read().split("\n")
hit = [i for i, l in enumerate(lines) if "gtk-doc" in l and "_pick" in l]
assert len(hit) == 1, "p11-kit: expected one gtk-doc _pick, got %d" % len(hit)
i = hit[0]
ind = re.match(r"^[ \t]*", lines[i]).group(0)
lines[i] = ind + ": # gtk_doc is false above, so usr/share/gtk-doc is never created."
io.open("PKGBUILD", "w", encoding="utf-8").write("\n".join(lines))
ZZPY
grep -qE "_pick doc .*gtk-doc" PKGBUILD && {
echo "p11-kit: the gtk-doc pick survived" >&2; exit 1; }
echo "p11-kit: gtk-doc split removed (nothing builds it now)"
# --- and the doc sub-package that now stages nothing --------------------------
#
# mv: cannot stat 'doc/*': No such file or directory
#
# THIRTEENTH time, and the third layer of the same package. Neutralising the
# _pick above stopped anything being staged into doc/, and package_p11-kit-doc()
# still runs `mv doc/* "$pkgdir"`. _pick, mv, and now the sub-package function
# that consumes what _pick staged: three places for one decision.
#
# The lesson is stated plainly because five of these have been mine: disabling a
# documentation build means following it through the ENTIRE package() chain --
# the build flag, the staging, and the sub-package that reads the staging area.
python3 - <<'ZZPY'
import io, re
lines = io.open("PKGBUILD", encoding="utf-8").read().split("\n")
hit = [i for i, l in enumerate(lines) if re.match(r"^[ \t]*mv doc/\* ", l)]
assert len(hit) == 1, "p11-kit: expected one `mv doc/*`, got %d" % len(hit)
i = hit[0]
ind = re.match(r"^[ \t]*", lines[i]).group(0)
lines[i] = ind + ": # nothing is staged into doc/: gtk_doc and man are both off."
io.open("PKGBUILD", "w", encoding="utf-8").write("\n".join(lines))
ZZPY
grep -qE "^[[:space:]]*mv doc/\*" PKGBUILD && {
echo "p11-kit: the doc move survived" >&2; exit 1; }
echo "p11-kit: doc sub-package stages nothing, and no longer tries"