git: 856e158dc4aa - main - freebsd-update: improve pkgbase check
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 02 Nov 2024 19:24:44 UTC
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=856e158dc4aa5e43f0f15fcd3089fc0d71861b0e
commit 856e158dc4aa5e43f0f15fcd3089fc0d71861b0e
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-11-01 02:13:44 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-11-02 19:24:39 +0000
freebsd-update: improve pkgbase check
The previous version used a case-insensitive match (default for -x).
The presence of packages like freebsd-git-devtools and freebsd-ftpd
would falsely trigger the packaged base check.
Instead, just use `pkg which /usr/bin/uname` as a packaged base
indication. pkg uses /usr/bin/uname to determine ABI, so we can rely on
it existing. If it comes from a package then packaged base is in use.
Also, extend the check to all freebsd-update commands. It is easier to
just disallow all commands, and easier to test.
Reported by: Mark Millard
Reviewed by: manu
Fixes: cf1aba2857c1 ("freebsd-update: refuse to operate on a pkgbase system")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47378
---
usr.sbin/freebsd-update/freebsd-update.sh | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
index 80a8bf288251..ccd98a883dca 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -1107,12 +1107,13 @@ check_pkgbase()
if ! pkg -c ${BASEDIR} -N >/dev/null 2>/dev/null; then
return
fi
- # Presence of FreeBSD-* package(s) indicates packaged base.
- if ! pkg -c ${BASEDIR} info -q -x '^FreeBSD' 2>/dev/null; then
+ # uname(1) is used by pkg to determine ABI, so it should exist.
+ # If it comes from a package then this system uses packaged base.
+ if ! pkg -c ${BASEDIR} which /usr/bin/uname >/dev/null; then
return
fi
cat <<EOF
-FreeBSD-update is incompatible with the use of packaged base. Please see
+freebsd-update is incompatible with the use of packaged base. Please see
https://wiki.freebsd.org/PkgBase for more information.
EOF
exit 1
@@ -3536,7 +3537,6 @@ cmd_cron () {
# Fetch files for upgrading to a new release.
cmd_upgrade () {
- check_pkgbase
finalize_components_config ${COMPONENTS}
upgrade_check_params
upgrade_check_kmod_ports
@@ -3571,7 +3571,6 @@ cmd_updatesready () {
# Install downloaded updates.
cmd_install () {
- check_pkgbase
finalize_components_config ${COMPONENTS}
install_check_params
install_create_be
@@ -3580,7 +3579,6 @@ cmd_install () {
# Rollback most recently installed updates.
cmd_rollback () {
- check_pkgbase
finalize_components_config ${COMPONENTS}
rollback_check_params
rollback_run || exit 1
@@ -3617,6 +3615,9 @@ export LC_ALL=C
# Clear environment variables that may affect operation of tools that we use.
unset GREP_OPTIONS
+# Disallow use with packaged base.
+check_pkgbase
+
get_params $@
for COMMAND in ${COMMANDS}; do
cmd_${COMMAND}