From d35d04801ad288941a310d58f5e80628006a98cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20=C3=85ne=20de=20Jong?= Date: Sun, 29 May 2022 17:17:42 +0200 Subject: [PATCH] Run freebsd-update at first boot instead of build Since the image probably isn't going to be rebuild that often, it's better to update at first boot, even though that will take longer. --- .../freebsd-build-opennebula-image.sh | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/opennebula-images/freebsd-build-opennebula-image.sh b/opennebula-images/freebsd-build-opennebula-image.sh index 5161cbd..d94bb81 100755 --- a/opennebula-images/freebsd-build-opennebula-image.sh +++ b/opennebula-images/freebsd-build-opennebula-image.sh @@ -79,6 +79,11 @@ CLOUDSETUP_PKG="/usr/ports/sysutils/firstboot-cloudsetup/work/pkg/firstboot-clou tar -tzf "$CLOUDSETUP_PKG" >/dev/null # check that it's a valid tar, or we crash due to set -e # tar -t lists the contents of a tar file, but does not extract +make -C /usr/ports/sysutils/firstboot-freebsd-update clean package +FBUPDATE_VERSION="$(fgrep VERSION /usr/ports/sysutils/firstboot-freebsd-update/Makefile | cut -f2- | tr -d \\t)" +FBUPDATE_PKG="/usr/ports/sysutils/firstboot-freebsd-update/work/pkg/firstboot-freebsd-update-${FBUPDATE_VERSION}.pkg" +tar -tzf "$FBUPDATE_PKG" >/dev/null # check that it's a valid tar, or we crash due to set -e + ufsdisk="$(mktemp /var/tmp/ufsdisk.XXXXX)" truncate -s 6G "$ufsdisk" mdconfig -a -t vnode -f "$ufsdisk" -u md1 @@ -154,7 +159,7 @@ mount_nullfs /var/tmp "$UFSTARGET/var/tmp" # --automatic means that the package is considered to be installed "automatically", # aka as a dependency of something, so pkg autoremove will remove it. # We do not run pkg autoremove ourselves, that's up to the administrator. -pkg --rootdir "$UFSTARGET" add --automatic "$CLOUDSETUP_PKG" +pkg --rootdir "$UFSTARGET" add --automatic "$CLOUDSETUP_PKG" "$FBUPDATE_PKG" # Configure new system. touch "$UFSTARGET/firstboot" @@ -168,6 +173,7 @@ sysrc -f "$UFSTARGET/etc/rc.conf" \ growfs_enable=YES \ hostname=freebsd \ firstboot_cloudsetup_enable=YES \ + firstboot_freebsd_update_enable=YES \ # The resolv.conf file is written by firstboot_cloudsetup #cp /etc/resolv.conf "$UFSTARGET/etc/resolv.conf" @@ -180,17 +186,6 @@ PasswordAuthentication no PermitEmptyPasswords no EOF -# freebsd-update is only supported for RELEASE -if printf %s "$RELEASE" | grep -q '.-RELEASE$' -then - env PAGER=true /usr/sbin/freebsd-update \ - -b "$UFSTARGET" \ - --currently-running "$RELEASE" \ - --not-running-from-cron -F \ - fetch install -fi -rm -rf "$UFSTARGET/var/db/freebsd-update/"* ||: - # Set zstd-19 compression, copy all data to the pool, and then set compression to default again # This will make the base image smaller, at the cost of taking longer to generate, as zstd-19 is slow to write # Therefore, afterwards we restore compression to default, so written files stay zstd-19, which is fast to read,