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 | |
| 5 | # A whitelist of entire directories or specific binary files |
| 6 | whitelist=( 'acenic' |
| 7 | 'bnx2' |
| 8 | 'bnx2x' |
| 9 | 'cxgb4' |
| 10 | 'cxgb3' |
| 11 | 'e100' |
| 12 | 'radeon/CAICOS_me.bin' |
| 13 | 'radeon/CEDAR_rlc.bin' |
| 14 | 'radeon/CAICOS_mc.bin' |
| 15 | 'radeon/CAICOS_pfp.bin' |
| 16 | 'radeon/CEDAR_pfp.bin' |
| 17 | 'radeon/CAICOS_smc.bin' |
| 18 | 'radeon/CEDAR_smc.bin' |
| 19 | 'radeon/CEDAR_me.bin' |
| 20 | 'radeon/CYPRESS_uvd.bin') |
| 21 | |
| 22 | if [ -z "${TARGET_DIR}" ] ; then |
| 23 | echo "TARGET_DIR not defined, setting to $1" |
| 24 | TARGET_DIR=$1 |
| 25 | fi |
| 26 | |
| 27 | files=$(find ${TARGET_DIR}/lib/firmware/*) |
| 28 | for file in ${files}; |
| 29 | do |
| 30 | if [ -d $file ] ; then |
| 31 | continue |
| 32 | fi |
| 33 | |
| 34 | found=0 |
| 35 | for item in ${whitelist[@]}; |
| 36 | do |
| 37 | if [ "${file/${item}}" != "${file}" ] ; then |
| 38 | found=1 |
| 39 | break |
| 40 | fi |
| 41 | done |
| 42 | |
| 43 | if [ "${found}" -ne "1" ] ; then |
| 44 | rm -v ${file} |
| 45 | fi |
| 46 | done |