4 # SPDX-License-Identifier: BSD-2-Clause
6 # Copyright 2023 Beckhoff Automation GmbH & Co. KG
7 # Copyright 2023 Bjoern A. Zeeb
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted providing that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
30 : ${LIBEXEC_PATH:="/usr/libexec/fwget"}
35 Usage: $(basename "$0") [options] [subsystem]
41 -n -- Do not install package, only print the results
54 if [ "${VERBOSE}" = "n" ]; then
68 "") packages="${_p}" ;;
69 *) # Avoid duplicates.
70 case " ${packages} " in
71 *\ ${_p}\ *) ;; # duplicate
72 *) packages="${packages} ${_p}" ;;
80 while [ $# -gt 0 ]; do
89 subsystems="${subsystems} $1"
95 # Default searching PCI subsystem
96 if [ -z "${subsystems}" ]; then
100 # Fail early on unsupported subsystem
101 for subsystem in ${subsystems}; do
102 if [ ! -f "${LIBEXEC_PATH}"/"${subsystem}" ]; then
105 . "${LIBEXEC_PATH}"/"${subsystem}"
109 for subsystem in ${subsystems}; do
110 "${subsystem}"_search_packages
113 case "${packages}" in
115 echo "No firmware packages to install."
120 echo "Needed firmware packages: '${packages}'"
121 if [ "${DRY_RUN}" = "y" ]; then
125 pkg install -qy ${packages}