Harald Hoyer b3dfe7
From 04fa94987767a035ebcf7a4bb46f1356e709d9e8 Mon Sep 17 00:00:00 2001
Harald Hoyer b3dfe7
From: Harald Hoyer <harald@hoyer.xyz>
Harald Hoyer b3dfe7
Date: Tue, 10 Oct 2017 13:29:41 +0200
Harald Hoyer b3dfe7
Subject: [PATCH] Merge pull request #284 from sm00th/kmoddir
Peter Robinson 56abad
Harald Hoyer b3dfe7
dracut-install: fix relative paths in --kerneldir
Peter Robinson 56abad
---
Harald Hoyer b3dfe7
 install/dracut-install.c | 15 ++++++++-------
Harald Hoyer b3dfe7
 1 file changed, 8 insertions(+), 7 deletions(-)
Peter Robinson 56abad
Harald Hoyer b3dfe7
diff --git a/install/dracut-install.c b/install/dracut-install.c
Harald Hoyer b3dfe7
index 2c20b491..95425e8d 100644
Harald Hoyer b3dfe7
--- a/install/dracut-install.c
Harald Hoyer b3dfe7
+++ b/install/dracut-install.c
Harald Hoyer b3dfe7
@@ -933,13 +933,6 @@ static int parse_argv(int argc, char *argv[])
Harald Hoyer b3dfe7
                         break;
Harald Hoyer b3dfe7
                 case ARG_KERNELDIR:
Harald Hoyer b3dfe7
                         kerneldir = strdup(optarg);
Harald Hoyer b3dfe7
-                        if ((strncmp("/lib/modules/", kerneldir, 13) != 0)
Harald Hoyer b3dfe7
-                            && (strncmp("/usr/lib/modules/", kerneldir, 17) != 0)) {
Harald Hoyer b3dfe7
-                                char *p;
Harald Hoyer b3dfe7
-                                p = strstr(kerneldir, "/lib/modules/");
Harald Hoyer b3dfe7
-                                if (p != NULL)
Harald Hoyer b3dfe7
-                                        kerneldirlen = p - kerneldir;
Harald Hoyer b3dfe7
-                        }
Harald Hoyer b3dfe7
                         break;
Harald Hoyer b3dfe7
                 case ARG_FIRMWAREDIRS:
Harald Hoyer b3dfe7
                         firmwaredirs = strv_split(optarg, ":");
Harald Hoyer b3dfe7
@@ -1399,9 +1392,17 @@ static int install_modules(int argc, char **argv)
Harald Hoyer b3dfe7
         struct kmod_module *mod = NULL, *mod_o = NULL;
Harald Hoyer b3dfe7
 
Harald Hoyer b3dfe7
         const char *modname = NULL;
Harald Hoyer b3dfe7
+        char *abskpath = NULL;
Harald Hoyer b3dfe7
+        char *p;
Harald Hoyer b3dfe7
         int i;
Harald Hoyer b3dfe7
 
Harald Hoyer b3dfe7
         ctx = kmod_new(kerneldir, NULL);
Harald Hoyer b3dfe7
+        abskpath = kmod_get_dirname(ctx);
Harald Hoyer b3dfe7
+
Harald Hoyer b3dfe7
+        p = strstr(abskpath, "/lib/modules/");
Harald Hoyer b3dfe7
+        if (p != NULL)
Harald Hoyer b3dfe7
+                kerneldirlen = p - abskpath;
Harald Hoyer b3dfe7
+
Harald Hoyer b3dfe7
         if (arg_hostonly) {
Harald Hoyer b3dfe7
                 char *modalias_file;
Harald Hoyer b3dfe7
                 modalias_file = getenv("DRACUT_KERNEL_MODALIASES");
Peter Robinson 56abad