]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - debian/scripts/misc/find-obsolete-firmware
UBUNTU: [debian] script to detect obsolete firmware
[mirror_ubuntu-zesty-kernel.git] / debian / scripts / misc / find-obsolete-firmware
1 #!/bin/bash
2 #
3 # Find all duplicate or obsolete firmware that is being carried
4 # in the kernel firmware directory. Compare these files against
5 # the linux-firmware package for the approriate release. For example,
6 # assuming this is raring, then compare the kernel firmware files
7 # against the raring branch of linux-firmware.
8 #
9 # Example: $0 ~/ubuntu/linux-firmware-raring
10
11 USEAGE="$0 LINUX-FIRMWARE"
12
13 . debian/debian.env
14
15 NFWINFO="`find $DEBIAN -name fwinfo|wc -l`"
16 if [ ! "$NFWINFO" = "1" ]
17 then
18 echo Your repo is hosed. There can only be one fwinfo file.
19 find $DEBIAN -name fwinfo
20 exit 1
21 fi
22
23 FWINFO="`pwd`/`find $DEBIAN -name fwinfo`"
24
25 if [ "$1" = "" ]
26 then
27 echo $USEAGE
28 exit 1
29 fi
30 FW="$1"
31
32 if [ ! -f $FW/WHENCE ]
33 then
34 echo Bogus linux-firmware directory
35 exit 1
36 fi
37 if ! egrep -q "^firmware:" $FWINFO
38 then
39 echo Bogus firmware info file
40 exit 1
41 fi
42
43 #
44 # Prepare the tree and make firmware.
45 #
46 TEE="tee -a"
47 LO=`pwd`/firmware.txt
48 LF=`pwd`/lib/firmware
49 rm -rf debian/build $LF $LO
50 fakeroot debian/rules clean prepare-generic
51 cp debian/build/build-generic/.config .
52 mkdir -p $LF
53 make firmware_install INSTALL_MOD_PATH=`pwd`
54
55 cd $LF
56 find . -type f | while read f
57 do
58 BN="`basename $f`"
59
60 if ! grep -q $BN $FWINFO
61 then
62 echo "Unused firmware: $f" | $TEE $LO
63 else
64 if [ -f $FW/$f ]
65 then
66 if ! cmp $FW/$f $f
67 then
68 echo "$f differs" | $TEE $LO
69 else
70 echo "$f is duplicated" | $TEE $LO
71 fi
72 else
73 echo "$f does not exist in $FW" | $TEE $LO
74 fi
75 fi
76 done
77
78 #
79 # Check for firmware files referenced by the kernel
80 # that do not exist in either location.
81 #
82 cat $FWINFO | while read fwi f
83 do
84 if [ ! -f $f ]
85 then
86 if [ ! -f $FW/$f ]
87 then
88 echo "Missing firmware $f" | $TEE $LO
89 fi
90 fi
91 done
92