All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Macko <rmacko72@gmail.com>
To: "Luis R. Rodriguez" <mcgrof@gmail.com>
Cc: reinette chatre <reinette.chatre@intel.com>,
	linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [Linux Wireless] Update of "en/users/Download" by ReinetteChatre
Date: Fri, 31 Jul 2009 17:19:52 -0400	[thread overview]
Message-ID: <4A735FF8.7000503@gmail.com> (raw)
In-Reply-To: <43e72e890907301831ped2ea3wd5173b95be54f912@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3646 bytes --]

Hi Luis,

here is promised patch

roman

Luis R. Rodriguez wrote:
> On Thu, Jul 30, 2009 at 6:20 PM, Roman Macko<rmacko72@gmail.com> wrote:
>   
>> Hi Luis,
>>
>> I have version 3.6 of module-init-tools and this version reads /etc/depmod.d
>> directory too.
>>
>> But I wanted to understand how depmod reads config files, so I looked into
>> source codes (both version 3.6 and 3.10)
>> and finally found out how it works.
>>
>> Assume depmod is run without -C or --config option
>>
>> Version 3.6 reads firstly /etc/depmod.conf file and then it reads config
>> files in directory /etc/depmod.d.
>> Files in directory /etc/depmod.d are read and parsed in unpredictable order
>> by readdir function (this function uses
>> raw directory structures of filesystem)
>>
>> Version 3.10 reads /etc/depmod.conf firstly as well, but this config file is
>> considered as deprecated in this version
>> and prints out warning about that. Then it reads config files in directory
>> /etc/depmod.d by readdir function as well, but before it starts
>> to parse them, it sorts them accord to filename, so you know the order in
>> which they are going to be parsed
>> and this is very improtant!!! This behavior should be from version 3.7
>>
>> The same for both versions:
>> 1) List of directories to be searched is created from search commands from
>> all config files in order how particular
>> search commands are found in config files (so order of parsed config files
>> is important). If no search command is found,
>> updates directory is added before "built-in" directory.
>>
>> 2) As for override command, the last one found for particular module and
>> kernel in all config files wins,
>> so again the order of parsed config files is important.
>>
>> From this is evident, that both versions can work differently which depends
>> on the order of parsed config files from
>> /etc/depmod.d directory that is different in both versions.
>>
>> So solution would be:
>> 1) if there is no search command in any of config files (in /etc/depmod.conf
>>  or those in /etc/depmod.d directory), do nothing.
>> 2) if there is a search command in any of config files and does not contain
>> updates directory before built-in add search command
>>   "search updates" in
>>  a) if system has version >=3.7, create config file in /etc/depmod.d
>> directory which name is alphabeticaly less than all you will find
>>     in that directory
>>  b) if system has version <=3.6 add search command "search updates" at the
>> begining of /etc/depmod.conf file
>>
>> But such adding of "search updates" can break depmod configuration in some
>> systems or it is not desirable to make search in
>> updates directory at all. So maybe it would be better to use another name
>> for directory than updates
>>
>> Or it would be also interesting to use override command for all modules
>> compiled in compat-wireless
>> and put it all to configuration file /etc/depmod.d/compat-wireless.conf and
>> not bothering with version of depmod nor
>> finding the search command in all configuration files, e.g
>>
>> compat-wireless.conf
>> ======================================
>> override iwlagn * updates/drivers/net/wireless/iwlwifi
>> override iwlcore * updates/drivers/net/wireless/iwlwifi
>> ....
>> ....
>> ....
>> ======================================
>>
>> it can make problem only when some other config file in /etc/depmod.d
>> directory contains override command for
>> any module from compat-wireless
>>
>>
>> I hope this help you
>>     
>
> Thanks, since you have read this and can read code, mind putting
> together a patch for the script on compat-wireless?
>
>   Luis
>   


[-- Attachment #2: check_depmod.patch --]
[-- Type: text/plain, Size: 3270 bytes --]

--- compat-wireless-2009-07-31/scripts/check_depmod	2009-07-31 10:42:52.000000000 -0400
+++ compat-wireless-patch/scripts/check_depmod	2009-07-31 16:30:22.000000000 -0400
@@ -7,50 +7,77 @@
 # 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_CONF_TMP="$DEPMOD_CONF.compat-wireless.old"
 DEPMOD_DIR="/etc/depmod.d/"
 COMPAT_DEPMOD_FILE=compat-wireless.conf
+GREP_REGEX_UPDATES="^[[:space:]]*search.*[[:space:]]updates\([[:space:]]\|$\)"
+GREP_REGEX_SEARCH="^[[:space:]]*search[[:space:]].\+$"
+DEPMOD_CMD="depmod"
 
 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 "updates/ directory being prioritized for modules, we're adding "
 	echo "one for you."
 	mkdir -p $DEPMOD_DIR
-	echo "search updates extra built-in" > $DEPMOD_DIR/$COMPAT_DEPMOD_FILE
+	FIRST_FILE=$(ls $DEPMOD_DIR|head -1)
+	[ -n "$FIRST_FILE" ] && while [[ $FIRST_FILE < $COMPAT_DEPMOD_FILE ]]; do
+		COMPAT_DEPMOD_FILE="0$COMPAT_DEPMOD_FILE"
+	done
+	echo "search updates" > $DEPMOD_DIR/$COMPAT_DEPMOD_FILE
 }
 
-function depmod_updates_ok {
-	echo "depmod will prefer updates/ over kernel/ -- OK!"
+function add_global_depmod_conf {
+	echo "NOTE: Your distribution lacks updates/ directory being"
+ 	echo "prioritized for modules, we're adding it to $DEPMOD_CONF."
+	rm -f $DEPMOD_CONF_TMP
+	[ -f $DEPMOD_CONF ] && cp -f $DEPMOD_CONF $DEPMOD_CONF_TMP
+	echo "search updates" > $DEPMOD_CONF
+	[ -f $DEPMOD_CONF_TMP ] && cat $DEPMOD_CONF_TMP >> $DEPMOD_CONF
 }
 
-function check_depmod_conf {
-	if [ -f $DEPMOD_CONF ]; then
-		grep -q updates $DEPMOD_CONF
-		return $?
-	fi
-	return 1
+function depmod_updates_ok {
+	echo "depmod will prefer updates/ over kernel/ -- OK!"
 }
 
-function add_depmod_conf_if_missing {
-	check_depmod_conf
-	if [[ $? -ne 0 ]]; then
-		add_compat_depmod_conf
+function add_depmod_conf {
+	if [ -f "$DEPMOD_CONF" ]; then
+		add_global_depmod_conf
 	else
-		depmod_updates_ok
+		DEPMOD_VERSION=$($DEPMOD_CMD --version | cut -d" " -f2 | sed "s/\.//")
+		if [[ $DEPMOD_VERSION -gt 36 ]]; then
+			add_compat_depmod_conf
+		else
+			add_global_depmod_conf
+		fi
 	fi
 }
 
+# =============================================================================
+# === MAIN ====================================================================
+# =============================================================================
+
+GREP_FILES=""
+[ -f $DEPMOD_CONF ] && GREP_FILES="$DEPMOD_CONF"
 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_FILE_COUNT -gt 0 ]] && GREP_FILES="$GREP_FILES $DEPMOD_DIR/*"
+fi
+
+if [ -n "$GREP_FILES" ]; then
+	grep -q "$GREP_REGEX_SEARCH" $GREP_FILES
+	if [[ $? -eq 0 ]]; then
+		grep -q "$GREP_REGEX_UPDATES" $GREP_FILES
+		if [[ $? -eq 0 ]]; then
 			depmod_updates_ok
+		else
+			add_depmod_conf
 		fi
+	else
+		depmod_updates_ok
 	fi
 else
-	add_depmod_conf_if_missing
+	depmod_updates_ok
 fi
+
+exit 0
+

  parent reply	other threads:[~2009-07-31 21:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090729214510.31738.90990@cl-1649.ham-01.de.sixxs.net>
2009-07-29 21:53 ` [Linux Wireless] Update of "en/users/Download" by ReinetteChatre Luis R. Rodriguez
2009-07-29 21:57   ` reinette chatre
2009-07-29 22:04     ` Luis R. Rodriguez
2009-07-30 13:12       ` Roman Macko
2009-07-30 14:43         ` Luis R. Rodriguez
2009-07-30 16:59           ` Roman Macko
2009-07-30 17:06             ` Luis R. Rodriguez
2009-07-31  1:20               ` Roman Macko
2009-07-31  1:31                 ` Luis R. Rodriguez
2009-07-31 14:36                   ` Roman Macko
2009-07-31 21:19                   ` Roman Macko [this message]
2009-07-31 23:36                     ` Luis R. Rodriguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A735FF8.7000503@gmail.com \
    --to=rmacko72@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mcgrof@gmail.com \
    --cc=reinette.chatre@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.