diff --git a/tools/userland.sh b/tools/userland.sh index 10922f68f3..cd12ba4811 100755 --- a/tools/userland.sh +++ b/tools/userland.sh @@ -239,6 +239,14 @@ ext_prepare() # The media's repository: the packages of kind "repo" and what they need at # run time, from the packages the build made (build/packages/All), as a # repository with a pkg_summary.gz that pkg_add can use (tools/cd3.sh). +# +# Only run-time dependencies belong here, and the built package itself says +# which those are: +CONTENTS carries them as @pkgdep. `show-depends-recursive' +# was wrong for this: it lists the build tools as well (pkgtools/cwrappers, +# libnbcompat, mktools, digest), which are built for the build host and have no +# package for the target -- seven "no package ... .tgz" lines in every release +# (measured 2026-11-23). A run-time dependency that the build did not produce +# is a real error and is reported as one. make_repo() { repo=$("$TOP/tools/pkglist.sh" repo) @@ -246,16 +254,49 @@ make_repo() out=$TOP/build/packages/$ARCH/All rm -rf "$out" mkdir -p "$out" + missing= + # The run-time closure. A package's +CONTENTS names its own run-time + # dependencies as "@pkgdep name>=version", and those can depend again: + # pkg_add reads only what is in this repository, so the closure is closed + # here. One pass per package is enough in practice, but the loop keeps + # going while the set still grows -- a three-deep chain is not unusual. + # `show-depends-recursive' was wrong for this: it also lists the build + # tools (pkgtools/cwrappers, libnbcompat, mktools, digest), which are made + # for the build host and have no package for the target -- seven "no + # package ... .tgz" lines in every release (measured 2026-11-23). + add_pkg() + { + [ -f "$out/$1.tgz" ] && return 0 + if [ ! -f "$TOP/build/packages/All/$1.tgz" ]; then + missing="$missing $1" + return 0 + fi + cp "$TOP/build/packages/All/$1.tgz" "$out/" + } for p in $repo; do - { - echo "$p" - (cd "$PKGSRC/$p" && "$BMAKE" show-depends-recursive 2> /dev/null) - } | sort -u | while read -r d; do - n=$(cd "$PKGSRC/$d" && "$BMAKE" -V '${PKGNAME}') - cp "$TOP/build/packages/All/$n.tgz" "$out/" || - echo "userland: no package $n.tgz for $d" >&2 - done + n=$(cd "$PKGSRC/$p" && "$BMAKE" -V '${PKGNAME}') + add_pkg "$n" done + grew=1 + while [ -n "$grew" ]; do + grew= + before=$(ls "$out" | grep -c '\.tgz$' || true) + for f in "$out"/*.tgz; do + [ -f "$f" ] || continue + tar -xzOf "$f" +CONTENTS 2>/dev/null | + sed -n 's/^@pkgdep //p' | + sed 's/[<>=].*$//' > "$out/.deps" || true + while read -r d; do + [ -n "$d" ] || continue + add_pkg "$d" + done < "$out/.deps" + done + rm -f "$out/.deps" + after=$(ls "$out" | grep -c '\.tgz$' || true) + if [ "$after" -gt "$before" ]; then grew=1; fi + done + [ -z "$missing" ] || + echo "userland: no package for:$missing -- these are run-time dependencies" >&2 (cd "$out" && "$TOP/build/pkg/sbin/pkg_info" -X ./*.tgz | gzip -9 > pkg_summary.gz) echo "userland: $(ls "$out" | grep -c '\.tgz$') packages in ${out#$TOP/}" }