Page MenuHomeFreeBSD

fwget: simplify adding firmware images to pkg to install
ClosedPublic

Authored by bz on May 11 2023, 8:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 17 2024, 9:43 PM
Unknown Object (File)
Oct 3 2024, 4:05 PM
Unknown Object (File)
Oct 3 2024, 7:30 AM
Unknown Object (File)
Oct 2 2024, 8:21 PM
Unknown Object (File)
Oct 2 2024, 6:27 PM
Unknown Object (File)
Oct 2 2024, 2:19 PM
Unknown Object (File)
Oct 2 2024, 2:17 PM
Unknown Object (File)
Oct 2 2024, 12:30 PM
Subscribers

Details

Summary

Rather than using echo to return the firmware package name, call a
new function (addpkg) which will also deal with (i) no leading space
and (ii) remove duplicates (as some devices have dual-wifi-cards).
In addition we won't have a line break when having multiple packages.

While here also do not call pkg(8) anymore if there is no package to
install and actually use the variable to install all and not just the
last found package.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bz requested review of this revision.May 11 2023, 8:44 PM
manu requested changes to this revision.May 12 2023, 5:08 AM

In that case we can also remove all the shell redirection since we do not echo anymore and the log functions can just echo directly.
Otherwise lgtm

This revision now requires changes to proceed.May 12 2023, 5:08 AM
In D40071#912590, @manu wrote:

In that case we can also remove all the shell redirection since we do not echo anymore and the log functions can just echo directly.
Otherwise lgtm

Cool. Would you mind if I do that as a 4th change on top of the current stack?

bapt requested changes to this revision.May 12 2023, 12:54 PM
bapt added inline comments.
usr.sbin/fwget/fwget.sh
75

this is not working:

addpkg mysuperpackage
addpkg super
echo $packages
mysuperpackages

If you want deduplication to work you need to change it to:

case " ${packages} " in
* ${_p} *) ;; #duplicate
*) packages="${packages} ${_p}" ;;
esac

note the new spaces

usr.sbin/fwget/fwget.sh
75

To my understanding this doesn't work either as the first one doesn't have a leading space and the last one in the list does not have a trailing one.
Almost have to iterate over $packages and check for an exact match?

usr.sbin/fwget/fwget.sh
75

no this will always work because I added space both around "${packages}" and *\ ${_p}\ *) ;;

usr.sbin/fwget/fwget.sh
75

Oh doh! I missed the former. I'll update the change immediately.

bz marked 2 inline comments as done.May 12 2023, 2:01 PM
bz added inline comments.
usr.sbin/fwget/fwget.sh
75

Had to add extra \ for the spaces to avoid errors by sh

This revision is now accepted and ready to land.May 20 2023, 10:01 AM