Registering the makronix set's packages -- measured, and the options (t0056)
Read and measured 2026-11-14.  Sources: tools/makronix-set.sh:166-184 (why
pkgdb is not in the set), src/external/bsd/pkg_install/dist/lib/pkgdb.c:72-77
and :296-330 (where pkg_install looks), src/external/bsd/pkg_install/lib/
Makefile:27 (-DPREFIX=\"/usr/pkg\"), pkg_install.conf(5) (PKG_DBDIR), the
sysroot's database build/obj/destdir.amd64/usr/pkg/pkgdb, and
docs/UPDATING.md "Packages".  The decision (step 2 of the task) is Konrad's.

1. The problem, as it stands
   - The makronix set is the files under /usr/pkg of the sysroot; its
     registration database is left out (makronix-set.sh:170: "it is pkgsrc's
     registration database for the build, not part of the distribution").
     On an installed system pkg_info, pkg_add -u and pkg_admin audit therefore
     see none of CDE, vim, git ... (docs/UPDATING.md), and a package upgrade has
     nothing to hold on to.
   - A second effect the file itself names (:177): without the database "an
     installed system would reinstall x11-links and hit PLIST conflicts with
     leftover files from the set".

2. Measured: what a shipped database would be
   - build/obj/destdir.amd64/usr/pkg/pkgdb: 155 package entries, 1423 files,
     11 MB, 1.4 MB as tar + gzip -9 (without the index).
   - Where it has to be: pkg_install's default is DEF_LOG_DIR = PREFIX
     "/pkgdb" (pkgdb.c:73) and the tree builds it with PREFIX=/usr/pkg
     (lib/Makefile:27): /usr/pkg/pkgdb, the very path of the sysroot.  The old
     /var/db/pkg is only a fallback for systems that already have it
     (pkgdb.c:307-327).  So no relocation and no pkg_install.conf change; the
     entries would sit inside the makronix set where the packages are.
   - Usable: a copy of the directory, with the index removed and rebuilt by
     `pkg_admin -K DIR rebuild` (exit 0), lists 155 packages with pkg_info, and
     pkg_info -E finds vim-9.2.1202, mcde-0.1.0, mcde-motif-2.3.8,
     fuse-afpfs-ng-0.8.1nb5, flex-2.6.4.
   - The index file pkgdb.byfile.db (which package owns a file) must NOT be
     shipped: rebuilt on the build host it is 8192 bytes, because `rebuild`
     checks every recorded file under /usr/pkg and finds none there (36151
     lines "is in +CONTENTS but not on filesystem").  It is made on the target:
     one `pkg_admin rebuild` after the set is unpacked (the time it takes is
     not measured; it needs the installed system).
   - Defects of the entries today (they would be generated and fixed by the set
     tool):
     * vim-9.2.1202 records "@cwd build/obj/destdir.amd64/usr/pkg", relative and
       wrong; the other 308 @cwd lines say /usr/pkg.
     * 67 files carry the build host's home directory: 40 +BUILD_INFO (the
       CONFIGURE_ENV, CONFIGURE_ARGS and LDFLAGS records), 13 +INSTALL and 13
       +DEINSTALL (AWK= and PERL5= paths of the build), and the +CONTENTS of
       x11-links ("@comment Symlink:/home/lotherk/.../destdir.amd64/usr/X11R7/
       ...").  Mostly cosmetic, and the set should not carry the home directory
       of whoever built it.  In the scripts it can matter: 26 of them define
       AWK= or PERL5= with a build-host path, and 3 USE it beyond the
       definition (xmlcatmgr-2.2nb1, fontconfig-2.18.3 and mcde-0.1.0, all
       +INSTALL, 4 uses each) -- run again on a target, e.g. by reinstalling
       that package, they would call a program that is not there.  Unpacking the
       set does not run them; pkg_add of a package brings its own scripts.
     * x11-links is a build-only shadow tree whose files the set does not ship
       (makronix-set.sh:171-182): its entry has to stay out, so that a package
       depending on it installs it fresh on the target, as the note intends.

3. Options
   (a) Ship the entries in the set (path above), generated by makronix-set.sh
       from the sysroot: cwd fixed, host paths removed, x11-links left out,
       index rebuilt on the target.  checkflist: the pkgdb paths enter the list
       (today it ignores them); the list is generated, so that follows.  Gives
       pkg_info, pkg_admin audit and pkg_add -u at once, one set as before.
       Open: who runs `pkg_admin rebuild` and when (sysinst after the sets, or
       a first-boot rc script -- an rc.d script after rc.subr).
   (b) Not in the set: install the packages as binary packages from the
       medium's repository with pkg_add (packages.list kind repo; sysinst).
       Everything is registered the NetBSD way.  Needs a binary package of every
       one of the 155 entries (build/packages/All holds 128, the downloads in
       build/packages/amd64/All 264, and the cross-built set packages are
       installed, not packaged: userland.sh uses `install` for set, `package`
       for repo), and the install takes as long as pkg_add of 155 archives.
   (c) Not decided here: a split of the two.

4. What I would pick, as a reading and not a measurement: (a).  It keeps the
   one set and the one install path, uses the default database location, and
   the defects are in a generator that is already ours.  (b) changes how the
   whole system is installed and needs 155 packages to be built and carried.
   Not measured for either: pkg_add -u against a newer repository (it needs an
   installed system; the cross-built packages, e.g. mcde, are not in the NetBSD
   repository and would simply be left alone), the time of `pkg_admin rebuild`
   on the target, and the effect on the size of the DVD (1.4 MB compressed).
