b3cd9f
From e6cb22f2d12dfe61abf32389fa7d8927105081e2 Mon Sep 17 00:00:00 2001
b3cd9f
From: David Tardon <dtardon@redhat.com>
b3cd9f
Date: Mon, 30 Aug 2021 10:02:22 +0200
b3cd9f
Subject: [PATCH] fix(install): extend hwcaps library handling to libraries
b3cd9f
 under glibc-hwcaps/
b3cd9f
b3cd9f
(cherry picked from commit 10ed204f873f454dcd15ffcc82dc3a1c781c1514)
b3cd9f
b3cd9f
Resolves: #1983030
b3cd9f
---
b3cd9f
 install/dracut-install.c | 17 +++++++++++++----
b3cd9f
 1 file changed, 13 insertions(+), 4 deletions(-)
b3cd9f
b3cd9f
diff --git a/install/dracut-install.c b/install/dracut-install.c
b3cd9f
index baf6dcff..4962316d 100644
b3cd9f
--- a/install/dracut-install.c
b3cd9f
+++ b/install/dracut-install.c
b3cd9f
@@ -335,8 +335,8 @@ static int cp(const char *src, const char *dst)
b3cd9f
 static int library_install(const char *src, const char *lib)
b3cd9f
 {
b3cd9f
         _cleanup_free_ char *p = NULL;
b3cd9f
-        _cleanup_free_ char *pdir = NULL, *ppdir = NULL, *clib = NULL;
b3cd9f
-        char *q;
b3cd9f
+        _cleanup_free_ char *pdir = NULL, *ppdir = NULL, *pppdir = NULL, *clib = NULL;
b3cd9f
+        char *q, *clibdir;
b3cd9f
         int r, ret = 0;
b3cd9f
 
b3cd9f
         p = strdup(lib);
b3cd9f
@@ -358,7 +358,8 @@ static int library_install(const char *src, const char *lib)
b3cd9f
                         log_debug("Lib install: '%s'", p);
b3cd9f
         }
b3cd9f
 
b3cd9f
-        /* Also try to install the same library from one directory above.
b3cd9f
+        /* Also try to install the same library from one directory above
b3cd9f
+         * or from one directory above glibc-hwcaps.
b3cd9f
            This fixes the case, where only the HWCAP lib would be installed
b3cd9f
            # ldconfig -p|grep -F libc.so
b3cd9f
            libc.so.6 (libc6,64bit, hwcap: 0x0000001000000000, OS ABI: Linux 2.6.32) => /lib64/power6/libc.so.6
b3cd9f
@@ -379,10 +380,18 @@ static int library_install(const char *src, const char *lib)
b3cd9f
                 return ret;
b3cd9f
 
b3cd9f
         ppdir = strdup(ppdir);
b3cd9f
+        pppdir = dirname(ppdir);
b3cd9f
+        if (!pppdir)
b3cd9f
+                return ret;
b3cd9f
+
b3cd9f
+        pppdir = strdup(pppdir);
b3cd9f
+        if (!pppdir)
b3cd9f
+                return ret;
b3cd9f
 
b3cd9f
         strcpy(p, lib);
b3cd9f
 
b3cd9f
-        clib = strjoin(ppdir, "/", basename(p), NULL);
b3cd9f
+        clibdir = streq(basename(ppdir), "glibc-hwcaps") ? pppdir : ppdir;
b3cd9f
+        clib = strjoin(clibdir, "/", basename(p), NULL);
b3cd9f
         if (dracut_install(clib, clib, false, false, true) == 0)
b3cd9f
                 log_debug("Lib install: '%s'", clib);
b3cd9f
         /* also install lib.so for lib.so.* files */
b3cd9f