diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2014-06-04 16:22:48 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2014-06-04 18:15:50 +0200 |
| commit | d3bbe992ec33860aedccb26734a7a83d263e7ec3 (patch) | |
| tree | a65e759094a771dc49b26ea59aac33bf6273c6c2 /gnu | |
| parent | 4654439be74353825fccf483b3a7827197179be6 (diff) | |
system: Tell module-init-tools where to look for modules.
* gnu/packages/linux.scm (module-init-tools)[source](patches): New
field.
* gnu/packages/patches/module-init-tools-moduledir.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/system.scm (etc-directory): Add #:kernel parameter. Set
'LINUX_MODULE_DIRECTORY' in bashrc.
(operating-system-etc-directory): Pass #:kernel to 'etc-directory'.
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/packages/linux.scm | 4 | ||||
| -rw-r--r-- | gnu/packages/patches/module-init-tools-moduledir.patch | 168 | ||||
| -rw-r--r-- | gnu/system.scm | 9 |
3 files changed, 179 insertions, 2 deletions
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 46f2178488b..518b0e41b9f 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm | |||
| @@ -133,7 +133,9 @@ | |||
| 133 | version ".tar.bz2")) | 133 | version ".tar.bz2")) |
| 134 | (sha256 | 134 | (sha256 |
| 135 | (base32 | 135 | (base32 |
| 136 | "0jxnz9ahfic79rp93l5wxcbgh4pkv85mwnjlbv1gz3jawv5cvwp1")))) | 136 | "0jxnz9ahfic79rp93l5wxcbgh4pkv85mwnjlbv1gz3jawv5cvwp1")) |
| 137 | (patches | ||
| 138 | (list (search-patch "module-init-tools-moduledir.patch"))))) | ||
| 137 | (build-system gnu-build-system) | 139 | (build-system gnu-build-system) |
| 138 | (arguments | 140 | (arguments |
| 139 | ;; FIXME: The upstream tarball lacks man pages, and building them would | 141 | ;; FIXME: The upstream tarball lacks man pages, and building them would |
diff --git a/gnu/packages/patches/module-init-tools-moduledir.patch b/gnu/packages/patches/module-init-tools-moduledir.patch new file mode 100644 index 00000000000..68d7988f532 --- /dev/null +++ b/gnu/packages/patches/module-init-tools-moduledir.patch | |||
| @@ -0,0 +1,168 @@ | |||
| 1 | This patch changes 'modprobe' & co. so they honor the 'LINUX_MODULE_DIRECTORY' | ||
| 2 | environment variable, rather than looking for modules exclusively in | ||
| 3 | /lib/modules. | ||
| 4 | |||
| 5 | Patch by David Guibert, from Nixpkgs; adjusted to use 'LINUX_MODULE_DIRECTORY' | ||
| 6 | rather than 'MODULE_DIR' as the variable name. | ||
| 7 | |||
| 8 | commit cf2c95edb7918bc658f6cae93793c1949fc9cb6e | ||
| 9 | Author: David Guibert <david.guibert@gmail.com> | ||
| 10 | Date: Fri Aug 5 14:20:12 2011 +0200 | ||
| 11 | |||
| 12 | introduce module-dir | ||
| 13 | |||
| 14 | diff --git a/depmod.c b/depmod.c | ||
| 15 | index a1d2f8c..9362a35 100644 | ||
| 16 | --- a/depmod.c | ||
| 17 | +++ b/depmod.c | ||
| 18 | @@ -48,9 +48,6 @@ | ||
| 19 | |||
| 20 | #include "testing.h" | ||
| 21 | |||
| 22 | -#ifndef MODULE_DIR | ||
| 23 | -#define MODULE_DIR "/lib/modules/" | ||
| 24 | -#endif | ||
| 25 | |||
| 26 | #ifndef MODULE_BUILTIN_KEY | ||
| 27 | #define MODULE_BUILTIN_KEY "built-in" | ||
| 28 | @@ -1516,6 +1513,7 @@ static int parse_config_file(const char *filename, | ||
| 29 | char *line; | ||
| 30 | unsigned int linenum = 0; | ||
| 31 | FILE *cfile; | ||
| 32 | + char *module_dir; | ||
| 33 | |||
| 34 | cfile = fopen(filename, "r"); | ||
| 35 | if (!cfile) { | ||
| 36 | @@ -1525,6 +1523,10 @@ static int parse_config_file(const char *filename, | ||
| 37 | return 0; | ||
| 38 | } | ||
| 39 | |||
| 40 | + if((module_dir = getenv("LINUX_MODULE_DIRECTORY")) == NULL) { | ||
| 41 | + module_dir = "/lib/modules/"; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | while ((line = getline_wrapped(cfile, &linenum)) != NULL) { | ||
| 45 | char *ptr = line; | ||
| 46 | char *cmd, *modname; | ||
| 47 | @@ -1550,7 +1552,7 @@ static int parse_config_file(const char *filename, | ||
| 48 | continue; | ||
| 49 | } | ||
| 50 | nofail_asprintf(&dirname, "%s%s%s/%s", basedir, | ||
| 51 | - MODULE_DIR, kernelversion, search_path); | ||
| 52 | + module_dir, kernelversion, search_path); | ||
| 53 | len = strlen(dirname); | ||
| 54 | *search = add_search(dirname, len, *search); | ||
| 55 | free(dirname); | ||
| 56 | @@ -1565,7 +1567,7 @@ static int parse_config_file(const char *filename, | ||
| 57 | continue; | ||
| 58 | |||
| 59 | nofail_asprintf(&pathname, "%s%s%s/%s/%s.ko", basedir, | ||
| 60 | - MODULE_DIR, kernelversion, subdir, modname); | ||
| 61 | + module_dir, kernelversion, subdir, modname); | ||
| 62 | |||
| 63 | *overrides = add_override(pathname, *overrides); | ||
| 64 | free(pathname); | ||
| 65 | @@ -1737,6 +1739,7 @@ int main(int argc, char *argv[]) | ||
| 66 | char *basedir = "", *dirname, *version; | ||
| 67 | char *system_map = NULL, *module_symvers = NULL; | ||
| 68 | int i; | ||
| 69 | + char *module_dir; | ||
| 70 | const char *config = NULL; | ||
| 71 | |||
| 72 | if (native_endianness() == 0) | ||
| 73 | @@ -1832,7 +1835,11 @@ int main(int argc, char *argv[]) | ||
| 74 | if (optind == argc) | ||
| 75 | all = 1; | ||
| 76 | |||
| 77 | - nofail_asprintf(&dirname, "%s%s%s", basedir, MODULE_DIR, version); | ||
| 78 | + if((module_dir = getenv("LINUX_MODULE_DIRECTORY")) == NULL) { | ||
| 79 | + module_dir = "/lib/modules/"; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + nofail_asprintf(&dirname, "%s%s%s", basedir, module_dir, version); | ||
| 83 | |||
| 84 | if (maybe_all) { | ||
| 85 | if (!doing_stdout && !depfile_out_of_date(dirname)) | ||
| 86 | @@ -1850,7 +1857,7 @@ int main(int argc, char *argv[]) | ||
| 87 | size_t len; | ||
| 88 | |||
| 89 | nofail_asprintf(&dirname, "%s%s%s/updates", basedir, | ||
| 90 | - MODULE_DIR, version); | ||
| 91 | + module_dir, version); | ||
| 92 | len = strlen(dirname); | ||
| 93 | search = add_search(dirname, len, search); | ||
| 94 | } | ||
| 95 | diff --git a/modinfo.c b/modinfo.c | ||
| 96 | index 1dd8469..67b1041 100644 | ||
| 97 | --- a/modinfo.c | ||
| 98 | +++ b/modinfo.c | ||
| 99 | @@ -19,9 +19,6 @@ | ||
| 100 | #include "zlibsupport.h" | ||
| 101 | #include "testing.h" | ||
| 102 | |||
| 103 | -#ifndef MODULE_DIR | ||
| 104 | -#define MODULE_DIR "/lib/modules" | ||
| 105 | -#endif | ||
| 106 | |||
| 107 | struct param | ||
| 108 | { | ||
| 109 | @@ -193,6 +190,11 @@ static struct elf_file *grab_module(const char *name, | ||
| 110 | struct utsname buf; | ||
| 111 | char *depname, *p, *moddir; | ||
| 112 | struct elf_file *module; | ||
| 113 | + char *module_dir; | ||
| 114 | + | ||
| 115 | + if((module_dir = getenv("LINUX_MODULE_DIRECTORY")) == NULL) { | ||
| 116 | + module_dir = "/lib/modules/"; | ||
| 117 | + } | ||
| 118 | |||
| 119 | if (strchr(name, '.') || strchr(name, '/')) { | ||
| 120 | module = grab_elf_file(name); | ||
| 121 | @@ -207,9 +209,9 @@ static struct elf_file *grab_module(const char *name, | ||
| 122 | kernel = buf.release; | ||
| 123 | } | ||
| 124 | if (strlen(basedir)) | ||
| 125 | - nofail_asprintf(&moddir, "%s/%s/%s", basedir, MODULE_DIR, kernel); | ||
| 126 | + nofail_asprintf(&moddir, "%s/%s/%s", basedir, module_dir, kernel); | ||
| 127 | else | ||
| 128 | - nofail_asprintf(&moddir, "%s/%s", MODULE_DIR, kernel); | ||
| 129 | + nofail_asprintf(&moddir, "%s/%s", module_dir, kernel); | ||
| 130 | |||
| 131 | /* Search for it in modules.dep. */ | ||
| 132 | nofail_asprintf(&depname, "%s/%s", moddir, "modules.dep"); | ||
| 133 | diff --git a/modprobe.c b/modprobe.c | ||
| 134 | index 5464f45..d9fbf9d 100644 | ||
| 135 | --- a/modprobe.c | ||
| 136 | +++ b/modprobe.c | ||
| 137 | @@ -86,10 +86,6 @@ typedef enum | ||
| 138 | |||
| 139 | } modprobe_flags_t; | ||
| 140 | |||
| 141 | -#ifndef MODULE_DIR | ||
| 142 | -#define MODULE_DIR "/lib/modules" | ||
| 143 | -#endif | ||
| 144 | - | ||
| 145 | /** | ||
| 146 | * print_usage - output the prefered program usage | ||
| 147 | * | ||
| 148 | @@ -2136,6 +2132,7 @@ int main(int argc, char *argv[]) | ||
| 149 | struct modprobe_conf conf = {}; | ||
| 150 | |||
| 151 | recursion_depth = 0; | ||
| 152 | + char *module_dir = NULL; | ||
| 153 | |||
| 154 | /* Prepend options from environment. */ | ||
| 155 | argv = merge_args(getenv("MODPROBE_OPTIONS"), argv, &argc); | ||
| 156 | @@ -2233,7 +2230,11 @@ int main(int argc, char *argv[]) | ||
| 157 | if (argc < optind + 1 && !dump_config && !list_only) | ||
| 158 | print_usage(argv[0]); | ||
| 159 | |||
| 160 | - nofail_asprintf(&dirname, "%s%s/%s", basedir, MODULE_DIR, buf.release); | ||
| 161 | + if((module_dir = getenv("LINUX_MODULE_DIRECTORY")) == NULL) { | ||
| 162 | + module_dir = "/lib/modules"; | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + nofail_asprintf(&dirname, "%s%s/%s", basedir, module_dir, buf.release); | ||
| 166 | |||
| 167 | /* Old-style -t xxx wildcard? Only with -l. */ | ||
| 168 | if (list_only) { | ||
diff --git a/gnu/system.scm b/gnu/system.scm index a224916c0d8..4dc6ebd5a72 100644 --- a/gnu/system.scm +++ b/gnu/system.scm | |||
| @@ -229,6 +229,7 @@ explicitly appear in OS." | |||
| 229 | This is the GNU system. Welcome.\n") | 229 | This is the GNU system. Welcome.\n") |
| 230 | 230 | ||
| 231 | (define* (etc-directory #:key | 231 | (define* (etc-directory #:key |
| 232 | kernel | ||
| 232 | (locale "C") (timezone "Europe/Paris") | 233 | (locale "C") (timezone "Europe/Paris") |
| 233 | (issue "Hello!\n") | 234 | (issue "Hello!\n") |
| 234 | (skeletons '()) | 235 | (skeletons '()) |
| @@ -255,6 +256,11 @@ export LC_ALL=\"" locale "\" | |||
| 255 | export TZ=\"" timezone "\" | 256 | export TZ=\"" timezone "\" |
| 256 | export TZDIR=\"" tzdata "/share/zoneinfo\" | 257 | export TZDIR=\"" tzdata "/share/zoneinfo\" |
| 257 | 258 | ||
| 259 | # Tell 'modprobe' & co. where to look for modules. | ||
| 260 | # XXX: The downside of doing it here is that when switching to a new config | ||
| 261 | # without rebooting, this variable possibly becomes invalid. | ||
| 262 | export LINUX_MODULE_DIRECTORY=" kernel "/lib/modules | ||
| 263 | |||
| 258 | export PATH=$HOME/.guix-profile/bin:/run/current-system/profile/bin | 264 | export PATH=$HOME/.guix-profile/bin:/run/current-system/profile/bin |
| 259 | export PATH=/run/setuid-programs:/run/current-system/profile/sbin:$PATH | 265 | export PATH=/run/setuid-programs:/run/current-system/profile/sbin:$PATH |
| 260 | export CPATH=$HOME/.guix-profile/include:" profile "/include | 266 | export CPATH=$HOME/.guix-profile/include:" profile "/include |
| @@ -317,7 +323,8 @@ alias ll='ls -l' | |||
| 317 | (append-map service-pam-services services)))) | 323 | (append-map service-pam-services services)))) |
| 318 | (profile-drv (operating-system-profile os)) | 324 | (profile-drv (operating-system-profile os)) |
| 319 | (skeletons (operating-system-skeletons os))) | 325 | (skeletons (operating-system-skeletons os))) |
| 320 | (etc-directory #:pam-services pam-services | 326 | (etc-directory #:kernel (operating-system-kernel os) |
| 327 | #:pam-services pam-services | ||
| 321 | #:skeletons skeletons | 328 | #:skeletons skeletons |
| 322 | #:issue (operating-system-issue os) | 329 | #:issue (operating-system-issue os) |
| 323 | #:locale (operating-system-locale os) | 330 | #:locale (operating-system-locale os) |
