beinstall.sh: Use bectl instead of beadm by default

This patch also introduces an environment variable BE_UTILITY,
which can be used to specify the utility to use for managing
ZFS boot environments (which can be either bectl or beadm).

While here, fix some typos in the manual page and
remove beadm from section "SEE ALSO".

Reviewed by:	bcr, kevans, rpokala
Approved by:	will
Differential Revision:	https://reviews.freebsd.org/D21111
This commit is contained in:
Mateusz Piotrowski 2020-10-30 09:40:55 +00:00
parent 418b5444f8
commit eb7f380f12
2 changed files with 23 additions and 13 deletions

View File

@ -25,7 +25,7 @@
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.Dd April 18, 2020 .Dd October 30, 2020
.Dt BEINSTALL.SH 8 .Dt BEINSTALL.SH 8
.Os .Os
.Sh NAME .Sh NAME
@ -65,10 +65,8 @@ in a new boot environment.
.Nm .Nm
requires a fully built world and kernel. requires a fully built world and kernel.
It also requires It also requires
.Xr beadm 1
and
.Xr pkg 8 , .Xr pkg 8 ,
which are not present in the base system and have to be installed manually. which is not present in the base system and has to be installed manually.
.Pp .Pp
The The
.Ar options .Ar options
@ -82,6 +80,13 @@ as described in
User modifiable variables. User modifiable variables.
Set these in the environment if desired: Set these in the environment if desired:
.Bl -tag -width indent .Bl -tag -width indent
.It Ev BE_UTILITY Pq default: Dq Li "bectl"
Utility to manage ZFS boot environments.
This can be either
.Xr bectl 8
from the base system or
.Xr beadm 1
from ports (sysutils/beadm).
.It Ev CONFIG_UPDATER Pq default: Dq Li "etcupdate" .It Ev CONFIG_UPDATER Pq default: Dq Li "etcupdate"
Config updater: Config updater:
.Xr etcupdate 8 .Xr etcupdate 8
@ -110,9 +115,9 @@ Place where
lives in the src tree. lives in the src tree.
.El .El
.Sh SEE ALSO .Sh SEE ALSO
.Xr beadm 1 ,
.Xr build 7 , .Xr build 7 ,
.Xr development 7 , .Xr development 7 ,
.Xr bectl 8 ,
.Xr etcupdate 8 , .Xr etcupdate 8 ,
.Xr mergemaster 8 , .Xr mergemaster 8 ,
.Xr pkg 8 .Xr pkg 8

View File

@ -30,7 +30,7 @@
# Install a boot environment using the current FreeBSD source tree. # Install a boot environment using the current FreeBSD source tree.
# Requires a fully built world & kernel. # Requires a fully built world & kernel.
# #
# Non-base tools required: beadm, pkg # Non-base tools required: pkg
# #
# In a sandbox for the new boot environment, this script also runs etcupdate # In a sandbox for the new boot environment, this script also runs etcupdate
# and pkg upgrade automatically in the sandbox. Upon successful completion, # and pkg upgrade automatically in the sandbox. Upon successful completion,
@ -42,6 +42,8 @@
# beinstall [optional world/kernel flags e.g. KERNCONF] # beinstall [optional world/kernel flags e.g. KERNCONF]
# #
## User modifiable variables - set these in the environment if desired. ## User modifiable variables - set these in the environment if desired.
# Utility to manage ZFS boot environments.
BE_UTILITY="${BE_UTILITY:-"bectl"}"
# If not empty, 'pkg upgrade' will be skipped. # If not empty, 'pkg upgrade' will be skipped.
NO_PKG_UPGRADE="${NO_PKG_UPGRADE:-""}" NO_PKG_UPGRADE="${NO_PKG_UPGRADE:-""}"
# Config updater - 'etcupdate' and 'mergemaster' are supported. Set to an # Config updater - 'etcupdate' and 'mergemaster' are supported. Set to an
@ -96,7 +98,7 @@ cleanup_be() {
if [ -n "${created_be_dirs}" ]; then if [ -n "${created_be_dirs}" ]; then
chroot ${BE_MNTPT} /bin/rm -rf ${created_be_dirs} chroot ${BE_MNTPT} /bin/rm -rf ${created_be_dirs}
fi fi
beadm destroy -F ${BENAME} ${BE_UTILITY} destroy -F ${BENAME}
} }
create_be_dirs() { create_be_dirs() {
@ -150,8 +152,8 @@ postmortem() {
unmount_be unmount_be
rmdir_be rmdir_be
echo "Post-mortem cleanup complete." echo "Post-mortem cleanup complete."
echo "To destroy the BE (recommended), run: beadm destroy ${BENAME}" echo "To destroy the BE (recommended), run: ${BE_UTILITY} destroy ${BENAME}"
echo "To instead continue with the BE, run: beadm activate ${BENAME}" echo "To instead continue with the BE, run: ${BE_UTILITY} activate ${BENAME}"
} }
if [ -n "$BEINSTALL_CMD" ]; then if [ -n "$BEINSTALL_CMD" ]; then
@ -159,6 +161,9 @@ if [ -n "$BEINSTALL_CMD" ]; then
exit $? exit $?
fi fi
if [ "$(basename -- "${BE_UTILITY}")" = "bectl" ]; then
${BE_UTILITY} check || errx "${BE_UTILITY} sanity check failed"
fi
cleanup_commands="" cleanup_commands=""
trap 'errx "Interrupt caught"' HUP INT TERM trap 'errx "Interrupt caught"' HUP INT TERM
@ -205,10 +210,10 @@ BE_MNTPT=${BE_TMP}/mnt
BE_MM_ROOT=${BE_TMP}/mergemaster # mergemaster will create BE_MM_ROOT=${BE_TMP}/mergemaster # mergemaster will create
mkdir -p ${BE_MNTPT} mkdir -p ${BE_MNTPT}
beadm create ${BENAME} >/dev/null || errx "Unable to create BE ${BENAME}" ${BE_UTILITY} create ${BENAME} >/dev/null || errx "Unable to create BE ${BENAME}"
[ -z "$NO_CLEANUP_BE" ] && cleanup_commands="cleanup_be ${cleanup_commands}" [ -z "$NO_CLEANUP_BE" ] && cleanup_commands="cleanup_be ${cleanup_commands}"
beadm mount ${BENAME} ${BE_TMP}/mnt || errx "Unable to mount BE ${BENAME}." ${BE_UTILITY} mount ${BENAME} ${BE_TMP}/mnt || errx "Unable to mount BE ${BENAME}."
echo "Mounted ${BENAME} to ${BE_MNTPT}, performing install/update ..." echo "Mounted ${BENAME} to ${BE_MNTPT}, performing install/update ..."
make "$@" DESTDIR=${BE_MNTPT} installkernel || errx "Installkernel failed!" make "$@" DESTDIR=${BE_MNTPT} installkernel || errx "Installkernel failed!"
@ -252,8 +257,8 @@ fi
unmount_be || errx "Unable to unmount BE" unmount_be || errx "Unable to unmount BE"
rmdir_be || errx "Unable to cleanup BE" rmdir_be || errx "Unable to cleanup BE"
beadm activate ${BENAME} || errx "Unable to activate BE" ${BE_UTILITY} activate ${BENAME} || errx "Unable to activate BE"
echo echo
beadm list ${BE_UTILITY} list
echo echo
echo "Boot environment ${BENAME} setup complete; reboot to use it." echo "Boot environment ${BENAME} setup complete; reboot to use it."