firmware-b43-installer.postinst 3.3 KB

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