aboutsummaryrefslogtreecommitdiff
path: root/release/tools
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2019-04-03 21:54:47 +0000
committerColin Percival <cperciva@FreeBSD.org>2019-04-03 21:54:47 +0000
commit1ecaa3f75e21ab45f5e7849b4d2042c4645659da (patch)
treeea620cfcae31571663b38bde96777b821c96d317 /release/tools
parent5eb264119ee0ef81b933f62a1df271b5a4250b59 (diff)
downloadsrc-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')
-rw-r--r--release/tools/ec2.conf2
-rw-r--r--release/tools/vmimage.subr18
2 files changed, 14 insertions, 6 deletions
diff --git a/release/tools/ec2.conf b/release/tools/ec2.conf
index bf8eb723d1bd..d053ebb1a8e0 100644
--- a/release/tools/ec2.conf
+++ b/release/tools/ec2.conf
@@ -40,7 +40,7 @@ vm_extra_pre_umount() {
# catalogue and install or update pkg when the instance first
# launches, so these files would just be replaced anyway; removing
# them from the image allows it to boot faster.
- chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \
+ chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \
/usr/sbin/pkg delete -f -y pkg
rm ${DESTDIR}/var/db/pkg/repo-*.sqlite
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