diff options
Diffstat (limited to 'release/tools/vmimage.subr')
| -rw-r--r-- | release/tools/vmimage.subr | 61 | 
1 files changed, 46 insertions, 15 deletions
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index c3c917dcd642..8531e9b8f2d6 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -97,7 +97,7 @@ vm_install_base() {  	if [ -z "${NOPKGBASE}" ]; then  		local pkg_cmd -		pkg_cmd="pkg --rootdir ${DESTDIR} --repo-conf-dir ${PKGBASE_REPO_DIR} +		pkg_cmd="${PKG_CMD} --rootdir ${DESTDIR} --repo-conf-dir ${PKGBASE_REPO_DIR}  			-o ASSUME_ALWAYS_YES=yes -o IGNORE_OSVERSION=yes  			-o ABI=${PKG_ABI} -o INSTALL_AS_USER=yes "  		if [ -n "${NO_ROOT}" ]; then @@ -212,17 +212,14 @@ 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 - -		# Add some database files which are created by pkg triggers; -		# at some point in the future the tools which create these -		# files should probably learn how to record them in METALOG -		# (which would simplify no-root installworld as well). -		metalog_add_data ./etc/login.conf.db -		metalog_add_data ./etc/passwd -		metalog_add_data ./etc/pwd.db -		metalog_add_data ./etc/spwd.db 600 -		metalog_add_data ./var/db/services.db  	else  		if [ -n "${WITHOUT_QEMU}" ]; then  			return 0 @@ -234,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 @@ -290,10 +289,42 @@ buildfs() {  		cat ${DESTDIR}/METALOG.pkg >> ${DESTDIR}/METALOG  	fi -	# Sort METALOG file; makefs produces directories with 000 permissions -	# if their contents are seen before the directories themselves. -	env -i LC_COLLATE=C sort -u ${DESTDIR}/METALOG > ${DESTDIR}/METALOG.sorted -	mv ${DESTDIR}/METALOG.sorted ${DESTDIR}/METALOG +	if [ -n "${NO_ROOT}" ]; then +		# Check for any directories in the staging tree which weren't +		# recorded in METALOG, and record them now.  This is a quick hack +		# to avoid creating unusable VM images and should go away once +		# the bugs which produce such unlogged directories are gone. +		grep type=dir ${DESTDIR}/METALOG | +		    cut -f 1 -d ' ' | +		    sort -u > ${DESTDIR}/METALOG.dirs +		( cd ${DESTDIR} && find . -type d ) | +		    sort | +		    comm -23 - ${DESTDIR}/METALOG.dirs > ${DESTDIR}/METALOG.missingdirs +		if [ -s ${DESTDIR}/METALOG.missingdirs ]; then +			echo "WARNING: Directories exist but were not in METALOG" +			cat ${DESTDIR}/METALOG.missingdirs +		fi +		while read DIR; do +			metalog_add_data ${DIR} +		done < ${DESTDIR}/METALOG.missingdirs + +		if [ -z "${NOPKGBASE}" ]; then +			# Add some database files which are created by pkg triggers; +			# at some point in the future the tools which create these +			# files should probably learn how to record them in METALOG +			# (which would simplify no-root installworld as well). +			metalog_add_data ./etc/login.conf.db +			metalog_add_data ./etc/passwd +			metalog_add_data ./etc/pwd.db +			metalog_add_data ./etc/spwd.db 600 +			metalog_add_data ./var/db/services.db +		fi + +		# Sort METALOG file; makefs produces directories with 000 permissions +		# if their contents are seen before the directories themselves. +		env -i LC_COLLATE=C sort -u ${DESTDIR}/METALOG > ${DESTDIR}/METALOG.sorted +		mv ${DESTDIR}/METALOG.sorted ${DESTDIR}/METALOG +	fi  	case "${VMFS}" in  	ufs)  | 
