blob: b8a95f001a7d2bf09dd81ebc12412e0669fd766d [file] [log] [blame]
Samuel Mendoza-Jonasd5d10af2016-07-19 15:03:56 +10001#!/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 Stanley182a2e02016-11-14 15:25:41 +10305# A whitelist of entire directories or specific binary files. The trailing
6# slash is required.
7whitelist=( 'acenic/'
8 'bnx2/'
Reza Arbab33c629b2022-03-21 13:57:35 -05009 'bnx2x/bnx2x-e2-7.13.15.0.fw'
Joel Stanley9b1006d2018-02-16 14:47:59 +103010 'cxgb4/t4fw-1.16.63.0.bin'
11 'cxgb4/t4fw.bin'
Joel Stanley182a2e02016-11-14 15:25:41 +103012 'cxgb3/'
Artem Senichev7a5902c2018-12-13 10:13:35 +030013 'qed/qed_init_values_zipped-8.37.2.0.bin'
Joel Stanleyf2955fb2018-08-20 16:00:10 +093014 'ql2500_fw.bin')
Samuel Mendoza-Jonasd5d10af2016-07-19 15:03:56 +100015
16if [ -z "${TARGET_DIR}" ] ; then
17 echo "TARGET_DIR not defined, setting to $1"
18 TARGET_DIR=$1
19fi
20
21files=$(find ${TARGET_DIR}/lib/firmware/*)
22for file in ${files};
23do
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
40done