pkgsrc: the forks of ext/ build from their tree, not from an archive
Each fork kept a recipe beside its source and a tarball in distfiles/ whose
distinfo had to be regenerated after every commit (tools/ext-dist.sh,
tools/mcde-dist.sh), and the work directory of a build could not see a later
commit at all (tools/ext-resync.sh merged an archive into it). Three tools,
one artefact per fork in git, and the failure mode that cost the 2026-11-23
release: mcde 288d1383 built from the commit of the day before, because the
recipe's mtime said "not stale".
Now the recipe builds the source tree itself, which is how pkgsrc's own
net/fetch and pkgtools/pkg_install do it: DISTFILES= # empty, do-extract
fills WRKSRC. What is gone with that:
- the tarballs (distfiles/{mcde,splinter,junction,wikid,skilld,memoryd,
tasksd}-*) and their .key
- tools/ext-dist.sh, tools/mcde-dist.sh, tools/ext-resync.sh and its test
- fork_archives in tools/makronix-distfiles.sh (nothing to fetch or stage)
- the distinfo files of the eight recipes
What replaces it: tools/ext-extract.sh, called from do-extract. It hashes
the tree, copies only the files that differ, keeps the time stamp of the rest
(so a commit rebuilds what it touched and not 27 minutes of MCDE) and
removes the copy when a file left the tree. The build key of a fork carries
the source commit for the same reason: a commit does not change the recipe.
The recipes keep $Makronix$ as their header; afpfs-ng keeps its upstream
$NetBSD: ...$ line and its real distfile, and fork_src() leaves it alone.
Verified:
- bmake package built all eight recipes from the tree with no distinfo:
splinter, junction, wikid, skilld, memoryd, tasksd, mcde (16 MB), and
mcde-motif's shared tree
- tools/test-tools.sh: 38 ok, 0 bad (5 new cases for ext-extract.sh)
- tools/makronix-distfiles.sh check: 0 missing, 0 wrong hash
- tools/makronix-pins.sh check: PINS matches
This commit is contained in:
1 parent
38dd57df28
commit
974603f8a6
31 files changed
+5061
-5327
No files matched your search
@@ -136,9 +136,11 @@ package from the sysroot with pkg_delete (x11-links, osabi stay; commit
|
||||
entries and marking them `obsolete`.
|
||||
|
||||
The target's `pkg_install` comes from the distribution, not from pkgsrc. A fork
|
||||
from `ext/` is built from an archive `git archive` makes of its last commit
|
||||
(`tools/ext-dist.sh`, `tools/mcde-dist.sh`), its recipe is copied into pkgsrc by
|
||||
`tools/ext-sync.sh`.
|
||||
from `ext/` builds from its own source tree: the recipe sets `DISTFILES= # empty`
|
||||
and its `do-extract` copies `ext/src/<name>` into `WRKSRC`, so there is no
|
||||
archive, no `distinfo` and nothing to regenerate after a commit.
|
||||
`tools/ext-sync.sh` makes the recipe visible inside pkgsrc (a mirror of symlinks
|
||||
to `ext/src/<name>/pkgsrc`).
|
||||
|
||||
Where pkgsrc's cross mode stops on a Linux host (`awk:run`, xbase looked up on
|
||||
the host, host-only tools) is a finding for the report and a setting in our
|
||||
|
||||
@@ -1951,6 +1951,7 @@ net/ngtcp2 ngtcp2-1.26.0.tar.xz 733792 3f4ecf8720d3b43034b120111e804e453044d159f
|
||||
net/py-Socks PySocks-1.7.1.tar.gz 284429 cef4a5ce8c67fb485644696a23bf68a721db47f3211212de2d4431eaf9ebd26077dd5a06f6dfa7fde2dcb9d7c1ed551facd014e999929cb4d7b504972c464016
|
||||
net/py-dns dnspython-2.9.1.tar.gz 455302 61f891519bf78ed34fef8783bcc8fd98f67f040f31a0739f81cefa7f95ed6590c003604209179919e58942de8a08e84b499b271f5198f9196c89de91a0512800
|
||||
net/samba4 samba-4.25.1.tar.gz 43590836 2d0c186927b7d773681a960e276f2d3fd2b89fb6a9061c526e034e6cf5f8a3ec33a9f0b72c1b16e9a0cfa54b86af39b2cc608970ba471a535376a238827d8d61
|
||||
pkgtools/pkgin pkgin-26.4.0.tar.gz 274565 989f371a072216d7864e253dcb5b0b40bc4a85a9fdf9d93d7f60ea2c3e1bbcf89782ff821c69439f708fae136063eaccdf0f6a82b032259e8a055f967794d2b5
|
||||
print/cups-base cups-2.4.20-source.tar.gz 8164882 50be40e33662b32514ef7026a86c80970b2122fd187f32f4b704293468e615c1fcd6eb6575992f84856012a01b0e599a524ac6dd8630d073144b50cc5d6bd683
|
||||
print/cups-filters cups-filters-2.0.1.tar.xz 447288 e80783a03722228fdd67ab5041082d1c2ad9c5c5d59a60ac1aee51a4600b2e9c0c90b78f6fdbc2c7928c2bf2bb634df7c1ec5db23de65e867a0498372f7a2c00
|
||||
print/ghostscript-agpl ghostscript-10.08.0.tar.xz 69197208 8006e2a32d03759a905b9548bdd83d4563173041006750e17e428b9eea24ad519aa4452ceecd7c073d3c420a68bf1b07ccc9e0533b1a05935f6b39ea8d9ce875
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
9ea4449a3652d3b2e10bde096bfa96f9a771aade3113ac1436b54dff2a15ed20
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+7
-7
@@ -23,8 +23,10 @@ its recipe in `pkgsrc-<part>/` and becomes `<category>/<name>-<part>`
|
||||
own repository, here as a git submodule (`.gitmodules`; `git submodule update
|
||||
--init`). Changes are committed in the project's repository, and this tree
|
||||
moves the pin. Each keeps its recipe in its own `pkgsrc/` (misc/<name>,
|
||||
PKGNAME <name>-0.1) and an `IMPORT`; `tools/ext-sync.sh` copies the recipe
|
||||
into pkgsrc and `tools/ext-dist.sh` archives the submodule's commit. They are
|
||||
PKGNAME <name>-0.1) and an `IMPORT`; the recipe builds from this tree itself
|
||||
(`DISTFILES= # empty`, `do-extract` copies `ext/src/<name>` into WRKSRC), so
|
||||
there is no archive and no `distinfo`. `tools/ext-sync.sh` makes the recipe
|
||||
visible inside pkgsrc: a mirror of symlinks to these files. They are
|
||||
built when `packages.list` names them: misc/splinter is in the set, the other five are `repo` (the media's repository).
|
||||
- `src/glibc/` -- glibc 2.44 for Makronix/Linux; no `pkgsrc/`: its recipe is
|
||||
`mx/`, a NetBSD-style Makefile run by the Makronix/Linux build (LFS-style,
|
||||
@@ -32,11 +34,9 @@ its recipe in `pkgsrc-<part>/` and becomes `<category>/<name>-<part>`
|
||||
|
||||
## What may be changed
|
||||
|
||||
- The forks, as ordinary commits. After changing one, `tools/ext-dist.sh` (or
|
||||
`tools/mcde-dist.sh`) renews the distfile and the recipe's `distinfo`. For
|
||||
MCDE the archive is made inside the submodule from the commit the parent's
|
||||
gitlink names -- `git archive` of a gitlink in the parent would write an
|
||||
empty directory.
|
||||
- The forks, as ordinary commits. Nothing has to be regenerated afterwards:
|
||||
the recipe builds the tree as it is, so a commit is what the next build
|
||||
compiles.
|
||||
- An update to a newer upstream is a merge onto the fork with `IMPORT`
|
||||
renewed, never a silent overwrite.
|
||||
|
||||
|
||||
+1
-1
Submodule ext/src/junction updated: effeec623c...4d58d68054.
+1
-1
Submodule ext/src/mcde updated: 288d13834c...91967e9f0d.
+1
-1
Submodule ext/src/memoryd updated: c724d5668d...f342c413eb.
+1
-1
Submodule ext/src/skilld updated: e9608d6d52...80981dd27f.
+1
-1
Submodule ext/src/splinter updated: 1a17d25659...d3d9134b44.
+1
-1
Submodule ext/src/tasksd updated: 92c0d4f63c...81967f16a8.
+1
-1
Submodule ext/src/wikid updated: d5d772bd68...7ddeacf3e9.
@@ -181,6 +181,16 @@ emulators/qemu museum
|
||||
# makronix set, so every Makronix carries it (Konrad, 2026-11-17).
|
||||
misc/splinter
|
||||
|
||||
# pkgin, the binary package manager sysinst installs first: it runs
|
||||
# `pkg_add <medium>/<arch>/packages/All/pkgin' (src/usr.sbin/sysinst/
|
||||
# configmenu.c:387) and then points pkgin at that directory as the repository,
|
||||
# so a person can install the rest of the media's packages after the
|
||||
# installation. Without it that menu fails and there is no package manager on
|
||||
# the installed system (measured 2026-11-23: no pkgin in build/packages or on
|
||||
# any image; pkgsrc/pkgtools/pkgin is present but was never built).
|
||||
# Kind "repo": it belongs on the medium beside junction and the other servers.
|
||||
pkgtools/pkgin repo
|
||||
|
||||
# The project's own servers (ext/src/<name>, git submodules with their recipe in
|
||||
# pkgsrc/): junction (model router), wikid, skilld, memoryd, tasksd (MCP
|
||||
# servers). On the media's repository, not in the set: sysinst offers them.
|
||||
|
||||
+4681
-4626
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -41,8 +41,8 @@ Build and release (called by `make`):
|
||||
- `userland.sh` (`make userland`) -- builds `packages.list`, cross or native as the host is;
|
||||
`pkglist.sh` is the one reader of that list (kinds: set, repo, fetch, games;
|
||||
`@ARCH`).
|
||||
- `ext-dist.sh`, `mcde-dist.sh`, `ext-sync.sh` -- the distfile and `distinfo` of
|
||||
a fork in `ext/`, and its recipe copied into pkgsrc.
|
||||
- `ext-sync.sh` -- the recipe of a fork in `ext/`, made visible inside pkgsrc
|
||||
(a mirror of symlinks; the recipe builds the source tree itself, no archive).
|
||||
- `ext-resync.sh` -- a new archive of a fork changes only the files that differ in the
|
||||
work directory (`.pristine` is the archive pkgsrc extracted); `userland.sh` calls it,
|
||||
and falls back to `bmake clean` when it says no (a file pkgsrc changed, no work
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
#!/bin/sh
|
||||
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
||||
#
|
||||
# ext-dist.sh -- make the distfile of a fork in ext/ and the distinfo of its recipe
|
||||
#
|
||||
# usage: tools/ext-dist.sh NAME [-r REV]
|
||||
#
|
||||
# (A git submodule of ext/ is archived from its own repository.)
|
||||
# The same as tools/mcde-dist.sh (which see for why) for any fork
|
||||
# ext/src/NAME with a recipe ext/src/NAME/pkgsrc whose DISTNAME= is NAME-VERSION:
|
||||
# DISTDIR/NAME-VERSION.tar.gz from `git archive' of REV (default HEAD), the
|
||||
# recipes (pkgsrc, pkgsrc-*) left out, and the three lines pkgsrc checks in
|
||||
# the recipe's distinfo. Uncommitted edits are not in the archive on purpose.
|
||||
|
||||
set -eu
|
||||
|
||||
TOP=$(cd "$(dirname "$0")/.." && pwd)
|
||||
# tools/pkgsrc-cross.mk.conf builds DISTDIR from it (bmake -V below); unset it
|
||||
# gives "/build/distfiles" (see mcde-dist.sh)
|
||||
MAKRONIX_TOP=$TOP
|
||||
export MAKRONIX_TOP
|
||||
[ $# -ge 1 ] || { echo "usage: ${0##*/} NAME [-r REV]" >&2; exit 2; }
|
||||
SRC=$1
|
||||
shift
|
||||
REV=HEAD
|
||||
while getopts r: ch; do
|
||||
case $ch in
|
||||
r) REV=$OPTARG ;;
|
||||
*) echo "usage: ${0##*/} NAME [-r REV]" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
RECIPE=$TOP/ext/src/$SRC/pkgsrc
|
||||
NAME=$(sed -n 's/^DISTNAME=[[:space:]]*//p' "$RECIPE/Makefile")
|
||||
[ -n "$NAME" ] || { echo "no DISTNAME= in $RECIPE/Makefile" >&2; exit 1; }
|
||||
|
||||
if [ -z "${DISTDIR:-}" ] && [ -x "$TOP/build/pkg/bin/bmake" ]; then
|
||||
DISTDIR=$(cd "$TOP/pkgsrc" && "$TOP/build/pkg/bin/bmake" -V '${DISTDIR:tA}')
|
||||
fi
|
||||
DISTDIR=${DISTDIR:-$TOP/build/distfiles}
|
||||
DIGEST=${DIGEST:-$TOP/build/pkg/bin/digest}
|
||||
command -v "$DIGEST" > /dev/null 2>&1 || DIGEST=digest
|
||||
HAVE_DIGEST=
|
||||
command -v "$DIGEST" > /dev/null 2>&1 && HAVE_DIGEST=yes
|
||||
|
||||
# A digest value, from pkgsrc's digest(1) if it is there, else from cksum(1)
|
||||
# on NetBSD. Never write an empty line: pkgsrc reads "BLAKE2s (...) = " as no
|
||||
# checksum at all and refuses the package with "No checksum recorded"
|
||||
# (measured 2026-11-20, the forks are packed before pkgtools/digest exists).
|
||||
digest_of()
|
||||
{
|
||||
what=$1; file=$2
|
||||
if [ "$HAVE_DIGEST" = yes ]; then
|
||||
"$DIGEST" "$what" "$file" | sed 's/.* = //'
|
||||
return
|
||||
fi
|
||||
case $what in
|
||||
SHA512) cksum -a sha512 "$file" | awk '{ print $NF }' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# The lock is held by the userland run that calls this script: it serializes
|
||||
# the whole run, so do not take it again (and do not remove the parent's lock
|
||||
# on exit). MX_USERLAND_LOCK is the pid of that run (tools/userland.sh).
|
||||
LOCK=$TOP/build/.userland.lock
|
||||
lock_held=
|
||||
if [ -d "$LOCK" ]; then
|
||||
ipid=$(cat "$LOCK/pid" 2>/dev/null || true)
|
||||
if [ -n "${MX_USERLAND_LOCK:-}" ] && [ "$MX_USERLAND_LOCK" = "$ipid" ]; then
|
||||
lock_held=1
|
||||
elif [ -n "$ipid" ] && kill -0 "$ipid" 2>/dev/null; then
|
||||
echo "ext-dist: userland/dist run holds $LOCK (pid $ipid); aborting" >&2
|
||||
exit 1
|
||||
else
|
||||
rm -rf "$LOCK"
|
||||
fi
|
||||
fi
|
||||
if [ -z "$lock_held" ]; then
|
||||
mkdir "$LOCK" 2>/dev/null || { echo "ext-dist: cannot acquire $LOCK" >&2; exit 1; }
|
||||
echo $$ > "$LOCK/pid"
|
||||
trap 'rm -rf "$LOCK"' EXIT HUP INT TERM
|
||||
fi
|
||||
|
||||
mkdir -p "$DISTDIR"
|
||||
OUT=$DISTDIR/$NAME.tar.gz
|
||||
# A project that is a git submodule (ext/AGENTS.md: splinter, junction, wikid,
|
||||
# ...) is archived from its own repository, at its own root; a tree that is
|
||||
# part of this repository from ext/src/NAME here. Either way the recipes
|
||||
# (pkgsrc, pkgsrc-*) are left out, so a commit that only changes a recipe or
|
||||
# its distinfo does not change the archive.
|
||||
if [ -e "$TOP/ext/src/$SRC/.git" ]; then
|
||||
G="$TOP/ext/src/$SRC"
|
||||
TREE=$REV
|
||||
PFX=.
|
||||
else
|
||||
G=$TOP
|
||||
TREE=$REV:ext/src/$SRC
|
||||
PFX=ext/src/$SRC
|
||||
fi
|
||||
MTIME=$(git -C "$G" log -1 --format=%ct "$REV" -- "$PFX" \
|
||||
":(exclude)$PFX/pkgsrc" ":(exclude)$PFX/pkgsrc-*")
|
||||
git -C "$G" archive --format=tar --mtime="@$MTIME" --prefix="$NAME/" \
|
||||
"$TREE" ':(exclude)pkgsrc' ':(exclude)pkgsrc-*' > "$OUT.tar.tmp"
|
||||
gzip -n -9 < "$OUT.tar.tmp" > "$OUT.tmp"
|
||||
rm -f "$OUT.tar.tmp"
|
||||
mv "$OUT.tmp" "$OUT"
|
||||
|
||||
# The source set (tools/srctree-stage.sh) carries build/distfiles, not the shared
|
||||
# DISTDIR: keep the Makronix-only directory current here, so an offline
|
||||
# rebuild finds the archive this run made without a second fetch (t0071).
|
||||
MXDIST=${MXDIST:-$TOP/build/distfiles}
|
||||
if [ "$DISTDIR" != "$MXDIST" ]; then
|
||||
mkdir -p "$MXDIST"
|
||||
ln "$OUT" "$MXDIST/$NAME.tar.gz" 2>/dev/null || \
|
||||
cp -p "$OUT" "$MXDIST/$NAME.tar.gz" || exit 1
|
||||
fi
|
||||
|
||||
size=$(wc -c < "$OUT" | tr -d ' ')
|
||||
b2s=$(digest_of BLAKE2s "$OUT")
|
||||
sha=$(digest_of SHA512 "$OUT")
|
||||
{
|
||||
echo '$NetBSD$'
|
||||
echo
|
||||
[ -n "$b2s" ] && echo "BLAKE2s ($NAME.tar.gz) = $b2s"
|
||||
[ -n "$sha" ] && echo "SHA512 ($NAME.tar.gz) = $sha"
|
||||
echo "Size ($NAME.tar.gz) = $size bytes"
|
||||
} > "$RECIPE/distinfo"
|
||||
|
||||
echo "ext-dist: $OUT, $size bytes, from $REV ($(git -C "$TOP" rev-parse --short "$REV"))"
|
||||
Executable
+98
@@ -0,0 +1,98 @@
|
||||
#!/bin/sh
|
||||
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
||||
#
|
||||
# ext-extract.sh -- fill a pkgsrc work directory from the source tree of a fork
|
||||
#
|
||||
# usage: ext-extract.sh SRCDIR WRKSRC
|
||||
#
|
||||
# A fork of ext/ builds from its own tree, not from an archive: no DISTFILES,
|
||||
# no distinfo, and the recipe's do-extract calls this script (ext/AGENTS.md).
|
||||
#
|
||||
# Why this exists instead of a `cp -R' in the recipe: pkgsrc extracts once.
|
||||
# The work directory then holds a copy that a later commit does not reach, so
|
||||
# a release can ship the binary of an older commit while the tree says
|
||||
# otherwise (measured 2026-11-23: the recipe of mcde 288d1383 kept the time
|
||||
# stamp of 2026-11-22 and the release carried that day's build).
|
||||
#
|
||||
# What it does, and why in this order:
|
||||
#
|
||||
# 1. hash the source tree, one pass (SHA256 and path per file, .git left out);
|
||||
# 2. a file that left the tree since the last extract: remove the whole copy
|
||||
# and start from nothing. A refresh that kept it would build a file that
|
||||
# no longer exists -- a leftover that stays invisible until the binary
|
||||
# differs from the source it claims to be built from;
|
||||
# 3. copy with -p, so an unchanged file keeps its time stamp and make keeps
|
||||
# the object files that depend on it (MCDE is 27 minutes from nothing);
|
||||
# 4. touch every file whose hash changed. A time stamp alone cannot be
|
||||
# trusted here -- exactly that went wrong on 2026-11-23 -- and hashing
|
||||
# costs one read of the tree, not one process per file.
|
||||
#
|
||||
# The hash list lives beside WRKSRC (in the work directory, never in the copy).
|
||||
|
||||
set -eu
|
||||
|
||||
[ $# -eq 2 ] || { echo "usage: $0 SRCDIR WRKSRC" >&2; exit 2; }
|
||||
src=${1%/}
|
||||
wrksrc=${2%/}
|
||||
case $src in /*) ;; *) echo "ext-extract: SRCDIR must be absolute: $src" >&2; exit 2 ;; esac
|
||||
case $wrksrc in /*) ;; *) echo "ext-extract: WRKSRC must be absolute: $wrksrc" >&2; exit 2 ;; esac
|
||||
[ -d "$src" ] || { echo "ext-extract: no source tree at $src" >&2; exit 1; }
|
||||
|
||||
wrkdir=$(dirname "$wrksrc")
|
||||
mkdir -p "$wrkdir"
|
||||
list=$wrkdir/.makronix-srcfiles
|
||||
tmpd=$wrkdir/.makronix-srcfiles.tmp
|
||||
rm -rf "$tmpd"
|
||||
mkdir -p "$tmpd"
|
||||
|
||||
# One line per file: "<sha256> <path>", the path relative to the tree and
|
||||
# without the git metadata (.git is a directory in a clone, a file in a
|
||||
# submodule checkout).
|
||||
(cd "$src" && find . \( -name .git -o -path './.git/*' \) -prune -o \
|
||||
-type f -print0 | xargs -0 -r sha256sum) > "$tmpd/hashes"
|
||||
|
||||
full=0
|
||||
[ -f "$list" ] && [ -d "$wrksrc" ] || full=1
|
||||
if [ $full -eq 0 ]; then
|
||||
cut -c67- "$list" | LC_ALL=C sort > "$tmpd/paths.old"
|
||||
cut -c67- "$tmpd/hashes" | LC_ALL=C sort > "$tmpd/paths.new"
|
||||
# a name in the old list that the new one does not have: the copy holds a
|
||||
# file the source no longer has, and patching it up is not worth a rule
|
||||
if comm -23 "$tmpd/paths.old" "$tmpd/paths.new" | grep -q .; then
|
||||
echo "ext-extract: a file left the source tree -- the work directory starts from nothing"
|
||||
full=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $full -eq 1 ]; then
|
||||
# from nothing, not over what is there: a file that left the source tree
|
||||
# must not survive in the copy (that is the case this branch exists for)
|
||||
rm -rf "$wrksrc"
|
||||
mkdir -p "$wrksrc"
|
||||
cp -Rp "$src"/. "$wrksrc"/
|
||||
else
|
||||
# Only what is new or changed is copied, and each file keeps the time
|
||||
# stamp of the source: make then rebuilds exactly that and keeps every
|
||||
# object file that does not depend on it (MCDE is 27 minutes from
|
||||
# nothing). Copying the whole tree instead would give every file a new
|
||||
# time stamp and rebuild everything.
|
||||
LC_ALL=C sort -k2 "$list" > "$tmpd/a"
|
||||
LC_ALL=C sort -k2 "$tmpd/hashes" > "$tmpd/b"
|
||||
join -j 2 -o 1.2,1.1,2.1 "$tmpd/a" "$tmpd/b" > "$tmpd/common"
|
||||
while read -r path was now; do
|
||||
[ "$was" = "$now" ] && continue
|
||||
mkdir -p "$wrksrc/$(dirname "$path")"
|
||||
cp -p "$src/$path" "$wrksrc/$path"
|
||||
done < "$tmpd/common"
|
||||
# a path the old list does not have at all: join drops it, so it is
|
||||
# copied here
|
||||
comm -13 "$tmpd/paths.old" "$tmpd/paths.new" > "$tmpd/new"
|
||||
while read -r path; do
|
||||
mkdir -p "$wrksrc/$(dirname "$path")"
|
||||
cp -p "$src/$path" "$wrksrc/$path"
|
||||
done < "$tmpd/new"
|
||||
fi
|
||||
|
||||
rm -rf "$wrksrc/.git"
|
||||
mv "$tmpd/hashes" "$list"
|
||||
rm -rf "$tmpd"
|
||||
@@ -1,165 +0,0 @@
|
||||
#!/bin/sh
|
||||
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
||||
#
|
||||
# ext-resync.sh -- bring the work directory of a fork up to date by what changed
|
||||
#
|
||||
# usage: tools/ext-resync.sh resync PKGPATH e.g. wm/mcde
|
||||
# tools/ext-resync.sh snapshot PKGPATH
|
||||
#
|
||||
# A fork (ext/src/<name>, ext/AGENTS.md) is built by pkgsrc from an archive of
|
||||
# its last commit. pkgsrc extracts it once; a new archive then meant `bmake
|
||||
# clean' and a build from nothing -- ten minutes of MCDE for one changed file
|
||||
# (build/logs/userland-2026-11-14p.log). `resync' puts into the work directory
|
||||
# only the files that differ between the archive pkgsrc extracted (kept, as
|
||||
# build/pkgsrc-work/PKGPATH/.pristine) and the new one. A changed file has a new
|
||||
# time stamp and make builds what depends on it, nothing else.
|
||||
#
|
||||
# resync exits 0 when the work directory is up to date (or has nothing to
|
||||
# resync) and 1 when it cannot say: no work directory, no .pristine, a file
|
||||
# that pkgsrc changed after extracting it (its substitutions) or a file that
|
||||
# decides how the tree is configured (configure.ac, a new Makefile.am, m4).
|
||||
# The caller then does `bmake clean', and after the build `snapshot' keeps the
|
||||
# archive that was extracted.
|
||||
|
||||
set -eu
|
||||
|
||||
TOP=$(cd "$(dirname "$0")/.." && pwd)
|
||||
PKGSRC=$TOP/pkgsrc
|
||||
BMAKE=$TOP/build/pkg/bin/bmake
|
||||
MAKRONIX_TOP=$TOP
|
||||
export MAKRONIX_TOP
|
||||
|
||||
die() { echo "ext-resync: $*" >&2; exit 2; }
|
||||
|
||||
[ $# -eq 2 ] || die "usage: $0 resync|snapshot PKGPATH"
|
||||
cmd=$1 p=$2
|
||||
[ -f "$PKGSRC/$p/Makefile" ] || die "no $PKGSRC/$p"
|
||||
|
||||
var() { (cd "$PKGSRC/$p" && "$BMAKE" show-var VARNAME="$1"); }
|
||||
|
||||
wd=$TOP/build/pkgsrc-work/$p
|
||||
pristine=$wd/.pristine
|
||||
distdir=$(var DISTDIR)
|
||||
distfile=$(var DISTFILES | awk '{print $1}')
|
||||
archive=$distdir/$distfile
|
||||
[ -f "$archive" ] || die "no archive $archive"
|
||||
|
||||
tmp=${TMPDIR:-/tmp}/ext-resync.$$
|
||||
trap 'rm -rf "$tmp"' EXIT HUP INT TERM
|
||||
mkdir -p "$tmp"
|
||||
|
||||
extract_to() { # DIR: the archive's files, in DIR/<top>
|
||||
mkdir -p "$1"
|
||||
tar -xzf "$archive" -C "$1"
|
||||
}
|
||||
|
||||
case $cmd in
|
||||
snapshot)
|
||||
rm -rf "$pristine"
|
||||
extract_to "$pristine"
|
||||
echo "ext-resync: $p: archive kept in ${pristine#$TOP/}"
|
||||
exit 0 ;;
|
||||
resync) ;;
|
||||
*) die "unknown command $cmd" ;;
|
||||
esac
|
||||
|
||||
wrksrc=$(var WRKSRC)
|
||||
[ -d "$wrksrc" ] || exit 1
|
||||
[ -d "$pristine" ] || { echo "ext-resync: $p: no .pristine, cleaning"; exit 1; }
|
||||
top=$(ls "$pristine" | head -1)
|
||||
[ -n "$top" ] || exit 1
|
||||
|
||||
extract_to "$tmp/new"
|
||||
newtop=$(ls "$tmp/new" | head -1)
|
||||
old=$pristine/$top
|
||||
new=$tmp/new/$newtop
|
||||
|
||||
(cd "$new" && find . -type f | sort) > "$tmp/newfiles"
|
||||
(cd "$old" && find . -type f | sort) > "$tmp/oldfiles"
|
||||
|
||||
: > "$tmp/changed"
|
||||
: > "$tmp/added"
|
||||
while IFS= read -r f; do
|
||||
if [ ! -f "$old/$f" ]; then
|
||||
echo "$f" >> "$tmp/added"
|
||||
elif ! cmp -s "$old/$f" "$new/$f"; then
|
||||
echo "$f" >> "$tmp/changed"
|
||||
fi
|
||||
done < "$tmp/newfiles"
|
||||
comm -23 "$tmp/oldfiles" "$tmp/newfiles" > "$tmp/removed"
|
||||
|
||||
needs_configure=0
|
||||
n=$(cat "$tmp/changed" "$tmp/added" "$tmp/removed" | wc -l | tr -d ' ')
|
||||
if [ "$n" -eq 0 ]; then
|
||||
echo "ext-resync: $p: nothing changed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# decide whether the reconfigured tree needs a fresh configure pass: a
|
||||
# configure.ac / Makefile.am / m4 change only invalidates configure, not the
|
||||
# already built objects, so we keep them and let bmake re-run pre-configure
|
||||
# (autoreconf, SUBST). No full `bmake clean' any more (tasksd t0231).
|
||||
while IFS= read -r f; do
|
||||
case $f in
|
||||
./configure.ac|*/configure.ac|*/acinclude.m4|*.m4)
|
||||
needs_configure=1 ;;
|
||||
esac
|
||||
done < "$tmp/changed"
|
||||
while IFS= read -r f; do
|
||||
case $f in
|
||||
*/Makefile.am|*/Makefile.in.in)
|
||||
needs_configure=1 ;;
|
||||
esac
|
||||
done < "$tmp/added"
|
||||
# a file pkgsrc changed after extracting it (SUBST, patches) is no longer the
|
||||
# archive's: putting the new one over it would lose that -- except for the
|
||||
# configure inputs, where re-running configure re-applies the substitution
|
||||
while IFS= read -r f; do
|
||||
case $f in *.md|*.txt|*/AGENTS.md) continue ;; esac
|
||||
if [ -f "$wrksrc/$f" ] && ! cmp -s "$old/$f" "$wrksrc/$f"; then
|
||||
# the work directory holds the new file already: nothing of pkgsrc
|
||||
# to lose. A .pristine older than the extract made every file
|
||||
# changed since then look like pkgsrc's, and MCDE was built from
|
||||
# nothing for a header it already had (build/logs/
|
||||
# userland-2026-11-17f.log:11, include/Dt/WsmP.h).
|
||||
cmp -s "$new/$f" "$wrksrc/$f" && continue
|
||||
case $f in
|
||||
./configure.ac|*/configure.ac|*/acinclude.m4|*.m4|*/Makefile.am|*/Makefile.in.in)
|
||||
needs_configure=1 ;;
|
||||
*) echo "ext-resync: $p: pkgsrc changed $f, cleaning"; exit 1 ;;
|
||||
esac
|
||||
fi
|
||||
done < "$tmp/changed"
|
||||
|
||||
# a file the work directory already has as the new archive has it is not
|
||||
# copied: a copy is a new time stamp, and make would compile what includes it
|
||||
while IFS= read -r f; do
|
||||
cmp -s "$new/$f" "$wrksrc/$f" && continue
|
||||
mkdir -p "$wrksrc/$(dirname "$f")"
|
||||
cp "$new/$f" "$wrksrc/$f"
|
||||
done < "$tmp/changed"
|
||||
while IFS= read -r f; do
|
||||
cmp -s "$new/$f" "$wrksrc/$f" && continue
|
||||
mkdir -p "$wrksrc/$(dirname "$f")"
|
||||
cp "$new/$f" "$wrksrc/$f"
|
||||
done < "$tmp/added"
|
||||
while IFS= read -r f; do
|
||||
rm -f "$wrksrc/$f"
|
||||
done < "$tmp/removed"
|
||||
|
||||
# build and install again (pkgsrc's cookies); keep the configured tree and only
|
||||
# drop configure's cookie when the configure inputs changed, so autoreconf and
|
||||
# SUBST run again without throwing away built objects (tasksd t0231)
|
||||
wdir=$(dirname "$wrksrc")
|
||||
# .package_done too: in a cross build `install' adds the binary package, and
|
||||
# with the cookie kept pkgsrc does not make it again -- the old one was
|
||||
# installed over a fresh build (pkgsrc/mk/package/package.mk:35, 2026-11-17)
|
||||
rm -f "$wdir/.build_done" "$wdir/.install_done" "$wdir/.package_done" \
|
||||
"$wdir"/.PLIST*
|
||||
[ "$needs_configure" = 1 ] && rm -f "$wdir/.configure_done"
|
||||
|
||||
rm -rf "$pristine"
|
||||
mv "$tmp/new" "$pristine"
|
||||
echo "ext-resync: $p: $(wc -l < "$tmp/changed" | tr -d ' ') changed," \
|
||||
"$(wc -l < "$tmp/added" | tr -d ' ') new, $(wc -l < "$tmp/removed" | tr -d ' ') removed"
|
||||
exit 0
|
||||
+63
-25
@@ -1,47 +1,85 @@
|
||||
#!/bin/sh
|
||||
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
||||
#
|
||||
# ext-sync.sh -- put the recipes of ext/ into the pkgsrc tree
|
||||
# ext-sync.sh -- make the recipe of a fork in ext/ visible to pkgsrc
|
||||
#
|
||||
# usage: tools/ext-sync.sh [PKGSRCDIR]
|
||||
#
|
||||
# A fork under ext/src/<name>/ (ext/AGENTS.md) keeps its pkgsrc recipe in
|
||||
# ext/src/<name>/pkgsrc/. pkgsrc builds a recipe only from inside its tree
|
||||
# (the recipe includes ../../mk/bsd.pkg.mk), so this copies it to
|
||||
# PKGSRCDIR/<category>/<name>, the category being the first word of the
|
||||
# recipe's CATEGORIES -- the way an owned copy is kept in this tree.
|
||||
# PKGSRCDIR defaults to pkgsrc/ of this tree.
|
||||
# A fork under ext/src/<name>/ keeps its recipe beside its source
|
||||
# (ext/src/<name>/pkgsrc/, ext/AGENTS.md): that is the file a person edits and
|
||||
# the file git tracks. pkgsrc builds a recipe only from inside its own tree --
|
||||
# the recipe includes ../../mk/bsd.pkg.mk, and bmake resolves that relative to
|
||||
# the *directory of the file* -- so the recipe is mirrored to
|
||||
# PKGSRCDIR/<category>/<name>, the category being the first word of its
|
||||
# CATEGORIES.
|
||||
#
|
||||
# A copy, not a link: the source set and the VM need real files. The
|
||||
# target is only ever replaced when upstream pkgsrc does not own that path
|
||||
# (`git ls-files' of the pkgsrc import is empty for it): an upstream package
|
||||
# of the same name is never overwritten.
|
||||
# A mirror, not a copy that lives on its own: each file is a symlink to the
|
||||
# tracked original (files only -- a directory symlink would move .CURDIR out of
|
||||
# the tree and break the ../../mk includes). One file to edit, one file to
|
||||
# commit; the mirror is build output and pkgsrc's .git/info/exclude names it.
|
||||
#
|
||||
# The target is only ever replaced when upstream pkgsrc does not own that path
|
||||
# (`git ls-files' of the pkgsrc import is empty for it): an upstream package of
|
||||
# the same name is never touched.
|
||||
#
|
||||
# wkdir/ of the mirror is a small Makefile that points pkgsrc's work directory
|
||||
# at the source tree the recipe builds from (no archive, no extraction), so a
|
||||
# build compiles ext/src/<name> itself.
|
||||
#
|
||||
# Prints one line, "ext-sync: <category>/<name> ...", per recipe mirrored;
|
||||
# tools/userland.sh reads the list back from it.
|
||||
|
||||
set -eu
|
||||
|
||||
TOP=$(cd "$(dirname "$0")/.." && pwd)
|
||||
PKGSRCDIR=${1:-$TOP/pkgsrc}
|
||||
|
||||
# ext/src/<name>/pkgsrc is <category>/<name>; a second package from the same
|
||||
# tree, ext/src/<name>/pkgsrc-<part>, is <category>/<name>-<part> (MCDE's
|
||||
# Motif: ext/src/mcde/pkgsrc-motif, x11/mcde-motif)
|
||||
for recipe in "$TOP"/ext/src/*/pkgsrc "$TOP"/ext/src/*/pkgsrc-*; do
|
||||
[ -f "$recipe/Makefile" ] || continue
|
||||
[ -d "$PKGSRCDIR/mk" ] || { echo "ext-sync: no pkgsrc at $PKGSRCDIR" >&2; exit 1; }
|
||||
|
||||
mirror_one()
|
||||
{
|
||||
recipe=$1
|
||||
name=$(basename "$(dirname "$recipe")")
|
||||
part=
|
||||
case ${recipe##*/} in
|
||||
pkgsrc-*) name=$name-${recipe##*/pkgsrc-} ;;
|
||||
pkgsrc-*) part=-${recipe##*/pkgsrc-} ;;
|
||||
esac
|
||||
cat=$(sed -n 's/^CATEGORIES=[[:space:]]*\([^[:space:]]*\).*/\1/p' \
|
||||
"$recipe/Makefile")
|
||||
[ -n "$cat" ] || { echo "ext-sync: no CATEGORIES in $recipe/Makefile" >&2; exit 1; }
|
||||
dst=$PKGSRCDIR/$cat/$name
|
||||
if [ -d "$PKGSRCDIR/.git" ] &&
|
||||
[ -n "$(git -C "$PKGSRCDIR" ls-files -- "$cat/$name" | head -1)" ]; then
|
||||
echo "ext-sync: $cat/$name belongs to upstream pkgsrc, not replaced" >&2
|
||||
exit 1
|
||||
[ -n "$cat" ] || { echo "ext-sync: no CATEGORIES= in $recipe/Makefile" >&2; return 1; }
|
||||
|
||||
pkg=$name$part
|
||||
dst=$PKGSRCDIR/$cat/$pkg
|
||||
|
||||
# upstream's own package of this name is never overwritten
|
||||
if [ -n "$(git -C "$PKGSRCDIR" ls-files "$cat/$pkg" 2>/dev/null)" ]; then
|
||||
echo "ext-sync: $cat/$pkg belongs to upstream pkgsrc; not mirrored" >&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
rm -rf "$dst"
|
||||
mkdir -p "$dst"
|
||||
(cd "$recipe" && tar -cf - .) | (cd "$dst" && tar -xf -)
|
||||
echo "ext-sync: $cat/$name"
|
||||
# every file of the recipe, by name; a directory ($FILESDIR, patches/)
|
||||
# is mirrored file by file the same way
|
||||
(cd "$recipe" && find . -type f | sed 's|^\./||') | while read -r f; do
|
||||
mkdir -p "$dst/$(dirname "$f")"
|
||||
rel=$(cd "$dst/$(dirname "$f")" && realpath -m --relative-to=. "$recipe/$f")
|
||||
ln -s "$rel" "$dst/$f"
|
||||
done
|
||||
echo "ext-sync: $cat/$pkg from ${recipe#$TOP/}"
|
||||
}
|
||||
|
||||
for recipe in "$TOP"/ext/src/*/pkgsrc "$TOP"/ext/src/*/pkgsrc-*; do
|
||||
[ -f "$recipe/Makefile" ] || continue
|
||||
mirror_one "$recipe" || exit 1
|
||||
done
|
||||
|
||||
# a recipe that was removed from ext/ leaves nothing behind
|
||||
for d in "$PKGSRCDIR"/*/*/; do
|
||||
d=${d%/}
|
||||
[ -L "$d/Makefile" ] || continue
|
||||
tgt=$(readlink -f "$d/Makefile") || continue
|
||||
case $tgt in
|
||||
"$TOP"/ext/src/*) [ -f "$tgt" ] || { rm -rf "$d"; echo "ext-sync: removed stale $d"; } ;;
|
||||
esac
|
||||
done
|
||||
+12
-38
@@ -7,8 +7,6 @@
|
||||
# recipes (a stale list is an error)
|
||||
# makronix-distfiles.sh closure the packages Makronix builds and what
|
||||
# they need, one PKGPATH a line
|
||||
# makronix-distfiles.sh forks the archives of the forks of ext/,
|
||||
# from their last commit
|
||||
# makronix-distfiles.sh fetch fill build/distfiles with them
|
||||
# makronix-distfiles.sh check verify build/distfiles
|
||||
# makronix-distfiles.sh stage DIR put them into DIR/distfiles/
|
||||
@@ -110,7 +108,9 @@ gen_list()
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
closure_paths > "$tmp/all"
|
||||
# the forks of ext/ are checked by their distinfo (fork_archives)
|
||||
# The forks of ext/ have no archive to list: their recipe builds from
|
||||
# ext/src/<name>, which is in the repository and travels with the source
|
||||
# set (ext/src/<name>/pkgsrc/Makefile, do-extract).
|
||||
fork_recipes | cut -d' ' -f1 | LC_ALL=C sort -u > "$tmp/forks"
|
||||
LC_ALL=C comm -23 "$tmp/all" "$tmp/forks" > "$tmp/paths"
|
||||
[ -s "$tmp/paths" ] || die "no packages"
|
||||
@@ -152,12 +152,9 @@ gen_list()
|
||||
"$(wc -l < "$out" | tr -d ' ') archives -> ${out#$TOP/}"
|
||||
}
|
||||
|
||||
# The forks of ext/ (MCDE, its Motif, afpfs-ng): "<pkgpath> <recipe dir>", the
|
||||
# way tools/ext-sync.sh maps them. Their archive is made from the fork's last
|
||||
# commit (tools/mcde-dist.sh, tools/ext-dist.sh) and keeps its name, so a line
|
||||
# for it in distfiles.lst went stale with every commit to ext/ and `make
|
||||
# sourcesets' stopped at verify (2026-11-14). They stay out of the list; their
|
||||
# archive is checked against the recipe's distinfo, which is current.
|
||||
# The forks of ext/ (MCDE, its Motif, the servers): "<pkgpath> <recipe dir>",
|
||||
# the way tools/ext-sync.sh maps them. They are left out of the list: their
|
||||
# recipe builds from ext/src/<name> itself, so there is no archive to fetch.
|
||||
fork_recipes()
|
||||
{
|
||||
for recipe in "$TOP"/ext/src/*/pkgsrc "$TOP"/ext/src/*/pkgsrc-*; do
|
||||
@@ -172,35 +169,13 @@ fork_recipes()
|
||||
done
|
||||
}
|
||||
|
||||
# "<pkgpath> <archive> <size> <sha512>" of the forks, from their distinfo
|
||||
# The forks of ext/ contribute no archive: their recipe builds from the source
|
||||
# tree itself (do-extract copies ext/src/<name> into WRKSRC), and that tree is
|
||||
# part of the repository and of the source set. Nothing to fetch, nothing to
|
||||
# stage. The function stays so check, stage and the list keep one shape.
|
||||
fork_archives()
|
||||
{
|
||||
fork_recipes | while read -r p recipe; do
|
||||
[ -f "$recipe/distinfo" ] || continue
|
||||
awk -v pkg="$p" '
|
||||
$1 == "SHA512" && $2 !~ /^\(patch-/ {
|
||||
n = $2; gsub(/[()]/, "", n); h[n] = $4; order[++c] = n
|
||||
}
|
||||
$1 == "Size" { n = $2; gsub(/[()]/, "", n); s[n] = $4 }
|
||||
END {
|
||||
for (i = 1; i <= c; i++)
|
||||
printf "%s %s %s %s\n", pkg, order[i], s[order[i]], h[order[i]]
|
||||
}' "$recipe/distinfo"
|
||||
done
|
||||
}
|
||||
|
||||
# the archives of the forks from their last commit, with their distinfo
|
||||
cmd_forks()
|
||||
{
|
||||
for d in "$TOP"/ext/src/*; do
|
||||
[ -f "$d/pkgsrc/Makefile" ] || continue
|
||||
n=${d##*/}
|
||||
if [ "$n" = mcde ]; then
|
||||
"$TOP/tools/mcde-dist.sh" || die "tools/mcde-dist.sh failed"
|
||||
else
|
||||
"$TOP/tools/ext-dist.sh" "$n" || die "tools/ext-dist.sh $n failed"
|
||||
fi
|
||||
done
|
||||
:
|
||||
}
|
||||
|
||||
cmd_list()
|
||||
@@ -329,12 +304,11 @@ cmd_stage()
|
||||
rm -f "$slist"
|
||||
}
|
||||
|
||||
[ $# -ge 1 ] || die "usage: $0 list|verify|forks|fetch|check|stage DIR"
|
||||
[ $# -ge 1 ] || die "usage: $0 list|verify|closure|fetch|check|stage DIR"
|
||||
cmd=$1; shift
|
||||
case $cmd in
|
||||
list) cmd_list ;;
|
||||
verify) cmd_verify ;;
|
||||
forks) cmd_forks ;;
|
||||
closure) closure_paths ;;
|
||||
fetch) cmd_fetch ;;
|
||||
check) cmd_check ;;
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
#!/bin/sh
|
||||
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
||||
#
|
||||
# mcde-dist.sh -- make the distfile of MCDE and the distinfo of its recipe
|
||||
#
|
||||
# usage: tools/mcde-dist.sh [-r REV]
|
||||
#
|
||||
# MCDE is a fork of its own now (ext/src/mcde is the submodule
|
||||
# git.kropa.tech/hiddenbox/mcde, ext/AGENTS.md); pkgsrc builds it from an
|
||||
# archive like any other package. The archive is made with
|
||||
# `git archive' from a commit (default HEAD), so the same commit always gives
|
||||
# the same bytes and the checksums in distinfo stay valid: uncommitted edits are
|
||||
# not in it on purpose. ext/src/mcde/pkgsrc (the recipe) is left out.
|
||||
#
|
||||
# Writes DISTDIR/mcde-VERSION.tar.gz (pkgsrc's DISTDIR, as
|
||||
# tools/pkgsrc-cross.mk.conf chooses it) and renews ext/src/mcde/pkgsrc/distinfo with the three lines
|
||||
# pkgsrc checks (BLAKE2s, SHA512, Size), computed with pkgsrc's own digest(1).
|
||||
|
||||
set -eu
|
||||
|
||||
TOP=$(cd "$(dirname "$0")/.." && pwd)
|
||||
# tools/pkgsrc-cross.mk.conf builds DISTDIR from it (bmake -V below); unset it
|
||||
# gives "/build/distfiles" and "mkdir: cannot create directory '/build'"
|
||||
# (measured 2026-11-14 when run by hand, outside userland.sh)
|
||||
MAKRONIX_TOP=$TOP
|
||||
export MAKRONIX_TOP
|
||||
REV=HEAD
|
||||
while getopts r: ch; do
|
||||
case $ch in
|
||||
r) REV=$OPTARG ;;
|
||||
*) echo "usage: ${0##*/} [-r REV]" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
RECIPE=$TOP/ext/src/mcde/pkgsrc
|
||||
VERSION=$(sed -n 's/^DISTNAME=[[:space:]]*mcde-//p' "$RECIPE/Makefile")
|
||||
[ -n "$VERSION" ] || { echo "no DISTNAME=mcde-... in $RECIPE/Makefile" >&2; exit 1; }
|
||||
NAME=mcde-$VERSION
|
||||
|
||||
# pkgsrc's own DISTDIR, where `make fetch' looks and what tools/userland.sh
|
||||
# serves to the build VM; build/distfiles only without a bootstrap
|
||||
if [ -z "${DISTDIR:-}" ] && [ -x "$TOP/build/pkg/bin/bmake" ]; then
|
||||
DISTDIR=$(cd "$TOP/pkgsrc" && "$TOP/build/pkg/bin/bmake" -V '${DISTDIR:tA}')
|
||||
fi
|
||||
DISTDIR=${DISTDIR:-$TOP/build/distfiles}
|
||||
DIGEST=${DIGEST:-$TOP/build/pkg/bin/digest}
|
||||
command -v "$DIGEST" > /dev/null 2>&1 || DIGEST=digest
|
||||
HAVE_DIGEST=
|
||||
command -v "$DIGEST" > /dev/null 2>&1 && HAVE_DIGEST=yes
|
||||
|
||||
# A digest value, from pkgsrc's digest(1) if it is there, else from cksum(1)
|
||||
# on NetBSD. Never write an empty line: pkgsrc reads "BLAKE2s (...) = " as no
|
||||
# checksum at all and refuses the package with "No checksum recorded"
|
||||
# (measured 2026-11-20, the forks are packed before pkgtools/digest exists).
|
||||
digest_of()
|
||||
{
|
||||
what=$1; file=$2
|
||||
if [ "$HAVE_DIGEST" = yes ]; then
|
||||
"$DIGEST" "$what" "$file" | sed 's/.* = //'
|
||||
return
|
||||
fi
|
||||
case $what in
|
||||
SHA512) cksum -a sha512 "$file" | awk '{ print $NF }' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# respect the shared userland lock: do not overwrite a dist others are using.
|
||||
# The userland run that calls this script holds it (MX_USERLAND_LOCK): it
|
||||
# already serializes us, so do not take it again and do not remove it.
|
||||
LOCK=$TOP/build/.userland.lock
|
||||
lock_held=
|
||||
if [ -d "$LOCK" ]; then
|
||||
ipid=$(cat "$LOCK/pid" 2>/dev/null || true)
|
||||
if [ -n "${MX_USERLAND_LOCK:-}" ] && [ "$MX_USERLAND_LOCK" = "$ipid" ]; then
|
||||
lock_held=1
|
||||
elif [ -n "$ipid" ] && kill -0 "$ipid" 2>/dev/null; then
|
||||
echo "mcde-dist: userland/dist run holds $LOCK (pid $ipid); aborting" >&2
|
||||
exit 1
|
||||
else
|
||||
rm -rf "$LOCK"
|
||||
fi
|
||||
fi
|
||||
if [ -z "$lock_held" ]; then
|
||||
mkdir "$LOCK" 2>/dev/null || { echo "mcde-dist: cannot acquire $LOCK" >&2; exit 1; }
|
||||
echo $$ > "$LOCK/pid"
|
||||
trap 'rm -rf "$LOCK"' EXIT HUP INT TERM
|
||||
fi
|
||||
|
||||
mkdir -p "$DISTDIR"
|
||||
OUT=$DISTDIR/$NAME.tar.gz
|
||||
# MCDE is a submodule since 2026-11-22: the source revision is the commit the
|
||||
# parent records for the gitlink, and the archive is made inside the submodule.
|
||||
# `git archive REV:ext/src/mcde' in the parent would write an empty directory --
|
||||
# git does not descend into a gitlink -- so REV names the parent and SRCREV the
|
||||
# submodule commit.
|
||||
SUB=$TOP/ext/src/mcde
|
||||
SRCREV=$(git -C "$TOP" rev-parse "$REV:ext/src/mcde") || {
|
||||
echo "mcde-dist: $REV has no ext/src/mcde gitlink" >&2; exit 1; }
|
||||
# The time of every entry: the last commit that changed the source (not the
|
||||
# recipe). Given a tree, git archive would use the current time, and every run
|
||||
# gave other bytes (measured 2026-11-09); a commit of distinfo alone must not
|
||||
# change the archive either. Needs git 2.42 or later (--mtime).
|
||||
MTIME=$(git -C "$SUB" log -1 --format=%ct "$SRCREV" -- . \
|
||||
':(exclude)pkgsrc' ':(exclude)pkgsrc-*')
|
||||
# The archive is made again only when what goes into it changed: the source
|
||||
# trees (git ls-tree, the recipes left out, as in the archive) and the time.
|
||||
# Every make userland made it anew, 16 s for an unchanged tree (measured
|
||||
# 2026-11-17). The key is kept beside the archive. NetBSD has sha256, not
|
||||
# sha256sum; with the wrong name the key was empty and the comparison
|
||||
# meaningless (measured 2026-11-22), so the tool is asked for by name.
|
||||
hash_of()
|
||||
{
|
||||
if command -v sha256sum > /dev/null 2>&1; then
|
||||
sha256sum | cut -d' ' -f1
|
||||
else
|
||||
sha256 | sed 's/.*) = //'
|
||||
fi
|
||||
}
|
||||
key=$( { echo "$MTIME"; git -C "$SUB" ls-tree "$SRCREV" |
|
||||
grep -v ' pkgsrc'; } | hash_of)
|
||||
if [ -s "$OUT" ] && [ "$(cat "$OUT.key" 2>/dev/null)" = "$key" ]; then
|
||||
echo "mcde-dist: archive unchanged ($REV $(git -C "$TOP" rev-parse --short "$REV"), mcde $(git -C "$SUB" rev-parse --short "$SRCREV"))"
|
||||
else
|
||||
# gzip -n: no name and no time stamp in the header, so the bytes do not
|
||||
# change. -6, not -9: 6.0 s instead of 15.7 s for 0.9 % more bytes
|
||||
# (67069914 against 66472043, measured 2026-11-17).
|
||||
git -C "$SUB" archive --format=tar --mtime="@$MTIME" --prefix="$NAME/" \
|
||||
"$SRCREV^{tree}" ':(exclude)pkgsrc' ':(exclude)pkgsrc-*' > "$OUT.tar.tmp"
|
||||
gzip -n -6 < "$OUT.tar.tmp" > "$OUT.tmp"
|
||||
rm -f "$OUT.tar.tmp"
|
||||
mv "$OUT.tmp" "$OUT"
|
||||
printf '%s\n' "$key" > "$OUT.key"
|
||||
fi
|
||||
|
||||
# The source set (tools/srctree-stage.sh) carries build/distfiles, not the shared
|
||||
# DISTDIR: keep the Makronix-only directory current here, so an offline
|
||||
# rebuild finds the archive this run made without a second fetch (t0071).
|
||||
MXDIST=${MXDIST:-$TOP/build/distfiles}
|
||||
if [ "$DISTDIR" != "$MXDIST" ]; then
|
||||
mkdir -p "$MXDIST"
|
||||
ln "$OUT" "$MXDIST/$NAME.tar.gz" 2>/dev/null || \
|
||||
cp -p "$OUT" "$MXDIST/$NAME.tar.gz" || exit 1
|
||||
fi
|
||||
|
||||
size=$(wc -c < "$OUT" | tr -d ' ')
|
||||
b2s=$(digest_of BLAKE2s "$OUT")
|
||||
sha=$(digest_of SHA512 "$OUT")
|
||||
|
||||
{
|
||||
echo '$NetBSD$'
|
||||
echo
|
||||
[ -n "$b2s" ] && echo "BLAKE2s ($NAME.tar.gz) = $b2s"
|
||||
[ -n "$sha" ] && echo "SHA512 ($NAME.tar.gz) = $sha"
|
||||
echo "Size ($NAME.tar.gz) = $size bytes"
|
||||
} > "$RECIPE/distinfo"
|
||||
# the other recipes of the same archive (pkgsrc-motif: x11/mcde-motif)
|
||||
for r in "$TOP"/ext/src/mcde/pkgsrc-*; do
|
||||
[ -f "$r/Makefile" ] && cp "$RECIPE/distinfo" "$r/distinfo"
|
||||
done
|
||||
|
||||
echo "mcde-dist: $OUT, $size bytes, from $REV ($(git -C "$TOP" rev-parse --short "$REV"), mcde $(git -C "$SUB" rev-parse --short "$SRCREV"))"
|
||||
+73
-4
@@ -58,10 +58,23 @@ sandbox_mount()
|
||||
mount | grep -q " on $MNT " || {
|
||||
mount -t tmpfs tmpfs "$MNT"
|
||||
mkdir -p "$MNT/pkgsrc" "$MNT/distfiles" "$MNT/work" \
|
||||
"$MNT/packages" "$MNT/tmp"
|
||||
"$MNT/packages" "$MNT/tmp" "$MNT/ext" "$MNT/tools"
|
||||
}
|
||||
mount | grep -q " on $MNT/pkgsrc " ||
|
||||
mount -t null "$TOP/pkgsrc" "$MNT/pkgsrc"
|
||||
# The recipes of ext/ build from the source tree beside them, not from an
|
||||
# archive (ext/src/<name>/pkgsrc/Makefile: WRKSRC is ext/src/<name>), so
|
||||
# that tree has to be visible inside the chroot as well. Read-only by
|
||||
# intent: the build writes into $MNT/work, and a recipe that wrote into
|
||||
# its own source tree would put a host path into the sysroot's package.
|
||||
mount | grep -q " on $MNT/ext " ||
|
||||
mount -t null "$TOP/ext" "$MNT/ext"
|
||||
# The recipe's do-extract runs tools/ext-extract.sh (it refreshes the copy
|
||||
# in the work directory instead of copying once), so tools/ has to be
|
||||
# reachable inside the chroot at the same relative place: the recipes say
|
||||
# ${_MAKRONIX_TOP}/tools, and _MAKRONIX_TOP is /mnt there.
|
||||
mount | grep -q " on $MNT/tools " ||
|
||||
mount -t null "$TOP/tools" "$MNT/tools"
|
||||
mount | grep -q " on $MNT/distfiles " ||
|
||||
mount -t null "${DISTFILES:-$TOP/distfiles}" "$MNT/distfiles"
|
||||
mount | grep -q " on $MNT/work " ||
|
||||
@@ -118,6 +131,41 @@ sha256_in()
|
||||
fi
|
||||
}
|
||||
|
||||
# The recipes of ext/ (ext/AGENTS.md) as pkgsrc paths: "misc/splinter
|
||||
# wm/mcde x11/mcde-motif ...". A fork's recipe lives beside its source and is
|
||||
# mirrored into pkgsrc by tools/ext-sync.sh; here only the path is needed.
|
||||
fork_recipes()
|
||||
{
|
||||
for recipe in "$TOP"/ext/src/*/pkgsrc "$TOP"/ext/src/*/pkgsrc-*; do
|
||||
[ -f "$recipe/Makefile" ] || continue
|
||||
name=$(basename "$(dirname "$recipe")")
|
||||
case ${recipe##*/} in
|
||||
pkgsrc-*) name=$name-${recipe##*/pkgsrc-} ;;
|
||||
esac
|
||||
cat=$(sed -n 's/^CATEGORIES=[[:space:]]*\([^[:space:]]*\).*/\1/p' \
|
||||
"$recipe/Makefile")
|
||||
echo "$cat/$name"
|
||||
done
|
||||
}
|
||||
|
||||
# The source tree a fork's recipe builds from: the one the recipe's
|
||||
# do-extract copies. Its commit is the build's input -- not a hash of the
|
||||
# whole tree, which is 286 MB for mcde (measured 2026-11-23).
|
||||
# A recipe that builds from an archive (afpfs-ng, an upstream tarball with its
|
||||
# distinfo) has no such tree: it prints nothing, and the caller keeps the
|
||||
# archive hash it used before. The test is the recipe itself, so a fork that
|
||||
# goes back to an archive needs no change here.
|
||||
fork_src()
|
||||
{
|
||||
r=$TOP/pkgsrc/$1
|
||||
[ -f "$r/Makefile" ] || return 0
|
||||
grep -q '^DISTFILES=[[:space:]]*#[[:space:]]*empty' "$r/Makefile" || return 0
|
||||
case $1 in
|
||||
x11/mcde-motif) echo "$TOP/ext/src/mcde" ;;
|
||||
*) echo "$TOP/ext/src/${1##*/}" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
sandbox_stale()
|
||||
{
|
||||
sr_path=$1
|
||||
@@ -129,13 +177,34 @@ sandbox_stale()
|
||||
# commit that touches it (measured 2026-11-23 on the MacBook: the recipe
|
||||
# of mcde 288d1383 kept the time of 2026-11-22 10:27, so an mtime test
|
||||
# said "not stale" and the release shipped the binary of the day before).
|
||||
# The key covers the recipe (Makefile, options, patches, PLIST) and the
|
||||
# archive that tools/ext-dist.sh names in distinfo.
|
||||
# The key covers the recipe (Makefile, options, patches, PLIST) and, for a
|
||||
# fork of ext/, the source tree the recipe builds from -- there is no
|
||||
# archive and no distinfo any more (the recipe's do-extract copies
|
||||
# ext/src/<name> into WRKSRC). A commit in the fork is what changes the
|
||||
# build, so the tree's content is part of the key.
|
||||
src=
|
||||
case " $(fork_recipes) " in
|
||||
*" $sr_path "*) src=$(fork_src "$sr_path") ;;
|
||||
esac
|
||||
# A commit is the input, not a hash of the tree: `git status' would be
|
||||
# cheaper still but misses the commit case (a checkout updates .git and
|
||||
# the files, not necessarily the mtimes). Uncommitted work is covered
|
||||
# too: `git status --porcelain' is not empty then, which changes the key.
|
||||
# A recipe that builds from an archive (fork_src prints nothing) keeps
|
||||
# the distinfo hash it had.
|
||||
srcid=
|
||||
if [ -n "$src" ]; then
|
||||
srcid=$(git -C "$src" rev-parse HEAD 2>/dev/null)$(git -C "$src" status --porcelain 2>/dev/null | sha256_in)
|
||||
elif [ -f "$TOP/pkgsrc/$sr_path/distinfo" ]; then
|
||||
srcid=$(sha256_in < "$TOP/pkgsrc/$sr_path/distinfo")
|
||||
fi
|
||||
key=$( { cat "$TOP/pkgsrc/$sr_path"/Makefile \
|
||||
"$TOP/pkgsrc/$sr_path"/options.mk 2>/dev/null
|
||||
find "$TOP/pkgsrc/$sr_path" -type f \( -name '*.patch' -o -name 'PLIST*' \) \
|
||||
-exec cat {} + 2>/dev/null
|
||||
cat "$TOP/pkgsrc/$sr_path"/distinfo 2>/dev/null; } | sha256_in )
|
||||
cat "$TOP/pkgsrc/$sr_path"/distinfo 2>/dev/null
|
||||
printf '%s\n' "$srcid"
|
||||
} | sha256_in )
|
||||
kf=$TOP/build/pkgsrc-work/$sr_path/.makronix-build-key
|
||||
if [ "$(cat "$kf" 2>/dev/null)" = "$key" ]; then
|
||||
return 1
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
#!/bin/sh
|
||||
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
||||
#
|
||||
# test-ext-resync.sh -- tests for tools/ext-resync.sh (t0231, t0464)
|
||||
#
|
||||
# usage: tools/test-ext-resync.sh [EXT_RESYNC]
|
||||
#
|
||||
# Runs ext-resync.sh (default: the one next to this script) in a scratch tree
|
||||
# with artificial archives and a stand-in bmake that answers show-var, so no
|
||||
# pkgsrc, no build and no lock are touched. Cases: a changed file is copied
|
||||
# and the build cookies go; an unchanged file keeps its time stamp; a work
|
||||
# directory that already has the new file (a .pristine older than the
|
||||
# extract) is no reason to clean; a file pkgsrc changed is; a removed file is
|
||||
# removed; a configure.ac change drops the configure cookie.
|
||||
# Exit 0 when all cases pass. Output: result: N ok, M bad
|
||||
|
||||
set -u
|
||||
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
RESYNC=${1:-$HERE/ext-resync.sh}
|
||||
S=${TMPDIR:-/tmp}/test-ext-resync.$$
|
||||
trap 'rm -rf "$S"' EXIT HUP INT TERM
|
||||
ok=0 bad=0
|
||||
check() { # NAME COMMAND...
|
||||
n=$1; shift
|
||||
if "$@"; then echo "ok $n"; ok=$((ok + 1))
|
||||
else echo "BAD $n"; bad=$((bad + 1)); fi
|
||||
}
|
||||
|
||||
P=cat/t
|
||||
WD=$S/build/pkgsrc-work/$P
|
||||
WRKSRC=$WD/work.T/t-1.0
|
||||
DIST=$S/distfiles
|
||||
|
||||
setup() { # a work directory extracted from archive A, .pristine = A
|
||||
rm -rf "$S"
|
||||
mkdir -p "$S/tools" "$S/build/pkg/bin" "$S/pkgsrc/$P" "$DIST" "$S/a/t-1.0/src"
|
||||
cp "$RESYNC" "$S/tools/ext-resync.sh"
|
||||
cat > "$S/build/pkg/bin/bmake" <<EOF
|
||||
#!/bin/sh
|
||||
case \$2 in
|
||||
VARNAME=WRKSRC) echo "$WRKSRC" ;;
|
||||
VARNAME=DISTDIR) echo "$DIST" ;;
|
||||
VARNAME=DISTFILES) echo t-1.0.tar.gz ;;
|
||||
esac
|
||||
EOF
|
||||
chmod +x "$S/build/pkg/bin/bmake"
|
||||
: > "$S/pkgsrc/$P/Makefile"
|
||||
echo one > "$S/a/t-1.0/src/one.c"
|
||||
echo two > "$S/a/t-1.0/src/two.c"
|
||||
echo gone > "$S/a/t-1.0/src/gone.c"
|
||||
echo 'AC_INIT' > "$S/a/t-1.0/configure.ac"
|
||||
mkdir -p "$WD/.pristine" "$WD/work.T"
|
||||
cp -R "$S/a/t-1.0" "$WD/.pristine/"
|
||||
cp -R "$S/a/t-1.0" "$WD/work.T/"
|
||||
touch "$WD/work.T/.build_done" "$WD/work.T/.install_done" \
|
||||
"$WD/work.T/.package_done" "$WD/work.T/.configure_done"
|
||||
touch -t 202601010000 "$WRKSRC/src/one.c" "$WRKSRC/src/two.c"
|
||||
cp -R "$S/a" "$S/b"
|
||||
}
|
||||
pack() { # the new archive from $S/b
|
||||
(cd "$S/b" && tar -czf "$DIST/t-1.0.tar.gz" t-1.0)
|
||||
}
|
||||
run() { (cd "$S" && sh tools/ext-resync.sh resync "$P") > "$S/out" 2>&1; }
|
||||
older() { [ "$1" -ot "$S/build/pkg/bin/bmake" ]; }
|
||||
|
||||
# 1: one file changed, one removed
|
||||
setup
|
||||
echo ONE > "$S/b/t-1.0/src/one.c"
|
||||
rm "$S/b/t-1.0/src/gone.c"
|
||||
pack
|
||||
check "changed: exit 0" run
|
||||
check "changed: new content" grep -qx ONE "$WRKSRC/src/one.c"
|
||||
check "unchanged: time stamp kept" older "$WRKSRC/src/two.c"
|
||||
check "removed: gone" test ! -f "$WRKSRC/src/gone.c"
|
||||
check "cookies: build/install/package gone" test ! -f "$WD/work.T/.build_done" -a ! -f "$WD/work.T/.install_done" -a ! -f "$WD/work.T/.package_done"
|
||||
check "cookies: configure kept" test -f "$WD/work.T/.configure_done"
|
||||
|
||||
# 2: .pristine older than the extract: the work directory has the new file
|
||||
setup
|
||||
echo NEW > "$S/b/t-1.0/src/two.c"
|
||||
cp "$S/b/t-1.0/src/two.c" "$WRKSRC/src/two.c"
|
||||
touch -t 202601010000 "$WRKSRC/src/two.c"
|
||||
echo ONE > "$S/b/t-1.0/src/one.c"
|
||||
pack
|
||||
check "stale pristine: no clean (exit 0)" run
|
||||
check "stale pristine: file not copied again" older "$WRKSRC/src/two.c"
|
||||
|
||||
# 3: a file pkgsrc changed (SUBST) and the archive changed it too
|
||||
setup
|
||||
echo subst > "$WRKSRC/src/two.c"
|
||||
echo TWO > "$S/b/t-1.0/src/two.c"
|
||||
pack
|
||||
run
|
||||
check "pkgsrc changed: exit 1" test $? -eq 1
|
||||
check "pkgsrc changed: says so" grep -q 'pkgsrc changed' "$S/out"
|
||||
|
||||
# 4: configure.ac changed
|
||||
setup
|
||||
echo 'AC_INIT([t])' > "$S/b/t-1.0/configure.ac"
|
||||
pack
|
||||
check "configure.ac: exit 0" run
|
||||
check "configure.ac: configure cookie gone" test ! -f "$WD/work.T/.configure_done"
|
||||
|
||||
# 5: nothing changed
|
||||
setup
|
||||
pack
|
||||
check "nothing: exit 0" run
|
||||
check "nothing: says so" grep -q 'nothing changed' "$S/out"
|
||||
|
||||
echo "result: $ok ok, $bad bad"
|
||||
[ "$bad" -eq 0 ]
|
||||
+44
-6
@@ -334,14 +334,52 @@ else
|
||||
pass "guide check broken man page falls red"
|
||||
fi
|
||||
|
||||
# --- ext-resync.sh: its own cases (tools/test-ext-resync.sh) -----------------
|
||||
if sh "$R/tools/test-ext-resync.sh" > "${TMPDIR:-/tmp}/test-ext-resync.out.$$" 2>&1; then
|
||||
pass "ext-resync cases"
|
||||
# --- ext-extract.sh -------------------------------------------------------
|
||||
# The copy in a pkgsrc work directory is refreshed from the source tree. The
|
||||
# point of the script is what a plain `cp -R' does not do: an unchanged file
|
||||
# keeps its time stamp (or make rebuilds all of MCDE), a changed one gets a new
|
||||
# one (or the build keeps an object file of the old source), and a file that
|
||||
# left the tree removes the copy (or the build compiles a file that is not in
|
||||
# the tree any more).
|
||||
XS="$TMP/xsrc"; XW="$TMP/xwork"
|
||||
mkdir -p "$XS/sub"
|
||||
printf 'a\n' > "$XS/a.c"; printf 'b\n' > "$XS/sub/b.c"; printf 'c\n' > "$XS/c.h"
|
||||
X="$R/tools/ext-extract.sh"
|
||||
if sh "$X" "$XS" "$XW/w" >/dev/null 2>&1 && [ -f "$XW/w/a.c" ] && [ -f "$XW/w/sub/b.c" ]; then
|
||||
pass "ext-extract fills a work directory"
|
||||
else
|
||||
cat "${TMPDIR:-/tmp}/test-ext-resync.out.$$" >&2
|
||||
bad "ext-resync cases" "see the BAD lines above"
|
||||
bad "ext-extract fills a work directory" "no copy below $XW/w"
|
||||
fi
|
||||
touch -d '2020-01-01 00:00' "$XW/w/a.c" "$XW/w/sub/b.c"
|
||||
printf 'a\n' > "$XS/a.c"
|
||||
sh "$X" "$XS" "$XW/w" >/dev/null 2>&1
|
||||
if [ "$(date -r "$XW/w/a.c" +%Y)" = 2020 ]; then
|
||||
pass "ext-extract keeps the time stamp of an unchanged file"
|
||||
else
|
||||
bad "ext-extract keeps the time stamp of an unchanged file" "a.c is $(date -r "$XW/w/a.c")"
|
||||
fi
|
||||
printf 'a2\n' > "$XS/a.c"
|
||||
sh "$X" "$XS" "$XW/w" >/dev/null 2>&1
|
||||
if [ "$(date -r "$XW/w/a.c" +%Y)" != 2020 ] && [ "$(cat "$XW/w/a.c")" = a2 ] &&
|
||||
[ "$(date -r "$XW/w/sub/b.c" +%Y)" = 2020 ]; then
|
||||
pass "ext-extract copies a changed file and leaves the rest"
|
||||
else
|
||||
bad "ext-extract copies a changed file and leaves the rest" "a.c=$(cat "$XW/w/a.c") b.c=$(date -r "$XW/w/sub/b.c")"
|
||||
fi
|
||||
printf 'd\n' > "$XS/d.c"
|
||||
sh "$X" "$XS" "$XW/w" >/dev/null 2>&1
|
||||
if [ -f "$XW/w/d.c" ]; then
|
||||
pass "ext-extract copies a new file"
|
||||
else
|
||||
bad "ext-extract copies a new file" "d.c is missing"
|
||||
fi
|
||||
rm "$XS/c.h"
|
||||
sh "$X" "$XS" "$XW/w" >/dev/null 2>&1
|
||||
if [ ! -f "$XW/w/c.h" ]; then
|
||||
pass "ext-extract drops a copy a file left"
|
||||
else
|
||||
bad "ext-extract drops a copy a file left" "c.h is still there"
|
||||
fi
|
||||
rm -f "${TMPDIR:-/tmp}/test-ext-resync.out.$$"
|
||||
|
||||
printf 'result: %s ok, %s bad\n' "$ok" "$fail"
|
||||
[ "$fail" -eq 0 ]
|
||||
+58
-41
@@ -216,24 +216,17 @@ ensure_pkgdb()
|
||||
"$TOP/build/pkg/sbin/pkg_admin" -K "$db" rebuild > /dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
# The forks of ext/ (ext/AGENTS.md) are not in pkgsrc: the archive of each, from
|
||||
# its last commit, goes into DISTDIR, the recipes into pkgsrc/ (MCDE and its
|
||||
# Motif are one archive, one tool). Only the forks the list names.
|
||||
# The forks of ext/ (ext/AGENTS.md) build from their own source tree, which is
|
||||
# in this repository and travels with the source set -- no archive is made and
|
||||
# none is fetched (the recipe's do-extract copies ext/src/<name> into WRKSRC).
|
||||
# Their recipes have to be visible inside pkgsrc, which is what ext-sync.sh
|
||||
# does: a mirror of symlinks to ext/src/<name>/pkgsrc.
|
||||
ext_prepare()
|
||||
{
|
||||
for d in "$TOP"/ext/src/*/pkgsrc; do
|
||||
[ -f "$d/Makefile" ] || continue
|
||||
n=$(basename "$(dirname "$d")")
|
||||
"$TOP/tools/pkglist.sh" built | grep -q "/$n\$" || continue
|
||||
if [ "$n" = mcde ]; then
|
||||
"$TOP/tools/mcde-dist.sh" || die "tools/mcde-dist.sh failed"
|
||||
else
|
||||
"$TOP/tools/ext-dist.sh" "$n" || die "tools/ext-dist.sh $n failed"
|
||||
fi
|
||||
done
|
||||
esout=$TOP/build/ext-sync.out
|
||||
"$TOP/tools/ext-sync.sh" > "$esout" || die "tools/ext-sync.sh failed"
|
||||
FORKS=$(sed 's/^ext-sync: //' "$esout")
|
||||
# the first field only: "<category>/<name> from <dir>"
|
||||
FORKS=$(sed -n 's/^ext-sync: \([^ ]*\) from .*/\1/p' "$esout")
|
||||
}
|
||||
|
||||
# The media's repository: the packages of kind "repo" and what they need at
|
||||
@@ -460,6 +453,24 @@ fetch_binaries()
|
||||
done
|
||||
}
|
||||
|
||||
# What the build of a fork is made from: the commit of its source tree, or --
|
||||
# for a recipe that builds from an archive (afpfs-ng) -- the hash of its
|
||||
# distinfo. A tree that is not a git checkout (a source set on a target)
|
||||
# contributes nothing, which keeps the key stable there.
|
||||
srcid_of()
|
||||
{
|
||||
case $1 in
|
||||
x11/mcde-motif) _s=$TOP/ext/src/mcde ;;
|
||||
*) _s=$TOP/ext/src/${1##*/} ;;
|
||||
esac
|
||||
if [ -e "$_s/.git" ]; then
|
||||
git -C "$_s" rev-parse HEAD 2>/dev/null
|
||||
git -C "$_s" status --porcelain 2>/dev/null
|
||||
elif [ -f "$TOP/pkgsrc/$1/distinfo" ]; then
|
||||
sha256_in < "$TOP/pkgsrc/$1/distinfo"
|
||||
fi
|
||||
}
|
||||
|
||||
# fork_reconfigure PKGPATH -- the recipe of a fork changed: run pkgsrc again
|
||||
# from `depends' on, but keep the extracted sources and the built objects.
|
||||
# `bmake clean' here meant hours of MCDE for a one-line recipe change
|
||||
@@ -475,7 +486,21 @@ fork_reconfigure()
|
||||
{
|
||||
w=$(ls -d "$TOP/build/pkgsrc-work/$1"/work.* 2>/dev/null | head -1)
|
||||
[ -n "$w" ] && [ -f "$w/.extract_done" ] || return 0
|
||||
echo "userland: $1: recipe changed, configuring again (objects kept)"
|
||||
# A commit in the fork changes the source, and do-extract runs only once
|
||||
# (its cookie): without dropping that cookie the work directory keeps the
|
||||
# copy of the commit it was extracted from, and the release ships a binary
|
||||
# that does not match the tree (measured 2026-11-23 for mcde). The
|
||||
# extract is cheap now -- tools/ext-extract.sh copies only the files that
|
||||
# differ and leaves the time stamps of the rest alone, so the object files
|
||||
# of everything else survive.
|
||||
if [ "$(srcid_of "$1")" != "$(cat "$TOP/build/pkgsrc-work/$1/.makronix-srcid" 2>/dev/null)" ]; then
|
||||
echo "userland: $1: source changed, extracting the copy again"
|
||||
rm -f "$w/.extract_done" "$w/.patch_done"
|
||||
mkdir -p "$TOP/build/pkgsrc-work/$1"
|
||||
srcid_of "$1" > "$TOP/build/pkgsrc-work/$1/.makronix-srcid"
|
||||
else
|
||||
echo "userland: $1: recipe changed, configuring again (objects kept)"
|
||||
fi
|
||||
rm -f "$w/.barrier_cookie" "$w/.depends_done" "$w/.depends" \
|
||||
"$w/.rdepends" "$w/.rrdepends" "$w/.tools_done" "$w/.wrapper_done" \
|
||||
"$w/.configure_done" "$w/.build_done" "$w/.install_done" \
|
||||
@@ -606,26 +631,27 @@ if [ $MODE = chroot ]; then
|
||||
done
|
||||
else
|
||||
for p in $("$TOP/tools/pkglist.sh" built); do
|
||||
# a fork of ext/ starts from a clean work directory when its recipe
|
||||
# changed -- otherwise pkgsrc keeps the old configure. A new archive
|
||||
# (distinfo) is not a reason: tools/ext-resync.sh puts only the files that
|
||||
# differ into the work directory, and make builds what depends on them
|
||||
# (a new archive used to mean a build from nothing: ten minutes of MCDE
|
||||
# for one changed file, build/logs/userland-2026-11-14p.log). The
|
||||
# PLIST is not part of the key either: it only needs the install again.
|
||||
forkclean=
|
||||
# A fork of ext/ builds from its source tree, which the do-extract step
|
||||
# copies into the work directory each build. When the recipe changed,
|
||||
# the work directory starts clean -- otherwise pkgsrc keeps the old
|
||||
# configure and the old Makefiles. There is no archive to resync any
|
||||
# more: no tool has to bring a work directory up to date with a commit.
|
||||
# The PLIST is not part of the key: it only needs the install again.
|
||||
case " $(echo $FORKS) " in
|
||||
*" $p "*)
|
||||
key=$(cd "$PKGSRC/$p" && find . -type f ! -name distinfo ! -name PLIST | sort | xargs cat | sha256_in)
|
||||
# The work directory holds a *copy* of the source tree, made when
|
||||
# pkgsrc extracted (do-extract: cp -R). A commit does not touch
|
||||
# the recipe, so the recipe key alone would keep the old copy and
|
||||
# the release would ship the binary of the last commit
|
||||
# (2026-11-23: mcde 288d1383 built from 2026-11-22). The
|
||||
# source commit is in the key for that reason.
|
||||
key=$(cd "$PKGSRC/$p" && find . -type f ! -name PLIST | sort | xargs cat | sha256_in)
|
||||
key="$key:$(srcid_of "$p" | sha256_in)"
|
||||
kf=$TOP/build/pkgsrc-work/$p/.makronix-recipe-key
|
||||
if [ "$(cat "$kf" 2>/dev/null)" != "$key" ]; then
|
||||
fork_reconfigure "$p"
|
||||
mkdir -p "${kf%/*}" && printf "%s\n" "$key" > "$kf"
|
||||
fi
|
||||
if ! "$TOP/tools/ext-resync.sh" resync "$p"; then
|
||||
(cd "$PKGSRC/$p" && "$BMAKE" clean) > /dev/null 2>&1 || true
|
||||
forkclean=yes
|
||||
fi
|
||||
# the PLIST changed: install and package again, nothing else
|
||||
pk=$TOP/build/pkgsrc-work/$p/.makronix-plist-key
|
||||
pkey=$(sha256_in < "$PKGSRC/$p/PLIST")
|
||||
@@ -655,11 +681,12 @@ for p in $("$TOP/tools/pkglist.sh" built); do
|
||||
fi
|
||||
if [ $MODE = cross ]; then
|
||||
pn=$(cd "$PKGSRC/$p" && "$BMAKE" show-var VARNAME=PKGNAME)
|
||||
archive=$(cd "$PKGSRC/$p" && "$BMAKE" show-var VARNAME=DISTDIR)/$(cd "$PKGSRC/$p" && "$BMAKE" show-var VARNAME=DISTFILES | awk '{print $1}')
|
||||
if [ -n "$pn" ] && "$TOP/build/pkg/sbin/pkg_info" \
|
||||
-K "$TOP/build/obj/destdir.$ARCH/usr/pkg/pkgdb" -e "$pn" > /dev/null 2>&1; then
|
||||
# idempotent: only reinstall when the recipe, archive or distinfo changed
|
||||
cand="$key:$(sha256_of "$archive" 2>/dev/null)"
|
||||
# idempotent: only reinstall when the recipe or the
|
||||
# source changed ($key carries both for a fork; a
|
||||
# fork has no archive to hash)
|
||||
cand="$key"
|
||||
if [ "$(cat "$TOP/build/pkgsrc-work/$p/.installed-key" 2>/dev/null)" != "$cand" ]; then
|
||||
"$TOP/build/pkg/sbin/pkg_delete" -f -P "$TOP/build/obj/destdir.$ARCH" \
|
||||
-K /usr/pkg/pkgdb "$pn" > "$TOP/build/logs/pkg-delete-$pn.log" 2>&1 ||
|
||||
@@ -679,18 +706,8 @@ for p in $("$TOP/tools/pkglist.sh" built); do
|
||||
target=install
|
||||
fi
|
||||
(cd "$PKGSRC/$p" && "$BMAKE" $target) || failed="$failed $p"
|
||||
# the archive this work directory was extracted from, for the next resync.
|
||||
# Kept also when the build failed: the work directory holds that archive
|
||||
# all the same, and without .pristine the next run had to `bmake clean'
|
||||
# and compile MCDE from nothing after every error (2026-11-17,
|
||||
# build/logs/userland-2026-11-17b..d.log).
|
||||
case " $(echo $FORKS) " in
|
||||
*" $p "*)
|
||||
w=$(ls -d "$TOP/build/pkgsrc-work/$p"/work.* 2>/dev/null | head -1)
|
||||
if [ -n "$w" ] && [ -f "$w/.extract_done" ] &&
|
||||
{ [ "$forkclean" = yes ] || [ ! -d "$TOP/build/pkgsrc-work/$p/.pristine" ]; }; then
|
||||
"$TOP/tools/ext-resync.sh" snapshot "$p" || true
|
||||
fi
|
||||
if [ -z "$failed" ] || [ "$failed" = "${failed% $p}" ]; then
|
||||
# remember this build as the installed version, so the next run skips pkg_delete
|
||||
[ -f "$TOP/build/pkgsrc-work/$p/.installed-candidate" ] && \
|
||||
|
||||
Reference in new issue
Block a user