rpms/module-init-tools/devel module-init-tools-3.10-multi_moddirs.patch, NONE, 1.1 .cvsignore, 1.22, 1.23 module-init-tools.spec, 1.90, 1.91 sources, 1.24, 1.25

Jon Masters jcm at fedoraproject.org
Thu Oct 1 23:39:51 UTC 2009


Author: jcm

Update of /cvs/pkgs/rpms/module-init-tools/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv9069

Modified Files:
	.cvsignore module-init-tools.spec sources 
Added Files:
	module-init-tools-3.10-multi_moddirs.patch 
Log Message:
Update to latest upstream and add a "path" option patch for depmod.

NOTE: The latter patch is under development and may change, so don't rely
      on the new "path" option yet.


module-init-tools-3.10-multi_moddirs.patch:
 depmod.c             |  208 +++++++++++++++++++++++++++++++++++++++++++++------
 doc/depmod.conf.sgml |   20 ++++
 2 files changed, 204 insertions(+), 24 deletions(-)

--- NEW FILE module-init-tools-3.10-multi_moddirs.patch ---
diff -urNp module-init-tools-3.10_orig/depmod.c module-init-tools-3.10/depmod.c
--- module-init-tools-3.10_orig/depmod.c	2009-06-23 04:06:03.000000000 -0400
+++ module-init-tools-3.10/depmod.c	2009-10-01 19:34:18.000000000 -0400
@@ -36,6 +36,10 @@
 #define MODULE_DIR "/lib/modules/"
 #endif
 
+#ifndef CURRENT_KERNEL_KEY
+#define CURRENT_KERNEL_KEY "current-kernel"
+#endif
+
 #ifndef MODULE_BUILTIN_KEY
 #define MODULE_BUILTIN_KEY "built-in"
 #endif
@@ -49,6 +53,16 @@ struct module_overrides
 	char *modfile;
 };
 
+struct module_path
+{
+	/* Next path */
+	struct module_path *next;
+
+	/* module path */
+	char *path;
+	size_t len;
+};
+
 struct module_search
 {
 	/* Next search */
@@ -618,21 +632,28 @@ static struct module *grab_dir(const cha
 	return next;
 }
 
-static struct module *grab_basedir(const char *dirname,
+static struct module *grab_basedir(struct module_path *modpaths,
 				   struct module_search *search,
 				   struct module_overrides *overrides)
 {
 	DIR *dir;
 	struct module *list;
+	struct module_path *mod_path;
 
-	dir = opendir(dirname);
-	if (!dir) {
-		warn("Couldn't open directory %s: %s\n",
-		     dirname, strerror(errno));
-		return NULL;
+	for (mod_path = modpaths; mod_path != NULL;
+	     mod_path = mod_path->next) {
+	
+		dir = opendir(mod_path->path);
+		if (!dir) {
+			warn("Couldn't open directory %s: %s\n",
+		    	 mod_path->path, strerror(errno));
+			continue;
+		} else {
+			list = grab_dir(mod_path->path, dir, list, do_module,
+					search, overrides);
+			closedir(dir);
+		}
 	}
-	list = grab_dir(dirname, dir, NULL, do_module, search, overrides);
-	closedir(dir);
 
 	return list;
 }
@@ -984,6 +1005,22 @@ static char *strsep_skipspace(char **str
 	return strsep(string, delim);
 }
 
+static struct module_path *add_path(const char *path,
+				    size_t len,
+				    struct module_path *paths)
+{
+
+	struct module_path *new;
+	
+	new = NOFAIL(malloc(sizeof(*new)));
+	new->path = NOFAIL(strdup(path));
+	new->len = len;
+	new->next = paths;
+
+	return new;
+	
+}
+
 static struct module_search *add_search(const char *search_path,
 					size_t len,
 					struct module_search *search)
@@ -1000,6 +1037,42 @@ static struct module_search *add_search(
 	
 }
 
+static struct module_search *add_search_tail(const char *search_path,
+					     size_t len,
+					     struct module_search *search)
+{
+
+	struct module_search *new;
+	struct module_search *last;
+
+	new = NOFAIL(malloc(sizeof(*new)));
+	new->search_path = NOFAIL(strdup(search_path));
+	new->len = len;
+	new->next = NULL;
+
+	if (!search) {
+		search = new;
+	} else {
+		for (last = search; (last != NULL) && (last->next != NULL);
+	     	     last = last->next);
+		last->next = new;
+	}
+
+	return search;
+}
+
+struct module_search *free_search(struct module_search *search)
+{
+	if (search) {
+		free_search(search->next);
+		free(search->search_path);
+		free(search);
+		search = NULL;
+	}
+
+	return NULL;
+}
+
 static struct module_overrides *add_override(const char *modfile,
 					     struct module_overrides *overrides)
 {
@@ -1017,12 +1090,14 @@ static struct module_overrides *add_over
 static int parse_config_scan(const char *filename,
 			     const char *basedir,
 			     const char *kernelversion,
+			     struct module_path **modpaths,
 			     struct module_search **search,
 			     struct module_overrides **overrides);
 
 static int parse_config_file(const char *filename,
 			     const char *basedir,
 			     const char *kernelversion,
+			     struct module_path **modpaths,
 			     struct module_search **search,
 			     struct module_overrides **overrides)
 {
@@ -1049,7 +1124,30 @@ static int parse_config_file(const char 
 			continue;
 		}
 
-		if (streq(cmd, "search")) {
+		if (streq(cmd, "path")) {
+			char *mod_path, *sstr;
+
+			while ((mod_path = strsep_skipspace(&ptr, "\t "))) {
+
+				if ((sstr = strstr(mod_path,
+						 CURRENT_KERNEL_KEY))) {
+					char *new_path;
+
+					sstr[0] = '\0';
+					nofail_asprintf(&new_path, "%s%s%s",
+					     mod_path,
+					     kernelversion,
+					     &sstr[strlen(CURRENT_KERNEL_KEY)]);
+					*modpaths = add_path(new_path,
+							     strlen(new_path),
+							     *modpaths);
+				} else {
+					*modpaths = add_path(mod_path,
+							     strlen(mod_path),
+							     *modpaths);
+				}
+			}
+		} else if (streq(cmd, "search")) {
 			char *search_path;
 			
 			while ((search_path = strsep_skipspace(&ptr, "\t "))) {
@@ -1062,8 +1160,8 @@ static int parse_config_file(const char 
 							     0, *search);
 					continue;
 				}
-				nofail_asprintf(&dirname, "%s%s%s/%s", basedir,
-					MODULE_DIR, kernelversion, search_path);
+				nofail_asprintf(&dirname, "%s",
+						search_path);
 				len = strlen(dirname);
 				*search = add_search(dirname, len, *search);
 				free(dirname);
@@ -1096,9 +1194,12 @@ static int parse_config_file(const char 
 					warn("\"include /etc/depmod.d\" is "
 					     "the default, ignored\n");
 				} else {
-					if (!parse_config_scan(newfilename, basedir,
+					if (!parse_config_scan(newfilename,
+							       basedir,
 							       kernelversion,
-							       search, overrides))
+							       modpaths,
+							       search,
+							       overrides))
 					warn("Failed to open included"
 					     " config file %s: %s\n",
 					     newfilename, strerror(errno));
@@ -1130,6 +1231,7 @@ static int parse_config_file(const char 
 static int parse_config_scan(const char *filename,
 			     const char *basedir,
 			     const char *kernelversion,
+			     struct module_path **modpaths,
 			     struct module_search **search,
 			     struct module_overrides **overrides)
 {
@@ -1177,7 +1279,7 @@ static int parse_config_scan(const char 
 
 			nofail_asprintf(&cfgfile, "%s/%s", filename, fe->name);
 			if (!parse_config_file(cfgfile, basedir, kernelversion,
-					       search, overrides))
+					       modpaths, search, overrides))
 				warn("Failed to open config file "
 				     "%s: %s\n", fe->name, strerror(errno));
 			free(cfgfile);
@@ -1187,8 +1289,8 @@ static int parse_config_scan(const char 
 
 		ret = 1;
 	} else {
-		if (parse_config_file(filename, basedir, kernelversion, search,
-				      overrides))
+		if (parse_config_file(filename, basedir, kernelversion,
+				      modpaths, search, overrides))
 			ret = 1;
 	}
 
@@ -1198,12 +1300,13 @@ static int parse_config_scan(const char 
 static void parse_toplevel_config(const char *filename,
 				  const char *basedir,
 				  const char *kernelversion,
+				  struct module_path **modpaths,
 				  struct module_search **search,
 				  struct module_overrides **overrides)
 {
 	if (filename) {
-		if (!parse_config_scan(filename, basedir, kernelversion, search,
-				 overrides))
+		if (!parse_config_scan(filename, basedir, kernelversion,
+				       modpaths, search, overrides))
 			fatal("Failed to open config file %s: %s\n",
 			      filename, strerror(errno));
 		return;
@@ -1211,19 +1314,59 @@ static void parse_toplevel_config(const 
 
 	/* deprecated config file */
 	if (parse_config_file("/etc/depmod.conf", basedir, kernelversion,
-			      search, overrides) > 0)
+			      modpaths, search, overrides) > 0)
 		warn("Deprecated config file /etc/depmod.conf, "
 		      "all config files belong into /etc/depmod.d/.\n");
 
 	/* default config */
 	parse_config_scan("/etc/depmod.d", basedir, kernelversion,
-			  search, overrides);
+			  modpaths, search, overrides);
+}
+
+static struct module_search *expand_search_paths(struct module_search *search,
+					  struct module_path *modpaths)
+{
+	struct module_path *mod_path;
+	struct module_search *new_search, *tmp_search;
+	char *new_path;
+	ssize_t len;
+	int done_builtin = 0;
+
+	for (tmp_search = search; tmp_search != NULL;
+	     tmp_search = tmp_search->next) {
+		for (mod_path = modpaths; mod_path != NULL;
+		     mod_path = mod_path->next) {
+			
+			if (streq(tmp_search->search_path,
+				  MODULE_BUILTIN_KEY)) {
+				if (!done_builtin) {
+				done_builtin = 1;
+				new_search = add_search_tail(MODULE_BUILTIN_KEY,
+							     0, new_search);
+				}
+			} else {
+				nofail_asprintf(&new_path, "%s/%s",
+						mod_path->path,
+						tmp_search->search_path);
+				len = strlen(new_path);
+				new_search = add_search_tail(new_path, len,
+							     new_search);
+				free(new_path);
+			}
+		}
+	}
+
+	/* free old list */
+	search = free_search(search);
+
+	return new_search;
 }
 
 /* Local to main, but not freed on exit.  Keep valgrind quiet. */
 struct module *list = NULL;
 struct module_search *search = NULL;
 struct module_overrides *overrides = NULL;
+struct module_path *modpaths = NULL;
 
 int main(int argc, char *argv[])
 {
@@ -1329,7 +1472,22 @@ int main(int argc, char *argv[])
 		all = 1;
 	}
 
-	parse_toplevel_config(config, basedir, version, &search, &overrides);
+	parse_toplevel_config(config, basedir, version,
+			      &modpaths, &search, &overrides);
+
+	/* For backward compatibility add the current kernel to the head of
+         * the path list here. But only if no "path" option specified.
+         */
+	if (!modpaths) {
+		char *mod_path;
+		size_t len;
+
+		nofail_asprintf(&mod_path, "%s%s%s", basedir,
+				MODULE_DIR, version);
+		
+		len = strlen(mod_path);
+		modpaths = add_path(mod_path, len, modpaths);
+	}
 
 	/* For backward compatibility add "updates" to the head of the search
 	 * list here. But only if there was no "search" option specified.
@@ -1338,11 +1496,13 @@ int main(int argc, char *argv[])
 		char *dirname;
 		size_t len;
 
-		nofail_asprintf(&dirname, "%s%s%s/updates", basedir,
-				MODULE_DIR, version);
+		nofail_asprintf(&dirname, "updates");
 		len = strlen(dirname);
 		search = add_search(dirname, len, search);
 	}
+
+	search = expand_search_paths(search, modpaths);
+
 	if (!all) {
 		/* Do command line args. */
 		for (opt = optind; opt < argc; opt++) {
@@ -1361,7 +1521,7 @@ int main(int argc, char *argv[])
 			list = new;
 		}
 	} else {
-		list = grab_basedir(dirname,search,overrides);
+		list = grab_basedir(modpaths,search,overrides);
 	}
 	list = sort_modules(dirname,list);
 	list = parse_modules(list);
diff -urNp module-init-tools-3.10_orig/doc/depmod.conf.sgml module-init-tools-3.10/doc/depmod.conf.sgml
--- module-init-tools-3.10_orig/doc/depmod.conf.sgml	2009-06-23 03:36:25.000000000 -0400
+++ module-init-tools-3.10/doc/depmod.conf.sgml	2009-10-01 19:34:28.000000000 -0400
@@ -51,6 +51,26 @@
     <title>COMMANDS</title>
     <variablelist>
       <varlistentry>
+        <term>path <replaceable>subdirectory...</replaceable>
+        </term>
+        <listitem>
+          <para>
+            This allows you to specify additional directories (other than
+            the default of /lib/modules) that will be searched and indexed
+            for available modules by <command>depmod</command>. This option
+            can be used in combination with the <command>search</command>
+            option (which configures behavior within a given directory
+            specified using the <command>path</command> option).
+          </para>
+          <para>
+            By default, <command>depmod</command> will search the standard
+            system /lib/modules/kernelversion directory for modules, but
+            you can use this option to have it index additional directories
+            that may be on an entirely different filesystem.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
         <term>search <replaceable>subdirectory...</replaceable>
         </term>
 	<listitem>


Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/module-init-tools/devel/.cvsignore,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -p -r1.22 -r1.23
--- .cvsignore	27 May 2009 18:54:34 -0000	1.22
+++ .cvsignore	1 Oct 2009 23:39:45 -0000	1.23
@@ -1,2 +1,2 @@
-module-init-tools-3.9.tar.bz2
-module-init-tools-3.9.tar.bz2.sign
+module-init-tools-3.10.tar.bz2
+module-init-tools-3.10.tar.bz2.sign


Index: module-init-tools.spec
===================================================================
RCS file: /cvs/pkgs/rpms/module-init-tools/devel/module-init-tools.spec,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -p -r1.90 -r1.91
--- module-init-tools.spec	16 Sep 2009 04:19:45 -0000	1.90
+++ module-init-tools.spec	1 Oct 2009 23:39:46 -0000	1.91
@@ -1,8 +1,8 @@
 Summary: Kernel module management utilities.
 Name: module-init-tools
-Version: 3.9
+Version: 3.10
 #define PreRelease
-Release: 3%{?dist}
+Release: 1%{?dist}
 License: GPLv2+
 Group: System Environment/Kernel
 #Source: http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-%{version}%{PreRelease}.tar.bz2
@@ -13,6 +13,7 @@ Source2: modprobe-dist.conf
 Source3: weak-modules
 Source4: depmod-dist.conf
 Source5: modprobe-dist-oss.conf
+Patch0: module-init-tools-3.10-multi_moddirs.patch
 Exclusiveos: Linux
 Prereq: /sbin/chkconfig sh-utils
 Obsoletes: modutils-devel modutils
@@ -30,6 +31,7 @@ are two examples of loaded and unloaded 
 %prep
 #setup -q -n module-init-tools-%{version}%{PreRelease}
 %setup -q -n module-init-tools-%{version}
+%patch0 -p1 -b .multi_moddirs
 
 %build
 export CC=gcc
@@ -85,6 +87,9 @@ fi
 %ghost %config(noreplace) %verify(not md5 size mtime) /etc/modprobe.d/local.conf
 
 %changelog
+* Thu Oct  1 2009 Jon Masters <jcm at jonmasters.org> - 3.10-1
+- Rebuild with latest upstream. Add a patch for "path" options.
+
 * Wed Sep 16 2009 Jon Masters <jcm at redhat.com> -3.9-3
 - Sync weak-modules with RHEL.
 


Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/module-init-tools/devel/sources,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -p -r1.24 -r1.25
--- sources	27 May 2009 18:54:34 -0000	1.24
+++ sources	1 Oct 2009 23:39:46 -0000	1.25
@@ -1,2 +1,2 @@
-738db2580f664795f05975846e53b298  module-init-tools-3.9.tar.bz2
-8485990039584dcfab7b870672e958b3  module-init-tools-3.9.tar.bz2.sign
+fcde0344ad07c4ae2ae6b40918fd092d  module-init-tools-3.10.tar.bz2
+973178e2969ac5354196bd5c2ff68ebe  module-init-tools-3.10.tar.bz2.sign




More information about the fedora-extras-commits mailing list