summaryrefslogtreecommitdiffstats
path: root/fwcutter/debian/firmware-b43-installer.postinst
blob: 677add3755007e3ff8e49073a0c5da6bd166bb42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/sh

set -e

. /usr/share/debconf/confmodule

tmp=`mktemp -q -d`

latest_firmware ()
{
cd $tmp
export FIRMWARE_INSTALL_DIR="/lib/firmware"

# use apt proxy
APT_PROXIES=$(apt-config shell \
http_proxy Acquire::http::Proxy \
https_proxy Acquire::https::Proxy \
ftp_proxy Acquire::ftp::Proxy \
)

if [ -n "$APT_PROXIES" ]; then
        eval export $APT_PROXIES
fi

wget --timeout=60 http://www.lwfinger.com/b43-firmware/broadcom-wl-5.100.138.tar.bz2
if [ $? -ne 0 ]; then
	echo "Some problem occurred during the firmware download. Please check your internet connection." 
	exit 0
    else
	if [ -d /lib/firmware/b43 ]; then
	   echo "Deleting old extracted firmware..."
	   rm -rf /lib/firmware/b43
	fi
fi
tar xvjf broadcom-wl-5.100.138.tar.bz2
cd broadcom-wl-5.100.138/linux
b43-fwcutter -w "$FIRMWARE_INSTALL_DIR" wl_apsta.o
rm -rf $tmp
}

# check environment
if [ "$(stat -c %d/%i /)" != "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ];
 then
    echo "A chroot environment has been detected."
    echo "Remember this firmware needs kernel >= 2.6.25."
    latest_firmware
    exit 0
 else 
    echo "No chroot environment found. Starting normal installation"
fi
     
     


# check kernel version
if dpkg --compare-versions 2.6.25 gt `uname -r | cut -d- -f1`; then
	echo "Kernel too old. This firmware needs >= 2.6.25!."
	echo "Aborting!"
	exit 0
fi

# install firmware unconditional if the corresponding debconf value is true
# this is usefull for live-systems or similar systems that should work on
# changing hardware
db_get b43-fwcutter/install-unconditional
if [ "$RET" = "true" ] ; then
    latest_firmware
    exit 0
fi

# Fix for BCM4306/3 [14e4:4320] (rev 03)
chip=`lspci -n | grep -o "14e4:4320 (rev 03)"` || true
if [ "$chip" ] ; then
   echo "Your card is BCM4306/3 [14e4:4320] (rev 03), firwmare 5.100.138 will be used"
   latest_firmware
   exit 0
fi 

# Fix for BCM4306/3 [14e4:4324] (rev 03)
chip=`lspci -n | grep -o "14e4:4324 (rev 03)"` || true
if [ "$chip" ] ; then
   echo "Your card is BCM4306/3 [14e4:4324] (rev 03), firwmare 5.100.138 will be used"
   latest_firmware
   exit 0
fi
   
# check chip
pci=`lspci -n | grep -o "14e4:[1234567890abcdef]\+"` || true

if [ -n "$pci" ]; then
	for device in $pci; do
		device_id=`echo $device | cut -d: -f2`
		case $device_id in
		4301 | 4306 | 4320 |4324 | 4325)
			legacy=1
		;;
		4307 | 4311 | 4312 | 4315 | 4318 | 4319 | 4321 | 4328 | 4329 | 432b | 432c | 4331 | 4353 | 4357 | 5354)
			latest=1
                ;;
		4322 | 4358 | 4365 | 4727 | a8d8)
			# b43 upstream says 3.6+ for a8d8
			unsupported="$unsupported $device_id"
		;;
		0576 | 4313 | 432a | 432d | 4358 | 4359 | 435a | a99d)
                        nottested=1
                ;;
		*)
		;;
		esac
	done
fi

if [ "$legacy" ]; then
	echo "An unsupported BCM4301, BCM4306 or BCM4306/2 device was found."
	echo "Use b43legacy firmware (firmware-b43legacy-installer package) instead."
	echo "Aborting."
	exit 0
elif [ "$unsupported" ]; then
	echo -n "Unsupported device(s) found: PCI id "
	for device_id in $unsupported; do echo -n "14e4:$device_id "; done
	echo
	echo "Aborting."
	exit 0
elif [ "$nottested" ]; then
        echo "This card is actually not tested. Please install the driver manually."
        exit 0
elif [ "$latest" ]; then
        echo "This card work with newer 5.100.138 firmware. Trying to install it."
        latest_firmware
        exit 0
fi

#DEBHELPER#
bues.ch cgit interface