diff --git a/patches/pkgbuild/grep.sh b/patches/pkgbuild/grep.sh new file mode 100755 index 0000000..f1a0230 --- /dev/null +++ b/patches/pkgbuild/grep.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# grep: skip ./bootstrap, which vets its host's autotools macros. +# +# ./bootstrap: do not use pkg.m4 serial 12; +# see https://lists.gnu.org/r/grep-devel/2025-04/msg00006.html +# +# grep is the only package in this list that INSPECTS the version of the m4 +# macros its build host provides, and refuses to proceed on the serial Ubuntu +# ships. It is not detecting a real incompatibility on s390x -- the same +# refusal happens on any Ubuntu host, x86 included. +# +# The release tarball is already bootstrapped: configure, Makefile.in and the +# gnulib tree are present. Re-running ./bootstrap regenerates what is already +# there, so skipping it costs nothing. +set -euo pipefail +sed -i 's|^\(\s*\)\./bootstrap|\1# bootstrap skipped by the port: see patches/pkgbuild/grep.sh\n\1true|' PKGBUILD +grep -qE '^\s*\./bootstrap' PKGBUILD && { echo "grep: bootstrap still invoked" >&2; exit 1; } +echo "grep: ./bootstrap skipped (it rejects the host pkg.m4 serial)" diff --git a/patches/pkgbuild/util-linux.sh b/patches/pkgbuild/util-linux.sh new file mode 100755 index 0000000..20b8eab --- /dev/null +++ b/patches/pkgbuild/util-linux.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# util-linux: s390x installs to lib64, Arch expects lib. +# +# rm: cannot remove '.../pkg/util-linux/usr/lib/lib*.la': No such file +# +# The same divergence already handled in gcc.sh: 64-bit Z installs libraries +# into usr/lib64, while every Arch PKGBUILD names usr/lib. Here it shows up +# as a glob that matches nothing, which `rm` reports as a missing file rather +# than an empty expansion -- so the error names a path that was never going +# to exist. +# +# Merged before package() touches anything, so the upstream paths keep +# working unchanged. +set -euo pipefail +python3 - <<'PY' +import io, re +s = io.open("PKGBUILD", encoding="utf-8").read() +merge = """ # s390x installs 64-bit libraries to lib64; Arch expects lib. + if [ -d "$pkgdir/usr/lib64" ]; then + mkdir -p "$pkgdir/usr/lib" + cp -a "$pkgdir/usr/lib64/." "$pkgdir/usr/lib/" + rm -rf "$pkgdir/usr/lib64" + fi +""" +m = re.search(r"\npackage_util-linux\(\) \{\n", s) +if not m: + m = re.search(r"\npackage\(\) \{\n", s) +assert m, "package function not found" +s = s[:m.end()] + merge + s[m.end():] +io.open("PKGBUILD", "w", encoding="utf-8").write(s) +PY +grep -q 'installs 64-bit libraries to lib64' PKGBUILD || { + echo "util-linux: lib64 merge not inserted" >&2; exit 1; } +echo "util-linux: lib64 merged into lib before packaging"