freebsd-update sets the currently running release from UNAME -r, which can be overridden via the --currently-running commandline option (or by setting UNAME_r in the environment). This is not valid if -b is used to specify a basedir other than /, so error out if -b is specified without setting the currently running version. PR: 283229
Details
Diff Detail
- Lint
- Lint Skipped 
- Unit
- Tests Skipped 
Event Timeline
| usr.sbin/freebsd-update/freebsd-update.sh | ||
|---|---|---|
| 762 | ||
You can use -b basedir just fine without setting --currently-running if it's the same version as the base system.
This seatbelt is probably useful but it's not strictly *necessary*.
To me it seems reasonable to require an explicitly specified --basedir. The PR that prompted this review at least had a fairly straightforward error, but I imagine that someone trying to update a 14.1-RELEASE basedir on a 14.2-RELEASE system would fail in even more surprising ways, as it wouldn't trigger the "can't update other than a release" error.
If you think this is a use case we need to accommodate I could make this a warning instead, e.g. WARNING: -b basedir set without --currently-running and perhaps also basedir must contain the same version as installed on the host. But I would rather have the user specify the version rather than supporting a case that may or may not work.
Is there a reason to not do the right thing automatically via ROOT=... freebsd-version?
Is there a reason to not do the right thing automatically via ROOT=... freebsd-version?
Mmm, we do that for -j already, that sounds like a good idea. I'd probably emit a notice about the detected version to make it clear.
ROOT=... freebsd-version?
It doesn't look like that would work -- we'd have to execute $BASEDIR/freebsd-version as USERLAND_VERSION is baked into the script. I'll take a look at that, but as a subsequent commit.
I'm not convinced that it's strictly necessary, but I guess that's the nature of seat belts. Certainly seems harmless enough.