fwcutter: Update copyright information
[b43-tools.git] / fwcutter / debian / firmware-b43-installer.postinst
1 #!/bin/sh
2
3 set -e
4
5 . /usr/share/debconf/confmodule
6
7 tmp=`mktemp -q -d`
8
9 latest_firmware ()
10 {
11 cd $tmp
12 export FIRMWARE_INSTALL_DIR="/lib/firmware"
13
14 # use apt proxy
15 APT_PROXIES=$(apt-config shell \
16 http_proxy Acquire::http::Proxy \
17 https_proxy Acquire::https::Proxy \
18 ftp_proxy Acquire::ftp::Proxy \
19 )
20
21 if [ -n "$APT_PROXIES" ]; then
22         eval export $APT_PROXIES
23 fi
24
25 wget --timeout=60 http://www.lwfinger.com/b43-firmware/broadcom-wl-5.100.138.tar.bz2
26 if [ $? -ne 0 ]; then
27         echo "Some problem occurred during the firmware download. Please check your internet connection." 
28         exit 0
29     else
30         if [ -d /lib/firmware/b43 ]; then
31            echo "Deleting old extracted firmware..."
32            rm -rf /lib/firmware/b43
33         fi
34 fi
35 tar xvjf broadcom-wl-5.100.138.tar.bz2
36 cd broadcom-wl-5.100.138/linux
37 b43-fwcutter -w "$FIRMWARE_INSTALL_DIR" wl_apsta.o
38 rm -rf $tmp
39 }
40
41 # check environment
42 if [ "$(stat -c %d/%i /)" != "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ];
43  then
44     echo "A chroot environment has been detected."
45     echo "Remember this firmware needs kernel >= 2.6.25."
46     latest_firmware
47     exit 0
48  else 
49     echo "No chroot environment found. Starting normal installation"
50 fi
51      
52      
53
54
55 # check kernel version
56 if dpkg --compare-versions 2.6.25 gt `uname -r | cut -d- -f1`; then
57         echo "Kernel too old. This firmware needs >= 2.6.25!."
58         echo "Aborting!"
59         exit 0
60 fi
61
62 # install firmware unconditional if the corresponding debconf value is true
63 # this is usefull for live-systems or similar systems that should work on
64 # changing hardware
65 db_get b43-fwcutter/install-unconditional
66 if [ "$RET" = "true" ] ; then
67     latest_firmware
68     exit 0
69 fi
70
71 # Fix for BCM4306/3 [14e4:4320] (rev 03)
72 chip=`lspci -n | grep -o "14e4:4320 (rev 03)"` || true
73 if [ "$chip" ] ; then
74    echo "Your card is BCM4306/3 [14e4:4320] (rev 03), firwmare 5.100.138 will be used"
75    latest_firmware
76    exit 0
77 fi 
78
79 # Fix for BCM4306/3 [14e4:4324] (rev 03)
80 chip=`lspci -n | grep -o "14e4:4324 (rev 03)"` || true
81 if [ "$chip" ] ; then
82    echo "Your card is BCM4306/3 [14e4:4324] (rev 03), firwmare 5.100.138 will be used"
83    latest_firmware
84    exit 0
85 fi
86    
87 # check chip
88 pci=`lspci -n | grep -o "14e4:[1234567890abcdef]\+"` || true
89
90 if [ -n "$pci" ]; then
91         for device in $pci; do
92                 device_id=`echo $device | cut -d: -f2`
93                 case $device_id in
94                 4301 | 4306 | 4320 |4324 | 4325)
95                         legacy=1
96                 ;;
97                 4307 | 4311 | 4312 | 4315 | 4318 | 4319 | 4321 | 4328 | 4329 | 432b | 432c | 4331 | 4353 | 4357 | 5354)
98                         latest=1
99                 ;;
100                 4322 | 4358 | 4365 | 4727 | a8d8)
101                         # b43 upstream says 3.6+ for a8d8
102                         unsupported="$unsupported $device_id"
103                 ;;
104                 0576 | 4313 | 432a | 432d | 4358 | 4359 | 435a | a99d)
105                         nottested=1
106                 ;;
107                 *)
108                 ;;
109                 esac
110         done
111 fi
112
113 if [ "$legacy" ]; then
114         echo "An unsupported BCM4301, BCM4306 or BCM4306/2 device was found."
115         echo "Use b43legacy firmware (firmware-b43legacy-installer package) instead."
116         echo "Aborting."
117         exit 0
118 elif [ "$unsupported" ]; then
119         echo -n "Unsupported device(s) found: PCI id "
120         for device_id in $unsupported; do echo -n "14e4:$device_id "; done
121         echo
122         echo "Aborting."
123         exit 0
124 elif [ "$nottested" ]; then
125         echo "This card is actually not tested. Please install the driver manually."
126         exit 0
127 elif [ "$latest" ]; then
128         echo "This card work with newer 5.100.138 firmware. Trying to install it."
129         latest_firmware
130         exit 0
131 fi
132
133 #DEBHELPER#