aboutsummaryrefslogtreecommitdiff
path: root/release/Makefile
diff options
context:
space:
mode:
authorGlen Barber <gjb@FreeBSD.org>2014-09-28 01:45:20 +0000
committerGlen Barber <gjb@FreeBSD.org>2014-09-28 01:45:20 +0000
commita68d274b869a4f3698d4e2bfbcd2e5715500cc3c (patch)
treeabd96c09d4e6e6a9d83aaa0b8843cab4d278adce /release/Makefile
parent4b443922e0d44014207ebc72ef5a16081d0c4fef (diff)
downloadsrc-a68d274b869a4f3698d4e2bfbcd2e5715500cc3c.tar.gz
src-a68d274b869a4f3698d4e2bfbcd2e5715500cc3c.zip
Initial commit to include virtual machine images as part
of the FreeBSD release builds. This adds a make(1) environment variable requirement, WITH_VMIMAGES, which triggers the virtual machine image targets when not defined to an empty value. Relevant user-driven variables include: o VMFORMATS: The virtual machine image formats to create. Valid formats are provided by running 'mkimg --formats' o VMSIZE: The size of the resulting virtual machine image. Typical compression is roughly 140Mb, regardless of the target size (10GB, 15GB, 20GB, 40GB sizes have been tested with the same result). o VMBASE: The prefix of the virtual machine disk images. The VMBASE make(1) environment variable is suffixed with each format in VMFORMATS for each individual disk image, as well as '.img' for the source UFS filesystem passed to mkimg(1). This also includes a new script, mk-vmimage.sh, based on how the VM images for 10.0-RELEASE, 9.3-RELEASE, and 10.1-RELEASE were created (mk-vmimage.sh in ^/user/gjb/thermite/). With the order in which the stages need to occur, as well as sanity-checking error cases, it makes much more sense to execute a shell script called from make(1), using env(1) to set specific parameters for the target image than it does to do this in make(1) directly. Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/projects/release-vmimage/; revision=272234
Diffstat (limited to 'release/Makefile')
-rw-r--r--release/Makefile53
1 files changed, 53 insertions, 0 deletions
diff --git a/release/Makefile b/release/Makefile
index 6b4517dc4377..434a130ac390 100644
--- a/release/Makefile
+++ b/release/Makefile
@@ -23,6 +23,7 @@
# WITH_DVD: if set, generate dvd1.iso
# WITH_COMPRESSED_IMAGES: if set, compress installation images with xz(1)
# (uncompressed images are not removed)
+# WITH_VMIMAGES: if set, build virtual machine images with the release
# TARGET/TARGET_ARCH: architecture of built release
#
@@ -94,6 +95,11 @@ IMAGES+= memstick.img
IMAGES+= mini-memstick.img
.endif
+VMTARGETS= vm-base vm-image
+VMFORMATS?= vhd vmdk qcow2 raw
+VMSIZE?= 20G # size in Gb
+VMBASE?= vm # name of the filesystem image
+
CLEANFILES= packagesystem *.txz MANIFEST system ${IMAGES}
.if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
. for I in ${IMAGES}
@@ -103,7 +109,16 @@ CLEANFILES+= ${I}.xz
.if defined(WITH_DVD) && !empty(WITH_DVD)
CLEANFILES+= pkg-stage
.endif
+.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
+CLEANFILES+= ${VMBASE}.img
+. for FORMAT in ${VMFORMATS}
+CLEANFILES+= vm.${FORMAT}
+. endfor
+.endif
CLEANDIRS= dist ftp release bootonly dvd
+.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
+CLEANDIRS+= ${VMTARGETS}
+.endif
beforeclean:
chflags -R noschg .
.include <bsd.obj.mk>
@@ -277,3 +292,41 @@ install:
.endfor
cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256
cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5
+.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
+ mkdir -p ${DESTDIR}/vmimages
+. for FORMAT in ${VMFORMATS}
+ cp -p ${VMBASE}.${FORMAT} \
+ ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT}
+. endfor
+. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
+# This is very time consuming, so defer it after the images are moved to
+# the DESTDIR.
+. for FORMAT in ${VMFORMATS}
+ # Don't keep the originals. There is a copy in ${.OBJDIR} if needed.
+ ${XZCMD} ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT}
+. endfor
+. endif
+ cd ${DESTDIR}/vmimages && sha256 ${OSRELEASE}* > \
+ ${DESTDIR}/vmimages/CHECKSUM.SHA256
+ cd ${DESTDIR}/vmimages && md5 ${OSRELEASE}* > \
+ ${DESTDIR}/vmimages/CHECKSUM.MD5
+.endif
+
+vm-base:
+.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
+ env IMAKE=${IMAKE} WORLDDIR=${WORLDDIR} \
+ VMBASE=${VMBASE}.img VMSIZE=${VMSIZE} DESTDIR=${.TARGET} \
+ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
+ ${.CURDIR}/scripts/mk-vmimage.sh ${.TARGET}
+.endif
+ touch ${.TARGET}
+
+vm-image: vm-base
+.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
+. for FORMAT in ${VMFORMATS}
+ env FORMAT=${FORMAT} VMIMAGE=${VMBASE}.${FORMAT} VMBASE=${VMBASE}.img \
+ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
+ ${.CURDIR}/scripts/mk-vmimage.sh ${.TARGET}
+. endfor
+.endif
+ touch ${.TARGET}