Blame 0009-install-dracut-install.c-Ensure-deps-are-resolved-wh.patch

Harald Hoyer 7e00d9
From 68318328f1fc394ac043b939425715ba78dc6f57 Mon Sep 17 00:00:00 2001
Harald Hoyer 7e00d9
From: Colin Guthrie <colin@mageia.org>
Harald Hoyer 7e00d9
Date: Tue, 14 Aug 2012 22:09:39 +0100
Harald Hoyer 7e00d9
Subject: [PATCH] install/dracut-install.c: Ensure deps are resolved when
Harald Hoyer 7e00d9
 handling scripts
Harald Hoyer 7e00d9
Harald Hoyer 7e00d9
If we are doing lazy dep solving and happen to process a script with a
Harald Hoyer 7e00d9
shebang on e.g. /bin/bash before we encounter the actual binary itself
Harald Hoyer 7e00d9
we effectively ignore the fact that we've been asked to resolve the deps
Harald Hoyer 7e00d9
and put the item in the 'seen' hashmap. Thus when we later really do try
Harald Hoyer 7e00d9
and resolve deps, we short circuit and don't do anything.
Harald Hoyer 7e00d9
Harald Hoyer 7e00d9
Example test case:
Harald Hoyer 7e00d9
Harald Hoyer 7e00d9
$ cd
Harald Hoyer 7e00d9
$ mkdir -p foo/bin
Harald Hoyer 7e00d9
$ cp /bin/bash foo/bin
Harald Hoyer 7e00d9
$ echo '#!/bin/bash' >foo/bin/script
Harald Hoyer 7e00d9
$ dracut-install -D $HOME/foo -R $HOME/foo/bin/script $HOME/foo/bin/bash
Harald Hoyer 7e00d9
---
Harald Hoyer 7e00d9
 install/dracut-install.c | 9 +++++++--
Harald Hoyer 7e00d9
 1 file changed, 7 insertions(+), 2 deletions(-)
Harald Hoyer 7e00d9
Harald Hoyer 7e00d9
diff --git a/install/dracut-install.c b/install/dracut-install.c
Harald Hoyer 7e00d9
index e79065d..9a244ba 100644
Harald Hoyer 7e00d9
--- a/install/dracut-install.c
Harald Hoyer 7e00d9
+++ b/install/dracut-install.c
Harald Hoyer 7e00d9
@@ -392,10 +392,15 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res
Harald Hoyer 7e00d9
         }
Harald Hoyer 7e00d9
 
Harald Hoyer 7e00d9
         if (ret == 0) {
Harald Hoyer 7e00d9
-                log_debug("'%s' already exists", fulldstpath);
Harald Hoyer 7e00d9
+                if (resolvedeps) {
Harald Hoyer 7e00d9
+                        log_debug("'%s' already exists, but checking for any deps", fulldstpath);
Harald Hoyer 7e00d9
+                        ret = resolve_deps(src);
Harald Hoyer 7e00d9
+                } else
Harald Hoyer 7e00d9
+                        log_debug("'%s' already exists", fulldstpath);
Harald Hoyer 7e00d9
+
Harald Hoyer 7e00d9
                 free(fulldstpath);
Harald Hoyer 7e00d9
                 /* dst does already exist */
Harald Hoyer 7e00d9
-                return 0;
Harald Hoyer 7e00d9
+                return ret;
Harald Hoyer 7e00d9
         }
Harald Hoyer 7e00d9
 
Harald Hoyer 7e00d9
         /* check destination directory */