summaryrefslogtreecommitdiffstats
path: root/release
diff options
context:
space:
mode:
authorgjb <gjb@FreeBSD.org>2015-02-19 03:57:47 +0000
committergjb <gjb@FreeBSD.org>2015-02-19 03:57:47 +0000
commit92782b6e3ed54141f547007dd44013356d40b2cd (patch)
tree4d9dcbeb44c9fa48f5c47477143ddda072a6f44d /release
parent7f01a931aa846c504c5d11a349cabc28983bcf12 (diff)
downloadFreeBSD-src-92782b6e3ed54141f547007dd44013356d40b2cd.zip
FreeBSD-src-92782b6e3ed54141f547007dd44013356d40b2cd.tar.gz
MFC r277458, r277536, r277606, r277609, r277836, r277839,
r278118, r278119, r278206, r278502: r277458: Move virtual machine / cloud provider targets and options from release/Makefile to their own Makefile. Add glue to allow enabling building cloud provider VM images by default. Add a 'vm-cloudware' target, used to drive all targets in CLOUDTARGETS. Add examples for WITH_CLOUDWARE to release.conf.sample. Add WITH_CLOUDWARE evaluation to RELEASE_RMAKEFLAGS. Rewrite to consolidate VM image build scripts into one. Fix duplicated mkimg(1) call in vm_create_disk(). Add primitive (untested) PowerPC/PowerPC64 VM image support. Note: As it is currently written, the /boot/pmbr and /boot/{gptboot,boot1.hfs} use the build host and not the target build. Fixing this is likely going to be a hack in itself. mount(8) and umount(8) devfs(5) as needed. Change path for mk-vmimage.sh from ${TARGET}/ to scripts/ now that it is consolidated into one file. Fix paths for the base image and output disk image files. Set the boot partition type to 'apple-boot' for powerpc. In vm_install_base(), copy the host resolv.conf into the build chroot before attempting to do anything that requires working DNS (i.e., pkg bootstrap). In vm_extra_pre_umount(), remove the resolv.conf before the disk image is unmounted from the backing md(4). Silence errors when umounting the chroot's /dev, since it probably doesn't exist when we're running this. Unmount filesystems before attempting to destroy the md which holds them. Unmount filesystem and destroy md before we read the vnode from disk and package it into a disk image. Otherwise we end up packaging an unclean filesystem. Merge duplicative vm-CLOUDTYPE targets before additional duplication gets added by the impending arrival of ec2 and gcloud. Add NOSWAP option which can be set by a vmimage.conf file to specify that no swap space should be created in the image. This will be used by EC2 builds, since FreeBSD/EC2 allocates swap space on "ephemeral" disks which are physically attached to the Xen host node. In vm_extra_install_packages(), only bootstrap pkg(8) if VM_EXTRA_PACKAGES is empty. In vm_extra_pre_umount(), cleanup downloaded packages if pkg(8) was bootstrapped earlier. In vm_extra_install_base(), do not install waagent in the openstack image, because it is not used. This appears to be a copy mistake. Remove vm_extra_install_base() from the openstack.conf entirely, since it does not need to be overridden. Enable password-less sudo for openstack images. Update the VM_EXTRA_PACKAGES list for the openstack images. Remove vm_extra_install_base() for the Azure image, now that the waagent exists in the ports tree. Add sysutils/azure-agent to the VM_EXTRA_PACKAGES list. In vm_extra_pre_umount(), remove the explicit pkg(8) install list, as dependencies are resolved by sysutils/azure-agent. Add a 'list-cloudware' target to print the list of supported CLOUDWARE values and a description. Add the AZURE_DESC and OPENSTACK_DESC descriptions. Update release(7) Add 'list-vmtargets' target, which produces a list of all supported VM and cloud provider images. Add VHD_DESC, VMDK_DESC, QCOW2_DESC, RAW_DESC image descriptions. Update release(7) to document the list-vmtargets target. Add initial support for the GCE (Google Compute Engine) cloud hosting provider image. Remove the console setting from rc.conf(5), which is not used there. While here, set console to include vidconsole in the loader.conf(5). Remove the pkg-clean(8) call from vm_extra_pre_umount() since the function is often overridden. Add vm_extra_pkg_rmcache() to call pkg-clean(8) to avoid duplicated code. Move resolv.conf(5) removal back to vm_extra_pre_umount() where it belongs. The GCE image needs resolv.conf(5) to exist (created as part of the image setup), so it cannot be removed. Comment the line that configures ttys(5) to 'off', which makes it impossible to test that the image boots. Add a note explaining why the line is commented, and not (yet) removed entirely. Move the 'install' bits that are specific to virtual machine images from the Makefile to Makefile.vm. Rename the 'install' target to 'release-install', and add a new 'vm-install' target. Add a new 'install' target that invokes the new targets. Add WITH_CLOUDWARE to the list of make(1) variables for the release build. Remove hw.vga.textmode=1 from the VM image loader.conf, which was included during test builds and not intended to be included when merging this project branch back to head. Remove mk-azure.sh, which is no longer needed. r277536: Rename the 'release' target to 'real-release', and add two targets, 'vm-release' and 'cloudware-release', that are invoked if WITH_VMIMAGES and WITH_CLOUDWARE are not empty. This fixes an issue where 'make release' would not build the cloud provider targets because CLOUDWARE was not yet set. Move the WITH_VMIMAGES and WITH_CLOUDWARE targets to Makefile.vm. Note: There is no 'cloudware-install' target yet, since some of the disk image names may need to be specific to the provider, so this is probably best handled by the build scripts. r277606: Provide a recipe of "true" for building the "release" target once its prerequisites are satisfied, in order to avoid having an implicit rule triggered by the presence of release.sh. r277609: When iterating through VMFORMATS, the VMBASE file is not removed or truncated to a zero-size file, which if used to create more than one disk image format, can result in accidental pollution of the target formatted disk image. Instead of using a single VMBASE image (vm.img, by default), use a single base file for each format, named as VMFORMAT.img, which produces VMBASE.VMFORMAT as the final formatted image. r277836: Rename the 'system' target to 'disc1', which is specific to the disc1.iso installer image. Replace 'system' with 'release' in CLEANFILES, and add 'disc1' to CLEANDIRS. Ensure the 'dvd' target depends on 'packagesystem'. Fix 'mini-memstick.img' prerequisite, which should be the 'bootonly' target, not 'disc1' (previously 'system'). Use .TARGET as the target installation directory for the disc1.iso and bootonly.iso images, which now expand to 'disc1' and 'bootonly' respectively, mimicking the behavior of the 'dvd' target. Remove '@true' from the 'release' target, and instead use 'touch ${.TARGET}' to prevent multiple iterations of 'make release' from clobbering previously-built installer medium. r277839: Update release(7) to reflect renaming the 'system' target to 'disc1'. r278118: Move service_enable="YES" rc.conf(5) additions to VM_RC_LIST and deduplicate. Evaluate if firstboot_freebsd_update should be enabled based on UNAME_r, because it is not supported for the -CURRENT or -STABLE branches. r278119: Use ifconfig_DEFAULT="" instead of hard-coding vtnet(4) r278206: Bump copyright after r277458. r278502: In scripts/mk-vmimage.sh, prevent incorrect usage() by defaulting VMCONFIG to /dev/null, and additionally ensuring VMCONFIG is not a character device before it is sourced. While here, be sure to exit if usage() is called. This should effectively be no-op, but the usage() output was discovered while investigating a larger issue. * Several changes local to stable/10 were needed in order to handle UEFI images that are specific to this branch. Tested with: stable/10@r278906 Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'release')
-rw-r--r--release/Makefile156
-rw-r--r--release/Makefile.vm121
-rwxr-xr-xrelease/amd64/mk-azure.sh173
-rwxr-xr-xrelease/amd64/mk-vmimage.sh197
-rwxr-xr-xrelease/i386/mk-azure.sh173
-rwxr-xr-xrelease/i386/mk-vmimage.sh197
-rw-r--r--release/release.conf.sample8
-rwxr-xr-xrelease/release.sh9
-rwxr-xr-xrelease/scripts/mk-vmimage.sh111
-rw-r--r--release/tools/azure.conf30
-rw-r--r--release/tools/gce.conf100
-rw-r--r--release/tools/openstack.conf25
-rw-r--r--release/tools/vmimage.subr185
13 files changed, 634 insertions, 851 deletions
diff --git a/release/Makefile b/release/Makefile
index 6198b8e..f6afc1c 100644
--- a/release/Makefile
+++ b/release/Makefile
@@ -8,8 +8,13 @@
# memstick: Builds memory stick image (memstick.img)
# mini-memstick: Builds minimal memory stick image (mini-memstick.img)
# ftp: Sets up FTP distribution area (ftp)
-# release: Build all media and FTP distribution area
-# install: Copies all release media into ${DESTDIR}
+# release: Invokes real-release, vm-release, and cloudware-release targets
+# real-release: Build all media and FTP distribution area
+# vm-release: Build all virtual machine image targets
+# cloudware-release: Build all cloud hosting provider targets
+# install: Invokes the release-install and vm-install targets
+# release-install: Copies all release installation media into ${DESTDIR}
+# vm-install: Copies all virtual machine images into ${DESTDIR}
#
# Variables affecting the build process:
# WORLDDIR: location of src tree -- must have built world and default kernel
@@ -26,6 +31,7 @@
# WITH_VMIMAGES: if set, build virtual machine images with the release
# WITH_COMPRESSED_VMIMAGES: if set, compress virtual machine disk images
# with xz(1) (extremely time consuming)
+# WITH_CLOUDWARE: if set, build cloud hosting disk images with the release
# TARGET/TARGET_ARCH: architecture of built release
#
@@ -119,13 +125,7 @@ IMAGES+= uefi-dvd1.iso
. endif
.endif
-VMTARGETS= vm-base vm-image
-VMFORMATS?= vhd vmdk qcow2 raw
-VMSIZE?= 20G
-VMBASE?= vm
-AZURECONF?= ${.CURDIR}/tools/azure.conf
-
-CLEANFILES= packagesystem *.txz MANIFEST system ${IMAGES}
+CLEANFILES= packagesystem *.txz MANIFEST release ${IMAGES}
.if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
. for I in ${IMAGES}
CLEANFILES+= ${I}.xz
@@ -134,22 +134,7 @@ 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+= ${VMBASE}.${FORMAT}
-. endfor
-.endif
-CLEANDIRS= dist ftp release bootonly dvd
-.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
-CLEANDIRS+= ${VMTARGETS}
-.endif
-.if exists(${.CURDIR}/${TARGET}/mk-azure.sh)
-CLEANFILES+= ${OSRELEASE}.vhd \
- ${OSRELEASE}.vhd.raw \
- azure.img
-CLEANDIRS+= vm-azure
-.endif
+CLEANDIRS= dist ftp disc1 bootonly dvd
beforeclean:
chflags -R noschg .
.include <bsd.obj.mk>
@@ -196,50 +181,50 @@ reldoc:
.endfor
cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc
-system: packagesystem
+disc1: packagesystem
# Install system
- mkdir -p release
+ mkdir -p ${.TARGET}
cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
- DESTDIR=${.OBJDIR}/release WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1 \
+ DESTDIR=${.OBJDIR}/${.TARGET} WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1 \
WITHOUT_PROFILE=1 WITHOUT_SENDMAIL=1 WITHOUT_ATF=1 WITHOUT_LIB32=1
# Copy distfiles
- mkdir -p release/usr/freebsd-dist
- cp *.txz MANIFEST release/usr/freebsd-dist
+ mkdir -p ${.TARGET}/usr/freebsd-dist
+ cp *.txz MANIFEST ${.TARGET}/usr/freebsd-dist
# Copy documentation, if generated
.if !defined(NODOC)
- cp reldoc/* release
+ cp reldoc/* ${.TARGET}
.endif
# Set up installation environment
- ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf
- echo sendmail_enable=\"NONE\" > release/etc/rc.conf
- echo hostid_enable=\"NO\" >> release/etc/rc.conf
- cp ${.CURDIR}/rc.local release/etc
+ ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
+ echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
+ echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
+ cp ${.CURDIR}/rc.local ${.TARGET}/etc
touch ${.TARGET}
bootonly: packagesystem
# Install system
- mkdir -p bootonly
+ mkdir -p ${.TARGET}
cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
- DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \
+ DESTDIR=${.OBJDIR}/${.TARGET} WITHOUT_AMD=1 WITHOUT_AT=1 \
WITHOUT_GAMES=1 WITHOUT_GROFF=1 \
WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \
WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_PROFILE=1 \
WITHOUT_INSTALLIB=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1 \
WITHOUT_KERNEL_SYMBOLS=1
# Copy manifest only (no distfiles) to get checksums
- mkdir -p bootonly/usr/freebsd-dist
- cp MANIFEST bootonly/usr/freebsd-dist
+ mkdir -p ${.TARGET}/usr/freebsd-dist
+ cp MANIFEST ${.TARGET}/usr/freebsd-dist
# Copy documentation, if generated
.if !defined(NODOC)
- cp reldoc/* bootonly
+ cp reldoc/* ${.TARGET}
.endif
# Set up installation environment
- ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf
- echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf
- echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf
- cp ${.CURDIR}/rc.local bootonly/etc
+ ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
+ echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
+ echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
+ cp ${.CURDIR}/rc.local ${.TARGET}/etc
-dvd:
+dvd: packagesystem
# Install system
mkdir -p ${.TARGET}
cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
@@ -259,13 +244,13 @@ dvd:
touch ${.TARGET}
release.iso: disc1.iso
-disc1.iso: system
- sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} release
+disc1.iso: disc1
+ sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} disc1
-uefi-disc1.iso: system
+uefi-disc1.iso: disc1
.if exists(${.CURDIR}/${TARGET}/mkisoimages-uefi.sh)
sh ${.CURDIR}/${TARGET}/mkisoimages-uefi.sh -b ${VOLUME_LABEL}_UEFICD \
- ${.TARGET} release
+ ${.TARGET} disc1
.endif
uefi-bootonly.iso: bootonly
@@ -287,21 +272,21 @@ bootonly.iso: bootonly
sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ${.TARGET} bootonly
memstick: memstick.img
-memstick.img: system
- sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET}
+memstick.img: disc1
+ sh ${.CURDIR}/${TARGET}/make-memstick.sh disc1 ${.TARGET}
mini-memstick: mini-memstick.img
-mini-memstick.img: system
+mini-memstick.img: bootonly
sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET}
uefi-memstick: uefi-memstick.img
-uefi-memstick.img: system
+uefi-memstick.img: disc1
.if exists(${.CURDIR}/${TARGET}/make-uefi-memstick.sh)
- sh ${.CURDIR}/${TARGET}/make-uefi-memstick.sh release ${.TARGET}
+ sh ${.CURDIR}/${TARGET}/make-uefi-memstick.sh disc1 ${.TARGET}
.endif
uefi-mini-memstick: uefi-mini-memstick.img
-uefi-mini-memstick.img: system
+uefi-mini-memstick.img: bootonly
.if exists(${.CURDIR}/${TARGET}/make-uefi-memstick.sh)
sh ${.CURDIR}/${TARGET}/make-uefi-memstick.sh bootonly ${.TARGET}
.endif
@@ -327,14 +312,16 @@ ftp: packagesystem
mkdir -p ftp
cp *.txz MANIFEST ftp
-release:
+release: real-release vm-release cloudware-release
+ touch ${.TARGET}
+
+real-release:
${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS}
-.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
- ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${VMTARGETS}
-.endif
-install:
+install: release-install vm-install
+
+release-install:
.if defined(DESTDIR) && !empty(DESTDIR)
mkdir -p ${DESTDIR}
.endif
@@ -347,52 +334,5 @@ 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_VMIMAGES) && !empty(WITH_COMPRESSED_VMIMAGES)
-# 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)
-. if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh)
- env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
- ${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \
- ${VMBASE}.img ${WORLDDIR} ${.OBJDIR}/${.TARGET} ${VMSIZE}
-. endif
-.endif
- touch ${.TARGET}
-vm-image: vm-base
-.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 ${.TARGET} \
- ${VMBASE}.img ${FORMAT} ${VMBASE}.${FORMAT}
-. endfor
-. endif
-.endif
- touch ${.TARGET}
-
-vm-azure:
-.if exists(${.CURDIR}/${TARGET}/mk-azure.sh)
- env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} AZURECONF=${AZURECONF} \
- ${.CURDIR}/${TARGET}/mk-azure.sh ${.TARGET} azure.img \
- ${WORLDDIR} ${.TARGET} ${VMSIZE} ${OSRELEASE}.vhd
-.endif
- touch ${.TARGET}
+.include "${.CURDIR}/Makefile.vm"
diff --git a/release/Makefile.vm b/release/Makefile.vm
new file mode 100644
index 0000000..fe955d3
--- /dev/null
+++ b/release/Makefile.vm
@@ -0,0 +1,121 @@
+#
+# $FreeBSD$
+#
+#
+# Makefile for building virtual machine and cloud provider disk images.
+#
+
+VMTARGETS= vm-image
+VMFORMATS?= vhd vmdk qcow2 raw
+VMSIZE?= 20G
+VMBASE?= vm
+
+VHD_DESC= Azure, VirtualPC, Hyper-V, Xen disk image
+VMDK_DESC= VMWare, VirtualBox disk image
+QCOW2_DESC= Qemu, KVM disk image
+RAW_DESC= Unformatted raw disk image
+
+CLOUDWARE?= AZURE \
+ GCE \
+ OPENSTACK
+AZURE_FORMAT= vhdf
+AZURE_DESC= Microsoft Azure platform image
+GCE_FORMAT= raw
+GCE_DESC= Google Compute Engine image
+OPENSTACK_FORMAT=qcow2
+OPENSTACK_DESC= OpenStack platform image
+
+.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
+
+vm-${_CW:tl}:
+ mkdir -p ${.OBJDIR}/${.TARGET}
+ env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
+ ${.CURDIR}/scripts/mk-vmimage.sh \
+ -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} \
+ -i ${.OBJDIR}/${_CW:tl}.img -s ${VMSIZE} -f ${${_CW}_FORMAT} \
+ -S ${WORLDDIR} -o ${.OBJDIR}/${${_CW}IMAGE} -c ${${_CW}CONF}
+ touch ${.TARGET}
+. endfor
+.endif
+
+.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
+CLEANDIRS+= ${VMTARGETS}
+. for FORMAT in ${VMFORMATS}
+CLEANFILES+= ${FORMAT}.img
+CLEANFILES+= ${VMBASE}.${FORMAT}
+. endfor
+.endif
+
+vm-base: vm-image
+
+vm-image:
+.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
+. for FORMAT in ${VMFORMATS}
+ mkdir -p ${.OBJDIR}/${.TARGET}
+ env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
+ ${.CURDIR}/scripts/mk-vmimage.sh \
+ -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} \
+ -i ${.OBJDIR}/${FORMAT}.img -s ${VMSIZE} -f ${FORMAT} \
+ -S ${WORLDDIR} -o ${.OBJDIR}/${VMBASE}.${FORMAT}
+. endfor
+.endif
+ touch ${.TARGET}
+
+vm-cloudware: ${CLOUDTARGETS}
+
+list-vmtargets: list-cloudware
+ @${ECHO}
+ @${ECHO} "Supported virtual machine disk image formats:"
+.for FORMAT in ${VMFORMATS:tu}
+ @${ECHO} " ${FORMAT:tl}: ${${FORMAT}_DESC}"
+.endfor
+
+list-cloudware:
+.if !empty(CLOUDWARE)
+ @${ECHO}
+ @${ECHO} "Supported cloud hosting provider images:"
+. for _CW in ${CLOUDWARE}
+ @${ECHO} " ${_CW:tu}: ${${_CW:tu}_DESC}"
+. endfor
+.endif
+
+vm-install:
+.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_VMIMAGES) && !empty(WITH_COMPRESSED_VMIMAGES)
+# 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-release:
+.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
+ ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${VMTARGETS}
+.endif
+
+cloudware-release:
+.if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE)
+ ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${CLOUDTARGETS}
+.endif
diff --git a/release/amd64/mk-azure.sh b/release/amd64/mk-azure.sh
deleted file mode 100755
index 45b70ae..0000000
--- a/release/amd64/mk-azure.sh
+++ /dev/null
@@ -1,173 +0,0 @@
-#!/bin/sh
-#-
-# Copyright (c) 2014 The FreeBSD Foundation
-# All rights reserved.
-#
-# This software was developed by Glen Barber under sponsorship
-# from the FreeBSD Foundation.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# mk-azure.sh: Create virtual machine disk images for Microsoft Azure
-#
-# $FreeBSD$
-#
-
-export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin"
-
-usage() {
- echo "Usage:"
- echo -n "$(basename ${0}) vm-azure <base image>"
- echo " <source tree> <dest dir> <disk image size> <vm image name>"
- exit 1
-}
-
-panic() {
- msg="${@}"
- printf "${msg}\n"
- if [ ! -z "${mddev}" ]; then
- mdconfig -d -u ${mddev}
- fi
- # Do not allow one failure case to chain through any remaining image
- # builds.
- exit 0
-}
-
-vm_create_azure() {
- # Arguments:
- # vm-azure <base image> <source tree> <dest dir> <disk image size> <vm image name>
-
- VMBASE="${1}"
- WORLDDIR="${2}"
- DESTDIR="${3}"
- VMSIZE="${4}"
- VMIMAGE="${5}"
-
- if [ -z "${VMBASE}" -o -z "${WORLDDIR}" -o -z "${DESTDIR}" \
- -o -z "${VMSIZE}" -o -z "${VMIMAGE}" ]; then
- usage
- fi
-
- trap "umount ${DESTDIR}/dev ${DESTDIR}" INT QUIT TRAP ABRT TERM
-
- i=0
- mkdir -p ${DESTDIR}
- truncate -s ${VMSIZE} ${VMBASE}
- mddev=$(mdconfig -f ${VMBASE})
- newfs -j /dev/${mddev}
- mkdir -p ${DESTDIR}
- mount /dev/${mddev} ${DESTDIR}
- make -C ${WORLDDIR} DESTDIR=$(realpath ${DESTDIR}) \
- installworld installkernel distribution || \
- panic 1 "\n\nCannot install the base system to ${DESTDIR}."
- mount -t devfs devfs ${DESTDIR}/dev
- chroot ${DESTDIR} /usr/bin/newaliases
- echo '# Custom /etc/fstab for FreeBSD VM images' \
- > ${DESTDIR}/etc/fstab
- echo '/dev/gpt/rootfs / ufs rw 2 2' \
- >> ${DESTDIR}/etc/fstab
- # Although a swap partition is created, it is not used in Azure.
- echo '#/dev/gpt/swapfs none swap sw 0 0' \
- >> ${DESTDIR}/etc/fstab
-
- chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart
- chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg bootstrap -y
- chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg install -y \
- python python2 python27 py27-asn1 sudo bash
- if [ ! -z "${VM_EXTRA_PACKAGES}" ]; then
- chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg install -y \
- ${VM_EXTRA_PACKAGES}
- fi
-
- fetch -o ${DESTDIR}/usr/sbin/waagent \
- http://people.freebsd.org/~gjb/waagent
- chmod +x ${DESTDIR}/usr/sbin/waagent
- rm -f ${DESTDIR}/etc/resolv.conf
- chroot ${DESTDIR} /usr/sbin/waagent -verbose -install
- yes | chroot ${DESTDIR} /usr/sbin/waagent -deprovision
- echo 'sshd_enable="YES"' > ${DESTDIR}/etc/rc.conf
- echo 'ifconfig_hn0="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
- echo 'waagent_enable="YES"' >> ${DESTDIR}/etc/rc.conf
-
- echo 'console="comconsole vidconsole"' >> ${DESTDIR}/boot/loader.conf
- echo 'comconsole_speed="115200"' >> ${DESTDIR}/boot/loader.conf
-
- if [ ! -z "${VM_RC_LIST}" ]; then
- for _rcvar in ${VM_RC_LIST}; do
- echo ${_rcvar}_enable="YES" >> ${DESTDIR}/etc/rc.conf
- done
- fi
-
- sync
-
- while ! umount ${DESTDIR}/dev ${DESTDIR}; do
- i=$(( $i + 1 ))
- if [ $i -ge 10 ]; then
- # This should never happen. But, it has happened.
- msg="Cannot umount(8) ${DESTDIR}\n"
- msg="${msg}Something has gone horribly wrong."
- panic 1 "${msg}"
- fi
- sleep 1
- done
-
- echo "Creating image... Please wait."
-
- mkimg -f vhdf -s gpt \
- -b /boot/pmbr -p freebsd-boot/bootfs:=/boot/gptboot \
- -p freebsd-swap/swapfs::1G \
- -p freebsd-ufs/rootfs:=${VMBASE} \
- -o ${VMIMAGE}.raw
-
- if [ ! -x "/usr/local/bin/qemu-img" ]; then
- env ASSUME_ALWAYS_YES=yes pkg install -y emulators/qemu-devel
- fi
-
- size=$(qemu-img info -f raw --output json ${VMIMAGE}.raw | awk '/virtual-size/ {print $2}' | tr -d ',')
- size=$(( ( ${size} / ( 1024 * 1024 ) + 1 ) * ( 1024 * 1024 ) ))
- qemu-img resize ${VMIMAGE}.raw ${size}
- qemu-img convert -f raw -o subformat=fixed -O vpc ${VMIMAGE}.raw ${VMIMAGE}
-
- return 0
-}
-
-main() {
- cmd="${1}"
- shift 1
-
- if [ -e "${AZURECONF}" -a ! -c "${AZURECONF}" ]; then
- . ${AZURECONF}
- fi
-
- case ${cmd} in
- vm-azure)
- eval vm_create_azure "$@" || return 0
- ;;
- *|\?)
- usage
- ;;
- esac
-
- return 0
-}
-
-main "$@"
diff --git a/release/amd64/mk-vmimage.sh b/release/amd64/mk-vmimage.sh
deleted file mode 100755
index b3ffd23..0000000
--- a/release/amd64/mk-vmimage.sh
+++ /dev/null
@@ -1,197 +0,0 @@
-#!/bin/sh
-#-
-# Copyright (c) 2014 The FreeBSD Foundation
-# All rights reserved.
-#
-# This software was developed by Glen Barber under sponsorship
-# from the FreeBSD Foundation.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# mk-vmimage.sh: Create virtual machine disk images in various formats.
-#
-# $FreeBSD$
-#
-
-PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
-export PATH
-
-usage_vm_base() {
- echo -n "$(basename ${0}) vm-base <base image> <source tree>"
- echo " <dest dir> <disk image size>"
- return 0
-}
-
-usage_vm_image() {
- echo -n "$(basename ${0}) vm-image <base image> <image format>"
- echo " <output image>"
- return 0
-}
-
-usage() {
- echo "Usage:"
- echo "$(basename ${0}) [vm-base|vm-image] [...]"
- echo
- usage_vm_base
- echo
- usage_vm_image
- exit 1
-}
-
-panic() {
- msg="${@}"
- printf "${msg}\n"
- if [ ! -z "${mddev}" ]; then
- mdconfig -d -u ${mddev}
- fi
- case ${cmd} in
- vm-base)
- # If the vm-base target fails, the vm-image target
- # cannot possibly succeed. Touch the .TARGET file
- # so it is not attempted.
- touch vm-image
- ;;
- *)
- # FALLTHROUGH
- ;;
- esac
- # Do not allow one failure case to chain through any remaining image
- # builds.
- return 1
-}
-
-vm_create_baseimage() {
- # Creates the UFS root filesystem for the virtual machine disk,
- # written to the formatted disk image with mkimg(1).
- #
- # Arguments:
- # vm-base <base image> <source tree> <dest dir> <disk image size>
-
- VMBASE="${1}"
- WORLDDIR="${2}"
- DESTDIR="${3}"
- VMSIZE="${4}"
-
- if [ -z "${VMBASE}" -o -z "${WORLDDIR}" -o -z "${DESTDIR}" \
- -o -z "${VMSIZE}" ]; then
- usage
- fi
-
- i=0
- mkdir -p ${DESTDIR}
- truncate -s ${VMSIZE} ${VMBASE}
- mddev=$(mdconfig -f ${VMBASE})
- newfs -j /dev/${mddev}
- mount /dev/${mddev} ${DESTDIR}
- cd ${WORLDDIR} && \
- make DESTDIR=${DESTDIR} \
- installworld installkernel distribution || \
- panic "\n\nCannot install the base system to ${DESTDIR}."
- chroot ${DESTDIR} /usr/bin/newaliases
- echo '# Custom /etc/fstab for FreeBSD VM images' \
- > ${DESTDIR}/etc/fstab
- echo '/dev/gpt/rootfs / ufs rw 2 2' \
- >> ${DESTDIR}/etc/fstab
- echo '/dev/gpt/swapfs none swap sw 0 0' \
- >> ${DESTDIR}/etc/fstab
- sync
- while ! umount ${DESTDIR}; do
- i=$(( $i + 1 ))
- if [ $i -ge 10 ]; then
- # This should never happen. But, it has happened.
- msg="Cannot umount(8) ${DESTDIR}\n"
- msg="${msg}Something has gone horribly wrong."
- panic "${msg}"
- fi
- sleep 1
- done
-
- return 0
-}
-
-vm_create_vmdisk() {
- # Creates the virtual machine disk image from the raw disk image.
- #
- # Arguments:
- # vm-image <base image> <image format> <output image>"
-
- VMBASE="${1}"
- FORMAT="${2}"
- VMIMAGE="${3}"
-
- if [ -z "${VMBASE}" -o -z "${FORMAT}" -o -z "${VMIMAGE}" ]; then
- usage
- fi
-
- mkimg_version=$(mkimg --version 2>/dev/null | awk '{print $2}')
-
- # We need mkimg(1) '--version' output, at minimum, to be able to
- # tell what virtual machine disk image formats are available.
- # Bail if mkimg(1) reports an empty '--version' value.
- if [ -z "${mkimg_version}" ]; then
- msg="Cannot determine mkimg(1) version.\n"
- msg="${msg}Cannot continue without a known mkimg(1) version."
- panic "${msg}"
- fi
-
- if ! mkimg --formats 2>/dev/null | grep -q ${FORMAT}; then
- panic "'${FORMAT}' is not supported by this mkimg(1).\n"
- fi
-
- case ${FORMAT} in
- vhd)
- mkimg_format=vhdf
- ;;
- *)
- mkimg_format=${FORMAT}
- ;;
- esac
-
- mkimg -f ${mkimg_format} -s gpt \
- -b /boot/pmbr -p freebsd-boot/bootfs:=/boot/gptboot \
- -p freebsd-swap/swapfs::1G \
- -p freebsd-ufs/rootfs:=${VMBASE} \
- -o ${VMIMAGE}
-
- return 0
-}
-
-main() {
- cmd="${1}"
- shift 1
-
- case ${cmd} in
- vm-base)
- eval vm_create_baseimage "$@" || return 0
- ;;
- vm-image)
- eval vm_create_vmdisk "$@" || return 0
- ;;
- *|\?)
- usage
- ;;
- esac
-
- return 0
-}
-
-main "$@"
diff --git a/release/i386/mk-azure.sh b/release/i386/mk-azure.sh
deleted file mode 100755
index 45b70ae..0000000
--- a/release/i386/mk-azure.sh
+++ /dev/null
@@ -1,173 +0,0 @@
-#!/bin/sh
-#-
-# Copyright (c) 2014 The FreeBSD Foundation
-# All rights reserved.
-#
-# This software was developed by Glen Barber under sponsorship
-# from the FreeBSD Foundation.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# mk-azure.sh: Create virtual machine disk images for Microsoft Azure
-#
-# $FreeBSD$
-#
-
-export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin"
-
-usage() {
- echo "Usage:"
- echo -n "$(basename ${0}) vm-azure <base image>"
- echo " <source tree> <dest dir> <disk image size> <vm image name>"
- exit 1
-}
-
-panic() {
- msg="${@}"
- printf "${msg}\n"
- if [ ! -z "${mddev}" ]; then
- mdconfig -d -u ${mddev}
- fi
- # Do not allow one failure case to chain through any remaining image
- # builds.
- exit 0
-}
-
-vm_create_azure() {
- # Arguments:
- # vm-azure <base image> <source tree> <dest dir> <disk image size> <vm image name>
-
- VMBASE="${1}"
- WORLDDIR="${2}"
- DESTDIR="${3}"
- VMSIZE="${4}"
- VMIMAGE="${5}"
-
- if [ -z "${VMBASE}" -o -z "${WORLDDIR}" -o -z "${DESTDIR}" \
- -o -z "${VMSIZE}" -o -z "${VMIMAGE}" ]; then
- usage
- fi
-
- trap "umount ${DESTDIR}/dev ${DESTDIR}" INT QUIT TRAP ABRT TERM
-
- i=0
- mkdir -p ${DESTDIR}
- truncate -s ${VMSIZE} ${VMBASE}
- mddev=$(mdconfig -f ${VMBASE})
- newfs -j /dev/${mddev}
- mkdir -p ${DESTDIR}
- mount /dev/${mddev} ${DESTDIR}
- make -C ${WORLDDIR} DESTDIR=$(realpath ${DESTDIR}) \
- installworld installkernel distribution || \
- panic 1 "\n\nCannot install the base system to ${DESTDIR}."
- mount -t devfs devfs ${DESTDIR}/dev
- chroot ${DESTDIR} /usr/bin/newaliases
- echo '# Custom /etc/fstab for FreeBSD VM images' \
- > ${DESTDIR}/etc/fstab
- echo '/dev/gpt/rootfs / ufs rw 2 2' \
- >> ${DESTDIR}/etc/fstab
- # Although a swap partition is created, it is not used in Azure.
- echo '#/dev/gpt/swapfs none swap sw 0 0' \
- >> ${DESTDIR}/etc/fstab
-
- chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart
- chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg bootstrap -y
- chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg install -y \
- python python2 python27 py27-asn1 sudo bash
- if [ ! -z "${VM_EXTRA_PACKAGES}" ]; then
- chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg install -y \
- ${VM_EXTRA_PACKAGES}
- fi
-
- fetch -o ${DESTDIR}/usr/sbin/waagent \
- http://people.freebsd.org/~gjb/waagent
- chmod +x ${DESTDIR}/usr/sbin/waagent
- rm -f ${DESTDIR}/etc/resolv.conf
- chroot ${DESTDIR} /usr/sbin/waagent -verbose -install
- yes | chroot ${DESTDIR} /usr/sbin/waagent -deprovision
- echo 'sshd_enable="YES"' > ${DESTDIR}/etc/rc.conf
- echo 'ifconfig_hn0="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
- echo 'waagent_enable="YES"' >> ${DESTDIR}/etc/rc.conf
-
- echo 'console="comconsole vidconsole"' >> ${DESTDIR}/boot/loader.conf
- echo 'comconsole_speed="115200"' >> ${DESTDIR}/boot/loader.conf
-
- if [ ! -z "${VM_RC_LIST}" ]; then
- for _rcvar in ${VM_RC_LIST}; do
- echo ${_rcvar}_enable="YES" >> ${DESTDIR}/etc/rc.conf
- done
- fi
-
- sync
-
- while ! umount ${DESTDIR}/dev ${DESTDIR}; do
- i=$(( $i + 1 ))
- if [ $i -ge 10 ]; then
- # This should never happen. But, it has happened.
- msg="Cannot umount(8) ${DESTDIR}\n"
- msg="${msg}Something has gone horribly wrong."
- panic 1 "${msg}"
- fi
- sleep 1
- done
-
- echo "Creating image... Please wait."
-
- mkimg -f vhdf -s gpt \
- -b /boot/pmbr -p freebsd-boot/bootfs:=/boot/gptboot \
- -p freebsd-swap/swapfs::1G \
- -p freebsd-ufs/rootfs:=${VMBASE} \
- -o ${VMIMAGE}.raw
-
- if [ ! -x "/usr/local/bin/qemu-img" ]; then
- env ASSUME_ALWAYS_YES=yes pkg install -y emulators/qemu-devel
- fi
-
- size=$(qemu-img info -f raw --output json ${VMIMAGE}.raw | awk '/virtual-size/ {print $2}' | tr -d ',')
- size=$(( ( ${size} / ( 1024 * 1024 ) + 1 ) * ( 1024 * 1024 ) ))
- qemu-img resize ${VMIMAGE}.raw ${size}
- qemu-img convert -f raw -o subformat=fixed -O vpc ${VMIMAGE}.raw ${VMIMAGE}
-
- return 0
-}
-
-main() {
- cmd="${1}"
- shift 1
-
- if [ -e "${AZURECONF}" -a ! -c "${AZURECONF}" ]; then
- . ${AZURECONF}
- fi
-
- case ${cmd} in
- vm-azure)
- eval vm_create_azure "$@" || return 0
- ;;
- *|\?)
- usage
- ;;
- esac
-
- return 0
-}
-
-main "$@"
diff --git a/release/i386/mk-vmimage.sh b/release/i386/mk-vmimage.sh
deleted file mode 100755
index b3ffd23..0000000
--- a/release/i386/mk-vmimage.sh
+++ /dev/null
@@ -1,197 +0,0 @@
-#!/bin/sh
-#-
-# Copyright (c) 2014 The FreeBSD Foundation
-# All rights reserved.
-#
-# This software was developed by Glen Barber under sponsorship
-# from the FreeBSD Foundation.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# mk-vmimage.sh: Create virtual machine disk images in various formats.
-#
-# $FreeBSD$
-#
-
-PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
-export PATH
-
-usage_vm_base() {
- echo -n "$(basename ${0}) vm-base <base image> <source tree>"
- echo " <dest dir> <disk image size>"
- return 0
-}
-
-usage_vm_image() {
- echo -n "$(basename ${0}) vm-image <base image> <image format>"
- echo " <output image>"
- return 0
-}
-
-usage() {
- echo "Usage:"
- echo "$(basename ${0}) [vm-base|vm-image] [...]"
- echo
- usage_vm_base
- echo
- usage_vm_image
- exit 1
-}
-
-panic() {
- msg="${@}"
- printf "${msg}\n"
- if [ ! -z "${mddev}" ]; then
- mdconfig -d -u ${mddev}
- fi
- case ${cmd} in
- vm-base)
- # If the vm-base target fails, the vm-image target
- # cannot possibly succeed. Touch the .TARGET file
- # so it is not attempted.
- touch vm-image
- ;;
- *)
- # FALLTHROUGH
- ;;
- esac
- # Do not allow one failure case to chain through any remaining image
- # builds.
- return 1
-}
-
-vm_create_baseimage() {
- # Creates the UFS root filesystem for the virtual machine disk,
- # written to the formatted disk image with mkimg(1).
- #
- # Arguments:
- # vm-base <base image> <source tree> <dest dir> <disk image size>
-
- VMBASE="${1}"
- WORLDDIR="${2}"
- DESTDIR="${3}"
- VMSIZE="${4}"
-
- if [ -z "${VMBASE}" -o -z "${WORLDDIR}" -o -z "${DESTDIR}" \
- -o -z "${VMSIZE}" ]; then
- usage
- fi
-
- i=0
- mkdir -p ${DESTDIR}
- truncate -s ${VMSIZE} ${VMBASE}
- mddev=$(mdconfig -f ${VMBASE})
- newfs -j /dev/${mddev}
- mount /dev/${mddev} ${DESTDIR}
- cd ${WORLDDIR} && \
- make DESTDIR=${DESTDIR} \
- installworld installkernel distribution || \
- panic "\n\nCannot install the base system to ${DESTDIR}."
- chroot ${DESTDIR} /usr/bin/newaliases
- echo '# Custom /etc/fstab for FreeBSD VM images' \
- > ${DESTDIR}/etc/fstab
- echo '/dev/gpt/rootfs / ufs rw 2 2' \
- >> ${DESTDIR}/etc/fstab
- echo '/dev/gpt/swapfs none swap sw 0 0' \
- >> ${DESTDIR}/etc/fstab
- sync
- while ! umount ${DESTDIR}; do
- i=$(( $i + 1 ))
- if [ $i -ge 10 ]; then
- # This should never happen. But, it has happened.
- msg="Cannot umount(8) ${DESTDIR}\n"
- msg="${msg}Something has gone horribly wrong."
- panic "${msg}"
- fi
- sleep 1
- done
-
- return 0
-}
-
-vm_create_vmdisk() {
- # Creates the virtual machine disk image from the raw disk image.
- #
- # Arguments:
- # vm-image <base image> <image format> <output image>"
-
- VMBASE="${1}"
- FORMAT="${2}"
- VMIMAGE="${3}"
-
- if [ -z "${VMBASE}" -o -z "${FORMAT}" -o -z "${VMIMAGE}" ]; then
- usage
- fi
-
- mkimg_version=$(mkimg --version 2>/dev/null | awk '{print $2}')
-
- # We need mkimg(1) '--version' output, at minimum, to be able to
- # tell what virtual machine disk image formats are available.
- # Bail if mkimg(1) reports an empty '--version' value.
- if [ -z "${mkimg_version}" ]; then
- msg="Cannot determine mkimg(1) version.\n"
- msg="${msg}Cannot continue without a known mkimg(1) version."
- panic "${msg}"
- fi
-
- if ! mkimg --formats 2>/dev/null | grep -q ${FORMAT}; then
- panic "'${FORMAT}' is not supported by this mkimg(1).\n"
- fi
-
- case ${FORMAT} in
- vhd)
- mkimg_format=vhdf
- ;;
- *)
- mkimg_format=${FORMAT}
- ;;
- esac
-
- mkimg -f ${mkimg_format} -s gpt \
- -b /boot/pmbr -p freebsd-boot/bootfs:=/boot/gptboot \
- -p freebsd-swap/swapfs::1G \
- -p freebsd-ufs/rootfs:=${VMBASE} \
- -o ${VMIMAGE}
-
- return 0
-}
-
-main() {
- cmd="${1}"
- shift 1
-
- case ${cmd} in
- vm-base)
- eval vm_create_baseimage "$@" || return 0
- ;;
- vm-image)
- eval vm_create_vmdisk "$@" || return 0
- ;;
- *|\?)
- usage
- ;;
- esac
-
- return 0
-}
-
-main "$@"
diff --git a/release/release.conf.sample b/release/release.conf.sample
index 4e56244..9009e9d 100644
--- a/release/release.conf.sample
+++ b/release/release.conf.sample
@@ -93,3 +93,11 @@ PORTBRANCH="ports/head@rHEAD"
## image formats to create. Valid values are listed in the mkimg(1)
## manual page, as well as 'mkimg --formats' output.
#VMFORMATS="vhdf vmdk qcow2 raw"
+
+## Set to a non-empty value to build virtual machine images for various
+## cloud providers as part of the release build.
+#WITH_CLOUDWARE=
+
+## If WITH_CLOUDWARE is set to a non-empty value, this is a list of providers
+## to create disk images.
+#CLOUDWARE="AZURE OPENSTACK"
diff --git a/release/release.sh b/release/release.sh
index 56e9fff..8ef8f7b 100755
--- a/release/release.sh
+++ b/release/release.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#-
-# Copyright (c) 2013, 2014 The FreeBSD Foundation
+# Copyright (c) 2013-2015 The FreeBSD Foundation
# Copyright (c) 2013 Glen Barber
# Copyright (c) 2011 Nathan Whitehorn
# All rights reserved.
@@ -90,6 +90,10 @@ WITH_COMPRESSED_IMAGES=
WITH_VMIMAGES=
WITH_COMPRESSED_VMIMAGES=
+# Set to non-empty value to build virtual machine images for various
+# cloud providers as part of the release.
+WITH_CLOUDWARE=
+
usage() {
echo "Usage: $0 [-c release.conf]"
exit 1
@@ -173,7 +177,8 @@ CHROOT_DMAKEFLAGS="${CONF_FILES}"
RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} ${CONF_FILES}"
RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=\"${KERNEL}\" ${CONF_FILES} \
- ${DOCPORTS} WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES}"
+ ${DOCPORTS} WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \
+ WITH_CLOUDWARE=${WITH_CLOUDWARE}"
# Force src checkout if configured
FORCE_SRC_KEY=
diff --git a/release/scripts/mk-vmimage.sh b/release/scripts/mk-vmimage.sh
new file mode 100755
index 0000000..b5fb350
--- /dev/null
+++ b/release/scripts/mk-vmimage.sh
@@ -0,0 +1,111 @@
+#!/bin/sh
+#-
+# Copyright (c) 2014 The FreeBSD Foundation
+# All rights reserved.
+#
+# This software was developed by Glen Barber under sponsorship
+# from the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# mk-vmimage.sh: Create virtual machine disk images in various formats.
+#
+# $FreeBSD$
+#
+
+usage() {
+ echo "${0} usage:"
+ echo "${@}"
+ return 1
+}
+
+main() {
+ local arg
+ VMCONFIG="/dev/null"
+ while getopts "C:c:d:f:i:o:s:S:" arg; do
+ case "${arg}" in
+ C)
+ VMBUILDCONF="${OPTARG}"
+ ;;
+ c)
+ VMCONFIG="${OPTARG}"
+ ;;
+ d)
+ DESTDIR="${OPTARG}"
+ ;;
+ f)
+ VMFORMAT="${OPTARG}"
+ ;;
+ i)
+ VMBASE="${OPTARG}"
+ ;;
+ o)
+ VMIMAGE="${OPTARG}"
+ ;;
+ s)
+ VMSIZE="${OPTARG}"
+ ;;
+ S)
+ WORLDDIR="${OPTARG}"
+ ;;
+ *)
+ ;;
+ esac
+ done
+ shift $(( ${OPTIND} - 1))
+
+ if [ -z "${VMBASE}" -o \
+ -z "${WORLDDIR}" -o \
+ -z "${DESTDIR}" -o \
+ -z "${VMSIZE}" -o \
+ -z "${VMIMAGE}" ];
+ then
+ usage || exit 0
+ fi
+
+ if [ -z "${VMBUILDCONF}" ] || [ ! -e "${VMBUILDCONF}" ]; then
+ echo "Must provide the path to vmimage.subr."
+ return 1
+ fi
+
+ . "${VMBUILDCONF}"
+
+ if [ ! -z "${VMCONFIG}" ] && [ ! -c "${VMCONFIG}" ]; then
+ . "${VMCONFIG}"
+ fi
+
+ vm_create_base
+ vm_install_base
+ vm_extra_install_base
+ vm_extra_install_packages
+ vm_extra_install_ports
+ vm_extra_enable_services
+ vm_extra_pre_umount
+ vm_extra_pkg_rmcache
+ cleanup
+ vm_create_disk || return 0
+ vm_extra_create_disk
+
+ return 0
+}
+
+main "$@"
diff --git a/release/tools/azure.conf b/release/tools/azure.conf
index 8f16acc..922f8d9 100644
--- a/release/tools/azure.conf
+++ b/release/tools/azure.conf
@@ -6,9 +6,37 @@
# Set to a list of packages to install.
# Example:
#export VM_EXTRA_PACKAGES="www/apache24"
-export VM_EXTRA_PACKAGES=
+export VM_EXTRA_PACKAGES="sysutils/azure-agent"
# Set to a list of third-party software to enable in rc.conf(5).
# Example:
#export VM_RC_LIST="apache24"
export VM_RC_LIST=
+
+vm_extra_pre_umount() {
+ chroot ${DESTDIR} /usr/sbin/waagent -verbose -install
+ yes | chroot ${DESTDIR} /usr/sbin/waagent -deprovision
+ echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'ifconfig_hn0="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
+ echo 'waagent_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'console="comconsole vidconsole"' >> ${DESTDIR}/boot/loader.conf
+ echo 'comconsole_speed="115200"' >> ${DESTDIR}/boot/loader.conf
+
+ rm -f ${DESTDIR}/etc/resolv.conf
+
+ return 0
+}
+
+vm_extra_create_disk() {
+ if [ ! -x "/usr/local/bin/qemu-img" ]; then
+ env ASSUME_ALWAYS_YES=yes pkg install -y emulators/qemu-devel
+ fi
+
+ mv ${VMIMAGE} ${VMIMAGE}.raw
+ size=$(qemu-img info -f raw --output json ${VMIMAGE}.raw | awk '/virtual-size/ {print $2}' | tr -d ',')
+ size=$(( ( ${size} / ( 1024 * 1024 ) + 1 ) * ( 1024 * 1024 ) ))
+ qemu-img resize ${VMIMAGE}.raw ${size}
+ qemu-img convert -f raw -o subformat=fixed -O vpc ${VMIMAGE}.raw ${VMIMAGE}
+
+ return 0
+}
diff --git a/release/tools/gce.conf b/release/tools/gce.conf
new file mode 100644
index 0000000..c8af650
--- /dev/null
+++ b/release/tools/gce.conf
@@ -0,0 +1,100 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# Set to a list of packages to install.
+export VM_EXTRA_PACKAGES="firstboot-freebsd-update firstboot-pkgs \
+ google-cloud-sdk google-daemon panicmail sudo firstboot-growfs \
+ google-startup-scripts"
+
+# Set to a list of third-party software to enable in rc.conf(5).
+export VM_RC_LIST="google_accounts_manager ntpd sshd firstboot_growfs \
+ firstboot_pkgs google_startup"
+
+vm_extra_install_base() {
+ echo 'search google.internal' > ${DESTDIR}/etc/resolv.conf
+ echo 'nameserver 169.254.169.254' >> ${DESTDIR}/etc/resolv.conf
+ echo 'nameserver 8.8.8.8' >> ${DESTDIR}/etc/resolv.conf
+}
+
+vm_extra_pre_umount() {
+ cat << EOF >> ${DESTDIR}/etc/rc.conf
+dumpdev="AUTO"
+ifconfig_DEFAULT="SYNCDHCP mtu 1460"
+ntpd_sync_on_start="YES"
+case \$(uname -r) in
+ *-BETA*|*-RC*|*-RELEASE*)
+ firstboot_freebsd_update_enable="YES"
+ ;;
+ *)
+ ;;
+esac
+# need to fill in something here
+#firstboot_pkgs_list=""
+panicmail_autosubmit="YES"
+EOF
+
+ cat << EOF >> ${DESTDIR}/boot/loader.conf
+autoboot_delay="-1"
+beastie_disable="YES"
+loader_logo="none"
+hw.memtest.tests="0"
+console="comconsole,vidconsole"
+hw.vtnet.mq_disable=1
+kern.timecounter.hardware=ACPI-safe
+aesni_load="YES"
+nvme_load="YES"
+EOF
+
+ echo '169.254.169.254 metadata.google.internal metadata' > \
+ ${DESTDIR}/etc/hosts
+
+ # overwrite ntp.conf
+ cat << EOF > ${DESTDIR}/etc/ntp.conf
+server metadata.google.internal iburst
+
+restrict default kod nomodify notrap nopeer noquery
+restrict -6 default kod nomodify notrap nopeer noquery
+
+restrict 127.0.0.1
+restrict -6 ::1
+restrict 127.127.1.0
+EOF
+
+ cat << EOF >> ${DESTDIR}/etc/syslog.conf
+*.err;kern.warning;auth.notice;mail.crit /dev/console
+EOF
+
+ cat << EOF >> ${DESTDIR}/etc/ssh/sshd_config
+ChallengeResponseAuthentication no
+X11Forwarding no
+AcceptEnv LANG
+Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
+AllowAgentForwarding no
+ClientAliveInterval 420
+EOF
+
+ cat << EOF >> ${DESTDIR}/etc/crontab
+0 3 * * * root /usr/sbin/freebsd-update cron
+EOF
+
+ cat << EOF >> ${DESTDIR}/etc/sysctl.conf
+net.inet.icmp.drop_redirect=1
+net.inet.ip.redirect=0
+net.inet.tcp.blackhole=2
+net.inet.udp.blackhole=1
+kern.ipc.somaxconn=1024
+debug.trace_on_panic=1
+debug.debugger_on_panic=0
+EOF
+
+ ## XXX: Verify this is needed. I do not see this requirement
+ ## in the docs, and it impairs the ability to boot-test a copy
+ ## of the image prior to packaging for upload to GCE.
+ #sed -E -i '' 's/^([^#].*[[:space:]])on/\1off/' ${DESTDIR}/etc/ttys
+
+ touch ${DESTDIR}/firstboot
+
+ return 0
+}
diff --git a/release/tools/openstack.conf b/release/tools/openstack.conf
new file mode 100644
index 0000000..5d188bb
--- /dev/null
+++ b/release/tools/openstack.conf
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# Set to a list of packages to install.
+export VM_EXTRA_PACKAGES="net/cloud-init devel/py-pbr devel/py-iso8601 \
+ net/py-eventlet net/py-netaddr comms/py-serial devel/py-six \
+ devel/py-babel net/py-oauth net/py-netifaces"
+
+# Set to a list of third-party software to enable in rc.conf(5).
+export VM_RC_LIST="cloudinit"
+
+vm_extra_pre_umount() {
+ echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
+
+ # Openstack wants sudo(8) usable by default without a password.
+ echo 'ALL ALL=(ALL) NOPASSWD:ALL' >> \
+ ${DESTDIR}/usr/local/etc/sudoers.d/cloud-init
+
+ rm -f ${DESTDIR}/etc/resolv.conf
+
+ return 0
+}
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
new file mode 100644
index 0000000..6207440
--- /dev/null
+++ b/release/tools/vmimage.subr
@@ -0,0 +1,185 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+#
+# Common functions for virtual machine image build scripts.
+#
+
+export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
+trap "cleanup" INT QUIT TRAP ABRT TERM
+
+write_partition_layout() {
+ if [ -z "${NOSWAP}" ]; then
+ SWAPOPT="-p freebsd-swap/swapfs::1G"
+ fi
+
+ case "${TARGET}:${TARGET_ARCH}" in
+ amd64:amd64 | i386:i386)
+ mkimg -s gpt -b /boot/pmbr \
+ -p freebsd-boot/bootfs:=/boot/gptboot \
+ ${SWAPOPT} \
+ -p freebsd-ufs/rootfs:=${VMBASE} \
+ -o ${VMIMAGE}
+ ;;
+ powerpc:powerpc*)
+ mkimg -s apm \
+ -p apple-boot/bootfs:=/boot/boot1.hfs \
+ ${SWAPOPT} \
+ -p freebsd-ufs/rootfs:=${VMBASE} \
+ -o ${VMIMAGE}
+ ;;
+ *)
+ # ENOTSUPP
+ return 1
+ ;;
+ esac
+
+ return 0
+}
+
+err() {
+ printf "${@}\n"
+ cleanup
+ return 1
+}
+
+cleanup() {
+ umount ${DESTDIR}/dev 2>/dev/null
+ umount ${DESTDIR}
+ if [ ! -z "${mddev}" ]; then
+ mdconfig -d -u ${mddev}
+ fi
+
+ return 0
+}
+
+vm_create_base() {
+ # Creates the UFS root filesystem for the virtual machine disk,
+ # written to the formatted disk image with mkimg(1).
+
+ mkdir -p ${DESTDIR}
+ truncate -s ${VMSIZE} ${VMBASE}
+ mddev=$(mdconfig -f ${VMBASE})
+ newfs -j /dev/${mddev}
+ mount /dev/${mddev} ${DESTDIR}
+
+ return 0
+}
+
+vm_install_base() {
+ # Installs the FreeBSD userland/kernel to the virtual machine disk.
+
+ cd ${WORLDDIR} && \
+ make DESTDIR=${DESTDIR} \
+ installworld installkernel distribution || \
+ err "\n\nCannot install the base system to ${DESTDIR}."
+
+ echo '# Custom /etc/fstab for FreeBSD VM images' \
+ > ${DESTDIR}/etc/fstab
+ echo '/dev/gpt/rootfs / ufs rw 1 1' \
+ >> ${DESTDIR}/etc/fstab
+ if [ -z "${NOSWAP}" ]; then
+ echo '/dev/gpt/swapfs none swap sw 0 0' \
+ >> ${DESTDIR}/etc/fstab
+ fi
+
+ mkdir -p ${DESTDIR}/dev
+ mount -t devfs devfs ${DESTDIR}/dev
+ chroot ${DESTDIR} /usr/bin/newaliases
+ chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart
+ umount ${DESTDIR}/dev
+
+ cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf
+
+ return 0
+}
+
+vm_extra_install_base() {
+ # Prototype. When overridden, runs extra post-installworld commands
+ # as needed, based on the target virtual machine image or cloud
+ # provider image target.
+
+ return 0
+}
+
+vm_extra_enable_services() {
+ if [ ! -z "${VM_RC_LIST}" ]; then
+ for _rcvar in ${VM_RC_LIST}; do
+ echo ${_rcvar}_enable="YES" >> ${DESTDIR}/etc/rc.conf
+ done
+ fi
+
+ return 0
+}
+
+vm_extra_install_packages() {
+ if [ -z "${VM_EXTRA_PACKAGES}" ]; then
+ return 0
+ fi
+ mkdir -p ${DESTDIR}/dev
+ mount -t devfs devfs ${DESTDIR}/dev
+ chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \
+ /usr/sbin/pkg bootstrap -y
+ chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \
+ /usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES}
+ umount ${DESTDIR}/dev
+
+ return 0
+}
+
+vm_extra_install_ports() {
+ # Prototype. When overridden, installs additional ports within the
+ # virtual machine environment.
+
+ return 0
+}
+
+vm_extra_pre_umount() {
+ # Prototype. When overridden, installs additional ports within the
+ # virtual machine environment.
+
+ rm -f ${DESTDIR}/etc/resolv.conf
+ return 0
+}
+
+vm_extra_pkg_rmcache() {
+ if [ -e ${DESTDIR}/usr/local/sbin/pkg ]; then
+ chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \
+ /usr/local/sbin/pkg clean -y -a
+ fi
+
+ return 0
+}
+
+vm_umount_base() {
+ i=0
+ sync
+ while ! umount ${DESTDIR}/dev ${DESTDIR}; do
+ i=$(( $i + 1 ))
+ if [ $i -ge 10 ]; then
+ # This should never happen. But, it has happened.
+ msg="Cannot umount(8) ${DESTDIR}\n"
+ msg="${msg}Something has gone horribly wrong."
+ err "${msg}"
+ fi
+ sleep 1
+ done
+
+ return 0
+}
+
+vm_create_disk() {
+ echo "Creating image... Please wait."
+ echo
+
+ write_partition_layout || return 1
+
+ return 0
+}
+
+vm_extra_create_disk() {
+
+ return 0
+}
+
OpenPOWER on IntegriCloud