firmware-b43legacy-installer.postinst 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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://downloads.openwrt.org/sources/wl_apsta-3.130.20.0.o
  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/b43legacy ]; then
  24. echo "Deleting old extracted firmware..."
  25. rm -rf /lib/firmware/b43legacy
  26. fi
  27. fi
  28. b43-fwcutter -w "$FIRMWARE_INSTALL_DIR" wl_apsta-3.130.20.0.o
  29. rm -rf $tmp
  30. }
  31. # check environment
  32. if [ "$(stat -c %d/%i /)" != "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ];
  33. then
  34. echo "A chroot environment has been detected."
  35. echo "Remember this firmware needs kernel >= 2.6.25."
  36. latest_firmware
  37. exit 0
  38. else
  39. echo "No chroot environment found. Starting normal installation"
  40. fi
  41. # install firmware unconditional if the corresponding debconf value is true
  42. # this is usefull for live-systems or similar systems that should work on
  43. # changing hardware
  44. db_get b43-fwcutter/install-unconditional
  45. if [ "$RET" = "true" ] ; then
  46. latest_firmware
  47. exit 0
  48. fi
  49. # Fix for BCM4306 [14e4:4320] (rev 02)
  50. chip=`lspci -n | grep -o "14e4:4320 (rev 02)"` || true
  51. if [ "$chip" ] ; then
  52. echo "Your card is BCM4306 [14e4:4320] (rev 02), using b43legacy firmware"
  53. latest_firmware
  54. exit 0
  55. fi
  56. # check chip
  57. supported=0
  58. pci=`lspci -n | grep -o "14e4:[1234567890abcdef]\+"` || true
  59. if [ -n "$pci" ]; then
  60. for device in $pci; do
  61. device_id=`echo $device | cut -d: -f2`
  62. case $device_id in
  63. 4301 | 4306 | 4320 | 4324 | 4325)
  64. supported=1
  65. break
  66. ;;
  67. esac
  68. done
  69. fi
  70. if [ "$supported" = 0 ]; then
  71. echo "No supported card found."
  72. echo "Use b43 firmware. This is just for the b43legacy driver."
  73. echo "Aborting."
  74. exit 0
  75. fi
  76. latest_firmware
  77. #DEBHELPER#