add a depmod check -- check for updates/ preference
authorLuis R. Rodriguez <lrodriguez@atheros.com>
Mon, 18 May 2009 22:35:15 +0000 (15:35 -0700)
committerLuis R. Rodriguez <lrodriguez@atheros.com>
Mon, 18 May 2009 22:36:21 +0000 (15:36 -0700)
If your distribution lacks an /etc/depmod.d/ or /etc/depmod.conf
file we'll add one for you. By default we add the file in
/etc/depmod.d/compat-wireless.conf

We could get more granular and only add this preference for
wireless stuff but that requires some work.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Makefile
scripts/check_depmod [new file with mode: 0755]

index 234db25fde9e772fa9954de114b462f5c2bd0d08..78aebb31e5902d3ddc78f15b7e76a3562454a479 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -96,6 +96,10 @@ install: uninstall modules
        @# won't know mac80211.ko should be used instead of
        @# mac80211.ko.gz
        @./scripts/compress_modules
+       @# Mandrake doesn't have a depmod.d/ conf file to prefer
+       @# the updates/ dir which is what we use so we add one for it
+       @# (or any other distribution that doens't have this).
+       @./scripts/check_depmod
        @/sbin/depmod -ae
        @echo
        @echo "Currently detected wireless subsystem modules:"
diff --git a/scripts/check_depmod b/scripts/check_depmod
new file mode 100755 (executable)
index 0000000..212bb6e
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/bash
+# Copyright 2009       Luis R. Rodriguez <mcgrof@gmail.com>
+# 
+# Ensures your distribution likes to prefer updates/ over the kernel/
+# search updates built-in
+
+# Seems Mandriva has an $DEPMOD_DIR but it doesn't have any files,
+# so lets deal with those distributions.
+DEPMOD_CONF="/etc/depmod.conf"
+DEPMOD_DIR="/etc/depmod.d/"
+COMPAT_DEPMOD_FILE=compat-wireless.conf
+
+function add_compat_depmod_conf {
+       echo "NOTE: Your distribution lacks an $DEPMOD_DIR directory with "
+       echo "updates/ directory being prioritized for mouldes, we're adding "
+       echo "one for you."
+       mkdir -p $DEPMOD_DIR
+       echo "search updates extra built-in" > $DEPMOD_DIR/$COMPAT_DEPMOD_FILE
+}
+
+function depmod_updates_ok {
+       echo "depmod will prefer updates/ over kernel/ -- OK!"
+}
+
+function check_depmod_conf {
+       if [ -f $DEPMOD_CONF ]; then
+               grep -q updates $DEPMOD_CONF
+               return $?
+       fi
+       return 1
+}
+
+function add_depmod_conf_if_missing {
+       check_depmod_conf
+       if [[ $? -ne 0 ]]; then
+               add_compat_depmod_conf
+       else
+               depmod_updates_ok
+       fi
+}
+
+if [ -d $DEPMOD_DIR ]; then
+       DEPMOD_FILE_COUNT=$(ls $DEPMOD_DIR | wc -l)
+       if [[ $DEPMOD_FILE_COUNT -eq 0 ]]; then
+               add_depmod_conf_if_missing
+       else
+               grep -q updates $DEPMOD_DIR/*
+               if [[ $? -ne 0 ]]; then
+                       add_depmod_conf_if_missing
+               else
+                       depmod_updates_ok
+               fi
+       fi
+else
+       add_depmod_conf_if_missing
+fi