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

From: Li-Wen Hsu <lwhsu_at_FreeBSD.org>
Date: Thu, 03 Nov 2022 19:18:43 UTC
The branch main has been updated by lwhsu:

URL: https://cgit.FreeBSD.org/src/commit/?id=c711f3b453703824c40bec1896d79ddcbd901781

commit c711f3b453703824c40bec1896d79ddcbd901781
Author:     Li-Wen Hsu <lwhsu@FreeBSD.org>
AuthorDate: 2022-11-03 19:17:43 +0000
Commit:     Li-Wen Hsu <lwhsu@FreeBSD.org>
CommitDate: 2022-11-03 19:17:43 +0000

    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
---
 release/tools/azure.conf | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/release/tools/azure.conf b/release/tools/azure.conf
index a9126ed8c389..dd43260201aa 100644
--- a/release/tools/azure.conf
+++ b/release/tools/azure.conf
@@ -20,17 +20,19 @@ export NOSWAP=YES
 export VM_BOOTPARTSOFFSET=1M
 
 vm_extra_pre_umount() {
+	mount -t devfs devfs ${DESTDIR}/dev
+
 	# The firstboot_pkgs rc.d script will download the repository
 	# 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.
-	mount -t devfs devfs ${DESTDIR}/dev
 	chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \
 		/usr/sbin/pkg delete -f -y pkg
-	umount ${DESTDIR}/dev
 	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
 ifconfig_hn0="SYNCDHCP"