Index | Thread | Search

From:
Andrew Hewus Fresh <andrew@afresh1.com>
Subject:
Re: Make fw_update(8) -p consistent
To:
tech@openbsd.org
Date:
Wed, 16 Oct 2024 18:25:58 -0700

Download raw body.

Thread
I got feedback that the man page change didn't go far enough.  Here's a
version that talks less about packages and more about firmware.

It also includes the important detail that `-F` will also download the
SHA256.sig along with the packages.  It turns out though that `-F` will
_always_ download SHA256.sig, even when using `-n` for "dry run".
Unfortunately, not an easy fix, but I will add it to my list.


On Wed, Oct 16, 2024 at 05:30:19PM -0700, Andrew Hewus Fresh wrote:
> I was talking about how to download firmware on one machine and install
> it on another.  That led to more reading of the man page which really
> makes the usage a weird inconsistency.  If you happen to use `-Fp $path`
> and the `$path` is a directory, we magically switch from `-p` being a
> _source_ to being a destination.
> 
> While here, be more consistent with "firmware" vs "firmware packages".
> 
> This is a non-backwards compatible change, so it may need a mention on
> current.html and upgrade77.html.
> 
> Comments, questions, "sorry, we're stuck with it", OK?
> 


Index: fw_update.8
===================================================================
RCS file: /cvs/src/usr.sbin/fw_update/fw_update.8,v
diff -u -p -r1.4 fw_update.8
--- fw_update.8	12 Oct 2024 23:56:23 -0000	1.4
+++ fw_update.8	17 Oct 2024 01:24:44 -0000
@@ -19,7 +19,7 @@
 .Os
 .Sh NAME
 .Nm fw_update
-.Nd install non-free firmware packages
+.Nd install non-free firmware
 .Sh SYNOPSIS
 .Nm
 .Op Fl adFnv
@@ -28,12 +28,12 @@
 .Sh DESCRIPTION
 The
 .Nm
-utility installs, updates, or deletes firmware packages for
+utility installs, updates, or deletes firmware for
 .Ar driver
 from the Internet.
 By default,
 .Nm
-tries to determine which firmware packages are needed.
+tries to determine which firmware are needed.
 .Pp
 Since firmware with an acceptable license is already present in
 .Ox ,
@@ -58,31 +58,25 @@ If used in conjunction with
 .Fl a ,
 delete firmware for all drivers.
 .It Fl F
-Download firmware only.
-By default downloads to the current directory.
-Specifying a URL with
-.Fl p
-downloads from that URL,
-specifying a path downloads to that directory.
+Download SHA256.sig and firmware .tgz to the current directory.
 .It Fl n
 Dry run.
-Do not actually install or update any firmware packages;
+Do not actually install or update any firmware;
 just report the steps that would be taken.
 .It Fl p Ar path
-Use the firmware found at package repository
+Use
 .Ar path ,
-being either a local directory or a URL,
-instead of the default location.
+either a local directory or a URL,
+as the source for firmware instead of the default location.
 .It Fl v
 Turn on verbose output.
 This flag can be specified multiple times for increased verbosity.
 .El
 .Pp
 Firmware is downloaded from release-specific directories at
-.Lk http://firmware.openbsd.org/firmware/ .
-The files are in the format required by
-.Xr pkg_add 1 ,
-but direct use of pkg_add is discouraged.
+.Lk http://firmware.openbsd.org/firmware/
+unless overridden with
+.Fl p .
 .Sh ENVIRONMENT
 .Bl -tag -width DESTDIRXXX
 .It Ev DESTDIR
Index: fw_update.sh
===================================================================
RCS file: /cvs/src/usr.sbin/fw_update/fw_update.sh,v
diff -u -p -r1.57 fw_update.sh
--- fw_update.sh	12 Oct 2024 23:56:23 -0000	1.57
+++ fw_update.sh	17 Oct 2024 01:24:44 -0000
@@ -500,7 +500,7 @@ do
 	d) DELETE=true ;;
 	F) OPT_F=true ;;
 	n) DRYRUN=true ;;
-	p) LOCALSRC="$OPTARG" ;;
+	p) FWURL="$OPTARG" ;;
 	v) ((++VERBOSE)) ;;
 	:)
 	    warn "${0##*/}: option requires an argument -- -$OPTARG"
@@ -517,33 +517,18 @@ shift $((OPTIND - 1))
 # Progress bars, not spinner When VERBOSE > 1
 ((VERBOSE > 1)) && ENABLE_SPINNER=false
 
-if [ "$LOCALSRC" ]; then
-	if [[ $LOCALSRC = @(ftp|http?(s))://* ]]; then
-		FWURL="${LOCALSRC}"
-		LOCALSRC=
-	else
-		LOCALSRC="${LOCALSRC#file:}"
-		! [ -d "$LOCALSRC" ] &&
-		    warn "The path must be a URL or an existing directory" &&
-		    exit 1
-	fi
+if [[ $FWURL != @(ftp|http?(s))://* ]]; then
+	FWURL="${FWURL#file:}"
+	! [ -d "$FWURL" ] &&
+	    warn "The path must be a URL or an existing directory" &&
+	    exit 1
+	FWURL="file:$FWURL"
 fi
 
 # "Download only" means local dir and don't install
 if [ "$OPT_F" ]; then
 	INSTALL=false
 	LOCALSRC="${LOCALSRC:-.}"
-
-	# Always check for latest CFILE and so latest firmware
-	if [ -e "$LOCALSRC/$CFILE" ]; then
-		mv "$LOCALSRC/$CFILE" "$LOCALSRC/$CFILE-OLD"
-		if check_cfile; then
-			rm -f "$LOCALSRC/$CFILE-OLD"
-		else
-			mv "$LOCALSRC/$CFILE-OLD" "$LOCALSRC/$CFILE"
-			warn "Using existing $CFILE"
-		fi
-	fi
 elif [ "$LOCALSRC" ]; then
 	DOWNLOAD=false
 fi