diff options
author | Colin Percival <cperciva@FreeBSD.org> | 2019-04-03 21:54:47 +0000 |
---|---|---|
committer | Colin Percival <cperciva@FreeBSD.org> | 2019-04-03 21:54:47 +0000 |
commit | 1ecaa3f75e21ab45f5e7849b4d2042c4645659da (patch) | |
tree | ea620cfcae31571663b38bde96777b821c96d317 /release/tools/vmimage.subr | |
parent | 5eb264119ee0ef81b933f62a1df271b5a4250b59 (diff) | |
download | src-1ecaa3f75e21ab45f5e7849b4d2042c4645659da.tar.gz src-1ecaa3f75e21ab45f5e7849b4d2042c4645659da.zip |
Add support for cross-building cloudware images.
If MACHINE_ARCH doesn't match TARGET_ARCH, and we're not in the special
case of building i386 images on an amd64 host, we need to pull in the
qemu-user-static package; this allows us to run some commands inside
the VM disk image chroot, most notably to install packages.
Reviewed by: gjb
MFC after: 2 weeks
Sponsored by: FreeBSD/EC2 patreon (https://www.patreon.com/cperciva)
Notes
Notes:
svn path=/head/; revision=345858
Diffstat (limited to 'release/tools/vmimage.subr')
-rw-r--r-- | release/tools/vmimage.subr | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr index 287c2741f156..ff3d69f5ba42 100644 --- a/release/tools/vmimage.subr +++ b/release/tools/vmimage.subr @@ -148,10 +148,15 @@ vm_install_base() { hostname="$(echo $(uname -o) | tr '[:upper:]' '[:lower:]')" echo "hostname=\"${hostname}\"" >> ${DESTDIR}/etc/rc.conf + if ! [ -z "${QEMUSTATIC}" ]; then + export EMULATOR=/qemu + cp ${QEMUSTATIC} ${DESTDIR}/${EMULATOR} + fi + mkdir -p ${DESTDIR}/dev mount -t devfs devfs ${DESTDIR}/dev - chroot ${DESTDIR} /usr/bin/newaliases - chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart + chroot ${DESTDIR} ${EMULATOR} /usr/bin/newaliases + chroot ${DESTDIR} ${EMULATOR} /bin/sh /etc/rc.d/ldconfig forcestart umount_loop ${DESTDIR}/dev cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf @@ -188,9 +193,9 @@ vm_extra_install_packages() { fi mkdir -p ${DESTDIR}/dev mount -t devfs devfs ${DESTDIR}/dev - chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ + chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg bootstrap -y - chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \ + chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES} umount_loop ${DESTDIR}/dev @@ -210,13 +215,16 @@ vm_extra_pre_umount() { # Note: When overriding this function, removing resolv.conf in the # disk image must be included. + if ! [ -z "${QEMUSTATIC}" ]; then + rm -f ${DESTDIR}/${EMULATOR} + fi 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 \ + chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ /usr/local/sbin/pkg clean -y -a fi |