archlinux-s390x/patches/pkgbuild/groff.sh
Mathieu Benoit ac5e5f3892 [FIX] groff: the figure and the document that includes it
Emptying DOC_GNU_EPS stopped the GNU logo being built and left the document that
includes it:

  doc/webpage.ms:45: error: cannot open gnu.eps
  doc/webpage.ms:45: fatal error: PSPIC failed to include gnu.eps

Tenth time in this port, fourth of my own making. PROCESSEDEXAMPLEFILES_PS lists
webpage.ps and grnexmpl.ps, and the HTML variant directly above it is ALREADY
empty with its real value left as a comment -- groff configure empties that one
when the tools are missing. This does the same for PS, which is the decision
groff would have made had it checked.

--- FR ---

Vider DOC_GNU_EPS a empeche la construction du logo GNU et laisse en place le
document qui l inclut :

  doc/webpage.ms:45: error: cannot open gnu.eps
  doc/webpage.ms:45: fatal error: PSPIC failed to include gnu.eps

Dixieme fois dans ce portage, quatrieme de ma main. PROCESSEDEXAMPLEFILES_PS
liste webpage.ps et grnexmpl.ps, et la variante HTML juste au-dessus est DEJA
vide, sa vraie valeur laissee en commentaire — le configure de groff vide
celle-la quand les outils manquent. Ceci fait de meme pour PS : la decision que
groff aurait prise s il avait verifie.

Assisted-by: Claude Opus 5
2026-08-23 21:03:23 -04:00

60 lines
3.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# groff: one decorative figure, and no netpbm to draw it.
#
# program 'xpmtoppm' is missing; can't generate doc/gnu.eps
# make[2]: *** [Makefile:19801: doc/gnu.eps] Error 1
#
# xpmtoppm belongs to netpbm. What it produces is the GNU logo, as EPS, for
# groff's own manual -- and getting it would mean packaging netpbm and the image
# libraries under it (libjpeg-turbo, libpng, libtiff, jbigkit), none of which
# anything else in this bootstrap wants.
#
# NO CONFIGURE SWITCH EXISTS: groff's configure has neither --without-doc nor
# --disable-doc, so there was nothing to turn off. Adding an invented flag would
# have been worse than useless -- autoconf merely warns about options it does not
# know, the build would have failed identically, and the hook's own check would
# have passed.
#
# The Makefile is generated, so it is edited after configure and before make. The
# variable is emptied rather than the rule patched, because the INSTALL side is
# already tolerant:
#
# if test -f "$$d/gnu.eps"; then ... fi
#
# so with nothing built, nothing is installed and nothing complains. One line,
# and the only one whose absence the rest of the Makefile already handles.
set -euo pipefail
python3 - <<'ZZPY'
import io, re
lines = io.open("PKGBUILD", encoding="utf-8").read().split("\n")
mk = [i for i, l in enumerate(lines) if re.match(r"^[ \t]*make[ \t]*$", l)]
assert len(mk) >= 1, "groff: no bare `make` line found in build()"
i = mk[0]
ind = re.match(r"^[ \t]*", lines[i]).group(0)
lines[i:i] = [
ind + "# doc/gnu.eps needs xpmtoppm from netpbm, which this port does not",
ind + "# package. The install side already skips the file when it is absent.",
ind + 'sed -i "s|^DOC_GNU_EPS = doc/gnu.eps$|DOC_GNU_EPS =|" Makefile',
ind + 'grep -q "^DOC_GNU_EPS =$" Makefile',
ind + "# And its CONSUMER. Emptying DOC_GNU_EPS removed the rule that",
ind + "# builds the figure and not the document that includes it:",
ind + "#",
ind + "# doc/webpage.ms:45: error: cannot open 'gnu.eps'",
ind + "# doc/webpage.ms:45: fatal error: PSPIC failed to include 'gnu.eps'",
ind + "#",
ind + "# PROCESSEDEXAMPLEFILES_PS lists webpage.ps and grnexmpl.ps. The",
ind + "# HTML variant right above it is ALREADY empty, with its real value",
ind + "# left as a comment -- groff's own configure empties that one when",
ind + "# the tools are missing. This does the same for PS, which is the",
ind + "# decision groff would have made had it checked.",
ind + 'sed -i "/^PROCESSEDEXAMPLEFILES_PS = /,/^$/ s|^.*$||" Makefile',
ind + 'grep -q "^PROCESSEDEXAMPLEFILES_PS" Makefile && { echo "groff: PS example list not emptied" >&2; exit 1; }',
]
io.open("PKGBUILD", "w", encoding="utf-8").write("\n".join(lines))
ZZPY
grep -q "DOC_GNU_EPS" PKGBUILD || { echo "groff: the figure was not dropped" >&2; exit 1; }
# The grep inside build() is the real check: it runs against the generated
# Makefile and fails the build if the variable was not what this hook expects.
grep -q 'grep -q "\^DOC_GNU_EPS =\$" Makefile' PKGBUILD || {
echo "groff: the in-build verification is missing" >&2; exit 1; }
echo "groff: GNU logo figure dropped (no netpbm)"