Add error detection to copy_binaries
authorSebastian Pipping <sebastian@pipping.org>
Mon, 16 Apr 2012 01:18:48 +0000 (03:18 +0200)
committerSebastian Pipping <sebastian@pipping.org>
Mon, 16 Apr 2012 01:58:01 +0000 (03:58 +0200)
gen_initramfs.sh

index f3c14c2c71ca09137a0db1d580d29711867fce92..61ebce14bb496717852d319187211e2a2dd2c572 100755 (executable)
@@ -6,13 +6,23 @@ CPIO_ARGS="--quiet -o -H newc"
 copy_binaries() {
        local destdir=$1
        shift
-       lddtree "$@" \
-               | tr ')(' '\n' \
-               | awk  '/=>/{ if($3 ~ /^\//){print $3}}' \
-               | sort \
-               | uniq \
-               | cpio -p --make-directories --dereference --quiet $destdir
 
+       for binary in "$@"; do
+               [[ -e "${binary}" ]] \
+                               || gen_die "Binary ${binary} could not be found"
+
+               if LC_ALL=C lddtree "${binary}" 2>&1 | fgrep -q 'not found'; then
+                       gen_die "Binary ${binary} is linked to missing libraries and may need to be re-built"
+               fi
+
+               lddtree "${binary}" \
+                               | tr ')(' '\n' \
+                               | awk  '/=>/{ if($3 ~ /^\//){print $3}}' \
+                               | sort \
+                               | uniq \
+                               | cpio -p --make-directories --dereference --quiet "${destdir}" \
+                               || gen_die "Binary ${f} or some of its library dependencies could not be copied"
+       done
 }
 
 append_base_layout() {