Page MenuHomeFreeBSD

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

Authored by emaste on Wed, Oct 30, 5:43 PM.
Tags
None
Referenced Files
F102078037: D47341.diff
Thu, Nov 7, 8:39 AM
Unknown Object (File)
Mon, Nov 4, 7:19 PM
Unknown Object (File)
Sun, Nov 3, 10:55 PM
Unknown Object (File)
Wed, Oct 30, 5:56 PM

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.Wed, Oct 30, 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.Wed, Oct 30, 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.Wed, Oct 30, 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.Wed, Oct 30, 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.Thu, Oct 31, 6:29 PM