Skip to content

Commit 6a13aea

Browse files
committed
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
1 parent f2d966f commit 6a13aea

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

release/tools/vmimage.subr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ vm_extra_install_packages() {
212212
-r ${DESTDIR} \
213213
install -y -r ${PKG_REPO_NAME} $pkg
214214
done
215+
INSTALL_AS_USER=yes \
216+
${PKG_CMD} \
217+
-o ABI=${PKG_ABI} \
218+
-o REPOS_DIR=${PKG_REPOS_DIR} \
219+
-o PKG_DBDIR=${DESTDIR}/var/db/pkg \
220+
-r ${DESTDIR} \
221+
autoremove
215222
metalog_add_data ./var/db/pkg/local.sqlite
216223
else
217224
if [ -n "${WITHOUT_QEMU}" ]; then
@@ -224,6 +231,8 @@ vm_extra_install_packages() {
224231
chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \
225232
/usr/sbin/pkg install -y ${p}
226233
done
234+
chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \
235+
/usr/sbin/pkg autoremove
227236
fi
228237

229238
return 0

0 commit comments

Comments
 (0)