Browse Source

feat: support for non-free firmware on armbian

close #60
HugoPoi 4 years ago
parent
commit
63e4f87efd
8 changed files with 25 additions and 40 deletions
  1. BIN
      conf/firmware_htc-7010.fw
  2. BIN
      conf/firmware_htc-9271.fw
  3. 16 2
      scripts/_common.sh
  4. 0 5
      scripts/backup
  5. 3 16
      scripts/install
  6. 0 9
      scripts/remove
  7. 3 6
      scripts/restore
  8. 3 2
      scripts/upgrade

BIN
conf/firmware_htc-7010.fw


BIN
conf/firmware_htc-9271.fw


+ 16 - 2
scripts/_common.sh

@@ -5,13 +5,27 @@
 #=================================================
 
 pkg_dependencies="sipcalc hostapd iptables iw dnsmasq"
-nonfree_packages="firmware-linux-free firmware-linux-nonfree firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware zd1211-firmware"
-free_packages="firmware-linux-free"
+nonfree_firmware_packages="firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware firmware-zd1211"
+free_firmware_packages="firmware-ath9k-htc"
 
 #=================================================
 # PERSONAL HELPERS
 #=================================================
 
+function check_armbian_nonfree_conflict()
+{
+
+  # If we're on armbian, force $firmware_nonfree
+  # because armbian-firmware conflicts with firmware-misc-nonfree package
+  if dpkg --list | grep -q armbian-firmware; then
+    echo "You are running Armbian and firmware-misc-nonfree are known to conflict with armbian-firwmare. " >&2
+    echo "The package firmware-misc-nonfree is a dependency of firmware-ralink, so firmware-ralink will NOT be installed" >&2
+    echo "You can manually install firmware-ralink with 'sudo apt -o Dpkg::Options::=\"--force-overwrite\" firmware-ralink'" >&2
+    nonfree_firmware_packages=$(echo $nonfree_firmware_packages | sed 's/ firmware-ralink//')
+  fi
+
+}
+
 #=================================================
 # EXPERIMENTAL HELPERS
 #=================================================

+ 0 - 5
scripts/backup

@@ -41,11 +41,6 @@ ynh_print_info --message="Declaring files to be backed up..."
 
 ynh_backup --src_path="$final_path"
 
-if [[ $firmware_nonfree -eq 0 ]]; then
-	ynh_backup --src_path="/lib/firmware/htc_7010.fw"
-	ynh_backup --src_path="/lib/firmware/htc_9271.fw"
-fi
-
 ynh_backup --src_path="/etc/sudoers.d/${app}_ynh"
 
 ynh_backup --src_path="/usr/local/bin/iw_multissid"

+ 3 - 16
scripts/install

@@ -59,14 +59,6 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde
 # Register (book) web path
 ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
 
-# If we're on armbian, force $firmware_nonfree
-# because armbian-firmware conflicts with the non-free packages ...
-if dpkg --list | grep -q armbian-firmware; then
-  echo "You are running Armbian and non-free firmware are known to conflict with armbian-firwmare. " >&2
-  firmware_nonfree=0
-  echo "Variable firmware_non_free has been forced to 'no'" >&2
-fi
-
 if [ $firmware_nonfree = "no" ]; then
   firmware_nonfree=0
 elif [ $firmware_nonfree = "yes" ]; then
@@ -125,15 +117,10 @@ if [[ $firmware_nonfree -eq 1 ]]; then
   if ! grep -q non-free /etc/apt/sources.list ; then
     sed '/debian/{s/main/& non-free/}' -i /etc/apt/sources.list
   fi
-  packages=$nonfree_packages
+  check_armbian_nonfree_conflict
+  packages=$nonfree_firmware_packages
 else
-  packages=$free_packages
-  # Extract from http://packages.trisquel.info/toutatis-updates/open-ath9k-htc-firmware
-  # https://www.fsf.org/news/ryf-certification-thinkpenguin-usb-with-atheros-chip
-  # https://wiki.debian.org/ath9k_htc/open_firmware
-  mkdir -p /lib/firmware
-  install -b -o root -g root -m 0644 ../conf/firmware_htc-7010.fw /lib/firmware/htc_7010.fw
-  install -b -o root -g root -m 0644 ../conf/firmware_htc-9271.fw /lib/firmware/htc_9271.fw
+  packages=$free_firmware_packages
 fi
 
 #=================================================

+ 0 - 9
scripts/remove

@@ -99,15 +99,6 @@ do
     ynh_secure_remove --file="$FILE"
 done
 
-# Remove packages
-if [[ $firmware_nonfree -eq 0 ]]; then
-  # Remove free firmwares
-  if ! dpkg -l firmware-atheros &> /dev/null; then
-    ynh_secure_remove --file="/lib/firmware/htc_7010.fw"
-    ynh_secure_remove --file="/lib/firmware/htc_9271.fw"
-  fi
-fi
-
 #=================================================
 # REMOVE NGINX CONFIGURATION
 #=================================================

+ 3 - 6
scripts/restore

@@ -62,13 +62,10 @@ if [[ $firmware_nonfree -eq 1 ]]; then
   if ! grep -q non-free /etc/apt/sources.list ; then
     sed '/debian/{s/main/& non-free/}' -i /etc/apt/sources.list
   fi
-
-  packages=$nonfree_packages
+  check_armbian_nonfree_conflict
+  packages=$nonfree_firmware_packages
 else
-  packages=$free_packages
-
-  ynh_restore_file --origin_path="/lib/firmware/htc_7010.fw"
-  ynh_restore_file --origin_path="/lib/firmware/htc_9271.fw"
+  packages=$free_firmware_packages
 fi
 
 ynh_restore_file --origin_path="/etc/sudoers.d/${app}_ynh"

+ 3 - 2
scripts/upgrade

@@ -122,9 +122,10 @@ ynh_add_nginx_config
 ynh_script_progression --message="Upgrading dependencies..."
 
 if [[ $firmware_nonfree -eq 1 ]]; then
-  packages=$nonfree_packages
+  check_armbian_nonfree_conflict
+  packages=$nonfree_firmware_packages
 else
-  packages=$free_packages
+  packages=$free_firmware_packages
 fi
 
 ynh_install_app_dependencies "$pkg_dependencies" "$packages"