Page MenuHomeFreeBSD

freebsd-update: Fix the pkgbase check
ClosedPublic

Authored by markj on Aug 6 2025, 8:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 10, 5:33 PM
Unknown Object (File)
Fri, Oct 10, 5:33 PM
Unknown Object (File)
Fri, Oct 10, 5:33 PM
Unknown Object (File)
Fri, Oct 10, 5:32 PM
Unknown Object (File)
Fri, Oct 10, 12:23 PM
Unknown Object (File)
Fri, Oct 3, 8:16 PM
Unknown Object (File)
Tue, Sep 30, 8:17 AM
Unknown Object (File)
Sat, Sep 27, 9:23 PM
Subscribers

Details

Summary

Even on a pkgbase system, it should be possible to use freebsd-update -j
to upgrade a non-pkgbase jail, at least for the team being. However,
the check_pkgbase() call came before get_params, so BASEDIR was 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).

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 66035
Build 62918: arc lint + arc unit

Event Timeline

markj requested review of this revision.Aug 6 2025, 8:40 PM
des added a subscriber: des.

lgtm modulo a couple of pre-existing issues

usr.sbin/freebsd-update/freebsd-update.sh
3614

pre-existing bug: $@ needs to be double-quoted.

3618

pre-existing bug: missing >&2

This revision is now accepted and ready to land.Aug 7 2025, 11:24 PM
markj added inline comments.
usr.sbin/freebsd-update/freebsd-update.sh
3618

freebsd-update is consistent about writing error messages to stdout for some reason (maybe it makes for easier debugging?), so I'd rather fix that separately.

markj marked an inline comment as done.

Quote $@

This revision now requires review to proceed.Aug 7 2025, 11:42 PM
This revision is now accepted and ready to land.Aug 8 2025, 12:54 AM
This revision was automatically updated to reflect the committed changes.