@@ -156,11 +156,14 @@ function update_node_version() {
156156
157157 if is_alpine " ${variant} " ; then
158158 alpine_version=" ${variant#* alpine} "
159- checksum=" \" $(
159+ checksum=$(
160160 curl -sSL --compressed " https://unofficial-builds.nodejs.org/download/release/v${nodeVersion} /SHASUMS256.txt" | grep " node-v${nodeVersion} -linux-x64-musl.tar.xz" | cut -d' ' -f1
161- ) \" "
161+ )
162+ if [ -z " $checksum " ]; then
163+ fatal " Failed to fetch checksum for version ${nodeVersion} "
164+ fi
162165 sed -Ei -e " s/(alpine:)0.0/\\ 1${alpine_version} /" " ${dockerfile} -tmp"
163- sed -Ei -e " s/CHECKSUM=CHECKSUM_x64/CHECKSUM=${checksum} /" " ${dockerfile} -tmp"
166+ sed -Ei -e " s/CHECKSUM=CHECKSUM_x64/CHECKSUM=\" ${checksum} \" /" " ${dockerfile} -tmp"
164167
165168 # Use python2 for nodejs < 14 on alpine
166169 if [ " $version " -lt 14 ]; then
@@ -203,9 +206,12 @@ for version in "${versions[@]}"; do
203206 # See details in function.sh
204207 IFS=' ' read -ra variants <<< " $(get_variants " ${parentpath} " )"
205208
209+ pids=()
210+
206211 if [ -f " ${version} /Dockerfile" ]; then
207212 if [ " ${update_version} " -eq 0 ]; then
208213 update_node_version " ${baseuri} " " ${versionnum} " " ${parentpath} /Dockerfile.template" " ${version} /Dockerfile" &
214+ pids+=($! )
209215 fi
210216 fi
211217
@@ -227,9 +233,15 @@ for version in "${versions[@]}"; do
227233 cp " ${parentpath} /docker-entrypoint.sh" " ${version} /${variant} /docker-entrypoint.sh"
228234 if [ " ${update_version} " -eq 0 ] && [ " ${update_variant} " -eq 0 ]; then
229235 update_node_version " ${baseuri} " " ${versionnum} " " ${template_file} " " ${version} /${variant} /Dockerfile" " ${variant} " &
236+ pids+=($! )
230237 fi
231238 done
232239done
233240
234- wait
241+ # The reason we explicitly wait on each pid is so the return status of this script is set properly
242+ # if one of the jobs fails. If we just called "wait", the exit status would always be 0
243+ for pid in " ${pids[@]} " ; do
244+ wait " $pid "
245+ done
246+
235247info " Done!"
0 commit comments