Module Name:    src
Committed By:   kre
Date:           Tue Nov 28 02:56:44 UTC 2017

Modified Files:
        src/distrib/utils/embedded: mkimage
        src/distrib/utils/embedded/conf: armv7.conf rpi.conf rpi_inst.conf
            x86.conf

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/distrib/utils/embedded/mkimage
cvs rdiff -u -r1.19 -r1.20 src/distrib/utils/embedded/conf/armv7.conf
cvs rdiff -u -r1.31 -r1.32 src/distrib/utils/embedded/conf/rpi.conf
cvs rdiff -u -r1.9 -r1.10 src/distrib/utils/embedded/conf/rpi_inst.conf
cvs rdiff -u -r1.7 -r1.8 src/distrib/utils/embedded/conf/x86.conf

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/utils/embedded/mkimage
diff -u src/distrib/utils/embedded/mkimage:1.68 src/distrib/utils/embedded/mkimage:1.69
--- src/distrib/utils/embedded/mkimage:1.68	Tue Nov 28 00:24:08 2017
+++ src/distrib/utils/embedded/mkimage	Tue Nov 28 02:56:44 2017
@@ -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.
@@ -78,6 +78,12 @@ cleanup() {
 	esac
 }
 
+fail() {
+	IFS=' '
+	echo >&2 "${PROG}: $*"
+	exit 1
+}
+
 getsize() {
 	set -- $(ls -l $1)
 	echo $5

Index: src/distrib/utils/embedded/conf/armv7.conf
diff -u src/distrib/utils/embedded/conf/armv7.conf:1.19 src/distrib/utils/embedded/conf/armv7.conf:1.20
--- src/distrib/utils/embedded/conf/armv7.conf:1.19	Thu Nov  9 21:36:46 2017
+++ src/distrib/utils/embedded/conf/armv7.conf	Tue Nov 28 02:56:44 2017
@@ -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 @@ populate() {
 		*)
 			cp "${k}" "${mnt}/boot/${tgt}"
 			;;
-		esac
+		esac ||
+			fail "Copy of ${k} to ${mnt}/boot/${tgt} failed"
 	done
 
 	# board specific configuration

Index: src/distrib/utils/embedded/conf/rpi.conf
diff -u src/distrib/utils/embedded/conf/rpi.conf:1.31 src/distrib/utils/embedded/conf/rpi.conf:1.32
--- src/distrib/utils/embedded/conf/rpi.conf:1.31	Thu Nov  9 21:36:46 2017
+++ src/distrib/utils/embedded/conf/rpi.conf	Tue Nov 28 02:56:44 2017
@@ -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 @@ EOF
 	*)
 		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 @@ EOF
 		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"
 
 }

Index: src/distrib/utils/embedded/conf/rpi_inst.conf
diff -u src/distrib/utils/embedded/conf/rpi_inst.conf:1.9 src/distrib/utils/embedded/conf/rpi_inst.conf:1.10
--- src/distrib/utils/embedded/conf/rpi_inst.conf:1.9	Mon Jul 31 16:34:22 2017
+++ src/distrib/utils/embedded/conf/rpi_inst.conf	Tue Nov 28 02:56:44 2017
@@ -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 @@ EOF
 	*)
 		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"
 
 }

Index: src/distrib/utils/embedded/conf/x86.conf
diff -u src/distrib/utils/embedded/conf/x86.conf:1.7 src/distrib/utils/embedded/conf/x86.conf:1.8
--- src/distrib/utils/embedded/conf/x86.conf:1.7	Thu Jan 29 14:54:06 2015
+++ src/distrib/utils/embedded/conf/x86.conf	Tue Nov 28 02:56:44 2017
@@ -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 @@ populate() {
 		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"

Reply via email to