summaryrefslogtreecommitdiff
path: root/mkinitramfs
diff options
context:
space:
mode:
authorKees Cook <kees@debian.org>2009-02-11 20:15:48 -0800
committermaximilian attems <maks@debian.org>2009-02-13 17:06:31 +0100
commit63cc7b9216d69f413cd5414c96cf2c9a403e03ae (patch)
tree72544964ae90257303b54189e7c36794e5e5fef7 /mkinitramfs
parent6a8c246803f170948e8e7ebf17d5590838cb19db (diff)
downloadinitramfs-tools-63cc7b9216d69f413cd5414c96cf2c9a403e03ae.tar.gz
initramfs-tools-63cc7b9216d69f413cd5414c96cf2c9a403e03ae.zip
minitramfs: find/cpio exit codes ignored while building initramfs
The final stage of mkinitramfs that builds the image does not verify the exit codes of find or cpio: (cd "${DESTDIR}" && find . | cpio --quiet --dereference -o -H newc | gzip >"${outfile}") || exit 1 Once bug 514936 is solved, this will be even more important, since cpio will actually return errors. Attached is a gross alternative to depending on bash... Current behavior: $ find /fail | cpio --quiet --dereference -o -H newc | gzip > /tmp/archive.gz find: `/fail': No such file or directory $ echo $? 0 Desired behavior: $ set -o pipefail $ find /fail | cpio --quiet --dereference -o -H newc | gzip > /tmp/archive.gz find: `/fail': No such file or directory $ echo $? 1 (closes: #514938) [ already useful in finding stupid mkinitramfs path errors -maks ]
Diffstat (limited to 'mkinitramfs')
-rwxr-xr-xmkinitramfs19
1 files changed, 18 insertions, 1 deletions
diff --git a/mkinitramfs b/mkinitramfs
index 70ff0fe..0aa2ba7 100755
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -266,7 +266,24 @@ if [ -e "${CONFDIR}/DSDT.aml" ]; then
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