freebsd-dev/release/Makefile.vm
Glen Barber 1e7c1f1742 Initial rewrite to consolidate VM image build scripts into one.
There may be some very sharp edges here while refactoring.

 - Move amd64/mk-vmimage.sh -> scripts/mk-vmimage.sh.
 - Remove vm-base target from Makefile.vm.
 - In vm-image target, use getopts flags for argument passing.
 - Create tools/vmimage.subr, containing default and prototype
   for the following functions that are used to drive the build,
   run in this order:

   vm_install_base()
   vm_extra_install_base()
   vm_extra_install_packages()
   vm_extra_install_ports()
   vm_extra_enable_services()
   vm_extra_pre_umount()
   vm_create_disk()
   vm_extra_create_disk()

 - In tools/azure.conf, override:

   vm_extra_install_base()
   vm_extra_pre_umount()
   vm_extra_create_disk()

 - In tools/openstack.conf, override:

   vm_extra_install_base()
   vm_extra_pre_umount()

Sponsored by:	The FreeBSD Foundation
2014-11-05 13:22:19 +00:00

77 lines
2.0 KiB
Makefile

#
# $FreeBSD$
#
#
# Makefile for building virtual machine and cloud provider disk images.
#
VMTARGETS= vm-image
VMFORMATS?= vhd vmdk qcow2 raw
VMSIZE?= 20G
VMBASE?= vm
CLOUDWARE?= AZURE \
OPENSTACK
AZURE_FORMAT= vhdf
OPENSTACK_FORMAT=qcow2
.if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE)
. for _CW in ${CLOUDWARE}
CLOUDTARGETS+= vm-${_CW:tl}
CLEANDIRS+= vm-${_CW:tl}
CLEANFILES+= ${_CW:tl}.img \
${_CW:tl}.${${_CW:tu}_FORMAT} \
${_CW:tl}.${${_CW:tu}_FORMAT}.raw
${_CW:tu}IMAGE= ${_CW:tl}.${${_CW:tu}_FORMAT}
. if exists(${.CURDIR}/tools/${_CW:tl}.conf) && !defined(${_CW:tu}CONF)
${_CW:tu}CONF?= ${.CURDIR}/tools/${_CW:tl}.conf
. endif
. endfor
.endif
.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
CLEANDIRS+= ${VMTARGETS}
CLEANFILES+= ${VMBASE}.img
. for FORMAT in ${VMFORMATS}
CLEANFILES+= ${VMBASE}.${FORMAT}
. endfor
.endif
vm-base: vm-image
vm-image:
.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
. if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh)
. for FORMAT in ${VMFORMATS}
env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
${.CURDIR}/${TARGET}/mk-vmimage.sh \
-C ${.CURDIR}/tools/vmimage.subr -d ${.TARGET} \
-i ${VMBASE}.img -s ${VMSIZE} -f ${FORMAT} \
-S ${WORLDDIR} -o ${VMBASE}.${FORMAT}
. endfor
. endif
.endif
touch ${.TARGET}
vm-cloudware: ${CLOUDTARGETS}
vm-azure:
.if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh)
env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
${.CURDIR}/${TARGET}/mk-vmimage.sh \
-C ${.CURDIR}/tools/vmimage.subr -d ${.TARGET} \
-i azure.img -s ${VMSIZE} -f ${AZURE_FORMAT} \
-S ${WORLDDIR} -o ${AZUREIMAGE} -c ${AZURECONF}
.endif
touch ${.TARGET}
vm-openstack:
.if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh)
env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
${.CURDIR}/${TARGET}/mk-vmimage.sh \
-C ${.CURDIR}/tools/vmimage.subr -d ${.TARGET} \
-i openstack.img -s ${VMSIZE} -f ${OPENSTACK_FORMAT} \
-S ${WORLDDIR} -o ${OPENSTACKIMAGE} -c ${OPENSTACKCONF}
.endif
touch ${.TARGET}