vmimage.subr: Fix NO_ROOT build in ..._rmcache

When doing a NO_ROOT build we can't run pkg inside a chroot, for
multiple reasons including not having /dev mounted.

MFC after:	6 hours
Sponsored by:	https://www.patreon.com/cperciva
This commit is contained in:
Colin Percival committed 2025-10-02 18:06:44 -07:00
1 parent 5c5c0571c2
commit 86221f965c
1 file changed
+10 -3
+10 -3
View File
@@ -250,9 +250,16 @@ vm_emulation_cleanup() {
}
vm_extra_pkg_rmcache() {
if [ -e ${DESTDIR}/usr/local/sbin/pkg ]; then
chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \
/usr/local/sbin/pkg clean -y -a
if [ -n "${NO_ROOT}" ]; then
${PKG_CMD} \
-o ASSUME_ALWAYS_YES=yes \
-r ${DESTDIR} \
clean -y -a
else
if [ -e ${DESTDIR}/usr/local/sbin/pkg ]; then
chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \
/usr/local/sbin/pkg clean -y -a
fi
fi
return 0