Samuel Mendoza-Jonas | d5d10af | 2016-07-19 15:03:56 +1000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Scan the /lib/firmware directory of the target and delete any firmware |
| 3 | # binaries that are not in our whitelist |
| 4 | |
Joel Stanley | 182a2e0 | 2016-11-14 15:25:41 +1030 | [diff] [blame] | 5 | # A whitelist of entire directories or specific binary files. The trailing |
| 6 | # slash is required. |
| 7 | whitelist=( 'acenic/' |
| 8 | 'bnx2/' |
Reza Arbab | 33c629b | 2022-03-21 13:57:35 -0500 | [diff] [blame] | 9 | 'bnx2x/bnx2x-e2-7.13.15.0.fw' |
Joel Stanley | 9b1006d | 2018-02-16 14:47:59 +1030 | [diff] [blame] | 10 | 'cxgb4/t4fw-1.16.63.0.bin' |
| 11 | 'cxgb4/t4fw.bin' |
Joel Stanley | 182a2e0 | 2016-11-14 15:25:41 +1030 | [diff] [blame] | 12 | 'cxgb3/' |
Artem Senichev | 7a5902c | 2018-12-13 10:13:35 +0300 | [diff] [blame] | 13 | 'qed/qed_init_values_zipped-8.37.2.0.bin' |
Joel Stanley | f2955fb | 2018-08-20 16:00:10 +0930 | [diff] [blame] | 14 | 'ql2500_fw.bin') |
Samuel Mendoza-Jonas | d5d10af | 2016-07-19 15:03:56 +1000 | [diff] [blame] | 15 | |
| 16 | if [ -z "${TARGET_DIR}" ] ; then |
| 17 | echo "TARGET_DIR not defined, setting to $1" |
| 18 | TARGET_DIR=$1 |
| 19 | fi |
| 20 | |
| 21 | files=$(find ${TARGET_DIR}/lib/firmware/*) |
| 22 | for file in ${files}; |
| 23 | do |
| 24 | if [ -d $file ] ; then |
| 25 | continue |
| 26 | fi |
| 27 | |
| 28 | found=0 |
| 29 | for item in ${whitelist[@]}; |
| 30 | do |
| 31 | if [ "${file/${item}}" != "${file}" ] ; then |
| 32 | found=1 |
| 33 | break |
| 34 | fi |
| 35 | done |
| 36 | |
| 37 | if [ "${found}" -ne "1" ] ; then |
| 38 | rm -v ${file} |
| 39 | fi |
| 40 | done |