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