HomeFreeBSD

freebsd-update: Fix the pkgbase check

Description

freebsd-update: Fix the pkgbase check

Even on a pkgbase system, it should be possible to use freebsd-update -j
to upgrade a non-pkgbase jail, at least for the time being. However,
the check_pkgbase() call came before get_params, so BASEDIR was always
set to /.

Make check_pkgbase() a pure function and call it after get_params().
While here, use pkg -r ${BASEDIR} instead of pkg -c ${BASEDIR} since the
latter requires root privileges. freebsd-update is supposed to be run
as root, but it doesn't actually check this that I can see, so let's not
make that assumption here since it affects the result of the function
(i.e., pkg -c ${BASEDIR} always fails as a non-root user).

Reviewed by: des
Fixes: 856e158dc4aa ("freebsd-update: improve pkgbase check")
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D51770

(cherry picked from commit 66c75fa63aff40e9c587345b2cc6b8148e396de8)

Details

Provenance
markjAuthored on Aug 6 2025, 8:36 PM
emasteCommitted on Sep 8 2025, 1:13 PM
Reviewer
rG856e158dc4aa: freebsd-update: improve pkgbase check
Differential Revision
D51770: freebsd-update: Fix the pkgbase check
Parents
rGd779cb94daaa: libc/amd64: rewrite memrchr() baseline impl. to read the string from the back
Branches
Unknown
Tags
Unknown