[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#514938: alternatively...



Attached is a gross alternative to depending on bash...

-- 
Kees Cook                                            @debian.org
--- mkinitramfs~	2009-02-11 17:18:41.000000000 -0800
+++ mkinitramfs	2009-02-11 20:13:16.000000000 -0800
@@ -296,7 +296,24 @@
 fi
 
 [ "${verbose}" = y ] && echo "Building cpio ${outfile} initramfs"
-(cd "${DESTDIR}" && find . | cpio --quiet --dereference -o -H newc | gzip >"${outfile}") || exit 1
+(
+# work around lack of "set -o pipefail" for the following pipe:
+# cd "${DESTDIR}" && find . | cpio --quiet --dereference -o -H newc | gzip >"${outfile}"
+exec 3>&1
+eval `
+    # http://cfaj.freeshell.org/shell/cus-faq-2.html
+    exec 4>&1 >&3 3>&-
+    {
+        cd "${DESTDIR}" && find . 4>&-; echo "ec1=$?;" >&4
+    } | {
+        cpio --quiet --dereference -o -H newc 4>&-; echo "ec2=$?;" >&4
+    } | gzip >"${outfile}"
+    echo "ec3=$?;" >&4
+`
+if [ "$ec1" -ne 0 ]; then exit "$ec1"; fi
+if [ "$ec2" -ne 0 ]; then exit "$ec2"; fi
+if [ "$ec3" -ne 0 ]; then exit "$ec3"; fi
+) || exit $?
 
 if [ -s "${__TMPCPIOGZ}" ]; then
 	cat "${__TMPCPIOGZ}" >>"${outfile}" || exit 1

Reply to: