Blame SOURCES/0128-dracut.sh-write-directly-to-the-output-file.patch

a56a5e
From 6381b9445980aae6c8533fe74603c902a9125fc5 Mon Sep 17 00:00:00 2001
966cef
From: Harald Hoyer <harald@redhat.com>
966cef
Date: Wed, 19 Feb 2014 15:22:39 +0100
966cef
Subject: [PATCH] dracut.sh: write directly to the output file
966cef
966cef
Because we already remove the output file before writing to it, we don't
966cef
have to play games and write to a temporary file first.
966cef
---
966cef
 dracut.sh | 9 +++------
966cef
 1 file changed, 3 insertions(+), 6 deletions(-)
966cef
966cef
diff --git a/dracut.sh b/dracut.sh
966cef
index 89df9cd..c4bf4eb 100755
966cef
--- a/dracut.sh
966cef
+++ b/dracut.sh
966cef
@@ -729,7 +729,6 @@ fi
966cef
 # clean up after ourselves no matter how we die.
966cef
 trap '
966cef
     ret=$?;
966cef
-    [[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";
966cef
     [[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; };
966cef
     [[ $keep ]] && echo "Not removing $early_cpio_dir." >&2 || { [[ $early_cpio_dir ]] && rm -Rf -- "$early_cpio_dir"; };
966cef
     [[ $_dlogdir ]] && rm -Rf -- "$_dlogdir";
966cef
@@ -1383,15 +1382,13 @@ dinfo "*** Creating image file ***"
966cef
 if [[ $create_early_cpio = yes ]]; then
966cef
     echo 1 > "$early_cpio_dir/d/early_cpio"
966cef
     # The microcode blob is _before_ the initramfs blob, not after
966cef
-    (cd "$early_cpio_dir/d";     find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet >../early.cpio)
966cef
-    mv $early_cpio_dir/early.cpio $outfile.$$
966cef
+    (cd "$early_cpio_dir/d";     find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet > $outfile)
966cef
 fi
966cef
 if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet | \
966cef
-    $compress >> "$outfile.$$"; ); then
966cef
-    dfatal "dracut: creation of $outfile.$$ failed"
966cef
+    $compress >> "$outfile"; ); then
966cef
+    dfatal "dracut: creation of $outfile failed"
966cef
     exit 1
966cef
 fi
966cef
-mv -- "$outfile.$$" "$outfile"
966cef
 dinfo "*** Creating image file done ***"
966cef
 
966cef
 if (( maxloglvl >= 5 )); then