Tue Nov 28 02:56:44 2017 UTC ()
Be more precise about exactly what fails when something does.

Relying upon set -e to abort things is sort of OK (it is not
a recommended option to use in general - too many odd special cases),
but only if user can work out from the "build failed" what actually
went wrong.

Tested only on amd64 build (for this, i386 is the same) - if anyone
has problems on builds for other systems, please let me know.  However
the changes affect only failure paths, the most likely problem would
be for a build to fail to halt on an error, and I hope I have avoided
that.  There should be no difference at all to error-free builds.


(kre)
diff -r1.68 -r1.69 src/distrib/utils/embedded/mkimage
diff -r1.19 -r1.20 src/distrib/utils/embedded/conf/armv7.conf
diff -r1.31 -r1.32 src/distrib/utils/embedded/conf/rpi.conf
diff -r1.9 -r1.10 src/distrib/utils/embedded/conf/rpi_inst.conf
diff -r1.7 -r1.8 src/distrib/utils/embedded/conf/x86.conf

cvs diff -r1.68 -r1.69 src/distrib/utils/embedded/mkimage (expand / switch to context diff)
--- src/distrib/utils/embedded/mkimage 2017/11/28 00:24:08 1.68
+++ src/distrib/utils/embedded/mkimage 2017/11/28 02:56:44 1.69
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: mkimage,v 1.68 2017/11/28 00:24:08 kre Exp $
+# $NetBSD: mkimage,v 1.69 2017/11/28 02:56:44 kre Exp $
 #
 # Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -76,6 +76,12 @@
 	case "$tmp" in
 	"${TMPDIR:-/tmp}/$PROG."*)	rm -fr "$tmp";;
 	esac
+}
+
+fail() {
+	IFS=' '
+	echo >&2 "${PROG}: $*"
+	exit 1
 }
 
 getsize() {

cvs diff -r1.19 -r1.20 src/distrib/utils/embedded/conf/armv7.conf (expand / switch to context diff)
--- src/distrib/utils/embedded/conf/armv7.conf 2017/11/09 21:36:46 1.19
+++ src/distrib/utils/embedded/conf/armv7.conf 2017/11/28 02:56:44 1.20
@@ -1,4 +1,4 @@
-# $NetBSD: armv7.conf,v 1.19 2017/11/09 21:36:46 skrll Exp $
+# $NetBSD: armv7.conf,v 1.20 2017/11/28 02:56:44 kre Exp $
 # ARMv7 customization script used by mkimage
 #
 board=armv7
@@ -150,7 +150,8 @@
 		*)
 			cp "${k}" "${mnt}/boot/${tgt}"
 			;;
-		esac
+		esac ||
+			fail "Copy of ${k} to ${mnt}/boot/${tgt} failed"
 	done
 
 	# board specific configuration

cvs diff -r1.31 -r1.32 src/distrib/utils/embedded/conf/rpi.conf (expand / switch to context diff)
--- src/distrib/utils/embedded/conf/rpi.conf 2017/11/09 21:36:46 1.31
+++ src/distrib/utils/embedded/conf/rpi.conf 2017/11/28 02:56:44 1.32
@@ -1,4 +1,4 @@
-# $NetBSD: rpi.conf,v 1.31 2017/11/09 21:36:46 skrll Exp $
+# $NetBSD: rpi.conf,v 1.32 2017/11/28 02:56:44 kre Exp $
 # Raspberry Pi customization script used by mkimage
 #
 
@@ -72,7 +72,7 @@
 	*)
 		cp ${kernel} ${mnt}/boot/kernel.img
 		;;
-	esac
+	esac || fail "copy of ${kernel} to ${mnt}/boot/kernel.img failed"
 
 	echo "${bar} installing RPI2 kernel ${bar}"
 	case ${rpi2_kernel} in
@@ -80,16 +80,16 @@
 		gzip -dc ${rpi2_kernel} > ${mnt}/boot/kernel7.img
 		;;
 	*)
-		cp ${rpi_kernel} ${mnt}/boot/kernel7.img
+		cp ${rpi2_kernel} ${mnt}/boot/kernel7.img
 		;;
-	esac
+	esac || fail "Copy of ${rpi2_kernel} to ${mnt}/boot/kernel7.img failed"
 
 	echo "${bar} installing firmware files ${bar}"
 	(cd ${mnt}/boot &&
 		for f in ${firmwarefiles}; do
 			echo " $f"
-			cp ${firmwaredir}/${f} .
+			cp ${firmwaredir}/${f} . || exit 1
 		done
-	)
+	) || fail "Copy of firmeware into ${mnt}/boot failed"
 
 }

cvs diff -r1.9 -r1.10 src/distrib/utils/embedded/conf/rpi_inst.conf (expand / switch to context diff)
--- src/distrib/utils/embedded/conf/rpi_inst.conf 2017/07/31 16:34:22 1.9
+++ src/distrib/utils/embedded/conf/rpi_inst.conf 2017/11/28 02:56:44 1.10
@@ -1,4 +1,4 @@
-# $NetBSD: rpi_inst.conf,v 1.9 2017/07/31 16:34:22 jmcneill Exp $
+# $NetBSD: rpi_inst.conf,v 1.10 2017/11/28 02:56:44 kre Exp $
 # Raspberry Pi customization script used by mkimage
 #
 
@@ -102,14 +102,14 @@
 	*)
 		cp ${kernel} ${mnt}/boot/kernel.img
 		;;
-	esac
+	esac || fail "copy of ${kernel} to  ${mnt}/boot/kernel.img failed"
 
 	echo "${bar} installing firmware files ${bar}"
 	(cd ${mnt}/boot &&
 		for f in ${firmwarefiles}; do
 			echo " $f"
-			cp ${firmwaredir}/${f} .
+			cp ${firmwaredir}/${f} . || exit 1
 		done
-	)
+	) || fail "Copy of firmware to ${mnt}/boot failed"
 
 }

cvs diff -r1.7 -r1.8 src/distrib/utils/embedded/conf/x86.conf (expand / switch to context diff)
--- src/distrib/utils/embedded/conf/x86.conf 2015/01/29 14:54:06 1.7
+++ src/distrib/utils/embedded/conf/x86.conf 2017/11/28 02:56:44 1.8
@@ -1,4 +1,4 @@
-# $NetBSD: x86.conf,v 1.7 2015/01/29 14:54:06 skrll Exp $
+# $NetBSD: x86.conf,v 1.8 2017/11/28 02:56:44 kre Exp $
 # x86 shared config
 #
 
@@ -140,7 +140,8 @@
 		echo ${PROG}: Missing ${bootfile} 1>&2
 		exit 1
 	fi
-	cp ${bootfile} ${mnt}/boot
+	cp ${bootfile} ${mnt}/boot ||
+	    fail "copy of ${bootfile} to ${mnt}/boot failed"
 
 	echo "./netbsd type=file uname=root gname=wheel mode=0755" \
 	    >> "$tmp/selected_sets"