2 # Copyright 2009 Luis R. Rodriguez <mcgrof@gmail.com>
4 # Ensures your distribution likes to prefer updates/ over the kernel/
5 # search updates built-in
7 # Seems Mandriva has an $DEPMOD_DIR but it doesn't have any files,
8 # so lets deal with those distributions.
9 DEPMOD_CONF="/etc/depmod.conf"
10 DEPMOD_CONF_TMP="$DEPMOD_CONF.compat-wireless.old"
11 DEPMOD_DIR="/etc/depmod.d/"
12 COMPAT_DEPMOD_FILE=compat-wireless.conf
13 GREP_REGEX_UPDATES="^[[:space:]]*search.*[[:space:]]updates\([[:space:]]\|$\)"
14 GREP_REGEX_SEARCH="^[[:space:]]*search[[:space:]].\+$"
17 function add_compat_depmod_conf {
18 echo "NOTE: Your distribution lacks an $DEPMOD_DIR directory with "
19 echo "updates/ directory being prioritized for modules, we're adding "
22 FIRST_FILE=$(ls $DEPMOD_DIR|head -1)
23 [ -n "$FIRST_FILE" ] && while [[ $FIRST_FILE < $COMPAT_DEPMOD_FILE ]]; do
24 COMPAT_DEPMOD_FILE="0$COMPAT_DEPMOD_FILE"
26 echo "search updates" > $DEPMOD_DIR/$COMPAT_DEPMOD_FILE
29 function add_global_depmod_conf {
30 echo "NOTE: Your distribution lacks updates/ directory being"
31 echo "prioritized for modules, we're adding it to $DEPMOD_CONF."
32 rm -f $DEPMOD_CONF_TMP
33 [ -f $DEPMOD_CONF ] && cp -f $DEPMOD_CONF $DEPMOD_CONF_TMP
34 echo "search updates" > $DEPMOD_CONF
35 [ -f $DEPMOD_CONF_TMP ] && cat $DEPMOD_CONF_TMP >> $DEPMOD_CONF
38 function depmod_updates_ok {
39 echo "depmod will prefer updates/ over kernel/ -- OK!"
42 function add_depmod_conf {
43 if [ -f "$DEPMOD_CONF" ]; then
44 add_global_depmod_conf
46 DEPMOD_VERSION=$($DEPMOD_CMD --version | cut -d" " -f2 | sed "s/\.//")
47 if [[ $DEPMOD_VERSION -gt 36 ]]; then
48 add_compat_depmod_conf
50 add_global_depmod_conf
55 # =============================================================================
56 # === MAIN ====================================================================
57 # =============================================================================
60 [ -f $DEPMOD_CONF ] && GREP_FILES="$DEPMOD_CONF"
61 if [ -d $DEPMOD_DIR ]; then
62 DEPMOD_FILE_COUNT=$(ls $DEPMOD_DIR | wc -l)
63 [[ $DEPMOD_FILE_COUNT -gt 0 ]] && GREP_FILES="$GREP_FILES $DEPMOD_DIR/*"
66 if [ -n "$GREP_FILES" ]; then
67 grep -q "$GREP_REGEX_SEARCH" $GREP_FILES
68 if [[ $? -eq 0 ]]; then
69 grep -q "$GREP_REGEX_UPDATES" $GREP_FILES
70 if [[ $? -eq 0 ]]; then