mxupgrade: write the sysupgrade configuration when it is missing

sysupgrade(8) stopped the first real upgrade with "Configuration file
/usr/pkg/etc/sysupgrade.conf does not exist" before it began (measured
2026-11-21 on the MacBook).  The release to install is on mxupgrade's command
line, but sysupgrade reads KERNEL, SETS and POSTINSTALL_AUTOFIX from that file,
so mxupgrade writes the defaults where the sysupgrade that runs looks for them
(/etc/sysupgrade.conf and /usr/pkg/etc/sysupgrade.conf), once, if absent.
Checked on the MacBook with a stub sysupgrade: the file is created and the run
reaches the end.
This commit is contained in:
lotherk committed 2026-11-21 20:52:47 +01:00
1 parent b419080298
commit 633787ec1f
1 file changed
+17
+17
View File
@@ -104,6 +104,23 @@ fi
[ "$(id -u)" = 0 ] || die "only root can upgrade the system"
command -v "$SYSUPGRADE" >/dev/null 2>&1 || die "$SYSUPGRADE is not installed"
# sysupgrade(8) refuses to run without its configuration file ("Configuration
# file /usr/pkg/etc/sysupgrade.conf does not exist", measured 2026-11-21 on the
# MacBook, where the upgrade then stopped before it began). What this script
# needs it takes from the command line, but sysupgrade reads KERNEL, SETS and
# POSTINSTALL_AUTOFIX from that file: the defaults are written where the
# sysupgrade that runs looks for them.
for c in "$CONF" /usr/pkg/etc/sysupgrade.conf; do
[ -f "$c" ] && continue
mkdir -p "${c%/*}" 2>/dev/null || continue
cat > "$c" <<'MXCONF' || die "cannot write $c"
# written by mxupgrade(8): the defaults sysupgrade(8) needs
KERNEL=AUTO
SETS=AUTO
POSTINSTALL_AUTOFIX="obsolete"
MXCONF
done
if [ "$yes" != yes ]; then
printf 'Upgrade now? [y/N] '
read -r a