commit:     8fcec8af378325d2c5e2477e2f08c39059d12f84
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  6 15:21:00 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Dec  6 17:54:25 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8fcec8af

multilib-build.eclass: Add missing error checks

 eclass/multilib-build.eclass | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass
index dd03553..8e58a2b 100644
--- a/eclass/multilib-build.eclass
+++ b/eclass/multilib-build.eclass
@@ -262,19 +262,23 @@ multilib_for_best_abi() {
 # runs (if any). Dies if header files differ.
 multilib_check_headers() {
        _multilib_header_cksum() {
-               [[ -d ${ED}usr/include ]] && \
-               find "${ED}"usr/include -type f \
-                       -exec cksum {} + | sort -k2
+               set -o pipefail
+
+               if [[ -d ${ED}usr/include ]]; then
+                       find "${ED}"usr/include -type f \
+                               -exec cksum {} + | sort -k2
+               fi
        }
 
-       local cksum=$(_multilib_header_cksum)
+       local cksum cksum_prev
        local cksum_file=${T}/.multilib_header_cksum
+       cksum=$(_multilib_header_cksum) || die
 
        if [[ -f ${cksum_file} ]]; then
-               local cksum_prev=$(< "${cksum_file}")
+               cksum_prev=$(< "${cksum_file}") || die
 
                if [[ ${cksum} != ${cksum_prev} ]]; then
-                       echo "${cksum}" > "${cksum_file}.new"
+                       echo "${cksum}" > "${cksum_file}.new" || die
 
                        eerror "Header files have changed between ABIs."
 
@@ -288,7 +292,7 @@ multilib_check_headers() {
                        die "Header checksum mismatch, aborting."
                fi
        else
-               echo "${cksum}" > "${cksum_file}"
+               echo "${cksum}" > "${cksum_file}" || die
        fi
 }
 
@@ -409,9 +413,9 @@ multilib_prepare_wrappers() {
 
                if [[ -L ${root}/${f} ]]; then
                        # rewrite the symlink target
-                       local target=$(readlink "${root}/${f}")
-                       local target_dir
-                       local target_fn=${target##*/}
+                       local target
+                       target=$(readlink "${root}/${f}") || die
+                       local target_dir target_fn=${target##*/}
 
                        [[ ${target} == */* ]] && target_dir=${target%/*}
 
@@ -453,7 +457,7 @@ multilib_prepare_wrappers() {
                                        if [[ ! -f 
${ED}/tmp/multilib-include${f} ]]; then
                                                dodir 
"/tmp/multilib-include${dir}"
                                                # a generic template
-                                               cat > "${wrapper}" <<_EOF_
+                                               cat > "${wrapper}" <<_EOF_ || 
die
 /* This file is auto-generated by multilib-build.eclass
  * as a multilib-friendly wrapper. For the original content,
  * please see the files that are #included below.

Reply via email to