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