File 0302-dracut-systemd_rootfs-generator.sh_always_create_generated_files.patch of Package dracut.892

From: NeilBrown <neilb@suse.de>
Subject: dracut-systemd/rootfs-generator.sh: always create generated files.
References: bnc#932735
Patch-Mainline: 
Git-commit: f53ede36fb26716301d57706f889124ca20f3397
Git-repo: git.kernel.org/pub/scm/boot/dracut/dracut.git

Signed-off-by: Thomas Renninger <trenn@suse.de>

When 'systemctl daemon-reload' is run, systemd will clean out
/run/systemd/generator and re-run all the generators.
So it is important that the generators always create the required
files.

rootfs-generator.sh currently does *not* create the desired files
if $hookdir/initqueue/finished/devexists-${_name}.sh
exists.

This is not removed by "systectl daemon-reload" so the first time this
generator is run it will do the right thing.  Subsequent times it
won't.

This results in incorrect timeouts after "daemon-reload" is run.

So let the existence of each file only guard the creation that file.

Signed-off-by: NeilBrown <neilb@suse.de>

Index: dracut-037/modules.d/98systemd/rootfs-generator.sh
===================================================================
--- dracut-037.orig/modules.d/98systemd/rootfs-generator.sh	2015-06-03 18:44:04.486045580 +0200
+++ dracut-037/modules.d/98systemd/rootfs-generator.sh	2015-06-03 18:44:16.966745889 +0200
@@ -13,14 +13,15 @@
     _timeout=$(getarg rd.timeout)
     _timeout=${_timeout:-0}
 
-    [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
+    if ! [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ]; then
 
-    printf '[ -e "%s" ]\n' $1 \
-        >> "$hookdir/initqueue/finished/devexists-${_name}.sh"
-    {
-        printf '[ -e "%s" ] || ' $1
-        printf 'warn "\"%s\" does not exist"\n' $1
-    } >> "$hookdir/emergency/80-${_name}.sh"
+        printf '[ -e "%s" ]\n' $1 \
+            >> "$hookdir/initqueue/finished/devexists-${_name}.sh"
+        {
+            printf '[ -e "%s" ] || ' $1
+            printf 'warn "\"%s\" does not exist"\n' $1
+        } >> "$hookdir/emergency/80-${_name}.sh"
+    fi
 
     _name=$(dev_unit_name "$1")
     if ! [ -L /run/systemd/generator/initrd.target.wants/${_name}.device ]; then