summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kmod
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2016-08-15 19:05:52 -0400
committerShea Levy <shea@shealevy.com>2016-08-15 19:05:52 -0400
commit9adad8612b082bcbae30c81678a04b79a44079a4 (patch)
tree6814d056ee2960d122842dc9c830bb411c40d5ff /pkgs/os-specific/linux/kmod
parent57b2d1e9b0dcdd1d25bd2d450174764b9417ffc1 (diff)
downloadnixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar.gz
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar.bz2
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar.lz
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar.xz
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.tar.zst
nixlib-9adad8612b082bcbae30c81678a04b79a44079a4.zip
Revert "Merge branch 'modprobe-fix' of git://github.com/abbradar/nixpkgs"
Was meant to go into staging, sorry

This reverts commit 57b2d1e9b0dcdd1d25bd2d450174764b9417ffc1, reversing
changes made to 760b2b9048ea775c319cb348d74447a20dea513e.
Diffstat (limited to 'pkgs/os-specific/linux/kmod')
-rw-r--r--pkgs/os-specific/linux/kmod/aggregator.nix2
-rw-r--r--pkgs/os-specific/linux/kmod/default.nix30
-rw-r--r--pkgs/os-specific/linux/kmod/module-dir.patch151
3 files changed, 37 insertions, 146 deletions
diff --git a/pkgs/os-specific/linux/kmod/aggregator.nix b/pkgs/os-specific/linux/kmod/aggregator.nix
index 88069ba4bf13..161af38ff608 100644
--- a/pkgs/os-specific/linux/kmod/aggregator.nix
+++ b/pkgs/os-specific/linux/kmod/aggregator.nix
@@ -21,7 +21,7 @@ buildEnv {
       # kernel version number, otherwise depmod will use `uname -r'.
       if test -w $out/lib/modules/$kernelVersion; then
           rm -f $out/lib/modules/$kernelVersion/modules.*
-          ${kmod}/bin/depmod -b $out -a $kernelVersion
+          ${kmod}/sbin/depmod -b $out -a $kernelVersion
       fi
     '';
 }
diff --git a/pkgs/os-specific/linux/kmod/default.nix b/pkgs/os-specific/linux/kmod/default.nix
index 58b0b9883512..12449a0a7dda 100644
--- a/pkgs/os-specific/linux/kmod/default.nix
+++ b/pkgs/os-specific/linux/kmod/default.nix
@@ -1,37 +1,25 @@
-{ stdenv, lib, fetchurl, autoreconfHook, xz, zlib, pkgconfig, libxslt }:
+{ stdenv, fetchurl, xz, zlib, pkgconfig, libxslt }:
 
-let
-  systems = [ "current-system" "booted-system" ];
-  modulesDirs = lib.concatMapStringsSep ":" (x: "/run/${x}/kernel-modules/lib/modules") systems;
-
-in stdenv.mkDerivation rec {
-  name = "kmod-${version}";
-  version = "22";
+stdenv.mkDerivation rec {
+  name = "kmod-22";
 
   src = fetchurl {
     url = "mirror://kernel/linux/utils/kernel/kmod/${name}.tar.xz";
     sha256 = "10lzfkmnpq6a43a3gkx7x633njh216w0bjwz31rv8a1jlgg1sfxs";
   };
 
-  nativeBuildInputs = [ autoreconfHook pkgconfig libxslt ];
-  buildInputs = [ xz /* zlib */ ];
+  buildInputs = [ pkgconfig libxslt xz /* zlib */ ];
 
-  configureFlags = [
-    "--sysconfdir=/etc"
-    "--with-xz"
-    "--with-modulesdirs=${modulesDirs}"
-    # "--with-zlib"
-  ];
+  configureFlags = [ "--sysconfdir=/etc" "--with-xz" /* "--with-zlib" */ ];
 
   patches = [ ./module-dir.patch ];
 
   postInstall = ''
-    for prog in rmmod insmod lsmod modinfo modprobe depmod; do
-      ln -sv $out/bin/kmod $out/bin/$prog
+    ln -s kmod $out/bin/lsmod
+    mkdir -p $out/sbin
+    for prog in rmmod insmod modinfo modprobe depmod; do
+      ln -sv $out/bin/kmod $out/sbin/$prog
     done
-
-    # Backwards compatibility
-    ln -s bin $out/sbin
   '';
 
   meta = {
diff --git a/pkgs/os-specific/linux/kmod/module-dir.patch b/pkgs/os-specific/linux/kmod/module-dir.patch
index f7432e3756e9..0c4ab4bd4c44 100644
--- a/pkgs/os-specific/linux/kmod/module-dir.patch
+++ b/pkgs/os-specific/linux/kmod/module-dir.patch
@@ -1,46 +1,7 @@
-diff --git a/Makefile.am b/Makefile.am
-index d4eeb7e..5c9f603 100644
---- a/Makefile.am
-+++ b/Makefile.am
-@@ -19,6 +19,7 @@ AM_CPPFLAGS = \
- 	-include $(top_builddir)/config.h \
- 	-I$(top_srcdir) \
- 	-DSYSCONFDIR=\""$(sysconfdir)"\" \
-+	-DMODULESDIRS=\""$(shell echo $(modulesdirs) | $(SED) 's|:|\\",\\"|g')"\" \
- 	${zlib_CFLAGS}
- 
- AM_CFLAGS = $(OUR_CFLAGS)
-diff --git a/configure.ac b/configure.ac
-index 23510c8..66490cf 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -202,6 +202,12 @@ GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
- ], [
- AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
- 
-+AC_ARG_WITH([modulesdirs],
-+	AS_HELP_STRING([--with-modulesdirs=DIRS], [Kernel modules directories, separated by :]),
-+	[],
-+	[with_modulesdirs=/lib/modules])
-+AC_SUBST([modulesdirs], [$with_modulesdirs])
-+
- 
- #####################################################################
- # Default CFLAGS and LDFLAGS
-diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
-index 69fe431..d37da32 100644
---- a/libkmod/libkmod.c
-+++ b/libkmod/libkmod.c
-@@ -206,12 +206,15 @@ static int log_priority(const char *priority)
- 	return 0;
- }
- 
--static const char *dirname_default_prefix = "/lib/modules";
-+static const char *dirname_default_prefixes[] = {
-+	MODULESDIRS,
-+	NULL
-+};
- 
+diff -ru -x '*~' kmod-17-orig/libkmod/libkmod.c kmod-17/libkmod/libkmod.c
+--- kmod-17-orig/libkmod/libkmod.c	2014-04-01 12:40:37.161940089 +0200
++++ kmod-17/libkmod/libkmod.c	2014-04-17 13:47:15.871441987 +0200
+@@ -201,7 +201,7 @@
  static char *get_kernel_release(const char *dirname)
  {
  	struct utsname u;
@@ -49,109 +10,51 @@ index 69fe431..d37da32 100644
  
  	if (dirname != NULL)
  		return path_make_absolute_cwd(dirname);
-@@ -219,8 +222,42 @@ static char *get_kernel_release(const char *dirname)
+@@ -209,7 +209,10 @@
  	if (uname(&u) < 0)
  		return NULL;
  
 -	if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
--		return NULL;
-+	if ((dirname_prefix = getenv("MODULE_DIR")) != NULL) {
-+		if(asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
-+			return NULL;
-+	} else {
-+		size_t i;
-+		char buf[PATH_MAX];
++	if ((dirname_prefix = getenv("MODULE_DIR")) == NULL)
++		dirname_prefix = dirname_default_prefix;
 +
-+		for (i = 0; dirname_default_prefixes[i] != NULL; i++) {
-+			int plen;
-+			struct stat dirstat;
-+
-+			plen = snprintf(buf, sizeof(buf), "%s/%s", dirname_default_prefixes[i], u.release);
-+			if (plen < 0)
-+				return NULL;
-+			else if (plen >= PATH_MAX)
-+				continue;
-+
-+			if (dirname_default_prefixes[i + 1] != NULL) {
-+				if (stat(buf, &dirstat) < 0) {
-+					if (errno == ENOENT)
-+						continue;
-+					else
-+						return NULL;
-+				}
-+
-+				if (!S_ISDIR(dirstat.st_mode))
-+					continue;
-+			}
-+
-+			p = malloc(plen + 1);
-+			if (p == NULL)
-+				return NULL;
-+			memcpy(p, buf, plen + 1);
-+			break;
-+		}
-+	}
++	if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
+ 		return NULL;
  
  	return p;
- }
-diff --git a/tools/static-nodes.c b/tools/static-nodes.c
-index 8d2356d..2ed306d 100644
---- a/tools/static-nodes.c
-+++ b/tools/static-nodes.c
-@@ -29,10 +29,11 @@
- #include <unistd.h>
- #include <sys/stat.h>
- #include <sys/types.h>
--#include <sys/utsname.h>
- 
- #include <shared/util.h>
- 
-+#include <libkmod/libkmod.h>
-+
- #include "kmod.h"
- 
- struct static_nodes_format {
-@@ -154,8 +155,8 @@ static void help(void)
- 
- static int do_static_nodes(int argc, char *argv[])
- {
--	struct utsname kernel;
- 	char modules[PATH_MAX], buf[4096];
-+	struct kmod_ctx *ctx;
- 	const char *output = "/dev/stdout";
+diff -ru -x '*~' kmod-17-orig/tools/static-nodes.c kmod-17/tools/static-nodes.c
+--- kmod-17-orig/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;
-@@ -206,22 +207,25 @@ static int do_static_nodes(int argc, char *argv[])
- 		}
- 	}
+ 	int r, ret = EXIT_SUCCESS;
++	char *dirname_prefix;
  
--	if (uname(&kernel) < 0) {
--		fputs("Error: uname failed!\n", stderr);
-+	ctx = kmod_new(NULL, NULL);
-+	if (ctx == NULL) {
-+		fprintf(stderr, "Error: failed to create kmod context\n");
- 		ret = EXIT_FAILURE;
+ 	for (;;) {
+ 		int c, idx = 0, valid;
+@@ -211,16 +212,19 @@
  		goto finish;
  	}
--
+ 
 -	snprintf(modules, sizeof(modules), "/lib/modules/%s/modules.devname", kernel.release);
-+	if (snprintf(modules, sizeof(modules), "%s/modules.devname", kmod_get_dirname(ctx)) < 0) {
-+		fprintf(stderr, "Error: path to modules.devname is too long\n");
-+		ret = EXIT_FAILURE;
-+		goto finish;
-+	}
-+	kmod_unref(ctx);
++	if ((dirname_prefix = getenv("MODULE_DIR")) == 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 not found - ignoring\n", modules);
++			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 - %m\n", modules);
++			fprintf(stderr, "Error: could not open %s/%s/modules.devname - %m\n",
++				dirname_prefix, kernel.release);
  			ret = EXIT_FAILURE;
  		}
  		goto finish;