git: e094f9015be1 - main - release/GCE: Remember whether we mounted /dev

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Thu, 19 Jun 2025 18:17:13 UTC
The branch main has been updated by cperciva:

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

commit e094f9015be16d07fe1c78c6eeaad73d1f8705ec
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2025-06-19 18:15:10 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-06-19 18:15:10 +0000

    release/GCE: Remember whether we mounted /dev
    
    Don't unmount /dev inside the image if we didn't mount it.  We might
    end up unmounting a /dev which is still needed.
    
    Fixes:  611c1457ff32 ("release: Add set -e to abort upon failure")
---
 release/tools/gce.conf | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/release/tools/gce.conf b/release/tools/gce.conf
index fc72b381a02d..382a839786f3 100644
--- a/release/tools/gce.conf
+++ b/release/tools/gce.conf
@@ -24,6 +24,8 @@ vm_extra_install_base() {
 }
 
 vm_extra_pre_umount() {
+	local DEVFSISOURS
+
 	# Enable growfs on every boot, not only the first, as as instance's disk can
 	# be enlarged post-creation
 	sed -i -e '/KEYWORD: firstboot/d' /etc/rc.d/growfs
@@ -93,6 +95,7 @@ EOF
 	# and fetch the sources for the third-party software installed on
 	# the image.
 	if [ ! -c "${DESTDIR}/dev/null" ]; then
+		DEVFSISOURS=1
 		mkdir -p ${DESTDIR}/dev
 		mount -t devfs devfs ${DESTDIR}/dev
 	fi
@@ -107,7 +110,7 @@ EOF
 				make -C /usr/ports/${PACKAGE} fetch
 		done
 	fi
-	if [ -c "${DESTDIR}/dev/null" ]; then
+	if [ "$DEVFSISOURS" = "1" ]; then
 		umount_loop ${DESTDIR}/dev
 	fi