Page MenuHomeFreeBSD

freebsd-update: refuse to operate on a pkgbase system
ClosedPublic

Authored by emaste on Oct 30 2024, 5:43 PM.
Tags
None
Referenced Files
F104818828: D47341.diff
Mon, Dec 9, 11:20 PM
F104733364: D47341.diff
Mon, Dec 9, 5:18 AM
Unknown Object (File)
Sat, Dec 7, 9:56 AM
Unknown Object (File)
Wed, Dec 4, 2:30 PM
Unknown Object (File)
Wed, Dec 4, 9:40 AM
Unknown Object (File)
Mon, Nov 25, 1:29 AM
Unknown Object (File)
Sun, Nov 24, 9:33 PM
Unknown Object (File)
Sun, Nov 24, 1:40 AM

Details

Summary

FreeBSD-update is not compatible with packaged base.

PR: 282252

NOTE: patch is currently an untested draft

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste created this revision.

Maybe it's OK to leave freebsd-update fetch and freebsd-update cron in place in a pkgbase context?

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

Does -c do the right thing here, to use the the pkg database under $BASEDIR? freebsd-update sets BASEDIR for both -j and -b options.

This revision is now accepted and ready to land.Oct 30 2024, 6:09 PM
usr.sbin/freebsd-update/freebsd-update.sh
1105

Tried an ad-hoc test, populating enough of a directory tree that pkg info works, and -c is indeed sufficient.

In addition to /var/db/pkg contents we need /etc/pwd.db, /etc/pkg/FreeBSD.conf, /usr/bin/uname.

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

This won't quite work on CheriBSD since there the package prefix is CheriBSD, but I doubt that'll be much of an issue in practice.

It would be nice to have a better way to check for pkgbase systems though.

What happens if you run this on a system where pkg hasn't been bootstrapped?

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

/usr/sbin/pkg doesn't support -q and we get:

pkg: illegal option -- q
pkg: Invalid argument provided

We could check for $BASEDIR/var/db/pkg/local.sqlite and then for /usr/local/sbin/pkg and either of those don't exist assume we're not in a pkgbase config. That will still fail if pkg is not bootstrapped on the host but a jail is being managed by pkgbase.

try to handle the case where pkg isn't bootstrapped

This revision now requires review to proceed.Oct 30 2024, 7:58 PM

I think this is ok. We might want a chicken switch to allow the user to override this, but we can add it later.

This revision is now accepted and ready to land.Oct 30 2024, 8:02 PM

We could make the expression `pkg info -q -x '^FreeBSD|^CheriBSD'. Ideally though we'd have some way to detect pkgbase independent of the package names so that any other downstream derivative can use their own package name prefix.

We might want a chicken switch to allow the user to override this, but we can add it later.

Good point, something like an awkward env var could do the trick (FREEBSD_UPDATE_IGNORE_PKGBASE_CHECK). I anticipate there will be some iteration here, anyway. I anticipate this won't be MFC'd in the near future (if at all).

I don't particularly like what I've come up with, but hope to provide a few pragmatic safety belts to avoid unfortunate situations. There's work in progress on pkgbase support in the installer, and I hope that we can have a canonical script/tool to migrate to pkgbase as well. I'd like to encourage wider testing and want to have something in place before then.

emaste added a reviewer: cperciva.
emaste added a subscriber: cperciva.

Better comments, let @cperciva take a look

This revision now requires review to proceed.Oct 30 2024, 9:03 PM

Just a minor observation.

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

/var/db/pkg is the default PKG_DBDIR, which could have been overridden?

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

use pkg -N to check if pkg is boostrapped.

Upload the right diff this time

This revision is now accepted and ready to land.Oct 31 2024, 6:29 PM