archlinux-s390x/scripts/bootstrap-pacman.sh

148 lines
6.4 KiB
Bash
Raw Normal View History

[ADD] bootstrap pacman, makepkg and repo-add natively on s390x The README lists pacman, bash and coreutils as three missing pieces. They are not three tasks: pacman is the only one that matters, because its source tree also ships makepkg and repo-add. Once those run, every remaining package stops being hand-work and becomes makepkg on the upstream PKGBUILD. pacman 7.1.0 builds unpatched on s390x. No cross-compilation is involved: on native hardware the whole userspace builds at full speed, which removes the z/VM round-trip the other scripts need. Measured end to end: zlib built from the official PKGBUILD yields zlib, zlib-static and minizip, all tagged arch = s390x, the library reporting "ELF 64-bit MSB shared object, IBM S/390", and repo-add indexing them into a usable core.db. --- FR --- Le README annonce pacman, bash et coreutils comme trois pieces manquantes. Ce ne sont pas trois travaux : seul pacman compte, parce que son arbre source livre aussi makepkg et repo-add. Des qu ils tournent, chaque paquet restant cesse d etre du travail manuel et devient un makepkg sur le PKGBUILD amont. pacman 7.1.0 se compile sans correctif sur s390x. Aucune compilation croisee n intervient : sur du materiel natif tout l espace utilisateur se batit a pleine vitesse, ce qui supprime l aller-retour z/VM dont dependent les autres scripts. Mesure de bout en bout : zlib bati depuis le PKGBUILD officiel produit zlib, zlib-static et minizip, tous marques arch = s390x, la bibliotheque se declarant « ELF 64-bit MSB shared object, IBM S/390 », et repo-add les indexant dans un core.db utilisable. Assisted-by: Claude Opus 5
2026-08-15 03:18:47 -04:00
#!/usr/bin/env bash
# Bootstrap the Arch packaging toolchain (pacman, makepkg, repo-add) on an
# s390x host, then build official Arch PKGBUILDs for s390x.
#
# WHY THIS IS THE KEYSTONE
#
# The README lists "pacman, bash and GNU coreutils are not yet ported" as three
# missing pieces. They are not three tasks -- pacman is the only one that
# matters, because pacman's source tree also ships makepkg and repo-add. Once
# those three run, every remaining package stops being hand-work and becomes
# `makepkg` on the upstream PKGBUILD.
#
# NO CROSS-COMPILATION IS NEEDED HERE. This runs on native s390x hardware, so
# the whole userspace builds at full speed with the host toolchain. That drops
# the z/VM round-trip the other scripts need.
set -euo pipefail
[FIX] trust artefacts, not exit codes; add a PKGBUILD patch mechanism A run reported "51 built, 0 failed" while glibc, gcc, coreutils and pacman had all failed. The cause is a bash rule that is easy to forget: callers invoke build_package inside an "if", and "if" DISABLES set -e for the whole function body. A failing makepkg fell through to repo-add, whose success became the function exit status. build_package now returns explicitly on failure and, more importantly, verifies that a package file actually exists. An exit code is not proof; only the artefact is. Measured before the fix: 23 files in the repository where a hundred were claimed. First real port patch, applied through a per-package hook rather than by hand: the glibc PKGBUILD passes --enable-sframe, and s390x has no SFrame at all -- configure refuses outright. Hooks re-clone cleanly, so an upstream change is never silently discarded. --nocheck for stage 1: these test suites run against the HOST libraries, not the Arch ones, so their verdict says nothing about the port. acl failed its check step on a sound build. Stage 2 runs them for real. The remaining failures were host makedepends that --nodeps hides: po4a, gnat, debuginfod and jansson are now installed up front. --- FR --- Une execution annoncait « 51 built, 0 failed » alors que glibc, gcc, coreutils et pacman avaient tous echoue. La cause est une regle de bash qu on oublie : build_package est appelee dans un « if », et « if » DESACTIVE set -e pour tout le corps de la fonction. Un makepkg en echec poursuivait jusqu a repo-add, dont la reussite devenait le code de sortie. build_package rend desormais la main explicitement en cas d echec et, surtout, verifie qu un fichier de paquet existe vraiment. Un code de sortie ne prouve rien ; seul l artefact prouve. Mesure avant correction : 23 fichiers dans le depot la ou cent etaient annonces. Premier vrai correctif de portage, applique par crochet et non a la main : le PKGBUILD de glibc passe --enable-sframe, et s390x n a aucun SFrame -- configure refuse net. Les crochets survivent a un reclonage, donc une evolution amont n est jamais perdue en silence. --nocheck pour l etage 1 : ces suites s executent contre les bibliotheques de l HOTE, pas celles d Arch, et leur verdict ne dit rien du portage. acl echouait a son etape check sur une compilation saine. L etage 2 les executera pour de vrai. Les autres echecs etaient des makedepends d hote que --nodeps masque : po4a, gnat, debuginfod et jansson sont poses d entree. Assisted-by: Claude Opus 5
2026-08-15 20:40:17 -04:00
HERE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PATCH_DIR="${PATCH_DIR:-$HERE_DIR/../patches/pkgbuild}"
[ADD] bootstrap pacman, makepkg and repo-add natively on s390x The README lists pacman, bash and coreutils as three missing pieces. They are not three tasks: pacman is the only one that matters, because its source tree also ships makepkg and repo-add. Once those run, every remaining package stops being hand-work and becomes makepkg on the upstream PKGBUILD. pacman 7.1.0 builds unpatched on s390x. No cross-compilation is involved: on native hardware the whole userspace builds at full speed, which removes the z/VM round-trip the other scripts need. Measured end to end: zlib built from the official PKGBUILD yields zlib, zlib-static and minizip, all tagged arch = s390x, the library reporting "ELF 64-bit MSB shared object, IBM S/390", and repo-add indexing them into a usable core.db. --- FR --- Le README annonce pacman, bash et coreutils comme trois pieces manquantes. Ce ne sont pas trois travaux : seul pacman compte, parce que son arbre source livre aussi makepkg et repo-add. Des qu ils tournent, chaque paquet restant cesse d etre du travail manuel et devient un makepkg sur le PKGBUILD amont. pacman 7.1.0 se compile sans correctif sur s390x. Aucune compilation croisee n intervient : sur du materiel natif tout l espace utilisateur se batit a pleine vitesse, ce qui supprime l aller-retour z/VM dont dependent les autres scripts. Mesure de bout en bout : zlib bati depuis le PKGBUILD officiel produit zlib, zlib-static et minizip, tous marques arch = s390x, la bibliotheque se declarant « ELF 64-bit MSB shared object, IBM S/390 », et repo-add les indexant dans un core.db utilisable. Assisted-by: Claude Opus 5
2026-08-15 03:18:47 -04:00
WORK="${WORK:-$HOME/work/arch-s390x}"
REPO="${REPO:-$WORK/repo/s390x}"
PACMAN_GIT="https://gitlab.archlinux.org/pacman/pacman.git"
PKG_GIT_BASE="https://gitlab.archlinux.org/archlinux/packaging/packages"
log() { printf '\n== %s ==\n' "$*"; }
install_host_deps() {
log "Host build dependencies"
[FIX] trust artefacts, not exit codes; add a PKGBUILD patch mechanism A run reported "51 built, 0 failed" while glibc, gcc, coreutils and pacman had all failed. The cause is a bash rule that is easy to forget: callers invoke build_package inside an "if", and "if" DISABLES set -e for the whole function body. A failing makepkg fell through to repo-add, whose success became the function exit status. build_package now returns explicitly on failure and, more importantly, verifies that a package file actually exists. An exit code is not proof; only the artefact is. Measured before the fix: 23 files in the repository where a hundred were claimed. First real port patch, applied through a per-package hook rather than by hand: the glibc PKGBUILD passes --enable-sframe, and s390x has no SFrame at all -- configure refuses outright. Hooks re-clone cleanly, so an upstream change is never silently discarded. --nocheck for stage 1: these test suites run against the HOST libraries, not the Arch ones, so their verdict says nothing about the port. acl failed its check step on a sound build. Stage 2 runs them for real. The remaining failures were host makedepends that --nodeps hides: po4a, gnat, debuginfod and jansson are now installed up front. --- FR --- Une execution annoncait « 51 built, 0 failed » alors que glibc, gcc, coreutils et pacman avaient tous echoue. La cause est une regle de bash qu on oublie : build_package est appelee dans un « if », et « if » DESACTIVE set -e pour tout le corps de la fonction. Un makepkg en echec poursuivait jusqu a repo-add, dont la reussite devenait le code de sortie. build_package rend desormais la main explicitement en cas d echec et, surtout, verifie qu un fichier de paquet existe vraiment. Un code de sortie ne prouve rien ; seul l artefact prouve. Mesure avant correction : 23 fichiers dans le depot la ou cent etaient annonces. Premier vrai correctif de portage, applique par crochet et non a la main : le PKGBUILD de glibc passe --enable-sframe, et s390x n a aucun SFrame -- configure refuse net. Les crochets survivent a un reclonage, donc une evolution amont n est jamais perdue en silence. --nocheck pour l etage 1 : ces suites s executent contre les bibliotheques de l HOTE, pas celles d Arch, et leur verdict ne dit rien du portage. acl echouait a son etape check sur une compilation saine. L etage 2 les executera pour de vrai. Les autres echecs etaient des makedepends d hote que --nodeps masque : po4a, gnat, debuginfod et jansson sont poses d entree. Assisted-by: Claude Opus 5
2026-08-15 20:40:17 -04:00
# Two distinct groups, and confusing them costs hours.
#
# makepkg's OWN requirements: bsdtar and fakeroot. Without them it fails
# deep inside extraction with a bare "bsdtar: command not found".
#
# The PKGBUILDs' makedepends: --nodeps tells pacman not to check them, so
# every one must be satisfied from the Ubuntu host by hand. Each name on
# the last three lines was added because a build stopped on it --
# systemtap-sdt-dev and gmp/mpfr/mpc for glibc and gcc, autopoint and
# gperf for coreutils, asciidoc for pacman, po4a for xz, gnat for gcc's
# Ada front end, debuginfod and jansson for binutils.
[ADD] bootstrap pacman, makepkg and repo-add natively on s390x The README lists pacman, bash and coreutils as three missing pieces. They are not three tasks: pacman is the only one that matters, because its source tree also ships makepkg and repo-add. Once those run, every remaining package stops being hand-work and becomes makepkg on the upstream PKGBUILD. pacman 7.1.0 builds unpatched on s390x. No cross-compilation is involved: on native hardware the whole userspace builds at full speed, which removes the z/VM round-trip the other scripts need. Measured end to end: zlib built from the official PKGBUILD yields zlib, zlib-static and minizip, all tagged arch = s390x, the library reporting "ELF 64-bit MSB shared object, IBM S/390", and repo-add indexing them into a usable core.db. --- FR --- Le README annonce pacman, bash et coreutils comme trois pieces manquantes. Ce ne sont pas trois travaux : seul pacman compte, parce que son arbre source livre aussi makepkg et repo-add. Des qu ils tournent, chaque paquet restant cesse d etre du travail manuel et devient un makepkg sur le PKGBUILD amont. pacman 7.1.0 se compile sans correctif sur s390x. Aucune compilation croisee n intervient : sur du materiel natif tout l espace utilisateur se batit a pleine vitesse, ce qui supprime l aller-retour z/VM dont dependent les autres scripts. Mesure de bout en bout : zlib bati depuis le PKGBUILD officiel produit zlib, zlib-static et minizip, tous marques arch = s390x, la bibliotheque se declarant « ELF 64-bit MSB shared object, IBM S/390 », et repo-add les indexant dans un core.db utilisable. Assisted-by: Claude Opus 5
2026-08-15 03:18:47 -04:00
sudo apt-get -o DPkg::Lock::Timeout=600 install -y -qq \
meson ninja-build pkg-config gettext \
libarchive-dev libcurl4-openssl-dev libgpgme-dev libssl-dev \
libarchive-tools fakeroot \
build-essential autoconf automake libtool m4 patch texinfo bison flex \
[FIX] trust artefacts, not exit codes; add a PKGBUILD patch mechanism A run reported "51 built, 0 failed" while glibc, gcc, coreutils and pacman had all failed. The cause is a bash rule that is easy to forget: callers invoke build_package inside an "if", and "if" DISABLES set -e for the whole function body. A failing makepkg fell through to repo-add, whose success became the function exit status. build_package now returns explicitly on failure and, more importantly, verifies that a package file actually exists. An exit code is not proof; only the artefact is. Measured before the fix: 23 files in the repository where a hundred were claimed. First real port patch, applied through a per-package hook rather than by hand: the glibc PKGBUILD passes --enable-sframe, and s390x has no SFrame at all -- configure refuses outright. Hooks re-clone cleanly, so an upstream change is never silently discarded. --nocheck for stage 1: these test suites run against the HOST libraries, not the Arch ones, so their verdict says nothing about the port. acl failed its check step on a sound build. Stage 2 runs them for real. The remaining failures were host makedepends that --nodeps hides: po4a, gnat, debuginfod and jansson are now installed up front. --- FR --- Une execution annoncait « 51 built, 0 failed » alors que glibc, gcc, coreutils et pacman avaient tous echoue. La cause est une regle de bash qu on oublie : build_package est appelee dans un « if », et « if » DESACTIVE set -e pour tout le corps de la fonction. Un makepkg en echec poursuivait jusqu a repo-add, dont la reussite devenait le code de sortie. build_package rend desormais la main explicitement en cas d echec et, surtout, verifie qu un fichier de paquet existe vraiment. Un code de sortie ne prouve rien ; seul l artefact prouve. Mesure avant correction : 23 fichiers dans le depot la ou cent etaient annonces. Premier vrai correctif de portage, applique par crochet et non a la main : le PKGBUILD de glibc passe --enable-sframe, et s390x n a aucun SFrame -- configure refuse net. Les crochets survivent a un reclonage, donc une evolution amont n est jamais perdue en silence. --nocheck pour l etage 1 : ces suites s executent contre les bibliotheques de l HOTE, pas celles d Arch, et leur verdict ne dit rien du portage. acl echouait a son etape check sur une compilation saine. L etage 2 les executera pour de vrai. Les autres echecs etaient des makedepends d hote que --nodeps masque : po4a, gnat, debuginfod et jansson sont poses d entree. Assisted-by: Claude Opus 5
2026-08-15 20:40:17 -04:00
zstd xz-utils bzip2 \
systemtap-sdt-dev asciidoc autopoint gperf help2man rsync \
libgmp-dev libmpfr-dev libmpc-dev python3-docutils \
libseccomp-dev libpcre2-dev \
po4a gnat libdebuginfod-dev libjansson-dev
[ADD] bootstrap pacman, makepkg and repo-add natively on s390x The README lists pacman, bash and coreutils as three missing pieces. They are not three tasks: pacman is the only one that matters, because its source tree also ships makepkg and repo-add. Once those run, every remaining package stops being hand-work and becomes makepkg on the upstream PKGBUILD. pacman 7.1.0 builds unpatched on s390x. No cross-compilation is involved: on native hardware the whole userspace builds at full speed, which removes the z/VM round-trip the other scripts need. Measured end to end: zlib built from the official PKGBUILD yields zlib, zlib-static and minizip, all tagged arch = s390x, the library reporting "ELF 64-bit MSB shared object, IBM S/390", and repo-add indexing them into a usable core.db. --- FR --- Le README annonce pacman, bash et coreutils comme trois pieces manquantes. Ce ne sont pas trois travaux : seul pacman compte, parce que son arbre source livre aussi makepkg et repo-add. Des qu ils tournent, chaque paquet restant cesse d etre du travail manuel et devient un makepkg sur le PKGBUILD amont. pacman 7.1.0 se compile sans correctif sur s390x. Aucune compilation croisee n intervient : sur du materiel natif tout l espace utilisateur se batit a pleine vitesse, ce qui supprime l aller-retour z/VM dont dependent les autres scripts. Mesure de bout en bout : zlib bati depuis le PKGBUILD officiel produit zlib, zlib-static et minizip, tous marques arch = s390x, la bibliotheque se declarant « ELF 64-bit MSB shared object, IBM S/390 », et repo-add les indexant dans un core.db utilisable. Assisted-by: Claude Opus 5
2026-08-15 03:18:47 -04:00
}
build_pacman() {
log "pacman + makepkg + repo-add"
mkdir -p "$WORK"
[ -d "$WORK/pacman" ] || git clone --depth 1 "$PACMAN_GIT" "$WORK/pacman"
cd "$WORK/pacman"
# /usr/local, never /usr: this host is Ubuntu and /usr belongs to dpkg.
# makepkg resolves its own libraries from the configured prefix, so the
# prefix has to be real -- running it from the build tree fails with
# "/usr/share/makepkg/*.sh: No such file or directory".
rm -rf build
meson setup build --prefix=/usr/local --buildtype=release \
-Ddoc=disabled -Ddoxygen=disabled -Di18n=false
ninja -C build -j"$(nproc)"
sudo ninja -C build install
}
configure_makepkg() {
log "makepkg configuration"
# CARCH is already detected as s390x by meson; CHOST must stay the
# auto-detected triplet -- configure scripts are matched against it, and
# inventing "s390x-pc-linux-gnu" breaks them.
sudo sed -i "s|^#\?MAKEFLAGS=.*|MAKEFLAGS=\"-j$(nproc)\"|" /etc/makepkg.conf
# pacman refuses to initialise alpm without its database directory. The
# error is only a warning during packaging, but it hides real ones.
sudo mkdir -p /var/lib/pacman
grep -E '^(CARCH|CHOST|MAKEFLAGS)=' /etc/makepkg.conf
}
# build_package <name> -- fetch the official PKGBUILD and build it for s390x.
#
# --ignorearch: upstream PKGBUILDs carry arch=(x86_64) and nothing else.
# --skipchecksums: GitLab regenerates .patch URLs, so their checksums drift
# from what the PKGBUILD recorded. Release tarballs still validate; only
# the generated patches are skipped.
[FIX] trust artefacts, not exit codes; add a PKGBUILD patch mechanism A run reported "51 built, 0 failed" while glibc, gcc, coreutils and pacman had all failed. The cause is a bash rule that is easy to forget: callers invoke build_package inside an "if", and "if" DISABLES set -e for the whole function body. A failing makepkg fell through to repo-add, whose success became the function exit status. build_package now returns explicitly on failure and, more importantly, verifies that a package file actually exists. An exit code is not proof; only the artefact is. Measured before the fix: 23 files in the repository where a hundred were claimed. First real port patch, applied through a per-package hook rather than by hand: the glibc PKGBUILD passes --enable-sframe, and s390x has no SFrame at all -- configure refuses outright. Hooks re-clone cleanly, so an upstream change is never silently discarded. --nocheck for stage 1: these test suites run against the HOST libraries, not the Arch ones, so their verdict says nothing about the port. acl failed its check step on a sound build. Stage 2 runs them for real. The remaining failures were host makedepends that --nodeps hides: po4a, gnat, debuginfod and jansson are now installed up front. --- FR --- Une execution annoncait « 51 built, 0 failed » alors que glibc, gcc, coreutils et pacman avaient tous echoue. La cause est une regle de bash qu on oublie : build_package est appelee dans un « if », et « if » DESACTIVE set -e pour tout le corps de la fonction. Un makepkg en echec poursuivait jusqu a repo-add, dont la reussite devenait le code de sortie. build_package rend desormais la main explicitement en cas d echec et, surtout, verifie qu un fichier de paquet existe vraiment. Un code de sortie ne prouve rien ; seul l artefact prouve. Mesure avant correction : 23 fichiers dans le depot la ou cent etaient annonces. Premier vrai correctif de portage, applique par crochet et non a la main : le PKGBUILD de glibc passe --enable-sframe, et s390x n a aucun SFrame -- configure refuse net. Les crochets survivent a un reclonage, donc une evolution amont n est jamais perdue en silence. --nocheck pour l etage 1 : ces suites s executent contre les bibliotheques de l HOTE, pas celles d Arch, et leur verdict ne dit rien du portage. acl echouait a son etape check sur une compilation saine. L etage 2 les executera pour de vrai. Les autres echecs etaient des makedepends d hote que --nodeps masque : po4a, gnat, debuginfod et jansson sont poses d entree. Assisted-by: Claude Opus 5
2026-08-15 20:40:17 -04:00
# --nocheck: stage-1 test suites run against the HOST libraries, not Arch's,
# so their verdict says nothing about the port. acl failed its check() on a
# perfectly sound build, and the suites cost hours. Stage 2 runs them.
[ADD] bootstrap pacman, makepkg and repo-add natively on s390x The README lists pacman, bash and coreutils as three missing pieces. They are not three tasks: pacman is the only one that matters, because its source tree also ships makepkg and repo-add. Once those run, every remaining package stops being hand-work and becomes makepkg on the upstream PKGBUILD. pacman 7.1.0 builds unpatched on s390x. No cross-compilation is involved: on native hardware the whole userspace builds at full speed, which removes the z/VM round-trip the other scripts need. Measured end to end: zlib built from the official PKGBUILD yields zlib, zlib-static and minizip, all tagged arch = s390x, the library reporting "ELF 64-bit MSB shared object, IBM S/390", and repo-add indexing them into a usable core.db. --- FR --- Le README annonce pacman, bash et coreutils comme trois pieces manquantes. Ce ne sont pas trois travaux : seul pacman compte, parce que son arbre source livre aussi makepkg et repo-add. Des qu ils tournent, chaque paquet restant cesse d etre du travail manuel et devient un makepkg sur le PKGBUILD amont. pacman 7.1.0 se compile sans correctif sur s390x. Aucune compilation croisee n intervient : sur du materiel natif tout l espace utilisateur se batit a pleine vitesse, ce qui supprime l aller-retour z/VM dont dependent les autres scripts. Mesure de bout en bout : zlib bati depuis le PKGBUILD officiel produit zlib, zlib-static et minizip, tous marques arch = s390x, la bibliotheque se declarant « ELF 64-bit MSB shared object, IBM S/390 », et repo-add les indexant dans un core.db utilisable. Assisted-by: Claude Opus 5
2026-08-15 03:18:47 -04:00
build_package() {
local name="$1"
log "Building $name"
mkdir -p "$WORK/pkg"
[ -d "$WORK/pkg/$name" ] || \
git clone --depth 1 "$PKG_GIT_BASE/$name.git" "$WORK/pkg/$name"
cd "$WORK/pkg/$name"
[FIX] trust artefacts, not exit codes; add a PKGBUILD patch mechanism A run reported "51 built, 0 failed" while glibc, gcc, coreutils and pacman had all failed. The cause is a bash rule that is easy to forget: callers invoke build_package inside an "if", and "if" DISABLES set -e for the whole function body. A failing makepkg fell through to repo-add, whose success became the function exit status. build_package now returns explicitly on failure and, more importantly, verifies that a package file actually exists. An exit code is not proof; only the artefact is. Measured before the fix: 23 files in the repository where a hundred were claimed. First real port patch, applied through a per-package hook rather than by hand: the glibc PKGBUILD passes --enable-sframe, and s390x has no SFrame at all -- configure refuses outright. Hooks re-clone cleanly, so an upstream change is never silently discarded. --nocheck for stage 1: these test suites run against the HOST libraries, not the Arch ones, so their verdict says nothing about the port. acl failed its check step on a sound build. Stage 2 runs them for real. The remaining failures were host makedepends that --nodeps hides: po4a, gnat, debuginfod and jansson are now installed up front. --- FR --- Une execution annoncait « 51 built, 0 failed » alors que glibc, gcc, coreutils et pacman avaient tous echoue. La cause est une regle de bash qu on oublie : build_package est appelee dans un « if », et « if » DESACTIVE set -e pour tout le corps de la fonction. Un makepkg en echec poursuivait jusqu a repo-add, dont la reussite devenait le code de sortie. build_package rend desormais la main explicitement en cas d echec et, surtout, verifie qu un fichier de paquet existe vraiment. Un code de sortie ne prouve rien ; seul l artefact prouve. Mesure avant correction : 23 fichiers dans le depot la ou cent etaient annonces. Premier vrai correctif de portage, applique par crochet et non a la main : le PKGBUILD de glibc passe --enable-sframe, et s390x n a aucun SFrame -- configure refuse net. Les crochets survivent a un reclonage, donc une evolution amont n est jamais perdue en silence. --nocheck pour l etage 1 : ces suites s executent contre les bibliotheques de l HOTE, pas celles d Arch, et leur verdict ne dit rien du portage. acl echouait a son etape check sur une compilation saine. L etage 2 les executera pour de vrai. Les autres echecs etaient des makedepends d hote que --nodeps masque : po4a, gnat, debuginfod et jansson sont poses d entree. Assisted-by: Claude Opus 5
2026-08-15 20:40:17 -04:00
# Port patches. Upstream PKGBUILDs are written for x86_64 and some carry
# flags no other architecture accepts -- glibc's --enable-sframe is the
# first. They are applied here, one hook per package, so each change is
# visible, reviewable and survives a re-clone, rather than being an edit
# someone once made by hand in a working copy.
local hook="$PATCH_DIR/$name.sh"
if [ -f "$hook" ]; then
git checkout -- PKGBUILD 2>/dev/null || true
bash "$hook" || return 1
fi
rm -f ./*.pkg.tar.*
# Explicit `|| return 1`. Relying on `set -e` here does NOT work: callers
# invoke build_package inside `if`, which disables set -e for the whole
# function body. A failing makepkg then fell through to repo-add, whose
# success became the function's exit status -- and a run reported
# "51 built, 0 failed" while glibc, gcc, coreutils and pacman had all
# failed. Measured: the repository held 23 files, not a hundred.
makepkg --nodeps --ignorearch --skippgpcheck --skipchecksums --nocheck -f \
|| return 1
# An exit code is not proof. Only the artefact is.
local produced=()
shopt -s nullglob
produced=(./*.pkg.tar.*)
shopt -u nullglob
if [ "${#produced[@]}" -eq 0 ]; then
echo "no package produced for $name" >&2
return 1
fi
[ADD] bootstrap pacman, makepkg and repo-add natively on s390x The README lists pacman, bash and coreutils as three missing pieces. They are not three tasks: pacman is the only one that matters, because its source tree also ships makepkg and repo-add. Once those run, every remaining package stops being hand-work and becomes makepkg on the upstream PKGBUILD. pacman 7.1.0 builds unpatched on s390x. No cross-compilation is involved: on native hardware the whole userspace builds at full speed, which removes the z/VM round-trip the other scripts need. Measured end to end: zlib built from the official PKGBUILD yields zlib, zlib-static and minizip, all tagged arch = s390x, the library reporting "ELF 64-bit MSB shared object, IBM S/390", and repo-add indexing them into a usable core.db. --- FR --- Le README annonce pacman, bash et coreutils comme trois pieces manquantes. Ce ne sont pas trois travaux : seul pacman compte, parce que son arbre source livre aussi makepkg et repo-add. Des qu ils tournent, chaque paquet restant cesse d etre du travail manuel et devient un makepkg sur le PKGBUILD amont. pacman 7.1.0 se compile sans correctif sur s390x. Aucune compilation croisee n intervient : sur du materiel natif tout l espace utilisateur se batit a pleine vitesse, ce qui supprime l aller-retour z/VM dont dependent les autres scripts. Mesure de bout en bout : zlib bati depuis le PKGBUILD officiel produit zlib, zlib-static et minizip, tous marques arch = s390x, la bibliotheque se declarant « ELF 64-bit MSB shared object, IBM S/390 », et repo-add les indexant dans un core.db utilisable. Assisted-by: Claude Opus 5
2026-08-15 03:18:47 -04:00
mkdir -p "$REPO"
[FIX] trust artefacts, not exit codes; add a PKGBUILD patch mechanism A run reported "51 built, 0 failed" while glibc, gcc, coreutils and pacman had all failed. The cause is a bash rule that is easy to forget: callers invoke build_package inside an "if", and "if" DISABLES set -e for the whole function body. A failing makepkg fell through to repo-add, whose success became the function exit status. build_package now returns explicitly on failure and, more importantly, verifies that a package file actually exists. An exit code is not proof; only the artefact is. Measured before the fix: 23 files in the repository where a hundred were claimed. First real port patch, applied through a per-package hook rather than by hand: the glibc PKGBUILD passes --enable-sframe, and s390x has no SFrame at all -- configure refuses outright. Hooks re-clone cleanly, so an upstream change is never silently discarded. --nocheck for stage 1: these test suites run against the HOST libraries, not the Arch ones, so their verdict says nothing about the port. acl failed its check step on a sound build. Stage 2 runs them for real. The remaining failures were host makedepends that --nodeps hides: po4a, gnat, debuginfod and jansson are now installed up front. --- FR --- Une execution annoncait « 51 built, 0 failed » alors que glibc, gcc, coreutils et pacman avaient tous echoue. La cause est une regle de bash qu on oublie : build_package est appelee dans un « if », et « if » DESACTIVE set -e pour tout le corps de la fonction. Un makepkg en echec poursuivait jusqu a repo-add, dont la reussite devenait le code de sortie. build_package rend desormais la main explicitement en cas d echec et, surtout, verifie qu un fichier de paquet existe vraiment. Un code de sortie ne prouve rien ; seul l artefact prouve. Mesure avant correction : 23 fichiers dans le depot la ou cent etaient annonces. Premier vrai correctif de portage, applique par crochet et non a la main : le PKGBUILD de glibc passe --enable-sframe, et s390x n a aucun SFrame -- configure refuse net. Les crochets survivent a un reclonage, donc une evolution amont n est jamais perdue en silence. --nocheck pour l etage 1 : ces suites s executent contre les bibliotheques de l HOTE, pas celles d Arch, et leur verdict ne dit rien du portage. acl echouait a son etape check sur une compilation saine. L etage 2 les executera pour de vrai. Les autres echecs etaient des makedepends d hote que --nodeps masque : po4a, gnat, debuginfod et jansson sont poses d entree. Assisted-by: Claude Opus 5
2026-08-15 20:40:17 -04:00
cp -f "${produced[@]}" "$REPO/" || return 1
# Only the new packages. Globbing the whole repository made repo-add
# re-index everything on every call: quadratic, and it buried the real
# lines under warnings about entries that already existed.
local names=() f
for f in "${produced[@]}"; do names+=("$(basename "$f")"); done
( cd "$REPO" && repo-add core.db.tar.gz "${names[@]}" ) || return 1
[ADD] bootstrap pacman, makepkg and repo-add natively on s390x The README lists pacman, bash and coreutils as three missing pieces. They are not three tasks: pacman is the only one that matters, because its source tree also ships makepkg and repo-add. Once those run, every remaining package stops being hand-work and becomes makepkg on the upstream PKGBUILD. pacman 7.1.0 builds unpatched on s390x. No cross-compilation is involved: on native hardware the whole userspace builds at full speed, which removes the z/VM round-trip the other scripts need. Measured end to end: zlib built from the official PKGBUILD yields zlib, zlib-static and minizip, all tagged arch = s390x, the library reporting "ELF 64-bit MSB shared object, IBM S/390", and repo-add indexing them into a usable core.db. --- FR --- Le README annonce pacman, bash et coreutils comme trois pieces manquantes. Ce ne sont pas trois travaux : seul pacman compte, parce que son arbre source livre aussi makepkg et repo-add. Des qu ils tournent, chaque paquet restant cesse d etre du travail manuel et devient un makepkg sur le PKGBUILD amont. pacman 7.1.0 se compile sans correctif sur s390x. Aucune compilation croisee n intervient : sur du materiel natif tout l espace utilisateur se batit a pleine vitesse, ce qui supprime l aller-retour z/VM dont dependent les autres scripts. Mesure de bout en bout : zlib bati depuis le PKGBUILD officiel produit zlib, zlib-static et minizip, tous marques arch = s390x, la bibliotheque se declarant « ELF 64-bit MSB shared object, IBM S/390 », et repo-add les indexant dans un core.db utilisable. Assisted-by: Claude Opus 5
2026-08-15 03:18:47 -04:00
}
main() {
install_host_deps
build_pacman
configure_makepkg
for p in "$@"; do build_package "$p"; done
log "Done"
command -v pacman makepkg repo-add
}
[ADD] stage 1: build a self-hosting core for s390x Forty-odd packages in link-time order, from linux-api-headers to pacman itself. The order follows what a compiler actually needs, not pacman metadata: --nodeps means nothing is ever checked, so anything required at link time has to exist already. A failure does not stop the run. One missing package must not hide the state of the forty that follow, so failures are collected and reported at the end, each with its own log. A state file makes the run resumable, which matters when a single gcc build is measured in tens of minutes. The header states why stage 1 is not the port: everything here links against the host glibc, because Arch glibc needs an Arch gcc which needs an Arch glibc. Stages 2 and 3 break that circle. bootstrap-pacman.sh now guards its own main so it can be sourced for build_package without re-running the whole bootstrap. --- FR --- Une quarantaine de paquets dans l ordre des dependances de lien, de linux-api-headers a pacman lui-meme. L ordre suit ce dont un compilateur a reellement besoin, pas les metadonnees de pacman : --nodeps ne verifie jamais rien, donc tout ce qui sert au lien doit deja exister. Un echec n arrete pas la course. Un paquet manquant ne doit pas masquer l etat des quarante suivants : les echecs sont collectes et rapportes a la fin, chacun avec son journal. Un fichier d etat rend la reprise possible, ce qui compte quand un seul gcc se compte en dizaines de minutes. L en-tete dit pourquoi l etage 1 n est pas le portage : tout s y lie a la glibc de l hote, parce que la glibc d Arch reclame un gcc d Arch qui reclame une glibc d Arch. Les etages 2 et 3 brisent ce cercle. bootstrap-pacman.sh garde desormais son main pour etre sourcable et fournir build_package sans relancer tout l amorcage. Assisted-by: Claude Opus 5
2026-08-15 15:48:30 -04:00
# Only run when executed, never when sourced: build-stage1.sh reuses
[FIX] trust artefacts, not exit codes; add a PKGBUILD patch mechanism A run reported "51 built, 0 failed" while glibc, gcc, coreutils and pacman had all failed. The cause is a bash rule that is easy to forget: callers invoke build_package inside an "if", and "if" DISABLES set -e for the whole function body. A failing makepkg fell through to repo-add, whose success became the function exit status. build_package now returns explicitly on failure and, more importantly, verifies that a package file actually exists. An exit code is not proof; only the artefact is. Measured before the fix: 23 files in the repository where a hundred were claimed. First real port patch, applied through a per-package hook rather than by hand: the glibc PKGBUILD passes --enable-sframe, and s390x has no SFrame at all -- configure refuses outright. Hooks re-clone cleanly, so an upstream change is never silently discarded. --nocheck for stage 1: these test suites run against the HOST libraries, not the Arch ones, so their verdict says nothing about the port. acl failed its check step on a sound build. Stage 2 runs them for real. The remaining failures were host makedepends that --nodeps hides: po4a, gnat, debuginfod and jansson are now installed up front. --- FR --- Une execution annoncait « 51 built, 0 failed » alors que glibc, gcc, coreutils et pacman avaient tous echoue. La cause est une regle de bash qu on oublie : build_package est appelee dans un « if », et « if » DESACTIVE set -e pour tout le corps de la fonction. Un makepkg en echec poursuivait jusqu a repo-add, dont la reussite devenait le code de sortie. build_package rend desormais la main explicitement en cas d echec et, surtout, verifie qu un fichier de paquet existe vraiment. Un code de sortie ne prouve rien ; seul l artefact prouve. Mesure avant correction : 23 fichiers dans le depot la ou cent etaient annonces. Premier vrai correctif de portage, applique par crochet et non a la main : le PKGBUILD de glibc passe --enable-sframe, et s390x n a aucun SFrame -- configure refuse net. Les crochets survivent a un reclonage, donc une evolution amont n est jamais perdue en silence. --nocheck pour l etage 1 : ces suites s executent contre les bibliotheques de l HOTE, pas celles d Arch, et leur verdict ne dit rien du portage. acl echouait a son etape check sur une compilation saine. L etage 2 les executera pour de vrai. Les autres echecs etaient des makedepends d hote que --nodeps masque : po4a, gnat, debuginfod et jansson sont poses d entree. Assisted-by: Claude Opus 5
2026-08-15 20:40:17 -04:00
# build_package and must not re-run the whole bootstrap to get it.
[ADD] stage 1: build a self-hosting core for s390x Forty-odd packages in link-time order, from linux-api-headers to pacman itself. The order follows what a compiler actually needs, not pacman metadata: --nodeps means nothing is ever checked, so anything required at link time has to exist already. A failure does not stop the run. One missing package must not hide the state of the forty that follow, so failures are collected and reported at the end, each with its own log. A state file makes the run resumable, which matters when a single gcc build is measured in tens of minutes. The header states why stage 1 is not the port: everything here links against the host glibc, because Arch glibc needs an Arch gcc which needs an Arch glibc. Stages 2 and 3 break that circle. bootstrap-pacman.sh now guards its own main so it can be sourced for build_package without re-running the whole bootstrap. --- FR --- Une quarantaine de paquets dans l ordre des dependances de lien, de linux-api-headers a pacman lui-meme. L ordre suit ce dont un compilateur a reellement besoin, pas les metadonnees de pacman : --nodeps ne verifie jamais rien, donc tout ce qui sert au lien doit deja exister. Un echec n arrete pas la course. Un paquet manquant ne doit pas masquer l etat des quarante suivants : les echecs sont collectes et rapportes a la fin, chacun avec son journal. Un fichier d etat rend la reprise possible, ce qui compte quand un seul gcc se compte en dizaines de minutes. L en-tete dit pourquoi l etage 1 n est pas le portage : tout s y lie a la glibc de l hote, parce que la glibc d Arch reclame un gcc d Arch qui reclame une glibc d Arch. Les etages 2 et 3 brisent ce cercle. bootstrap-pacman.sh garde desormais son main pour etre sourcable et fournir build_package sans relancer tout l amorcage. Assisted-by: Claude Opus 5
2026-08-15 15:48:30 -04:00
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi