aboutsummaryrefslogtreecommitdiff
This patch changes libkmod so it honors the 'LINUX_MODULE_DIRECTORY'
environment variable, rather than looking for modules exclusively in
/lib/modules.

Patch by Shea Levy and Eelco Dolstra, from Nixpkgs; adjusted to
use 'LINUX_MODULE_DIRECTORY' rather than 'MODULE_DIR' as the variable
name.


--- kmod-7/libkmod/libkmod.c	2012-03-15 08:19:16.750010226 -0400
+++ kmod-7/libkmod/libkmod.c	2012-04-04 15:21:29.532074313 -0400
@@ -200,7 +200,7 @@
 static char *get_kernel_release(const char *dirname)
 {
 	struct utsname u;
-	char *p;
+	char *p, *dirname_prefix;
 
 	if (dirname != NULL)
 		return path_make_absolute_cwd(dirname);
@@ -208,7 +208,10 @@
 	if (uname(&u) < 0)
 		return NULL;
 
-	if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
+	if ((dirname_prefix = getenv("LINUX_MODULE_DIRECTORY")) == NULL)
+		dirname_prefix = dirname_default_prefix;
+
+	if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
 		return NULL;
 
 	return p;

--- kmod-17/tools/static-nodes.c	2013-12-17 22:05:42.159047316 +0100
+++ kmod-17/tools/static-nodes.c	2014-04-17 13:51:17.945974320 +0200
@@ -159,6 +159,7 @@
 	FILE *in = NULL, *out = NULL;
 	const struct static_nodes_format *format = &static_nodes_format_human;
 	int r, ret = EXIT_SUCCESS;
+	char *dirname_prefix;
 
 	for (;;) {
 		int c, idx = 0, valid;
@@ -211,16 +212,19 @@
 		goto finish;
 	}
 
-	snprintf(modules, sizeof(modules), "/lib/modules/%s/modules.devname", kernel.release);
+	if ((dirname_prefix = getenv("LINUX_MODULE_DIRECTORY")) == NULL)
+		dirname_prefix = "/lib/modules";
+
+	snprintf(modules, sizeof(modules), "%s/%s/modules.devname", dirname_prefix, kernel.release);
 	in = fopen(modules, "re");
 	if (in == NULL) {
 		if (errno == ENOENT) {
-			fprintf(stderr, "Warning: /lib/modules/%s/modules.devname not found - ignoring\n",
-				kernel.release);
+			fprintf(stderr, "Warning: %s/%s/modules.devname not found - ignoring\n",
+				dirname_prefix, kernel.release);
 			ret = EXIT_SUCCESS;
 		} else {
-			fprintf(stderr, "Error: could not open /lib/modules/%s/modules.devname - %m\n",
-				kernel.release);
+			fprintf(stderr, "Error: could not open %s/%s/modules.devname - %m\n",
+				dirname_prefix, kernel.release);
 			ret = EXIT_FAILURE;
 		}
 		goto finish;
/span>Efraim Flashner 2018-03-20Merge branch 'master' into core-updatesMark H Weaver 2018-03-20Correct name and Email for ng0....ng0 2018-03-17Merge branch 'master' into core-updatesMark H Weaver 2018-03-16gnu: All snippets report errors using exceptions, else return #t....Mark H Weaver 2018-03-15gnu: libburn: Update to 1.4.8....Tobias Geerinckx-Rice 2018-03-15gnu: libisofs: Fix description typos....Tobias Geerinckx-Rice 2018-03-15gnu: libisofs: Update to 1.4.8....Tobias Geerinckx-Rice 2018-02-26gnu: dvdstyler: Remove hard-coded version string....Tobias Geerinckx-Rice 2018-02-19gnu: dvdstyler: Update to 3.0.4....Tobias Geerinckx-Rice 2018-02-01gnu: xorriso: Remove 'bzip2' and 'libcdio' from inputs....ng0 2018-02-01gnu: Add libisofs....ng0 2018-02-01gnu: Add libburn....ng0 2018-01-11gnu: libcdio-paranoia: Update to 10.2+0.94.2....Kei Kebreau 2018-01-11gnu: libcdio: Update to 2.0.0....Kei Kebreau 2017-12-07gnu: libcue: Update to 2.2.0....Tobias Geerinckx-Rice 2017-09-20gnu: Use 'modify-phases' syntax....Kei Kebreau 2017-09-13gnu: xorriso: Update to 1.4.8....Efraim Flashner 2017-06-20gnu: Move contents of zip module into compression module....Arun Isaac 2017-05-10gnu: Add dvdstyler....Thomas Danckaert 2017-05-10gnu: Add dvd+rw-tools....Thomas Danckaert 2017-05-10gnu: Add cdrtools....Thomas Danckaert 2017-03-30gnu: Use HTTPS for almost all gnu.org HOME-PAGEs....Tobias Geerinckx-Rice 2017-02-28gnu: Add ccd2cue...John Darrington 2017-02-03gnu: abcde: Update to 2.8.1....Efraim Flashner