Skip to content

Commit

Permalink
fwget: add -q for quiet output
Browse files Browse the repository at this point in the history
Introduce -q to quieten other output (unless -v is also given).

pkg-install(8) currently has no option to allow skipping unavail
packages but it will just fail.
We would realy want to try to install as much firmware found as
possible from the installer.
Work around this by doing one firmware package at a time.
For that it is highly helpful to be able to query (or possibly re-query)
all outstanding fimrware packages.
-q together with -n only shows each package to be installed one by line.

Once freebsd/pkg#2195 will be implemented
we could undo this part of the change and future changes to the installer
and use the new option for pkg-install(8) there.

While here switch to getopts so -qn works and not just -q -n.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D47445
  • Loading branch information
Bjoern A. Zeeb authored and Bjoern A. Zeeb committed Nov 8, 2024
1 parent 52f8e99 commit 1eb3f15
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions usr.sbin/fwget/fwget.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Supported subsystems
pci
Options:
-n -- Do not install package, only print the results
-n -- Do not install packages, only print the results
-q -- Quiet mode. If used with -n only prints a package a line
-v -- More verbose
EOF
exit 1
Expand Down Expand Up @@ -75,22 +76,27 @@ addpkg()
}

DRY_RUN=n
QUIET=n
VERBOSE=n

while [ $# -gt 0 ]; do
case $1 in
-n)
DRY_RUN=y
;;
-v)
VERBOSE=y
;;
*)
subsystems="${subsystems} $1"
;;
while getopts ":nqv" _arg; do
case ${_arg} in
n)
DRY_RUN=y
;;
q)
QUIET=y
;;
v)
VERBOSE=y
;;
?)
usage
;;
esac
shift
done
shift $(($OPTIND - 1))
subsystems="$@"

# Default searching PCI subsystem
if [ -z "${subsystems}" ]; then
Expand All @@ -112,13 +118,25 @@ done

case "${packages}" in
""|^[[:space:]]*$)
echo "No firmware packages to install."
if [ "${QUIET}" != "y" ]; then
echo "No firmware packages to install."
fi
exit 0
;;
esac

echo "Needed firmware packages: '${packages}'"
if [ "${QUIET}" != "y" ]; then
echo "Needed firmware packages: '${packages}'"
fi
if [ "${DRY_RUN}" = "y" ]; then
if [ "${QUIET}" = "y" ]; then
for pkg in ${packages}; do
case "${pkg}" in
""|^[[:space:]]*$) continue ;;
esac
echo "${pkg}"
done
fi
exit 0
fi

Expand Down

0 comments on commit 1eb3f15

Please sign in to comment.