release/azure: Don't use azure-agent deprovision to build image

Deprovision feature of waagent is used for preparing to capture a
running VM and turn it into a VM image.  Using it in the process of
building a VM image from scratch will cause some side effects such as
the hostname of the building host getting reset.

Remove calling the deprovision command and use a simpler way to fulfill
the requirements of the Azure VM image.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Li-Wen Hsu 2022-11-04 03:17:43 +08:00
parent 4dfd380e06
commit c711f3b453
No known key found for this signature in database
GPG Key ID: 82B261B14D3BC7AF

View File

@ -20,17 +20,19 @@ export NOSWAP=YES
export VM_BOOTPARTSOFFSET=1M export VM_BOOTPARTSOFFSET=1M
vm_extra_pre_umount() { vm_extra_pre_umount() {
mount -t devfs devfs ${DESTDIR}/dev
# The firstboot_pkgs rc.d script will download the repository # The firstboot_pkgs rc.d script will download the repository
# catalogue and install or update pkg when the instance first # catalogue and install or update pkg when the instance first
# launches, so these files would just be replaced anyway; removing # launches, so these files would just be replaced anyway; removing
# them from the image allows it to boot faster. # them from the image allows it to boot faster.
mount -t devfs devfs ${DESTDIR}/dev
chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \ chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \
/usr/sbin/pkg delete -f -y pkg /usr/sbin/pkg delete -f -y pkg
umount ${DESTDIR}/dev
rm ${DESTDIR}/var/db/pkg/repo-*.sqlite rm ${DESTDIR}/var/db/pkg/repo-*.sqlite
yes | chroot ${DESTDIR} ${EMULATOR} /usr/local/sbin/waagent -deprovision chroot ${DESTDIR} ${EMULATOR} pw usermod root -h -
umount ${DESTDIR}/dev
cat << EOF >> ${DESTDIR}/etc/rc.conf cat << EOF >> ${DESTDIR}/etc/rc.conf
ifconfig_hn0="SYNCDHCP" ifconfig_hn0="SYNCDHCP"