| 1 |
#!/bin/sh |
| 2 |
set -e |
| 3 |
|
| 4 |
######################################################################### |
| 5 |
|
| 6 |
VERSION="" |
| 7 |
|
| 8 |
BROADCOM_WL="" |
| 9 |
|
| 10 |
WL_APSTA="wl_apsta-3.130.20.0.o" |
| 11 |
|
| 12 |
DOWNLOAD="${WL_APSTA}" |
| 13 |
|
| 14 |
URL="https://downloads.openwrt.org/sources/${WL_APSTA}" |
| 15 |
|
| 16 |
SHA512SUM="d89ed52045307449bbae79a4d1807cc6cd89ae67c4a22e8e8aa51c1396edbb6ed8b157cd0756faf8b660a537b48b62117c57967f2048245b5b102d9d9bca4bbd" |
| 17 |
|
| 18 |
FIRMWARE_INSTALL_DIR="/usr/lib/firmware" |
| 19 |
|
| 20 |
B43="b43legacy" |
| 21 |
|
| 22 |
######################################################################### |
| 23 |
# stable sections below, not updated for firmware updates # |
| 24 |
######################################################################### |
| 25 |
|
| 26 |
. /usr/share/debconf/confmodule |
| 27 |
|
| 28 |
latest_firmware () |
| 29 |
{ |
| 30 |
tmp=$(mktemp -q -d) |
| 31 |
|
| 32 |
cd $tmp |
| 33 |
|
| 34 |
# use apt proxy |
| 35 |
APT_PROXIES=$(apt-config shell \ |
| 36 |
http_proxy Acquire::http::Proxy \ |
| 37 |
https_proxy Acquire::https::Proxy \ |
| 38 |
ftp_proxy Acquire::ftp::Proxy \ |
| 39 |
) |
| 40 |
|
| 41 |
if [ -n "$APT_PROXIES" ]; then |
| 42 |
eval export $APT_PROXIES |
| 43 |
fi |
| 44 |
|
| 45 |
if ! wget --timeout=60 "${URL}"; then |
| 46 |
echo "$0: Some problem occurred during the firmware download. Please check your internet connection." 1>&2 |
| 47 |
exit 1 |
| 48 |
fi |
| 49 |
if ! sha512sum -c /dev/stdin << EOF; then |
| 50 |
${SHA512SUM} ${DOWNLOAD} |
| 51 |
EOF |
| 52 |
echo "$0: Downloaded firmware did not match known SHA512 checksum, aborting." 1>&2 |
| 53 |
exit 1 |
| 54 |
fi |
| 55 |
if [ "${DOWNLOAD}" != "${WL_APSTA}" ]; then |
| 56 |
if ! tar xvjf "${DOWNLOAD}" "${WL_APSTA}"; then |
| 57 |
echo "$0: Unpacking firmware file failed, unable to continue (is /tmp full?)." 1>&2 |
| 58 |
exit 1 |
| 59 |
fi |
| 60 |
fi |
| 61 |
catalog="${FIRMWARE_INSTALL_DIR}/${B43}/firmware-${B43}-installer.catalog" |
| 62 |
if [ -f "${catalog}" ]; then |
| 63 |
echo "$0: Deleting old extracted firmware..." 1>&2 |
| 64 |
LC_ALL=C xargs -r -0 -a "${catalog}" dpkg-query -S 2>&1 1>/dev/null | sed -es',[^/]\+,,' | xargs -r rm -f -- |
| 65 |
rm "${catalog}" |
| 66 |
fi |
| 67 |
mkdir -p "${FIRMWARE_INSTALL_DIR}/${B43}" |
| 68 |
retcode=0 |
| 69 |
b43-fwcutter -w "${FIRMWARE_INSTALL_DIR}" "${WL_APSTA}" | while read line |
| 70 |
do echo "${line}" |
| 71 |
file="${line#Extracting }" |
| 72 |
if [ "${file}" != "${line}" ] |
| 73 |
then if [ "${retcode}" -ne 0 ] |
| 74 |
then rm "${FIRMWARE_INSTALL_DIR}/${file}" |
| 75 |
|
| 76 |
elif [ -z "${FIRMWARE_INSTALL_DIR}/${file}" ] || \ |
| 77 |
! printf %s/%s\\000 "${FIRMWARE_INSTALL_DIR}" "${file}" >> "${catalog}" |
| 78 |
then echo "$0: Failed during extraction of ${file} from ${WL_APSTA}" 1>&2 |
| 79 |
echo "$0: Warning, manual removal/cleaning of ${FIRMWARE_INSTALL_DIR}/${B43} may be needed!" 1>&2 |
| 80 |
rm "${FIRMWARE_INSTALL_DIR}/${file}" |
| 81 |
retcode=1 |
| 82 |
fi |
| 83 |
fi |
| 84 |
done |
| 85 |
|
| 86 |
rm -f "${DOWNLOAD}" "${WL_APSTA}" |
| 87 |
rm -rf "${BROADCOM_WL}" |
| 88 |
|
| 89 |
# otherwise can't delete things |
| 90 |
cd / |
| 91 |
|
| 92 |
rmdir $tmp || echo "$0: DEBUG: targeted cleaning failed" 1>&2 |
| 93 |
|
| 94 |
rm -rf $tmp |
| 95 |
[ ${retcode} -eq 0 ] || exit ${retcode} |
| 96 |
} |
| 97 |
|
| 98 |
# check environment |
| 99 |
if [ "$(stat -c %d/%i /)" != "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; |
| 100 |
then |
| 101 |
echo "A chroot environment has been detected." |
| 102 |
echo "Remember this firmware needs kernel >= 2.6.25." |
| 103 |
latest_firmware |
| 104 |
exit 0 |
| 105 |
else |
| 106 |
echo "No chroot environment found. Starting normal installation" |
| 107 |
fi |
| 108 |
|
| 109 |
# install firmware unconditional if the corresponding debconf value is true |
| 110 |
# this is usefull for live-systems or similar systems that should work on |
| 111 |
# changing hardware |
| 112 |
db_get b43-fwcutter/install-unconditional |
| 113 |
if [ "$RET" = "true" ] ; then |
| 114 |
latest_firmware |
| 115 |
exit 0 |
| 116 |
fi |
| 117 |
|
| 118 |
# Fix for BCM4306 [14e4:4320] (rev 02) |
| 119 |
chip=`lspci -n | grep -o "14e4:4320 (rev 02)"` || true |
| 120 |
if [ "$chip" ] ; then |
| 121 |
echo "Your card is BCM4306 [14e4:4320] (rev 02), using b43legacy firmware" |
| 122 |
latest_firmware |
| 123 |
exit 0 |
| 124 |
fi |
| 125 |
|
| 126 |
# check chip |
| 127 |
supported=0 |
| 128 |
pci=`lspci -n | grep -o "14e4:[1234567890abcdef]\+"` || true |
| 129 |
|
| 130 |
if [ -n "$pci" ]; then |
| 131 |
for device in $pci; do |
| 132 |
device_id=`echo $device | cut -d: -f2` |
| 133 |
case $device_id in |
| 134 |
4301 | 4306 | 4320 | 4324 | 4325) |
| 135 |
supported=1 |
| 136 |
break |
| 137 |
;; |
| 138 |
esac |
| 139 |
done |
| 140 |
fi |
| 141 |
|
| 142 |
if [ "$supported" = 0 ]; then |
| 143 |
echo "No supported card found." |
| 144 |
echo "Use b43 firmware. This is just for the b43legacy driver." |
| 145 |
echo "Aborting." |
| 146 |
exit 0 |
| 147 |
fi |
| 148 |
|
| 149 |
latest_firmware |
| 150 |
|
| 151 |
#DEBHELPER# |