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/' |
Joel Stanley | 41a7f1e | 2016-10-31 23:15:44 +1030 | [diff] [blame] | 9 | 'bnx2x/bnx2x-e2-7.13.1.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/' |
| 13 | 'e100/' |
Samuel Mendoza-Jonas | d5155dc | 2017-09-27 11:50:02 +1000 | [diff] [blame] | 14 | 'ql2500_fw.bin' |
Samuel Mendoza-Jonas | d5d10af | 2016-07-19 15:03:56 +1000 | [diff] [blame] | 15 | 'radeon/CEDAR_rlc.bin' |
Samuel Mendoza-Jonas | d5d10af | 2016-07-19 15:03:56 +1000 | [diff] [blame] | 16 | 'radeon/CEDAR_pfp.bin' |
Samuel Mendoza-Jonas | d5d10af | 2016-07-19 15:03:56 +1000 | [diff] [blame] | 17 | 'radeon/CEDAR_smc.bin' |
| 18 | 'radeon/CEDAR_me.bin' |
Samuel Mendoza-Jonas | 379b91c | 2016-09-13 11:26:16 +1000 | [diff] [blame] | 19 | 'radeon/CYPRESS_uvd.bin') |
Samuel Mendoza-Jonas | d5d10af | 2016-07-19 15:03:56 +1000 | [diff] [blame] | 20 | |
| 21 | if [ -z "${TARGET_DIR}" ] ; then |
| 22 | echo "TARGET_DIR not defined, setting to $1" |
| 23 | TARGET_DIR=$1 |
| 24 | fi |
| 25 | |
| 26 | files=$(find ${TARGET_DIR}/lib/firmware/*) |
| 27 | for file in ${files}; |
| 28 | do |
| 29 | if [ -d $file ] ; then |
| 30 | continue |
| 31 | fi |
| 32 | |
| 33 | found=0 |
| 34 | for item in ${whitelist[@]}; |
| 35 | do |
| 36 | if [ "${file/${item}}" != "${file}" ] ; then |
| 37 | found=1 |
| 38 | break |
| 39 | fi |
| 40 | done |
| 41 | |
| 42 | if [ "${found}" -ne "1" ] ; then |
| 43 | rm -v ${file} |
| 44 | fi |
| 45 | done |