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