History log of /openbsd-current/usr.sbin/sysupgrade/sysupgrade.sh
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.49 12-Oct-2023 kn

Remove default sets answer

The autoinstall(8) response file contains only non-defaults, except for
Set name(s)? (or 'abort' or 'done') [done] done
which is the hardcoded default since 2009.

Added in 2019 r1.23 "Let sysupgrade(8) create auto_upgrade.conf file [...]"
with all others, remove the exception.

OK florian


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.48 08-Jun-2022 mglocker

Add a new option which allows to set an alternative base-directory to
download the installation files to. This is helpful if the default
base-directory /home isn't available for writing, i.e. when using auto
mounted home directories.

Discussed with and input received from
florian@, jmc@, sthen@, schwarze@, and ajacoutot@.

OK florian@, jmc@, sthen@


# 1.47 02-Jun-2022 florian

When running sysupgrade on -stable move to the next release, not
-current.
Found the hard way by & OK sthen


Revision tags: OPENBSD_7_1_BASE
# 1.46 03-Mar-2022 sdk

Pick correct firmware directory. Read the target kernel version and use
the release directory for everything except -current.

OK afresh1@


# 1.45 11-Feb-2022 florian

It's fw_update's job to say what went wrong.
input jca
OK kmos sthen deraadt kn


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.44 22-Oct-2020 tb

ug_err() was renamed to err() in r1.41. A new ug_err call was added in
r1.42 by accident (that diff was written before the renaming was done).

From Mikolaj Kucharski


# 1.43 21-Oct-2020 kn

Specify version with fw_update(1)

sysupgrade(8) calls fw_update(1) without specifying a path, so
running on pre-6.8 snapshot and upgrading to 6.8 release with "-r"
will update firmware packages to snapshots.

Spotted by sthen
OK sthen
"looks good" deraadt


# 1.42 08-Oct-2020 kn

Fail on invalid installurl

Validate the URL's protocol identifier to avoid passing bogus arguments to
ftp(1) which otherwise might drop into the "ftp> " prompt instead of causing
sysupgrade(8) to exit non-zero.

Code taken from syspatch(8) as advised by ajacoutot.

Feedback jca
Feedback OK naddy


# 1.41 08-Oct-2020 kn

Print usage to stderr, print error messages in errx(3) fashion

While here, rename sg_err()/ug_err() to just err() and sync code between
syspatch(8) and sysupgrade(8).

Feedback OK naddy


Revision tags: OPENBSD_6_8_BASE
# 1.40 05-Sep-2020 florian

Use SETSDIR consistently.
From Alex Holst, thanks!
OK kn


# 1.39 04-Jul-2020 ajacoutot

Our old ksh(1) bug where eval()uating a || compound list would terminate the
shell has been fixed by benno@; remove workaround.

ok naddy@


# 1.38 17-Jun-2020 florian

We are no longer using the "keep" file as a flag.
Pointed out by Martin Vahlensieck, thanks!


Revision tags: OPENBSD_6_7_BASE
# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.48 08-Jun-2022 mglocker

Add a new option which allows to set an alternative base-directory to
download the installation files to. This is helpful if the default
base-directory /home isn't available for writing, i.e. when using auto
mounted home directories.

Discussed with and input received from
florian@, jmc@, sthen@, schwarze@, and ajacoutot@.

OK florian@, jmc@, sthen@


# 1.47 02-Jun-2022 florian

When running sysupgrade on -stable move to the next release, not
-current.
Found the hard way by & OK sthen


Revision tags: OPENBSD_7_1_BASE
# 1.46 03-Mar-2022 sdk

Pick correct firmware directory. Read the target kernel version and use
the release directory for everything except -current.

OK afresh1@


# 1.45 11-Feb-2022 florian

It's fw_update's job to say what went wrong.
input jca
OK kmos sthen deraadt kn


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.44 22-Oct-2020 tb

ug_err() was renamed to err() in r1.41. A new ug_err call was added in
r1.42 by accident (that diff was written before the renaming was done).

From Mikolaj Kucharski


# 1.43 21-Oct-2020 kn

Specify version with fw_update(1)

sysupgrade(8) calls fw_update(1) without specifying a path, so
running on pre-6.8 snapshot and upgrading to 6.8 release with "-r"
will update firmware packages to snapshots.

Spotted by sthen
OK sthen
"looks good" deraadt


# 1.42 08-Oct-2020 kn

Fail on invalid installurl

Validate the URL's protocol identifier to avoid passing bogus arguments to
ftp(1) which otherwise might drop into the "ftp> " prompt instead of causing
sysupgrade(8) to exit non-zero.

Code taken from syspatch(8) as advised by ajacoutot.

Feedback jca
Feedback OK naddy


# 1.41 08-Oct-2020 kn

Print usage to stderr, print error messages in errx(3) fashion

While here, rename sg_err()/ug_err() to just err() and sync code between
syspatch(8) and sysupgrade(8).

Feedback OK naddy


Revision tags: OPENBSD_6_8_BASE
# 1.40 05-Sep-2020 florian

Use SETSDIR consistently.
From Alex Holst, thanks!
OK kn


# 1.39 04-Jul-2020 ajacoutot

Our old ksh(1) bug where eval()uating a || compound list would terminate the
shell has been fixed by benno@; remove workaround.

ok naddy@


# 1.38 17-Jun-2020 florian

We are no longer using the "keep" file as a flag.
Pointed out by Martin Vahlensieck, thanks!


Revision tags: OPENBSD_6_7_BASE
# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.47 02-Jun-2022 florian

When running sysupgrade on -stable move to the next release, not
-current.
Found the hard way by & OK sthen


Revision tags: OPENBSD_7_1_BASE
# 1.46 03-Mar-2022 sdk

Pick correct firmware directory. Read the target kernel version and use
the release directory for everything except -current.

OK afresh1@


# 1.45 11-Feb-2022 florian

It's fw_update's job to say what went wrong.
input jca
OK kmos sthen deraadt kn


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.44 22-Oct-2020 tb

ug_err() was renamed to err() in r1.41. A new ug_err call was added in
r1.42 by accident (that diff was written before the renaming was done).

From Mikolaj Kucharski


# 1.43 21-Oct-2020 kn

Specify version with fw_update(1)

sysupgrade(8) calls fw_update(1) without specifying a path, so
running on pre-6.8 snapshot and upgrading to 6.8 release with "-r"
will update firmware packages to snapshots.

Spotted by sthen
OK sthen
"looks good" deraadt


# 1.42 08-Oct-2020 kn

Fail on invalid installurl

Validate the URL's protocol identifier to avoid passing bogus arguments to
ftp(1) which otherwise might drop into the "ftp> " prompt instead of causing
sysupgrade(8) to exit non-zero.

Code taken from syspatch(8) as advised by ajacoutot.

Feedback jca
Feedback OK naddy


# 1.41 08-Oct-2020 kn

Print usage to stderr, print error messages in errx(3) fashion

While here, rename sg_err()/ug_err() to just err() and sync code between
syspatch(8) and sysupgrade(8).

Feedback OK naddy


Revision tags: OPENBSD_6_8_BASE
# 1.40 05-Sep-2020 florian

Use SETSDIR consistently.
From Alex Holst, thanks!
OK kn


# 1.39 04-Jul-2020 ajacoutot

Our old ksh(1) bug where eval()uating a || compound list would terminate the
shell has been fixed by benno@; remove workaround.

ok naddy@


# 1.38 17-Jun-2020 florian

We are no longer using the "keep" file as a flag.
Pointed out by Martin Vahlensieck, thanks!


Revision tags: OPENBSD_6_7_BASE
# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.46 03-Mar-2022 sdk

Pick correct firmware directory. Read the target kernel version and use
the release directory for everything except -current.

OK afresh1@


# 1.45 11-Feb-2022 florian

It's fw_update's job to say what went wrong.
input jca
OK kmos sthen deraadt kn


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.44 22-Oct-2020 tb

ug_err() was renamed to err() in r1.41. A new ug_err call was added in
r1.42 by accident (that diff was written before the renaming was done).

From Mikolaj Kucharski


# 1.43 21-Oct-2020 kn

Specify version with fw_update(1)

sysupgrade(8) calls fw_update(1) without specifying a path, so
running on pre-6.8 snapshot and upgrading to 6.8 release with "-r"
will update firmware packages to snapshots.

Spotted by sthen
OK sthen
"looks good" deraadt


# 1.42 08-Oct-2020 kn

Fail on invalid installurl

Validate the URL's protocol identifier to avoid passing bogus arguments to
ftp(1) which otherwise might drop into the "ftp> " prompt instead of causing
sysupgrade(8) to exit non-zero.

Code taken from syspatch(8) as advised by ajacoutot.

Feedback jca
Feedback OK naddy


# 1.41 08-Oct-2020 kn

Print usage to stderr, print error messages in errx(3) fashion

While here, rename sg_err()/ug_err() to just err() and sync code between
syspatch(8) and sysupgrade(8).

Feedback OK naddy


Revision tags: OPENBSD_6_8_BASE
# 1.40 05-Sep-2020 florian

Use SETSDIR consistently.
From Alex Holst, thanks!
OK kn


# 1.39 04-Jul-2020 ajacoutot

Our old ksh(1) bug where eval()uating a || compound list would terminate the
shell has been fixed by benno@; remove workaround.

ok naddy@


# 1.38 17-Jun-2020 florian

We are no longer using the "keep" file as a flag.
Pointed out by Martin Vahlensieck, thanks!


Revision tags: OPENBSD_6_7_BASE
# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.45 11-Feb-2022 florian

It's fw_update's job to say what went wrong.
input jca
OK kmos sthen deraadt kn


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.44 22-Oct-2020 tb

ug_err() was renamed to err() in r1.41. A new ug_err call was added in
r1.42 by accident (that diff was written before the renaming was done).

From Mikolaj Kucharski


# 1.43 21-Oct-2020 kn

Specify version with fw_update(1)

sysupgrade(8) calls fw_update(1) without specifying a path, so
running on pre-6.8 snapshot and upgrading to 6.8 release with "-r"
will update firmware packages to snapshots.

Spotted by sthen
OK sthen
"looks good" deraadt


# 1.42 08-Oct-2020 kn

Fail on invalid installurl

Validate the URL's protocol identifier to avoid passing bogus arguments to
ftp(1) which otherwise might drop into the "ftp> " prompt instead of causing
sysupgrade(8) to exit non-zero.

Code taken from syspatch(8) as advised by ajacoutot.

Feedback jca
Feedback OK naddy


# 1.41 08-Oct-2020 kn

Print usage to stderr, print error messages in errx(3) fashion

While here, rename sg_err()/ug_err() to just err() and sync code between
syspatch(8) and sysupgrade(8).

Feedback OK naddy


Revision tags: OPENBSD_6_8_BASE
# 1.40 05-Sep-2020 florian

Use SETSDIR consistently.
From Alex Holst, thanks!
OK kn


# 1.39 04-Jul-2020 ajacoutot

Our old ksh(1) bug where eval()uating a || compound list would terminate the
shell has been fixed by benno@; remove workaround.

ok naddy@


# 1.38 17-Jun-2020 florian

We are no longer using the "keep" file as a flag.
Pointed out by Martin Vahlensieck, thanks!


Revision tags: OPENBSD_6_7_BASE
# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.44 22-Oct-2020 tb

ug_err() was renamed to err() in r1.41. A new ug_err call was added in
r1.42 by accident (that diff was written before the renaming was done).

From Mikolaj Kucharski


# 1.43 21-Oct-2020 kn

Specify version with fw_update(1)

sysupgrade(8) calls fw_update(1) without specifying a path, so
running on pre-6.8 snapshot and upgrading to 6.8 release with "-r"
will update firmware packages to snapshots.

Spotted by sthen
OK sthen
"looks good" deraadt


# 1.42 08-Oct-2020 kn

Fail on invalid installurl

Validate the URL's protocol identifier to avoid passing bogus arguments to
ftp(1) which otherwise might drop into the "ftp> " prompt instead of causing
sysupgrade(8) to exit non-zero.

Code taken from syspatch(8) as advised by ajacoutot.

Feedback jca
Feedback OK naddy


# 1.41 08-Oct-2020 kn

Print usage to stderr, print error messages in errx(3) fashion

While here, rename sg_err()/ug_err() to just err() and sync code between
syspatch(8) and sysupgrade(8).

Feedback OK naddy


Revision tags: OPENBSD_6_8_BASE
# 1.40 05-Sep-2020 florian

Use SETSDIR consistently.
From Alex Holst, thanks!
OK kn


# 1.39 04-Jul-2020 ajacoutot

Our old ksh(1) bug where eval()uating a || compound list would terminate the
shell has been fixed by benno@; remove workaround.

ok naddy@


# 1.38 17-Jun-2020 florian

We are no longer using the "keep" file as a flag.
Pointed out by Martin Vahlensieck, thanks!


Revision tags: OPENBSD_6_7_BASE
# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.42 08-Oct-2020 kn

Fail on invalid installurl

Validate the URL's protocol identifier to avoid passing bogus arguments to
ftp(1) which otherwise might drop into the "ftp> " prompt instead of causing
sysupgrade(8) to exit non-zero.

Code taken from syspatch(8) as advised by ajacoutot.

Feedback jca
Feedback OK naddy


# 1.41 08-Oct-2020 kn

Print usage to stderr, print error messages in errx(3) fashion

While here, rename sg_err()/ug_err() to just err() and sync code between
syspatch(8) and sysupgrade(8).

Feedback OK naddy


Revision tags: OPENBSD_6_8_BASE
# 1.40 05-Sep-2020 florian

Use SETSDIR consistently.
From Alex Holst, thanks!
OK kn


# 1.39 04-Jul-2020 ajacoutot

Our old ksh(1) bug where eval()uating a || compound list would terminate the
shell has been fixed by benno@; remove workaround.

ok naddy@


# 1.38 17-Jun-2020 florian

We are no longer using the "keep" file as a flag.
Pointed out by Martin Vahlensieck, thanks!


Revision tags: OPENBSD_6_7_BASE
# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.40 05-Sep-2020 florian

Use SETSDIR consistently.
From Alex Holst, thanks!
OK kn


# 1.39 04-Jul-2020 ajacoutot

Our old ksh(1) bug where eval()uating a || compound list would terminate the
shell has been fixed by benno@; remove workaround.

ok naddy@


# 1.38 17-Jun-2020 florian

We are no longer using the "keep" file as a flag.
Pointed out by Martin Vahlensieck, thanks!


Revision tags: OPENBSD_6_7_BASE
# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.39 04-Jul-2020 ajacoutot

Our old ksh(1) bug where eval()uating a || compound list would terminate the
shell has been fixed by benno@; remove workaround.

ok naddy@


# 1.38 17-Jun-2020 florian

We are no longer using the "keep" file as a flag.
Pointed out by Martin Vahlensieck, thanks!


Revision tags: OPENBSD_6_7_BASE
# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.38 17-Jun-2020 florian

We are no longer using the "keep" file as a flag.
Pointed out by Martin Vahlensieck, thanks!


Revision tags: OPENBSD_6_7_BASE
# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.37 26-Jan-2020 benno

Log the old kernel version before doing the upgrade. Makes it easier
to figure out what version you were tunning before the upgrade when
you hit a bug/problem after the upgrade.
ok sthen@


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.36 01-Dec-2019 ajacoutot

Simplify sets directory check and creation (/home/_syspatch).
It can now be a symlink.

ok naddy@ solene@ kn@


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.35 24-Nov-2019 florian

revert previous, has not been thought through


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.34 24-Nov-2019 florian

Show the build date of the (about to be) fetched snapshot / release.
OK phessler, pamela, jung, benno


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2; 1.25.4;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.33 12-Nov-2019 sthen

use the default URL when running fw_update, we can't guarantee that pkg_add will
be able to cope with packages from the next OpenBSD release - firmware packages
are occasionally updated on the release branch post-release.

this should handle most situations - the corner-case is an old snapshot upgrading
to a new snapshot across some types of pkg_add change, but as fw_update is usually
not mandatory this is usually good enough.

ok beck deraadt


# 1.32 11-Nov-2019 sthen

print the URL when sysupgrade fetches new sets, allowing time for a quick ^C
if it's going to the wrong place/dir. ok deraadt@


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.31 10-Nov-2019 beck

Opportunisticly run fw_update before rebooting to run the upgrade.

Warn if it fails, but allow the upgrade to continue for now.

discussed with many, refinements by naddy@ sthen@

"commit something" deraadt@


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.30 03-Nov-2019 florian

Our version numbers go
m.n-beta -> m.n
not
m.n-beta -> m.n + 0.1
Handle this correctly for the -r case to stick to a release after
beta.
OK sthen


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.29 26-Oct-2019 deraadt

use ftp -N option; ok jca


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.28 20-Oct-2019 ajacoutot

Tweak and sync comment.


# 1.27 19-Oct-2019 tb

Determine the OS version in a way that won't break after 9.9.
Do it the same way in all three copies of the code.

Based on a patch from Chris Waddey.
with & ok ajacoutot


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.26 14-Oct-2019 ajacoutot

unpriv(): propagate error code to the caller instead of failing hard.
This will allow reacting on failure.

ok florian@


Revision tags: OPENBSD_6_6_BASE
# 1.25 28-Sep-2019 ajacoutot

branches: 1.25.2;
Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.25 28-Sep-2019 ajacoutot

Add where missing and harmonize PATH to be _PATH_DEFPATH (without local nor
X11R6).
Suggested by tb@

ok deraadt@ tb@ millert@


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.24 25-Sep-2019 florian

Let sysupgrade(8) handle cleanup of downloaded sets by filling in
/etc/rc.firsttime in preparation of moving the functionality out of
install.sub.
OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.23 24-Sep-2019 florian

Let sysupgrade(8) create auto_upgrade.conf file in preparation of
moving the functionality out of install.sub.
OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.22 21-Jun-2019 florian

Try harder to have a complete /bsd.upgrade on disk.
Adapted from recent changes to the KARL infrastructure.
OK deraadt, sthen


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.21 14-May-2019 ajacoutot

Revert my recent sysupgrade changes; it broke unattended upgrades for
espie@. Need to look deeper.


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.20 13-May-2019 ajacoutot

Use the same heuristic as the installer to find a proper prefetch area for the
sets instead of hardcoding /home. This leads the way to a knob for manually
choosing a sets directory if we want that.

Create /auto_upgrade.conf that will get picked up by the installer for the
unattended upgrade mode.

Similar inputs from naddy@ and kn@
ok florian@ kmos@ kn@


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.19 10-May-2019 naddy

tweak verbosity; ok ccardenas@


# 1.18 09-May-2019 naddy

Add a -k flag to keep the files in /home/_sysupgrade, since they
will be deleted after the upgrade by default. ok kn@


# 1.17 09-May-2019 naddy

sysupgrade already verifies all sets, so eliminate redundant
verification by the installer:

Verification is triggered by the presence of SHA256.sig.
In sysupgrade, remove SHA256.sig once the signature has been verified.
Compare SHA256 against a stored copy from the previous install/upgrade.

In the installer, stash away a copy of SHA256 and move that code
into install_files() where the sets are actually processed.
Confirm in the response file that we want to proceed without
verifying the sets.

ok florian@ tj@


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.16 08-May-2019 naddy

It is not an error condition if no new snapshot is available.
ok jasper@ florian@


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.15 04-May-2019 naddy

oops, fix unpriv() argument handling; from install.sub


# 1.14 04-May-2019 naddy

* For "unpriv -f file", chown file back to root once the command finishes,
like install.sub does.
* Only verify the signature once.
* Only checksum the newly downloaded files.

ok florian@


# 1.13 04-May-2019 ajacoutot

Require root to run (still allow access to usage).

ok naddy@ florian@


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.12 03-May-2019 florian

Rename -c to -s since the correct term is snapshot, not current. Also
implement -r for symetry reasons to force an upgrade to the next
release.
suggested by & OK deraadt, OK benno, kmos


# 1.11 03-May-2019 ian

typo in previous


# 1.10 03-May-2019 ian

sysupgrade gains -n for no-reboot option. Accidentally duplicated benno's diff, who
graciously OK'd mine. Improvement from naddy; polishing and OKs from kn and ingo.


# 1.9 03-May-2019 florian

Only fetch and upgrade if a new snapshot is available.
Based on a diff by Marco Bonetti (sid77 AT slackware.it).

discussed with deraadt@, OK kn


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt


# 1.8 29-Apr-2019 ian

Install upgrade kernel with ln -f, as per kernel build. ok florian@


# 1.7 28-Apr-2019 florian

Quiet down signify, seeing all the OKs scroll by is not helping.


# 1.6 26-Apr-2019 ajacoutot

Fix default MIRROR.

ok florian@


# 1.5 26-Apr-2019 naddy

do not re-verify the signature for each file when checking the old files,
sha256 is enough; ok florian@


# 1.4 26-Apr-2019 naddy

Use a different approach to determine the appropriate signing key:
Read the first line "untrusted comment ..." from SHA256.sig. Use the
key named there if it corresponds to the current or next OS version.


# 1.3 26-Apr-2019 florian

check owner and permission of download directory


# 1.2 25-Apr-2019 naddy

don't be overly specific in set selection and don't use an undefined
variable


# 1.1 25-Apr-2019 florian

Add sysupgrade(8) a tool to upgrade OpenBSD to the next release or a
new snapshot.
Cargo culted from bits and pieces of a script originally posted
by naddy@ to misc, install.sub and syspatch(8)
with & OK deraadt