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 unified 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,15 +1,15 @@ @@ -1,15 +1,15 @@
1#!/bin/sh 1#!/bin/sh
2# $NetBSD: mkimage,v 1.68 2017/11/28 00:24:08 kre Exp $ 2# $NetBSD: mkimage,v 1.69 2017/11/28 02:56:44 kre Exp $
3# 3#
4# Copyright (c) 2013, 2014 The NetBSD Foundation, Inc. 4# Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
5# All rights reserved. 5# All rights reserved.
6# 6#
7# This code is derived from software contributed to The NetBSD Foundation 7# This code is derived from software contributed to The NetBSD Foundation
8# by Christos Zoulas. 8# by Christos Zoulas.
9# 9#
10# Redistribution and use in source and binary forms, with or without 10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions 11# modification, are permitted provided that the following conditions
12# are met: 12# are met:
13# 1. Redistributions of source code must retain the above copyright 13# 1. Redistributions of source code must retain the above copyright
14# notice, this list of conditions and the following disclaimer. 14# notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright 15# 2. Redistributions in binary form must reproduce the above copyright
@@ -68,26 +68,32 @@ bar="===" @@ -68,26 +68,32 @@ bar="==="
68 68
69tmp="$(mktemp -d "${TMPDIR:-/tmp}/$PROG.XXXXXX")" 69tmp="$(mktemp -d "${TMPDIR:-/tmp}/$PROG.XXXXXX")"
70mnt="${tmp}/mnt" 70mnt="${tmp}/mnt"
71mkdir -p "${mnt}/etc" "${mnt}/dev" 71mkdir -p "${mnt}/etc" "${mnt}/dev"
72 72
73trap "cleanup" 0 1 2 3 15 73trap "cleanup" 0 1 2 3 15
74 74
75cleanup() { 75cleanup() {
76 case "$tmp" in 76 case "$tmp" in
77 "${TMPDIR:-/tmp}/$PROG."*) rm -fr "$tmp";; 77 "${TMPDIR:-/tmp}/$PROG."*) rm -fr "$tmp";;
78 esac 78 esac
79} 79}
80 80
 81fail() {
 82 IFS=' '
 83 echo >&2 "${PROG}: $*"
 84 exit 1
 85}
 86
81getsize() { 87getsize() {
82 set -- $(ls -l $1) 88 set -- $(ls -l $1)
83 echo $5 89 echo $5
84} 90}
85 91
86getsectors() { 92getsectors() {
87 case "$1" in 93 case "$1" in
88 *g) 94 *g)
89 m=1073741824 95 m=1073741824
90 v=${1%g} 96 v=${1%g}
91 ;; 97 ;;
92 *m) 98 *m)
93 m=1048576 99 m=1048576

cvs diff -r1.19 -r1.20 src/distrib/utils/embedded/conf/armv7.conf (expand / switch to unified 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,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: armv7.conf,v 1.19 2017/11/09 21:36:46 skrll Exp $ 1# $NetBSD: armv7.conf,v 1.20 2017/11/28 02:56:44 kre Exp $
2# ARMv7 customization script used by mkimage 2# ARMv7 customization script used by mkimage
3# 3#
4board=armv7 4board=armv7
5console=fb 5console=fb
6resize=true 6resize=true
7 7
8. ${DIR}/conf/evbarm.conf 8. ${DIR}/conf/evbarm.conf
9 9
10kernels_beagle="BEAGLEBOARD BEAGLEBONE" 10kernels_beagle="BEAGLEBOARD BEAGLEBONE"
11kernels_awin="BPI CUBIEBOARD CUBIETRUCK" 11kernels_awin="BPI CUBIEBOARD CUBIETRUCK"
12kernels_rpi="RPI2" 12kernels_rpi="RPI2"
13kernels_amlogic="ODROID-C1" 13kernels_amlogic="ODROID-C1"
14kernels_tegra="TEGRA" 14kernels_tegra="TEGRA"
@@ -140,27 +140,28 @@ populate() { @@ -140,27 +140,28 @@ populate() {
140 done 140 done
141 141
142 # install kernels to /boot partition 142 # install kernels to /boot partition
143 for k in ${kernels}; do 143 for k in ${kernels}; do
144 tgt="$(basename ${k} | sed 's/\.gz$//')" 144 tgt="$(basename ${k} | sed 's/\.gz$//')"
145 echo "${bar} installing ${k} to /boot/${tgt} ${bar}" 145 echo "${bar} installing ${k} to /boot/${tgt} ${bar}"
146 case "${k}" in 146 case "${k}" in
147 *.gz) 147 *.gz)
148 ${GZIP_CMD} -dc "${k}" > "${mnt}/boot/${tgt}" 148 ${GZIP_CMD} -dc "${k}" > "${mnt}/boot/${tgt}"
149 ;; 149 ;;
150 *) 150 *)
151 cp "${k}" "${mnt}/boot/${tgt}" 151 cp "${k}" "${mnt}/boot/${tgt}"
152 ;; 152 ;;
153 esac 153 esac ||
 154 fail "Copy of ${k} to ${mnt}/boot/${tgt} failed"
154 done 155 done
155 156
156 # board specific configuration 157 # board specific configuration
157 populate_beagle 158 populate_beagle
158 populate_awin 159 populate_awin
159 populate_rpi 160 populate_rpi
160 populate_amlogic 161 populate_amlogic
161 populate_tegra 162 populate_tegra
162 populate_sunxi 163 populate_sunxi
163 164
164 # common configuration 165 # common configuration
165 populate_common 166 populate_common
166} 167}

cvs diff -r1.31 -r1.32 src/distrib/utils/embedded/conf/rpi.conf (expand / switch to unified 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,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: rpi.conf,v 1.31 2017/11/09 21:36:46 skrll Exp $ 1# $NetBSD: rpi.conf,v 1.32 2017/11/28 02:56:44 kre Exp $
2# Raspberry Pi customization script used by mkimage 2# Raspberry Pi customization script used by mkimage
3# 3#
4 4
5board=rpi 5board=rpi
6kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI.bin 6kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI.bin
7resize=true 7resize=true
8 8
9. ${DIR}/conf/evbarm.conf 9. ${DIR}/conf/evbarm.conf
10 10
11firmwaredir=$src/external/broadcom/rpi-firmware/dist 11firmwaredir=$src/external/broadcom/rpi-firmware/dist
12firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf" 12firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
13 13
14make_fstab() { 14make_fstab() {
@@ -62,34 +62,34 @@ EOF @@ -62,34 +62,34 @@ EOF
62 if [ ! -f ${kernel} ]; then 62 if [ ! -f ${kernel} ]; then
63 echo ${PROG}: Missing ${kernel} 1>&2 63 echo ${PROG}: Missing ${kernel} 1>&2
64 exit 1 64 exit 1
65 fi 65 fi
66 66
67 echo "${bar} installing RPI kernel ${bar}" 67 echo "${bar} installing RPI kernel ${bar}"
68 case ${kernel} in 68 case ${kernel} in
69 *.gz) 69 *.gz)
70 gzip -dc ${kernel} > ${mnt}/boot/kernel.img 70 gzip -dc ${kernel} > ${mnt}/boot/kernel.img
71 ;; 71 ;;
72 *) 72 *)
73 cp ${kernel} ${mnt}/boot/kernel.img 73 cp ${kernel} ${mnt}/boot/kernel.img
74 ;; 74 ;;
75 esac 75 esac || fail "copy of ${kernel} to ${mnt}/boot/kernel.img failed"
76 76
77 echo "${bar} installing RPI2 kernel ${bar}" 77 echo "${bar} installing RPI2 kernel ${bar}"
78 case ${rpi2_kernel} in 78 case ${rpi2_kernel} in
79 *.gz) 79 *.gz)
80 gzip -dc ${rpi2_kernel} > ${mnt}/boot/kernel7.img 80 gzip -dc ${rpi2_kernel} > ${mnt}/boot/kernel7.img
81 ;; 81 ;;
82 *) 82 *)
83 cp ${rpi_kernel} ${mnt}/boot/kernel7.img 83 cp ${rpi2_kernel} ${mnt}/boot/kernel7.img
84 ;; 84 ;;
85 esac 85 esac || fail "Copy of ${rpi2_kernel} to ${mnt}/boot/kernel7.img failed"
86 86
87 echo "${bar} installing firmware files ${bar}" 87 echo "${bar} installing firmware files ${bar}"
88 (cd ${mnt}/boot && 88 (cd ${mnt}/boot &&
89 for f in ${firmwarefiles}; do 89 for f in ${firmwarefiles}; do
90 echo " $f" 90 echo " $f"
91 cp ${firmwaredir}/${f} . 91 cp ${firmwaredir}/${f} . || exit 1
92 done 92 done
93 ) 93 ) || fail "Copy of firmeware into ${mnt}/boot failed"
94 94
95} 95}

cvs diff -r1.9 -r1.10 src/distrib/utils/embedded/conf/rpi_inst.conf (expand / switch to unified 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,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: rpi_inst.conf,v 1.9 2017/07/31 16:34:22 jmcneill Exp $ 1# $NetBSD: rpi_inst.conf,v 1.10 2017/11/28 02:56:44 kre Exp $
2# Raspberry Pi customization script used by mkimage 2# Raspberry Pi customization script used by mkimage
3# 3#
4 4
5board=rpi_inst 5board=rpi_inst
6kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI_INSTALL.bin 6kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI_INSTALL.bin
7 7
8. ${DIR}/conf/evbarm.conf 8. ${DIR}/conf/evbarm.conf
9 9
10image=$HOME/${board}.img 10image=$HOME/${board}.img
11 11
12swap=8 12swap=8
13extra=8 # spare space 13extra=8 # spare space
14boot=112 14boot=112
@@ -92,24 +92,24 @@ EOF @@ -92,24 +92,24 @@ EOF
92 if [ ! -f ${kernel} ]; then 92 if [ ! -f ${kernel} ]; then
93 echo ${PROG}: Missing ${kernel} 1>&2 93 echo ${PROG}: Missing ${kernel} 1>&2
94 exit 1 94 exit 1
95 fi 95 fi
96 96
97 echo "${bar} installing kernel ${bar}" 97 echo "${bar} installing kernel ${bar}"
98 case ${kernel} in 98 case ${kernel} in
99 *.gz) 99 *.gz)
100 ${GZIP_CMD} -dc ${kernel} > ${mnt}/boot/kernel.img 100 ${GZIP_CMD} -dc ${kernel} > ${mnt}/boot/kernel.img
101 ;; 101 ;;
102 *) 102 *)
103 cp ${kernel} ${mnt}/boot/kernel.img 103 cp ${kernel} ${mnt}/boot/kernel.img
104 ;; 104 ;;
105 esac 105 esac || fail "copy of ${kernel} to ${mnt}/boot/kernel.img failed"
106 106
107 echo "${bar} installing firmware files ${bar}" 107 echo "${bar} installing firmware files ${bar}"
108 (cd ${mnt}/boot && 108 (cd ${mnt}/boot &&
109 for f in ${firmwarefiles}; do 109 for f in ${firmwarefiles}; do
110 echo " $f" 110 echo " $f"
111 cp ${firmwaredir}/${f} . 111 cp ${firmwaredir}/${f} . || exit 1
112 done 112 done
113 ) 113 ) || fail "Copy of firmware to ${mnt}/boot failed"
114 114
115} 115}

cvs diff -r1.7 -r1.8 src/distrib/utils/embedded/conf/x86.conf (expand / switch to unified 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,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: x86.conf,v 1.7 2015/01/29 14:54:06 skrll Exp $ 1# $NetBSD: x86.conf,v 1.8 2017/11/28 02:56:44 kre Exp $
2# x86 shared config 2# x86 shared config
3# 3#
4 4
5image=$HOME/${board}.img 5image=$HOME/${board}.img
6MACHINE=${board} 6MACHINE=${board}
7kernel=$src/sys/arch/${board}/compile/GENERIC/netbsd 7kernel=$src/sys/arch/${board}/compile/GENERIC/netbsd
8bootfile=$release/usr/mdec/boot 8bootfile=$release/usr/mdec/boot
9 9
10extra=8 # spare space 10extra=8 # spare space
11size=0 # autocompute 11size=0 # autocompute
12netbsdid=169 12netbsdid=169
13init=63 13init=63
14ffsoffset=${init}b 14ffsoffset=${init}b
@@ -130,20 +130,21 @@ EOF @@ -130,20 +130,21 @@ EOF
130 130
131populate() { 131populate() {
132 if [ ! -f ${kernel} ]; then 132 if [ ! -f ${kernel} ]; then
133 echo ${PROG}: Missing ${kernel} 1>&2 133 echo ${PROG}: Missing ${kernel} 1>&2
134 exit 1 134 exit 1
135 fi 135 fi
136 136
137 echo "${bar} installing kernel ${bar}" 137 echo "${bar} installing kernel ${bar}"
138 cp ${kernel} ${mnt}/netbsd 138 cp ${kernel} ${mnt}/netbsd
139 if [ ! -f ${bootfile} ]; then 139 if [ ! -f ${bootfile} ]; then
140 echo ${PROG}: Missing ${bootfile} 1>&2 140 echo ${PROG}: Missing ${bootfile} 1>&2
141 exit 1 141 exit 1
142 fi 142 fi
143 cp ${bootfile} ${mnt}/boot 143 cp ${bootfile} ${mnt}/boot ||
 144 fail "copy of ${bootfile} to ${mnt}/boot failed"
144 145
145 echo "./netbsd type=file uname=root gname=wheel mode=0755" \ 146 echo "./netbsd type=file uname=root gname=wheel mode=0755" \
146 >> "$tmp/selected_sets" 147 >> "$tmp/selected_sets"
147 echo "./boot type=file uname=root gname=wheel mode=0444" \ 148 echo "./boot type=file uname=root gname=wheel mode=0444" \
148 >> "$tmp/selected_sets" 149 >> "$tmp/selected_sets"
149} 150}