unos-repository

APK repository for unos
git clone git://git.finwo.net/misc/unos-repository
Log | Files | Refs | README

commit fef0447e0efef7ae91c3bbc2851c4da9e7e1a1b8
parent b49c973f124f64e4abf9549840c89a2f9aae4ce1
Author: Robin Bron <robin.bron@yourhosting.nl>
Date:   Fri, 25 Sep 2026 19:47:58 +0200

More apk-tools fixes

Diffstat:
M.conductor.yml | 29+++++++++++++++--------------
Mmk/build.sh | 4++--
Mmk/deps.sh | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Mmk/gen-pipeline.sh | 4+++-
Mmk/sysroot.sh | 4++--
Mpackages/apk-tools/template | 10+++++-----
6 files changed, 85 insertions(+), 32 deletions(-)

diff --git a/.conductor.yml b/.conductor.yml @@ -84,12 +84,26 @@ tasks: - ./mk/build.sh openssl - ./mk/publish.sh --arch "$ARCH" openssl + pkg-linux-longterm: + needs: + - check + arch: [x86_64] + requires: [unos-sign-key] + script: + - ./mk/check-revision.sh linux-longterm --pkgver 6.18.51-r0 --repo "${BUCKET_PUBLIC_URL%/}/$ARCH" || { rc=$?; [ "$rc" = 1 ] && exit 0; exit "$rc"; } + - ./mk/ci-setup.sh + - ./mk/bootstrap-host.sh + - ./mk/sysroot.sh --arch "$ARCH" --repo "$BUCKET_PUBLIC_URL" linux-longterm + - ./mk/build.sh linux-longterm + - ./mk/publish.sh --arch "$ARCH" linux-longterm + pkg-apk-tools: needs: - check - pkg-glibc - pkg-zlib - pkg-openssl + - pkg-linux-longterm arch: [x86_64] requires: [unos-sign-key] script: @@ -318,19 +332,6 @@ tasks: - ./mk/build.sh linkd - ./mk/publish.sh --arch "$ARCH" linkd - pkg-linux-longterm: - needs: - - check - arch: [x86_64] - requires: [unos-sign-key] - script: - - ./mk/check-revision.sh linux-longterm --pkgver 6.18.51-r0 --repo "${BUCKET_PUBLIC_URL%/}/$ARCH" || { rc=$?; [ "$rc" = 1 ] && exit 0; exit "$rc"; } - - ./mk/ci-setup.sh - - ./mk/bootstrap-host.sh - - ./mk/sysroot.sh --arch "$ARCH" --repo "$BUCKET_PUBLIC_URL" linux-longterm - - ./mk/build.sh linux-longterm - - ./mk/publish.sh --arch "$ARCH" linux-longterm - pkg-linux-mainline: needs: - check @@ -415,6 +416,7 @@ tasks: - pkg-glibc - pkg-zlib - pkg-openssl + - pkg-linux-longterm - pkg-apk-tools - pkg-base-files - pkg-busybox @@ -432,7 +434,6 @@ tasks: - pkg-libcap - pkg-iproute2 - pkg-linkd - - pkg-linux-longterm - pkg-linux-mainline - pkg-linux-stable - pkg-smartmontools diff --git a/mk/build.sh b/mk/build.sh @@ -112,8 +112,8 @@ for _h in ${hostmakedepends}; do done for _m in ${makedepends}; do - [ -f "${ROOT}/packages/${_m}/template" ] \ - || die "makedepends: '${_m}' is not a package under packages/" + "${HERE}/deps.sh" owner "${_m}" >/dev/null 2>&1 \ + || die "makedepends: '${_m}' is not a package or subpackage under packages/" # Presence of a built .apk is the signal that its sysroot seed has been # installed; templates that other packages build against install twice # (DESTDIR + SYSROOT), so one implies the other. diff --git a/mk/deps.sh b/mk/deps.sh @@ -62,19 +62,45 @@ read_vars() { subpackages= # Templates reference these; define them so sourcing cannot fail on an # unset variable under `set -u`. - SYSROOT=; DESTDIR=; WRKSRC=; FILESDIR=; WORK=; SRCDEST=; UNOS_MKDIR= + SYSROOT=; DESTDIR=; WRKSRC=; FILESDIR=; WORK=; SRCDEST= + # Real path: `.` is a special builtin, so a missing kernel.inc kills + # the subshell outright and every field comes back empty. + UNOS_MKDIR="${HERE}" die() { :; } msg() { :; } vinstall() { :; } vmkdir() { :; } # shellcheck disable=SC1090 . "${t}" >/dev/null 2>&1 || true - printf '%s|%s|%s\n' "${depends}" "${makedepends}" "${hostmakedepends}" + printf '%s|%s|%s|%s\n' "${depends}" "${makedepends}" "${hostmakedepends}" "${subpackages}" ) } field() { read_vars "$1" | cut -d'|' -f"$2"; } +# A makedepends may name a subpackage (linux-longterm-headers) rather than a +# template. The build graph needs the template that produces it. +owner_of() { + if [ -f "${PKGDIR}/$1/template" ]; then echo "$1"; return 0; fi + found= + for _o in $(list_pkgs); do + for _s in $(field "${_o}" 4); do + [ "${_s}" = "$1" ] || continue + [ -z "${found}" ] || die "'$1' is provided by both '${found}' and '${_o}'" + found="${_o}" + done + done + [ -n "${found}" ] || return 1 + echo "${found}" +} + +# makedepends of <pkg>, each resolved to its owning template. +makedeps_of() { + for _d in $(field "$1" 2); do + owner_of "${_d}" || die "$1: makedepends '${_d}' is not a package or subpackage" + done +} + cmd_vars() { pkg="${1:?usage: deps.sh vars <pkg>}" v=$(read_vars "${pkg}") @@ -86,7 +112,7 @@ cmd_vars() { cmd_graph() { for p in $(list_pkgs); do - for d in $(field "${p}" 2); do + for d in $(makedeps_of "${p}"); do printf '%s\t%s\n' "${p}" "${d}" done done @@ -97,7 +123,7 @@ cmd_rdeps() { [ $# -ge 1 ] || die "usage: deps.sh rdeps <pkg>" target="$1" for p in $(list_pkgs); do - for d in $(field "${p}" 2); do + for d in $(makedeps_of "${p}"); do if [ "${d}" = "${target}" ]; then echo "${p}" break @@ -159,7 +185,7 @@ cmd_changed() { # no associative arrays: <tmp>/seen.<pkg> marks done, <tmp>/path.<pkg> marks # "currently on the recursion stack", which is how cycles are detected. TMP= -cleanup() { [ -n "${TMP}" ] && rm -rf "${TMP}"; } +cleanup() { [ -n "${TMP}" ] && rm -rf "${TMP}"; return 0; } trap cleanup EXIT # NOTE: everything here uses "$1" rather than a named variable. POSIX sh has no @@ -175,7 +201,7 @@ visit() { fi [ -f "${PKGDIR}/$1/template" ] || die "'$1' is a makedepends of something but has no template" : > "${TMP}/path.$1" - for d in $(field "$1" 2); do + for d in $(makedeps_of "$1"); do visit "${d}" done rm -f "${TMP}/path.$1" @@ -194,6 +220,28 @@ cmd_order() { cat "${TMP}/order" } +# Like visit(), but emits the names as written (subpackages stay subpackages) +# because these are apk package names to install, not templates to build. +seed_visit() { + [ -e "${TMP}/seen.$1" ] && return 0 + : > "${TMP}/seen.$1" + for d in $(field "$(owner_of "$1")" 2); do + seed_visit "${d}" + done + echo "$1" >> "${TMP}/order" +} + +cmd_seed() { + TMP=$(mktemp -d /tmp/unos-deps.XXXXXX) + : > "${TMP}/order" + if [ $# -gt 0 ]; then + for p in "$@"; do seed_visit "${p}"; done + else + for p in $(list_pkgs); do seed_visit "${p}"; done + fi + cat "${TMP}/order" +} + cmd_check() { rc=0 TMP=$(mktemp -d /tmp/unos-deps.XXXXXX) @@ -202,8 +250,8 @@ cmd_check() { for p in $(list_pkgs); do # every makedepends must name a real package for d in $(field "${p}" 2); do - if [ ! -f "${PKGDIR}/${d}/template" ]; then - echo "FAIL: ${p}: makedepends '${d}' is not a package" >&2 + if ! owner_of "${d}" >/dev/null 2>&1; then + echo "FAIL: ${p}: makedepends '${d}' is not a package or subpackage" >&2 rc=1 fi if [ "${d}" = "${p}" ]; then @@ -238,6 +286,8 @@ case "${1:-}" in vars) shift; cmd_vars "$@" ;; graph) cmd_graph ;; order) shift; cmd_order "$@" ;; + seed) shift; cmd_seed "$@" ;; + owner) shift; owner_of "${1:?usage: deps.sh owner <name>}" ;; rdeps) shift; cmd_rdeps "$@" ;; changed) shift; cmd_changed "$@" ;; check) cmd_check ;; diff --git a/mk/gen-pipeline.sh b/mk/gen-pipeline.sh @@ -105,7 +105,9 @@ HEADER # One task per package, in dependency order so the file reads top-down. for p in $(cd "${ROOT}" && ./mk/deps.sh order); do - deps=$(cd "${ROOT}" && ./mk/deps.sh vars "$p" | sed -n 's/^makedepends: *//p') + # graph, not vars: makedepends may name a subpackage, and the task that + # builds it is the owning template's. + deps=$(cd "${ROOT}" && ./mk/deps.sh graph | awk -v p="$p" '$1 == p { print $2 }') printf ' %s:\n' "$(task_name "$p")" printf ' needs:\n' printf ' - check\n' diff --git a/mk/sysroot.sh b/mk/sysroot.sh @@ -82,10 +82,10 @@ fi # requested packages themselves; filter to just the dependencies. if [ -z "${PKGS}" ] || [ "${PKGS}" = " " ]; then # all packages: seed everything (used for full sysroot) - ORDER=$("${ROOT}/mk/deps.sh" order) || exit 1 + ORDER=$("${ROOT}/mk/deps.sh" seed) || exit 1 else # shellcheck disable=SC2086 - ORDER=$("${ROOT}/mk/deps.sh" order ${PKGS}) || exit 1 + ORDER=$("${ROOT}/mk/deps.sh" seed ${PKGS}) || exit 1 fi # Build set of needed packages: transitive makedepends of requested pkgs. diff --git a/packages/apk-tools/template b/packages/apk-tools/template @@ -9,7 +9,7 @@ homepage="https://gitlab.alpinelinux.org/alpine/apk-tools" distfiles="https://gitlab.alpinelinux.org/alpine/apk-tools/-/archive/v3.0.8/apk-tools-v3.0.8.tar.gz" checksum=e81c64a6e7c3806d45d4622c253e757aee970be84048554fa0eed79310e9453e depends="glibc zlib openssl" -makedepends="glibc zlib openssl" +makedepends="glibc zlib openssl linux-longterm-headers" hostmakedepends="muon" # Notes: @@ -28,10 +28,10 @@ hostmakedepends="muon" do_configure() { mkdir -p "${WORK}/build" cd "${WRKSRC}" - # --sysroot: sysroot glibc headers redirect to __isoc23_*, absent in host libc. - # -isystem: kernel UAPI headers (linux/*, asm/*) live on the host only, and - # rank below the sysroot -I so glibc still resolves from the sysroot. - export CFLAGS="${CFLAGS:-} --sysroot=${SYSROOT} -isystem /usr/include" + # --sysroot: sysroot glibc headers redirect to __isoc23_*, absent in host + # libc. Nothing from the host's /usr/include may mix in, so the kernel UAPI + # headers come from linux-longterm-headers in the sysroot. + export CFLAGS="${CFLAGS:-} --sysroot=${SYSROOT}" export LDFLAGS="${LDFLAGS:-} --sysroot=${SYSROOT} -L${SYSROOT}/usr/lib -Wl,-rpath-link,${SYSROOT}/usr/lib" muon setup \ -Dprefix=/usr \