History log of /openbsd-current/usr.sbin/fw_update/fw_update.sh
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.56 21-Mar-2024 afresh1

Clear spinner after each cycle

Otherwise we can get left with a piece of the spinner if all firmware
gets updates and don't print a "kept" value.

While here, replace \010 with the ksh supported \b, as suggested by cheloha@

Noticed by deraadt@


Revision tags: OPENBSD_7_5_BASE
# 1.55 15-Nov-2023 afresh1

Don't let signify mess up our status line

While not verbose the status line is built as we go, so save errors from
signify until after we've finished the status line. This should exit and print
the error immediately, since this happens when fetching the SHA256.sig and
fw_update exits early in that case.


# 1.54 15-Nov-2023 afresh1

Improve output after waiting for package db lock

OpenBSD::PackageInfo::lock_db will send messages to STDERR if we ended up
waiting for a lock, if that happens, it stomped over the "fw_update:" prefix on
the status line so tidy up and print it out again.


# 1.53 15-Nov-2023 afresh1

Better handle ftp errors in fw_update

Trap STDERR to post-process it looking for 404 errors to handle them differently.

The fetch method now also returns different error codes for errors that can
continue on. Currently only 404 is special and everything else should cause
fw_update to exit early without trying all the files.

Exit early if the SHA256.sig gets a 404 because that is required to figure out
what valid firmware are.


# 1.52 15-Nov-2023 afresh1

Improve fw_update output on errors

Mostly some setup for the future, by separating out the filehandles we use for
the status and errors more specifically, we can trap the things we know about
without hiding surprises.


# 1.51 14-Oct-2023 afresh1

Verify but don't overwrite SHA256.sig in fw_update(8)

Signify is happy to overwite the file with the signature stripped off.
However, if we do that, when downloading firmware we lose the ability
to check the signature before verifying checksums on the downloaded files.

Noticed by Thomas <exnihilo () fastmail ! org>
Right deraadt@


Revision tags: OPENBSD_7_4_BASE
# 1.50 28-Sep-2023 afresh1

Don't register firmware already in /var/db/pkg

If installing firmware with `make install` from a port, it doesn't register
properly by adding "@option firmware" to the packing list, this means we ignore
that it is installed and reinstall it over and over with the registration
ending up in a tmpdir named directory inside the existing directory in
/var/db/pkg.

Unfortunately I don't know of a good way to automatically clean up from that,
so we just print a message after installing the actual firmware.

Reported by job@
No complaints about the patch on tech@ for several weeks.


# 1.49 28-Sep-2023 afresh1

Exit successfully at the end of fw_update

Otherwise the exit status depends on whether we kept any firmware.

Reported by Brian Conway <bconway () rcesoftware ! com>
The clean solution suggested by guenther@


# 1.48 28-Sep-2023 afresh1

Download firmware to LOCALSRC when using filenames

Previously if you did: fw_update otus-firmware-1.0p1.tgz
and that firmware didn't exist in the current directory,
we would download that firmware into the current directory.
Which is not the expected outcome.


# 1.47 31-Aug-2023 afresh1

Add spaces for failure status


# 1.46 31-Aug-2023 afresh1

Exit fw_update(8) lock_db subprocess when parent exits

If fw_update exits unexpectedly the package database would never unlock.

select solution from millert@


# 1.45 31-Aug-2023 afresh1

Improve feedback from fw_update(8)

Show status as we go with spinner rather than printing only at the end.

Suggestions from deraadt@

Most of this has been in snapshots for a while


Revision tags: OPENBSD_7_3_BASE
# 1.44 12-Dec-2022 afresh1

Remove extra : in parameter substitution

From Rob Whitlock <rwhitlock22 () gmail ! com>


Revision tags: OPENBSD_7_2_BASE
# 1.43 05-Aug-2022 afresh1

Support wildcards in fw_update patterns

Up to two wildcards, since we have to work around the way ksh does things.

Tweaks and suggestions from kn@ and halex@


Revision tags: OPENBSD_7_1_BASE
# 1.42 20-Feb-2022 afresh1

Only use /snapshots dir when -current

Not during release, -stable, or -beta.

This diverges from how packages work and how things were done in the past
where -beta also looked in /snapshots.

Discussed in icb.
OK deraadt@


# 1.41 20-Feb-2022 afresh1

Remove downloaded SHA256.sig if signature validation fails

Without the "noclobber" setting we would have overwitten with an empty
file and best not to leave a failed file around.

Noticed by florian@


# 1.40 20-Feb-2022 afresh1

Show summary even if no firmware are detected or installed

OK florian@


# 1.39 19-Feb-2022 afresh1

Ignore sitelib in perl snippet

All base tools should be doing that and I forgot.

While here remove the no longer necessary TERM handler,
it was only needed so a TERM signal would still trigger the END block.


# 1.38 15-Feb-2022 espie

make use of pkg_* infra simplifications
okay afresh1@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.55 15-Nov-2023 afresh1

Don't let signify mess up our status line

While not verbose the status line is built as we go, so save errors from
signify until after we've finished the status line. This should exit and print
the error immediately, since this happens when fetching the SHA256.sig and
fw_update exits early in that case.


# 1.54 15-Nov-2023 afresh1

Improve output after waiting for package db lock

OpenBSD::PackageInfo::lock_db will send messages to STDERR if we ended up
waiting for a lock, if that happens, it stomped over the "fw_update:" prefix on
the status line so tidy up and print it out again.


# 1.53 15-Nov-2023 afresh1

Better handle ftp errors in fw_update

Trap STDERR to post-process it looking for 404 errors to handle them differently.

The fetch method now also returns different error codes for errors that can
continue on. Currently only 404 is special and everything else should cause
fw_update to exit early without trying all the files.

Exit early if the SHA256.sig gets a 404 because that is required to figure out
what valid firmware are.


# 1.52 15-Nov-2023 afresh1

Improve fw_update output on errors

Mostly some setup for the future, by separating out the filehandles we use for
the status and errors more specifically, we can trap the things we know about
without hiding surprises.


# 1.51 14-Oct-2023 afresh1

Verify but don't overwrite SHA256.sig in fw_update(8)

Signify is happy to overwite the file with the signature stripped off.
However, if we do that, when downloading firmware we lose the ability
to check the signature before verifying checksums on the downloaded files.

Noticed by Thomas <exnihilo () fastmail ! org>
Right deraadt@


Revision tags: OPENBSD_7_4_BASE
# 1.50 28-Sep-2023 afresh1

Don't register firmware already in /var/db/pkg

If installing firmware with `make install` from a port, it doesn't register
properly by adding "@option firmware" to the packing list, this means we ignore
that it is installed and reinstall it over and over with the registration
ending up in a tmpdir named directory inside the existing directory in
/var/db/pkg.

Unfortunately I don't know of a good way to automatically clean up from that,
so we just print a message after installing the actual firmware.

Reported by job@
No complaints about the patch on tech@ for several weeks.


# 1.49 28-Sep-2023 afresh1

Exit successfully at the end of fw_update

Otherwise the exit status depends on whether we kept any firmware.

Reported by Brian Conway <bconway () rcesoftware ! com>
The clean solution suggested by guenther@


# 1.48 28-Sep-2023 afresh1

Download firmware to LOCALSRC when using filenames

Previously if you did: fw_update otus-firmware-1.0p1.tgz
and that firmware didn't exist in the current directory,
we would download that firmware into the current directory.
Which is not the expected outcome.


# 1.47 31-Aug-2023 afresh1

Add spaces for failure status


# 1.46 31-Aug-2023 afresh1

Exit fw_update(8) lock_db subprocess when parent exits

If fw_update exits unexpectedly the package database would never unlock.

select solution from millert@


# 1.45 31-Aug-2023 afresh1

Improve feedback from fw_update(8)

Show status as we go with spinner rather than printing only at the end.

Suggestions from deraadt@

Most of this has been in snapshots for a while


Revision tags: OPENBSD_7_3_BASE
# 1.44 12-Dec-2022 afresh1

Remove extra : in parameter substitution

From Rob Whitlock <rwhitlock22 () gmail ! com>


Revision tags: OPENBSD_7_2_BASE
# 1.43 05-Aug-2022 afresh1

Support wildcards in fw_update patterns

Up to two wildcards, since we have to work around the way ksh does things.

Tweaks and suggestions from kn@ and halex@


Revision tags: OPENBSD_7_1_BASE
# 1.42 20-Feb-2022 afresh1

Only use /snapshots dir when -current

Not during release, -stable, or -beta.

This diverges from how packages work and how things were done in the past
where -beta also looked in /snapshots.

Discussed in icb.
OK deraadt@


# 1.41 20-Feb-2022 afresh1

Remove downloaded SHA256.sig if signature validation fails

Without the "noclobber" setting we would have overwitten with an empty
file and best not to leave a failed file around.

Noticed by florian@


# 1.40 20-Feb-2022 afresh1

Show summary even if no firmware are detected or installed

OK florian@


# 1.39 19-Feb-2022 afresh1

Ignore sitelib in perl snippet

All base tools should be doing that and I forgot.

While here remove the no longer necessary TERM handler,
it was only needed so a TERM signal would still trigger the END block.


# 1.38 15-Feb-2022 espie

make use of pkg_* infra simplifications
okay afresh1@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.51 14-Oct-2023 afresh1

Verify but don't overwrite SHA256.sig in fw_update(8)

Signify is happy to overwite the file with the signature stripped off.
However, if we do that, when downloading firmware we lose the ability
to check the signature before verifying checksums on the downloaded files.

Noticed by Thomas <exnihilo () fastmail ! org>
Right deraadt@


Revision tags: OPENBSD_7_4_BASE
# 1.50 28-Sep-2023 afresh1

Don't register firmware already in /var/db/pkg

If installing firmware with `make install` from a port, it doesn't register
properly by adding "@option firmware" to the packing list, this means we ignore
that it is installed and reinstall it over and over with the registration
ending up in a tmpdir named directory inside the existing directory in
/var/db/pkg.

Unfortunately I don't know of a good way to automatically clean up from that,
so we just print a message after installing the actual firmware.

Reported by job@
No complaints about the patch on tech@ for several weeks.


# 1.49 28-Sep-2023 afresh1

Exit successfully at the end of fw_update

Otherwise the exit status depends on whether we kept any firmware.

Reported by Brian Conway <bconway () rcesoftware ! com>
The clean solution suggested by guenther@


# 1.48 28-Sep-2023 afresh1

Download firmware to LOCALSRC when using filenames

Previously if you did: fw_update otus-firmware-1.0p1.tgz
and that firmware didn't exist in the current directory,
we would download that firmware into the current directory.
Which is not the expected outcome.


# 1.47 31-Aug-2023 afresh1

Add spaces for failure status


# 1.46 31-Aug-2023 afresh1

Exit fw_update(8) lock_db subprocess when parent exits

If fw_update exits unexpectedly the package database would never unlock.

select solution from millert@


# 1.45 31-Aug-2023 afresh1

Improve feedback from fw_update(8)

Show status as we go with spinner rather than printing only at the end.

Suggestions from deraadt@

Most of this has been in snapshots for a while


Revision tags: OPENBSD_7_3_BASE
# 1.44 12-Dec-2022 afresh1

Remove extra : in parameter substitution

From Rob Whitlock <rwhitlock22 () gmail ! com>


Revision tags: OPENBSD_7_2_BASE
# 1.43 05-Aug-2022 afresh1

Support wildcards in fw_update patterns

Up to two wildcards, since we have to work around the way ksh does things.

Tweaks and suggestions from kn@ and halex@


Revision tags: OPENBSD_7_1_BASE
# 1.42 20-Feb-2022 afresh1

Only use /snapshots dir when -current

Not during release, -stable, or -beta.

This diverges from how packages work and how things were done in the past
where -beta also looked in /snapshots.

Discussed in icb.
OK deraadt@


# 1.41 20-Feb-2022 afresh1

Remove downloaded SHA256.sig if signature validation fails

Without the "noclobber" setting we would have overwitten with an empty
file and best not to leave a failed file around.

Noticed by florian@


# 1.40 20-Feb-2022 afresh1

Show summary even if no firmware are detected or installed

OK florian@


# 1.39 19-Feb-2022 afresh1

Ignore sitelib in perl snippet

All base tools should be doing that and I forgot.

While here remove the no longer necessary TERM handler,
it was only needed so a TERM signal would still trigger the END block.


# 1.38 15-Feb-2022 espie

make use of pkg_* infra simplifications
okay afresh1@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.50 28-Sep-2023 afresh1

Don't register firmware already in /var/db/pkg

If installing firmware with `make install` from a port, it doesn't register
properly by adding "@option firmware" to the packing list, this means we ignore
that it is installed and reinstall it over and over with the registration
ending up in a tmpdir named directory inside the existing directory in
/var/db/pkg.

Unfortunately I don't know of a good way to automatically clean up from that,
so we just print a message after installing the actual firmware.

Reported by job@
No complaints about the patch on tech@ for several weeks.


# 1.49 28-Sep-2023 afresh1

Exit successfully at the end of fw_update

Otherwise the exit status depends on whether we kept any firmware.

Reported by Brian Conway <bconway () rcesoftware ! com>
The clean solution suggested by guenther@


# 1.48 28-Sep-2023 afresh1

Download firmware to LOCALSRC when using filenames

Previously if you did: fw_update otus-firmware-1.0p1.tgz
and that firmware didn't exist in the current directory,
we would download that firmware into the current directory.
Which is not the expected outcome.


# 1.47 31-Aug-2023 afresh1

Add spaces for failure status


# 1.46 31-Aug-2023 afresh1

Exit fw_update(8) lock_db subprocess when parent exits

If fw_update exits unexpectedly the package database would never unlock.

select solution from millert@


# 1.45 31-Aug-2023 afresh1

Improve feedback from fw_update(8)

Show status as we go with spinner rather than printing only at the end.

Suggestions from deraadt@

Most of this has been in snapshots for a while


Revision tags: OPENBSD_7_3_BASE
# 1.44 12-Dec-2022 afresh1

Remove extra : in parameter substitution

From Rob Whitlock <rwhitlock22 () gmail ! com>


Revision tags: OPENBSD_7_2_BASE
# 1.43 05-Aug-2022 afresh1

Support wildcards in fw_update patterns

Up to two wildcards, since we have to work around the way ksh does things.

Tweaks and suggestions from kn@ and halex@


Revision tags: OPENBSD_7_1_BASE
# 1.42 20-Feb-2022 afresh1

Only use /snapshots dir when -current

Not during release, -stable, or -beta.

This diverges from how packages work and how things were done in the past
where -beta also looked in /snapshots.

Discussed in icb.
OK deraadt@


# 1.41 20-Feb-2022 afresh1

Remove downloaded SHA256.sig if signature validation fails

Without the "noclobber" setting we would have overwitten with an empty
file and best not to leave a failed file around.

Noticed by florian@


# 1.40 20-Feb-2022 afresh1

Show summary even if no firmware are detected or installed

OK florian@


# 1.39 19-Feb-2022 afresh1

Ignore sitelib in perl snippet

All base tools should be doing that and I forgot.

While here remove the no longer necessary TERM handler,
it was only needed so a TERM signal would still trigger the END block.


# 1.38 15-Feb-2022 espie

make use of pkg_* infra simplifications
okay afresh1@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.47 31-Aug-2023 afresh1

Add spaces for failure status


# 1.46 31-Aug-2023 afresh1

Exit fw_update(8) lock_db subprocess when parent exits

If fw_update exits unexpectedly the package database would never unlock.

select solution from millert@


# 1.45 31-Aug-2023 afresh1

Improve feedback from fw_update(8)

Show status as we go with spinner rather than printing only at the end.

Suggestions from deraadt@

Most of this has been in snapshots for a while


Revision tags: OPENBSD_7_3_BASE
# 1.44 12-Dec-2022 afresh1

Remove extra : in parameter substitution

From Rob Whitlock <rwhitlock22 () gmail ! com>


Revision tags: OPENBSD_7_2_BASE
# 1.43 05-Aug-2022 afresh1

Support wildcards in fw_update patterns

Up to two wildcards, since we have to work around the way ksh does things.

Tweaks and suggestions from kn@ and halex@


Revision tags: OPENBSD_7_1_BASE
# 1.42 20-Feb-2022 afresh1

Only use /snapshots dir when -current

Not during release, -stable, or -beta.

This diverges from how packages work and how things were done in the past
where -beta also looked in /snapshots.

Discussed in icb.
OK deraadt@


# 1.41 20-Feb-2022 afresh1

Remove downloaded SHA256.sig if signature validation fails

Without the "noclobber" setting we would have overwitten with an empty
file and best not to leave a failed file around.

Noticed by florian@


# 1.40 20-Feb-2022 afresh1

Show summary even if no firmware are detected or installed

OK florian@


# 1.39 19-Feb-2022 afresh1

Ignore sitelib in perl snippet

All base tools should be doing that and I forgot.

While here remove the no longer necessary TERM handler,
it was only needed so a TERM signal would still trigger the END block.


# 1.38 15-Feb-2022 espie

make use of pkg_* infra simplifications
okay afresh1@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.44 12-Dec-2022 afresh1

Remove extra : in parameter substitution

From Rob Whitlock <rwhitlock22 () gmail ! com>


Revision tags: OPENBSD_7_2_BASE
# 1.43 05-Aug-2022 afresh1

Support wildcards in fw_update patterns

Up to two wildcards, since we have to work around the way ksh does things.

Tweaks and suggestions from kn@ and halex@


Revision tags: OPENBSD_7_1_BASE
# 1.42 20-Feb-2022 afresh1

Only use /snapshots dir when -current

Not during release, -stable, or -beta.

This diverges from how packages work and how things were done in the past
where -beta also looked in /snapshots.

Discussed in icb.
OK deraadt@


# 1.41 20-Feb-2022 afresh1

Remove downloaded SHA256.sig if signature validation fails

Without the "noclobber" setting we would have overwitten with an empty
file and best not to leave a failed file around.

Noticed by florian@


# 1.40 20-Feb-2022 afresh1

Show summary even if no firmware are detected or installed

OK florian@


# 1.39 19-Feb-2022 afresh1

Ignore sitelib in perl snippet

All base tools should be doing that and I forgot.

While here remove the no longer necessary TERM handler,
it was only needed so a TERM signal would still trigger the END block.


# 1.38 15-Feb-2022 espie

make use of pkg_* infra simplifications
okay afresh1@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.43 05-Aug-2022 afresh1

Support wildcards in fw_update patterns

Up to two wildcards, since we have to work around the way ksh does things.

Tweaks and suggestions from kn@ and halex@


Revision tags: OPENBSD_7_1_BASE
# 1.42 20-Feb-2022 afresh1

Only use /snapshots dir when -current

Not during release, -stable, or -beta.

This diverges from how packages work and how things were done in the past
where -beta also looked in /snapshots.

Discussed in icb.
OK deraadt@


# 1.41 20-Feb-2022 afresh1

Remove downloaded SHA256.sig if signature validation fails

Without the "noclobber" setting we would have overwitten with an empty
file and best not to leave a failed file around.

Noticed by florian@


# 1.40 20-Feb-2022 afresh1

Show summary even if no firmware are detected or installed

OK florian@


# 1.39 19-Feb-2022 afresh1

Ignore sitelib in perl snippet

All base tools should be doing that and I forgot.

While here remove the no longer necessary TERM handler,
it was only needed so a TERM signal would still trigger the END block.


# 1.38 15-Feb-2022 espie

make use of pkg_* infra simplifications
okay afresh1@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.42 20-Feb-2022 afresh1

Only use /snapshots dir when -current

Not during release, -stable, or -beta.

This diverges from how packages work and how things were done in the past
where -beta also looked in /snapshots.

Discussed in icb.
OK deraadt@


# 1.41 20-Feb-2022 afresh1

Remove downloaded SHA256.sig if signature validation fails

Without the "noclobber" setting we would have overwitten with an empty
file and best not to leave a failed file around.

Noticed by florian@


# 1.40 20-Feb-2022 afresh1

Show summary even if no firmware are detected or installed

OK florian@


# 1.39 19-Feb-2022 afresh1

Ignore sitelib in perl snippet

All base tools should be doing that and I forgot.

While here remove the no longer necessary TERM handler,
it was only needed so a TERM signal would still trigger the END block.


# 1.38 15-Feb-2022 espie

make use of pkg_* infra simplifications
okay afresh1@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.39 19-Feb-2022 afresh1

Ignore sitelib in perl snippet

All base tools should be doing that and I forgot.

While here remove the no longer necessary TERM handler,
it was only needed so a TERM signal would still trigger the END block.


# 1.38 15-Feb-2022 espie

make use of pkg_* infra simplifications
okay afresh1@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.38 15-Feb-2022 espie

make use of pkg_* infra simplifications
okay afresh1@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.37 11-Feb-2022 afresh1

Lock the pkg db while running

At least when not running in the installer.

Suggestions from espie@
Works for me sthen@
fine deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.36 10-Feb-2022 afresh1

Don't unregister firmware if we can't fetch the SHA256.sig

Also avoid trying to download it multiple times if it fails,
which makes error reporting much nicer.

Noticed by and OK semarie@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.35 30-Jan-2022 afresh1

Localize variables used only in functions

Somehow I missed some


# 1.34 29-Jan-2022 afresh1

Clean up exit codes

Being different didn't help me figure out what was going wrong anyway.

Suggested by deraadt@


# 1.33 29-Jan-2022 afresh1

"Unregister" installed firmware that isn't in the SHA256.sig

We assume in this case that the firmware's license was improved and
it moved to be distributed in the base system. If we find that situation
remove the package registration but leave the firmware files.


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.32 24-Jan-2022 afresh1

Redownload existing files with failed checksums


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.31 22-Jan-2022 afresh1

Support multiple -v as promised in the man page

There are now four levels of verbosity:
0. Prints only the summary
1. Prints a line when installing/removing
2. Uses the ftp(1) progress bar
3. Provides more details for debugging

With some excellent ksh knowledge provided by kn@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.30 12-Jan-2022 afresh1

Bug fixes and performance improvements

Plus improving usage to match the man page

fine deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@


# 1.29 11-Jan-2022 afresh1

Tidy up some comments

requested by deraadt@


# 1.28 08-Jan-2022 afresh1

Don't download SHA256.sig unless it's needed

This allows installing local files without network.

it *might* work now deraadt@


# 1.27 07-Jan-2022 afresh1

whitespace


# 1.26 06-Jan-2022 deraadt

repair usage


# 1.25 06-Jan-2022 afresh1

Switch fw_update -D to instead -F

The perl version of fw_update used -D for something else and although
the mneumonic isn't as good, the conflict was worse.

Requested by deraadt@


# 1.24 05-Jan-2022 afresh1

Commit the correct version of fw_update

Sigh.


# 1.23 05-Jan-2022 afresh1

Add the shell based fw_update and updated man page

This allows installing firmware from the installer without having
to wait to boot into a live system.

commit deraadt@


# 1.22 23-Jan-2015 halex

Killing my darling. Functionality and binary name moved to pkg_* and
friends. So long and thanks for all the fish.

ok deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.21 23-Feb-2014 halex

- add a -p <path> switch for specifying the location of
firmware packages
- reword 'firmware files' to 'firmware'
- pick some style and whitespace nits

ok deraadt@


# 1.20 23-Feb-2014 halex

print out the path to the firmware packages in verbose mode, for use with
the upcoming -p <path> flag


# 1.19 30-Jan-2014 halex

add a -d flag to remove the specified firmware packages

ok espie@


# 1.18 03-Jan-2014 espie

explicitly tells pkg_add we're fw_update, will have some nice side-effects
later.

okay deraadt@


# 1.17 18-Oct-2013 halex

don't silence stderr from pkg_add when running in verbose mode

suggested by Alexander Holupirek
ok rpe@


# 1.16 20-Aug-2013 halex

use a single line in usage() and SYNOPSIS and explain in text which
combinations are not allowed

discussed with jmc@


# 1.15 20-Aug-2013 mpi

tedu netnatm and ueagle(4).

ok mikeb@, sthen@, tedu@ (implied), doc bits ok jmc@


# 1.14 13-Aug-2013 kettenis

Handle firmware for radeondrm(4).

pointed out by jasper@


# 1.13 13-Aug-2013 halex

allow the user to specify which firmware to install, or install all of
them using the -a switch

ok rpe@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.12 17-Sep-2012 rpe

simplify the detection of release/stable vs. snapshot kernel by
using the same logic from install.sub

ok halex@


# 1.11 05-Sep-2012 espie

don't let pkg_add turn interactive, and waive the @ask-update questions.
okay sthen@
halex "you know best"...

problem(s) reported by claudio@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.10 26-Jan-2012 halex

closing fd 0-2 is bad practice, so dup to /dev/null instead

ok krw@


# 1.9 25-Oct-2011 halex

Reduce noice by fw_update on network errors, among others

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.8 02-Aug-2011 deraadt

Say "firmware files" instead of "firmwares". It is so hard to be clear
when they are per-device packages which can containing more than one
firmware files..
Shown to halex, no response


# 1.7 27-Jul-2011 halex

a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot

ok deraadt krw


# 1.6 16-Jul-2011 espie

missing $OpenBSD$ marker


# 1.5 09-Jul-2011 halex

zap a glob leftover

noted by weerd@, thanks


# 1.4 09-Jul-2011 halex

- use pkg_info -q instead of looking in /var/db/pkg/*. it is not as expensive
as I thought.
- pass -D repair to pkg_add
- move the 'updating firmwares' message into rc.firsttime

first two from espie@ and sthen@, respectively; thanks

"looks good" deraadt@


# 1.3 09-Jul-2011 halex

when checking for installed packages we should indeed be as precise
as possible

pointed out by sthen@


# 1.2 09-Jul-2011 halex

error messages goes to stderr

pointed out by naddy@


# 1.1 09-Jul-2011 halex

welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it

"go ahead and commit it" deraadt@