D18849, commit r343152, bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224048
aimed to fix freebsd-update's detection if the src component is installed.
Unfortunately this fix doesn't work, as freebsd-update's option calculation works
differently.
1. If BaseDir is configured in freebsd-update.conf, COMPONENTS is calculated
first, so BASEDIR isn't set yet when used in config_Components
2. If BaseDir is specified on the command line (-b), it's moved to
BASEDIR_saved before parsing the configuration file, so again, it's
not available when used in config_Components
The cleanest fix seemed to add an additional function that's called
after parsing all inputs and check if "src" needs to be removed.
The result of this problem is that the existence of /usr/src/COPYRIGHT
determines if the src components should be updated or not, leading
to not updating it or error messages as it isn't around. This
is a common problem for certain jail setups (I noticed it while
upgrading an iocage jail).
While debugging this issue, I added a `config` command, which I
found useful enough to leave it in and document it in the man page.
Like discussed somewhere else, I also added an `updatesready` command
that can be used to check if there are any pending fetched updates that
can be installed. It exits on status code 2 in case there aren't any
pending updates so that if one can tell apart exit 1 (=error) from it
(right now there is no code path for that, but if more checks are added
in the future this could be useful).
Finally, I changed the exit code of `freebsd-update install` in case
there are no updates pending to be installed and there wasn't a fetch
phase to 2 - this should allow future scripts to differentiate between
"error" and "nothing to be done" without breaking existing jail managers
like ezjail and iocell.
Besides documentation changed, I also added a comma in the manpage to pacify
igor.
Happy to accept naming changes (like, if the reviewers happen to not
like `updatesready` and `config`). Feel free to correct my English.
See also:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239997
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240177