aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2022-02-12 21:36:24 +0000
committerKyle Evans <kevans@FreeBSD.org>2022-02-12 21:36:24 +0000
commite01e8f911b935eabcc35b4d121951e4e21042ee5 (patch)
treea9f35ab5af0e6df6cd1deec3423ce562f18d57fa
parent08c7dc7fd4735b85e9696d0439af6cc98b23b25d (diff)
downloadsrc-e01e8f911b935eabcc35b4d121951e4e21042ee5.tar.gz
src-e01e8f911b935eabcc35b4d121951e4e21042ee5.zip
freebsd-update: improve BE creation feature
This addresses one nit and one bug in the BE creation feature of freebsd-update: The nit addressed is that it currently only names the BEs after the userland version, but the kernel version may be higher. After this change, we request both and pass them through sort(1) to choose the highest. This is especially helpful if a freebsd-update patch touched one but not the other. The bug fixed is that roots updated that are not located at '/', e.g., by using -b or -j, will no longer create boot environments automatically. There's a very low chance these will actually change the BE in any meaningful way, anyways. It could make sense in the future to allow an argument-override to create the BE anyways if someone comes up with a non-standard setup, e.g., where a jail is an important part of their boot environment on an appliance or some such setup. Half of this patch is submitted by delphij@, the other half kevans@. PR: 261446 MFC after: 3 days Reviewed by: delphij, emaste, Dave Fullard <dave_fullard.ca> Differential Revision: https://reviews.freebsd.org/D34257
-rw-r--r--usr.sbin/freebsd-update/freebsd-update.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
index 1776115d0776..9743cd652d16 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -890,7 +890,12 @@ install_check_params () {
install_create_be () {
# Figure out if we're running in a jail and return if we are
if [ `sysctl -n security.jail.jailed` = 1 ]; then
- return 1
+ return 1
+ fi
+ # Operating on roots that aren't located at / will, more often than not,
+ # not touch the boot environment.
+ if [ "$BASEDIR" != "/" ]; then
+ return 1
fi
# Create a boot environment if enabled
if [ ${BOOTENV} = yes ]; then
@@ -911,7 +916,7 @@ install_create_be () {
esac
if [ ${CREATEBE} = yes ]; then
echo -n "Creating snapshot of existing boot environment... "
- VERSION=`freebsd-version -k`
+ VERSION=`freebsd-version -ku | sort -V | tail -n 1`
TIMESTAMP=`date +"%Y-%m-%d_%H%M%S"`
bectl create ${VERSION}_${TIMESTAMP}
if [ $? -eq 0 ]; then