From: Luis R. Rodriguez Date: Mon, 18 May 2009 22:35:15 +0000 (-0700) Subject: add a depmod check -- check for updates/ preference X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=f28a63413564ffa18da05ea53cb44909b97d3b4d;p=openwrt%2Fstaging%2Fblogic.git add a depmod check -- check for updates/ preference 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 --- diff --git a/Makefile b/Makefile index 234db25fde9e..78aebb31e590 100644 --- 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 index 000000000000..212bb6e61b9f --- /dev/null +++ b/scripts/check_depmod @@ -0,0 +1,56 @@ +#!/bin/bash +# Copyright 2009 Luis R. Rodriguez +# +# 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