aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2025-11-03 01:16:19 +0000
committerColin Percival <cperciva@FreeBSD.org>2025-11-03 21:40:17 +0000
commit6a13aeac3c1f98db7cf156f24a4d6bc8d3c321f6 (patch)
tree74de9858856b59d578f80afb1e122eb7c7a42dba
parentf2d966f6c13d93cccceb8e594a69d1a50471d314 (diff)
vmimage.subr: pkg autoremove after pkg install
A bug in pkg, which somehow only surfaced as a consequence of pkgbase, results in pkg install sometimes pulling in false dependencies. This problem might be limited to cases when the lib32 pkgbase packages are not installed. In the case of EC2 "small" images, installing the ebsnvme-id package results in binutils, gcc12-devel, gmp, indexinfo, liblz4, mpc, mpfr, and zstd packages being installed. These false dependencies are however not recorded as dependencies -- at some level pkg does understand that they're not needed -- so running pkg autoremove immediately after pkg install cleans them up. Note: This does not remove lines from METALOG corresponding to these packages, and makefs emits an error when it attempts to create the filesystem but cannot find the files listed in METALOG -- but makefs does seem to complete normally despite the error messages. This change should be reverted once the pkg issue has been located and fixed. Reviewed by: ivy MFC after: 3 days Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D53543
-rw-r--r--release/tools/vmimage.subr9
1 files changed, 9 insertions, 0 deletions
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index 3bfef585f613..8531e9b8f2d6 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -212,6 +212,13 @@ vm_extra_install_packages() {
-r ${DESTDIR} \
install -y -r ${PKG_REPO_NAME} $pkg
done
+ INSTALL_AS_USER=yes \
+ ${PKG_CMD} \
+ -o ABI=${PKG_ABI} \
+ -o REPOS_DIR=${PKG_REPOS_DIR} \
+ -o PKG_DBDIR=${DESTDIR}/var/db/pkg \
+ -r ${DESTDIR} \
+ autoremove
metalog_add_data ./var/db/pkg/local.sqlite
else
if [ -n "${WITHOUT_QEMU}" ]; then
@@ -224,6 +231,8 @@ vm_extra_install_packages() {
chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \
/usr/sbin/pkg install -y ${p}
done
+ chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \
+ /usr/sbin/pkg autoremove
fi
return 0