FYI: pkgbase and pkg issue details that came up during my pkgbase system upgrade (main-amd64)

From: Mark Millard <marklmi_at_yahoo.com>
Date: Sun, 10 Aug 2025 05:07:08 UTC
These notes are very narrowly focused on specific things that
happened. I do not necessarily present them all in the order
that they occurred.

I made no use of "force". (I normally do not.)

The context has:

# grep BACKUP /usr/local/etc/pkg.conf
BACKUP_LIBRARIES=true


I first dealt with the kernel installations and the
reboot using the kernel.GENERIC-NODEBUG kernel. That
got me to:

# uname -apKU
FreeBSD 7950X3D-ZFS 15.0-PRERELEASE FreeBSD 15.0-PRERELEASE main-n279519-7a9834041c91 GENERIC-NODEBUG amd64 amd64 1500059 1500048

The sequence for that was, in part:

# pkg-static install -F -rFreeBSD-base -g 'FreeBSD-kernel-*' FreeBSD-src-sys
# pkg-static install -U -rFreeBSD-base -g 'FreeBSD-kernel-*' FreeBSD-src-sys
# shutdown -r now

(The context does not involve a FreeBSD-dtb .)


I then used what is likely an unusual sequence  for the
rest of the base package updating:

# pkg-static install -F -rFreeBSD-base -g 'FreeBSD-*'
# pkg-static install -U -rFreeBSD-base -g 'FreeBSD-src*'
# pkg-static install -U -rFreeBSD-base -g 'FreeBSD-*'

That last eventually stopped with:

[580/1170] Deleting files for pkcs11-helper-1.29.0_3: 100%
pkg-static: Cannot runscript POST-DEINSTALL:No such file or directory
pkg-static: Cannot delete pkg itself without force flag

At this point the context had the property:

pkg-static: Unable to determine the ABI, none of the ABI_FILEs can be read.

So I continued with (no use of 'env' as it was "not found"):

# ABI=FreeBSD:15:amd64 pkg-static install -U -rFreeBSD-base -g 'FreeBSD-*'


With that for context, my various notes are . . .


) pkg ended up disabled (but not removed) :

I naturally got the notice:

pkg-static: Cannot delete pkg itself without force flag

and it naturally stopped because of it.

But I unnaturally got the status (presuming I'm
supposed to be able to use pkg at that point):

# pkg check -sa
ld-elf.so.1: Shared object "libutil.so.9" not found, required by "pkg"

I had to use pkg-static explicitly (or explicitly cause it
to be used where it normally is not).

Note: poudriere-devel uses a mix of pkg-static and pkg and so
does not work in this context. I modified poudriere-devel for
it to be able to later do the likes of:

# poudriere jail -j  release-amd64 -u

(where release-amd64 is based on pkgbase).

Note: As of yet, an updated pkg that avoids libutil.so.9 was
not available from the distribution servers.

Note: pkg-static can try to run other programs. Thus it need
not be fully functional, despite its static status. I did not
explore this issue.


) port-package removals vs. POST-DEINSTALL :

I got 5 instances of:

pkg-static: Cannot runscript POST-DEINSTALL:No such file or directory

Specifically:

565/1170] Deinstalling coreutils-9.7...
[565/1170] Deleting files for coreutils-9.7: 100%
pkg-static: Cannot runscript POST-DEINSTALL:No such file or directory
. . .
[568/1170] Deinstalling git-2.50.0...
[568/1170] Deleting files for git-2.50.0: 100%
pkg-static: Cannot runscript POST-DEINSTALL:No such file or directory
. . .
[570/1170] Deinstalling llvm20-20.1.6...
[570/1170] Deleting files for llvm20-20.1.6: 100%
pkg-static: Cannot runscript POST-DEINSTALL:No such file or directory
. . .
[572/1170] Deinstalling openvpn-2.6.14...
[572/1170] Deleting files for openvpn-2.6.14: 100%
pkg-static: Cannot runscript POST-DEINSTALL:No such file or directory
. . .
[580/1170] Deinstalling pkcs11-helper-1.29.0_3...
[580/1170] Deleting files for pkcs11-helper-1.29.0_3: 100%
pkg-static: Cannot runscript POST-DEINSTALL:No such file or directory

It appeared to me that POST-DEINSTALL became unavailable
too early relative to when port-packages were being
deleted. (Wording not trying to determines what moves
where to get the proper order.)


) base-package upgrades vs. POST-INSTALL :

I got:

[402/513] Upgrading FreeBSD-caroot from 15.snap20250313075117 to 15.snap20250808125411...
[402/513] Extracting FreeBSD-caroot-15.snap20250808125411: 100%
pkg-static: Cannot runscript POST-INSTALL:No such file or directory

It appeared to me that POST-INSTALL became available
too late relative to when base-packages were being
upgraded that try to use POST-INSTALL . (Wording not
trying to determines what moves where to get the proper
order.)

This was from the command after pkg was not deleted:

# ABI=FreeBSD:15:amd64 pkg-static install -U -rFreeBSD-base -g 'FreeBSD-*'


Other information . . .

Note: I ignore here dealing with *.pkgsave and the like.

# shutdown -r now

got me to a world with system processes based on:

# uname -apKU
FreeBSD 7950X3D-ZFS 15.0-PRERELEASE FreeBSD 15.0-PRERELEASE main-n279519-7a9834041c91 GENERIC-NODEBUG amd64 amd64 1500059 

pkg still had the property:

ld-elf.so.1: Shared object "libutil.so.9" not found, required by "pkg"


To deal with port-packages, I used:

# pkg-static install -rFreeBSD    `cat ~/origins/amd64-pkgs.txt`
# pkg-static upgrade -rFreeBSD

(I'll ignore dealing with packages conflicts here.)

Note: main-amd64's distribution server for port-packages
was missing poudriere-devel so it was not listed in that
amd64-pkgs.txt file.

The poudiere-devel patches for avoiding pkg use and using
pkg-static instead are as shown by:

diff -ru /mnt/usr/local/share/poudriere/image.sh /usr/local/share/poudriere/image.sh
--- /mnt/usr/local/share/poudriere/image.sh	2025-06-13 18:13:29.000000000 -0700
+++ /usr/local/share/poudriere/image.sh	2025-08-09 20:19:24.112622000 -0700
@@ -230,8 +230,8 @@
 	export REPOS_DIR PKG_DBDIR
 	# Always need this from host.
 	export ABI_FILE="${WRKDIR}/world/usr/lib/crt1.o"
-	pkg -o ASSUME_ALWAYS_YES=yes update  >/dev/null || :
-	pkg rquery '%At %o@%Av %n-%v' | \
+	pkg-static -o ASSUME_ALWAYS_YES=yes update  >/dev/null || :
+	pkg-static rquery '%At %o@%Av %n-%v' | \
 	    awk -v pkglist="${PACKAGELIST}" \
 	    -f "${AWKPREFIX}/unique_pkgnames_from_flavored_origins.awk"
 	rm -rf "${PKG_DBDIR:?}" "${REPOS_DIR:?}"
@@ -248,10 +248,10 @@
                enabled: true
 	       }
 -EOF
-	pkg -o ABI_FILE="${mnt}/usr/lib/crt1.o" -o REPOS_DIR=${WRKDIR}/world/etc/pkg/ -o ASSUME_ALWAYS_YES=yes -r ${WRKDIR:?}/world update ${PKG_QUIET}
+	pkg-static -o ABI_FILE="${mnt}/usr/lib/crt1.o" -o REPOS_DIR=${WRKDIR}/world/etc/pkg/ -o ASSUME_ALWAYS_YES=yes -r ${WRKDIR:?}/world update ${PKG_QUIET}
 	msg "Installing base packages"
 	while read line; do
-		pkg -o ABI_FILE="${mnt}/usr/lib/crt1.o" -o REPOS_DIR=${WRKDIR}/world/etc/pkg/ -o ASSUME_ALWAYS_YES=yes -r ${WRKDIR:?}/world install -r local ${PKG_QUIET} -y ${line}
+		pkg-static -o ABI_FILE="${mnt}/usr/lib/crt1.o" -o REPOS_DIR=${WRKDIR}/world/etc/pkg/ -o ASSUME_ALWAYS_YES=yes -r ${WRKDIR:?}/world install -r local ${PKG_QUIET} -y ${line}
 	done < ${PKGBASELIST}
 	rm ${WRKDIR:?}/world/etc/pkg/FreeBSD-base.conf
 	msg "Base packages installed"
@@ -572,7 +572,7 @@
 			export ASSUME_ALWAYS_YES=yes SYSLOG=no \
 			    REPOS_DIR="${WRKDIR}/world/tmp/" \
 			    ABI_FILE="${WRKDIR}/world/usr/lib/crt1.o"
-			pkg -r "${WRKDIR:?}/world/" install pkg
+			pkg-static -r "${WRKDIR:?}/world/" install pkg
 			convert_package_list "${PACKAGELIST}" | \
 			    xargs pkg -r "${WRKDIR:?}/world/" install
 		)
diff -ru /mnt/usr/local/share/poudriere/include/pkg.sh /usr/local/share/poudriere/include/pkg.sh
--- /mnt/usr/local/share/poudriere/include/pkg.sh	2025-06-13 18:13:29.000000000 -0700
+++ /usr/local/share/poudriere/include/pkg.sh	2025-08-09 20:18:57.636494000 -0700
@@ -634,7 +634,7 @@
 		*)
 			local repokeypath=$(repo_key_path)
 
-			pkg key --sign -t "${repokeytype}" "${repokeypath}" < "${pkgfile}" \
+			pkg-static key --sign -t "${repokeytype}" "${repokeypath}" < "${pkgfile}" \
 			    > "${pkgfile}.pubkeysig"
 			;;
 		esac
diff -ru /mnt/usr/local/share/poudriere/jail.sh /usr/local/share/poudriere/jail.sh
--- /mnt/usr/local/share/poudriere/jail.sh	2025-06-13 18:13:29.000000000 -0700
+++ /usr/local/share/poudriere/jail.sh	2025-08-09 20:20:23.447656000 -0700
@@ -375,9 +375,9 @@
 	pkgbase)
 		VERSION=$(jget ${JAILNAME} version | cut -d '.' -f 1)
 		[ -z "${ARCH}" ] && ARCH=$(jget ${JAILNAME} arch)
-		pkg -o IGNORE_OSVERSION=yes -o ABI="FreeBSD:${VERSION}:${ARCH}" -o REPOS_DIR="${JAILMNT}/etc/pkg" -r "${JAILMNT}" update || \
+		pkg-static -o IGNORE_OSVERSION=yes -o ABI="FreeBSD:${VERSION}:${ARCH}" -o REPOS_DIR="${JAILMNT}/etc/pkg" -r "${JAILMNT}" update || \
 			err 1 "pkg update failed"
-		pkg -o IGNORE_OSVERSION=yes -o ABI="FreeBSD:${VERSION}:${ARCH}" -o REPOS_DIR="${JAILMNT}/etc/pkg" -r "${JAILMNT}" upgrade -y || \
+		pkg-static -o IGNORE_OSVERSION=yes -o ABI="FreeBSD:${VERSION}:${ARCH}" -o REPOS_DIR="${JAILMNT}/etc/pkg" -r "${JAILMNT}" upgrade -y || \
 			err 1 "pkg upgrade failed"
 		markfs clean ${JAILMNT}
 		;;
@@ -927,12 +927,12 @@
 }
 EOF
 
-	pkg -o IGNORE_OSVERSION=yes -o REPOS_DIR="${JAILMNT}/etc/pkg" -o ABI="FreeBSD:${VERSION}:${ARCH}" -r ${JAILMNT}/ update
+	pkg-static -o IGNORE_OSVERSION=yes -o REPOS_DIR="${JAILMNT}/etc/pkg" -o ABI="FreeBSD:${VERSION}:${ARCH}" -r ${JAILMNT}/ update
 	# Omit the man/debug/kernel/src and tests packages, unneeded for us.
-	pkg -o IGNORE_OSVERSION=yes -o REPOS_DIR="${JAILMNT}/etc/pkg" -o ABI="FreeBSD:${VERSION}:${ARCH}" -r ${JAILMNT}/ search -qCx '^FreeBSD-.*' | grep -vE -- '-man|-dbg|-kernel-|-tests|-src-' | xargs pkg -o REPOS_DIR="${JAILMNT}/etc/pkg" -r ${JAILMNT}/ install -y
-	pkg -o IGNORE_OSVERSION=yes -o REPOS_DIR="${JAILMNT}/etc/pkg" -o ABI="FreeBSD:${VERSION}:${ARCH}" -r ${JAILMNT}/ search -q '^FreeBSD-src-sys' | xargs pkg -o REPOS_DIR="${JAILMNT}/etc/pkg" -r ${JAILMNT}/ install -y
+	pkg-static -o IGNORE_OSVERSION=yes -o REPOS_DIR="${JAILMNT}/etc/pkg" -o ABI="FreeBSD:${VERSION}:${ARCH}" -r ${JAILMNT}/ search -qCx '^FreeBSD-.*' | grep -vE -- '-man|-dbg|-kernel-|-tests|-src-' | xargs pkg -o REPOS_DIR="${JAILMNT}/etc/pkg" -r ${JAILMNT}/ install -y
+	pkg-static -o IGNORE_OSVERSION=yes -o REPOS_DIR="${JAILMNT}/etc/pkg" -o ABI="FreeBSD:${VERSION}:${ARCH}" -r ${JAILMNT}/ search -q '^FreeBSD-src-sys' | xargs pkg -o REPOS_DIR="${JAILMNT}/etc/pkg" -r ${JAILMNT}/ install -y
 	if [ -n "${KERNEL}" ]; then
-		pkg -o IGNORE_OSVERSION=yes -o REPOS_DIR="${JAILMNT}/etc/pkg" -o ABI="FreeBSD:${VERSION}:${ARCH}" -r ${JAILMNT}/ install -y FreeBSD-kernel-"${KERNEL}" || \
+		pkg-static -o IGNORE_OSVERSION=yes -o REPOS_DIR="${JAILMNT}/etc/pkg" -o ABI="FreeBSD:${VERSION}:${ARCH}" -r ${JAILMNT}/ install -y FreeBSD-kernel-"${KERNEL}" || \
 			err 1 "Failed to install FreeBSD-kernel-${KERNEL}"
 	fi
 


Note: I have some other lines patched in
/usr/local/share/poudriere/common.sh for
other reasons (for my normal use).


===
Mark Millard
marklmi at yahoo.com