svn commit: r281783 - head/release/tools

Glen Barber gjb at FreeBSD.org
Mon Apr 20 19:54:55 UTC 2015


Author: gjb
Date: Mon Apr 20 19:54:54 2015
New Revision: 281783
URL: https://svnweb.freebsd.org/changeset/base/281783

Log:
  When building VM disk images, vm_copy_base() uses tar(1) to
  copy the userland from one md(4)-mounted filesystem to a clean
  filesystem to prevent remnants of files that were added and
  removed from resulting in an unclean filesystem.  When newfs(8)
  creates the first filesystem with journaled soft-updates enabled,
  the /.sujournal file in the new filesystem cannot be overwritten
  by the /.sujournal in the original filesystem.
  
  To avoid this particular error case, do not enable journaled
  soft-updates when creating the md(4)-backed filesystems, and
  instead use tunefs(8) to enable journaled soft-updates after
  the new filesystem is populated in vm_copy_base().
  
  While here, fix a long standing bug where the build environment
  /boot files were used by mkimg(1) when creating the VM disk
  images by using the files in .OBJDIR.
  
  MFC after:	3 days
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/release/tools/vmimage.subr

Modified: head/release/tools/vmimage.subr
==============================================================================
--- head/release/tools/vmimage.subr	Mon Apr 20 19:11:27 2015	(r281782)
+++ head/release/tools/vmimage.subr	Mon Apr 20 19:54:54 2015	(r281783)
@@ -14,17 +14,24 @@ write_partition_layout() {
 		SWAPOPT="-p freebsd-swap/swapfs::1G"
 	fi
 
+	_OBJDIR="$(make -C ${WORLDDIR} -V .OBJDIR)"
+	if [ -d "${_OBJDIR%%/usr/src}/${TARGET}.${TARGET_ARCH}" ]; then
+		BOOTFILES="${_OBJDIR%%/usr/src}/${TARGET}.${TARGET_ARCH}/usr/src/sys/boot"
+	else
+		BOOTFILES="${_OBJDIR}/usr/src/sys/boot"
+	fi
+
 	case "${TARGET}:${TARGET_ARCH}" in
 		amd64:amd64 | i386:i386)
-			mkimg -s gpt -b /boot/pmbr \
-				-p freebsd-boot/bootfs:=/boot/gptboot \
+			mkimg -s gpt -b ${BOOTFILES}/i386/pmbr/pmbr \
+				-p freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot \
 				${SWAPOPT} \
 				-p freebsd-ufs/rootfs:=${VMBASE} \
 				-o ${VMIMAGE}
 			;;
 		powerpc:powerpc*)
 			mkimg -s apm \
-				-p apple-boot/bootfs:=/boot/boot1.hfs \
+				-p apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs \
 				${SWAPOPT} \
 				-p freebsd-ufs/rootfs:=${VMBASE} \
 				-o ${VMIMAGE}
@@ -63,7 +70,7 @@ vm_create_base() {
 	mkdir -p ${DESTDIR}
 	truncate -s ${VMSIZE} ${VMBASE}
 	mddev=$(mdconfig -f ${VMBASE})
-	newfs -j /dev/${mddev}
+	newfs /dev/${mddev}
 	mount /dev/${mddev} ${DESTDIR}
 
 	return 0
@@ -83,10 +90,10 @@ vm_copy_base() {
 	truncate -s ${VMSIZE} ${VMBASE}.tmp
 	mkdir -p ${DESTDIR}/new
 	mdnew=$(mdconfig -f ${VMBASE}.tmp)
-	newfs -j /dev/${mdnew}
+	newfs /dev/${mdnew}
 	mount /dev/${mdnew} ${DESTDIR}/new
 
-	tar -cf- -C ${DESTDIR}/old . | tar -xf- -C ${DESTDIR}/new
+	tar -cf- -C ${DESTDIR}/old . | tar -xUf- -C ${DESTDIR}/new
 
 	umount_loop /dev/${mdold}
 	rmdir ${DESTDIR}/old
@@ -94,6 +101,7 @@ vm_copy_base() {
 
 	umount_loop /dev/${mdnew}
 	rmdir ${DESTDIR}/new
+	tunefs -j enable /dev/${mdnew}
 	mdconfig -d -u ${mdnew}
 	mv ${VMBASE}.tmp ${VMBASE}
 }


More information about the svn-src-head mailing list