archlinux-s390x/patches/pkgbuild/rsync.sh
Mathieu Benoit eafa3355aa [FIX] stage 2: the build tools the host was providing silently
glibc rebuilt inside the chroot; binutils died on `make info-recursive`, and
makeinfo said why: its XS module was compiled against the host's perl 5.40 and
our perl is 5.42. Stage-1 texinfo cannot run in there. Everything that builds
.info documentation needs it, and it sat near the end of the list because that
is where its own dependencies are, so stage 2 hoists it.

linux-api-headers stopped earlier on `rsync: command not found` -- the kernel's
headers_install runs it. apt had put it there and a build that finds its tool
says nothing, so stage 1 never mentioned it. Its man pages come from Markdown
the git tag does not pre-render, hence --disable-md2man.

An inventory of the 110 apt packages against the chroot found 84 more such
binaries. Most are documentation; the rest wait until something needs them.

--- FR ---

glibc a été rebâti dans le chroot ; binutils est mort sur `make info-recursive`,
et makeinfo en donne la raison : son module XS a été compilé contre le perl 5.40
de l'hôte, or le nôtre est en 5.42. Le texinfo de l'étage 1 ne peut pas tourner
là-dedans. Tout ce qui bâtit de la documentation .info en dépend, et il figurait
en fin de liste, là où sont ses propres dépendances : l'étage 2 le remonte.

linux-api-headers s'était arrêté avant sur `rsync: command not found` — le
headers_install du noyau l'appelle. apt l'avait posé, et une construction qui
trouve son outil n'en dit rien : l'étage 1 ne l'a jamais mentionné. Ses pages de
manuel viennent d'un Markdown que l'étiquette git ne rend pas, d'où
--disable-md2man.

Un inventaire des 110 paquets apt face au chroot a trouvé 84 autres binaires du
même genre. La plupart sont de la documentation ; le reste attendra qu'un paquet
les réclame.

Assisted-by: Claude Opus 5
2026-08-20 01:34:41 -04:00

60 lines
2.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# rsync: no man pages, because nothing here can render them.
#
# - You need python3 and either the cmarkgfm OR commonmark python3 lib in
# order to build manpages based on the git source
# configure.sh: error: Aborting configure run
#
# rsync is built from the git tag, and the git tree ships man pages as Markdown
# rather than nroff -- the release tarballs carry them pre-rendered, the tag
# does not. Rendering wants a Python Markdown library that this port does not
# have at either stage: not on the host, and not in the chroot, where there is
# no pip to reach for.
#
# --disable-md2man is named by the error itself. Same arbitration as
# --auto-features auto in build-stage2.sh: the documentation gives way and the
# tool gets built. Restore at stage 3, alongside the rest of it.
#
# WHY rsync IS HERE AT ALL. It is not part of Arch's base and nothing in this
# port depends on it at runtime. It is a BUILD tool: the kernel's
# headers_install target runs it, so linux-api-headers -- the first entry in
# packages.sh -- cannot be rebuilt inside the chroot without it. The host had
# it from apt, which is precisely why stage 1 never mentioned it.
#
# BOTH STAGES, no skip entry: the chroot has no Markdown renderer either, and
# stage 2 is where rsync is actually needed.
set -euo pipefail
python3 - <<'ZZPY'
import io, re
# LINE-BASED, and [ \t]* rather than \s*.
#
# The first attempt matched r"^(\s*)\./configure" and inserted at the match
# end. It produced
#
# ./configure \
# <- blank line
# --disable-md2man \
#
# and the guard below caught it. \s MATCHES NEWLINES: with re.M the pattern
# could start at the blank line above, swallow "\n " into the captured
# indent, and put that newline back into the file. The flag was in the file,
# on its own paragraph, attached to nothing.
#
# Working on the LINE removes the arithmetic entirely -- there is no offset to
# be wrong about.
lines = io.open("PKGBUILD", encoding="utf-8").read().split("\n")
hit = [i for i, l in enumerate(lines) if re.match(r"^[ \t]*\./configure\b", l)]
assert len(hit) == 1, "rsync: expected exactly one ./configure line, got %d" % len(hit)
i = hit[0]
indent = re.match(r"^[ \t]*", lines[i]).group(0)
assert lines[i].rstrip().endswith("\\"), "rsync: ./configure does not continue onto the next line"
lines.insert(i + 1, indent + " --disable-md2man \\")
io.open("PKGBUILD", "w", encoding="utf-8").write("\n".join(lines))
ZZPY
grep -q -- '--disable-md2man' PKGBUILD || {
echo "rsync: --disable-md2man was not inserted" >&2; exit 1; }
# The insert must have landed on the configure line, not merely somewhere in the
# file -- a flag in a comment or a later block would look identical to grep.
grep -A1 -E '^\s*\./configure' PKGBUILD | grep -q -- '--disable-md2man' || {
echo "rsync: the flag is in the file but not on ./configure" >&2; exit 1; }
echo "rsync: man pages disabled (no Markdown renderer at either stage)"