backports: add support for module compression
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>
Wed, 10 Apr 2013 11:35:24 +0000 (04:35 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 10 Apr 2013 20:22:04 +0000 (22:22 +0200)
Some Linux distributions like to compress their modules.
Add support to detect this in a modutils / modprobe agnostic
way.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
[refactor to just a single script]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
backport/Makefile.real
backport/scripts/compress_modules.sh [new file with mode: 0755]

index 032a8d755539f2c24d1c17c3f40b1f48549b2b57..d79aafc13f3203e6a97c6f3dd25218fdbcd41d38 100644 (file)
@@ -88,13 +88,13 @@ install: modules
                INSTALL_MOD_DIR=$(KMODDIR) $(KMODPATH_ARG)              \
                modules_install
        @./scripts/blacklist.sh $(KLIB)/ $(KLIB)/$(KMODDIR)
+       @./scripts/compress_modules.sh $(KLIB)/$(KMODDIR)
        @/sbin/depmod -ae
        @echo
        @echo Your backported driver modules should be installed now.
        @echo Try loading them with modprobe.
        @echo
 # FIXME:
-#      compress modules
 #      check depmod
 #      install/load/unload/... scripts?
 #      compat firmware class udev stuff
diff --git a/backport/scripts/compress_modules.sh b/backport/scripts/compress_modules.sh
new file mode 100755 (executable)
index 0000000..31cd1d4
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+set -e
+
+function mod_filename()
+{
+       which modinfo > /dev/null 2>&1
+       if [[ $? -eq 0 ]]; then
+               MOD_QUERY="modinfo -F filename"
+       else
+               MOD_QUERY="modprobe -l"
+       fi
+       mod_path="$($MOD_QUERY $1 | tail -1)"
+       echo $(basename "$mod_path")
+}
+
+test "$(mod_filename mac80211)" = "mac80211.ko.gz" &&
+       for driver in $(find "$1" -type f -name *.ko); do
+               gzip -9 $driver
+       done