Index | Thread | Search

From:
Jason McIntyre <jmc@kerhand.co.uk>
Subject:
Re: Make fw_update -a mean all available firmware
To:
tech@openbsd.org
Date:
Thu, 10 Oct 2024 07:18:17 +0100

Download raw body.

Thread
On Wed, Oct 09, 2024 at 06:23:15PM -0700, Andrew Hewus Fresh wrote:
> Someone at EuroBSDCon mentioned that `fw_update -a` doesn't install all
> firmware, but instead only detected.
> 
> I suppose it makes sense that all means all, and I could see the use
> with `-F`.
> 
> If whoever that was at EuroBSDCon could remind me, I'd like to give
> credit.
> 
> Comments, suggestions, OK?
> 
> Index: fw_update.8
> ===================================================================
> RCS file: /cvs/src/usr.sbin/fw_update/fw_update.8,v
> retrieving revision 1.3
> diff -u -p -r1.3 fw_update.8
> --- fw_update.8	9 Mar 2022 22:39:12 -0000	1.3
> +++ fw_update.8	10 Oct 2024 01:04:20 -0000
> @@ -31,7 +31,9 @@ The
>  utility installs, updates, or deletes firmware packages for
>  .Ar driver
>  from the Internet.
> -If no
> +If neither
> +.Fl a
> +or any
>  .Ar driver
>  is specified, the
>  .Nm

hi.

being picky, you probably want neither/nor rather than neither/or.

you could reword it: fw_update does blah, unless...

however i hate how we tie ourselves in knots trying to cover corner
cases, when usually things seem fairly obvious. for example, if you
specify "fw_upgrade <driver>", you would hardly expect it to "try to
determine which firmware is needed on the system". but we say it!

could we just simplify it to:

	By default, fw_upgrade tries to determine which firmware is
	needed on the system.

then expect people to know if they run it with options or arguments it
will work differently to the default?

(it is fair game to document conflicts/extensions within option
descriptions, not trying to suggest otherwise)

jmc

> @@ -51,9 +53,6 @@ Install or update firmware for all drive
>  It is an error to specify this option with any
>  .Ar driver
>  arguments.
> -This is enabled by default unless drivers, files or
> -.Fl d
> -are specified.
>  .It Fl d
>  Delete firmware for
>  .Ar driver .
> Index: fw_update.sh
> ===================================================================
> RCS file: /cvs/src/usr.sbin/fw_update/fw_update.sh,v
> retrieving revision 1.56
> diff -u -p -r1.56 fw_update.sh
> --- fw_update.sh	21 Mar 2024 01:02:29 -0000	1.56
> +++ fw_update.sh	10 Oct 2024 01:04:20 -0000
> @@ -331,6 +331,11 @@ EOL
>  	return 0
>  }
>  
> +available_firmware() {
> +	check_cfile || return $?
> +	sed -n 's/.*(\(.*\)-firmware.*/\1/p' "$CFILE"
> +}
> +
>  installed_firmware() {
>  	local _pre="$1" _match="$2" _post="$3" _firmware _fw
>  	set -sA _firmware -- $(
> @@ -626,6 +631,8 @@ CFILE="$LOCALSRC/$CFILE"
>  
>  if [ "${devices[*]:-}" ]; then
>  	"$ALL" && warn "Cannot use -a and devices/files" && usage
> +elif "$ALL"; then
> +	set -sA devices -- $( available_firmware )
>  else
>  	((VERBOSE > 1)) && echo -n "Detect firmware ..."
>  	set -sA devices -- $( detect_firmware )
>