mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-23 12:31:13 +01:00
32dbc82982
into the image and running 'pkg install' from there, use 'pkg fetch' to download packages into a temporary location and then 'pkg add' to install them into the image. This simplifies the code by avoiding the need to copy /etc/resolv.conf into the image and then delete it later, and makes it possible to cross build (e.g., to create an amd64 image when running on i386 hardware; or in the future for building disk images for embedded platforms). Because pkg was implicitly installed when VM_EXTRA_PACKAGES was non-empty, add it to VM_EXTRA_PACKAGES in azure.conf and openstack.conf to maintain the current behaviour. By default repo-FreeBSD.sqlite is copied into the image, (a) to match previous behaviour, where the file would be downloaded by the chrooted pkg invocation; and (b) because it may be useful for testing purposes, e.g., to see why a package didn't get installed. Because this file is large (46 MB) and not likely to be useful in -RELEASE images which are being launched into Clouds several months later, it can be disabled by setting NOREPOSQLITE. As far as I know this commit does not change the disk images produced in any filesystem-visible way.
51 lines
1.4 KiB
Bash
51 lines
1.4 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# Set to a list of packages to install.
|
|
# Example:
|
|
#export VM_EXTRA_PACKAGES="www/apache24 ports-mgmt/pkg"
|
|
export VM_EXTRA_PACKAGES=
|
|
|
|
# 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_install_base() {
|
|
fetch -o ${DESTDIR}/usr/sbin/waagent \
|
|
http://people.freebsd.org/~gjb/waagent
|
|
chmod +x ${DESTDIR}/usr/sbin/waagent
|
|
|
|
return 0
|
|
}
|
|
|
|
vm_extra_pre_umount() {
|
|
chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes /usr/sbin/pkg install -y \
|
|
python python2 python27 py27-asn1 sudo bash
|
|
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
|
|
|
|
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
|
|
}
|