Skip to content

Commit

Permalink
Merge pull request nodejs#1577 from MasonM/better-error-handling-in-u…
Browse files Browse the repository at this point in the history
…pdatesh

fix: Better error handling in update.sh
  • Loading branch information
nschonni authored Oct 16, 2021
2 parents 961785b + 8261a02 commit 3bfbca7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,14 @@ function update_node_version() {

if is_alpine "${variant}"; then
alpine_version="${variant#*alpine}"
checksum="\"$(
checksum=$(
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
)\""
)
if [ -z "$checksum" ]; then
fatal "Failed to fetch checksum for version ${nodeVersion}"
fi
sed -Ei -e "s/(alpine:)0.0/\\1${alpine_version}/" "${dockerfile}-tmp"
sed -Ei -e "s/CHECKSUM=CHECKSUM_x64/CHECKSUM=${checksum}/" "${dockerfile}-tmp"
sed -Ei -e "s/CHECKSUM=CHECKSUM_x64/CHECKSUM=\"${checksum}\"/" "${dockerfile}-tmp"

# Use python2 for nodejs < 14 on alpine
if [ "$version" -lt 14 ]; then
Expand Down Expand Up @@ -203,9 +206,12 @@ for version in "${versions[@]}"; do
# See details in function.sh
IFS=' ' read -ra variants <<< "$(get_variants "${parentpath}")"

pids=()

if [ -f "${version}/Dockerfile" ]; then
if [ "${update_version}" -eq 0 ]; then
update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile.template" "${version}/Dockerfile" &
pids+=($!)
fi
fi

Expand All @@ -227,9 +233,15 @@ for version in "${versions[@]}"; do
cp "${parentpath}/docker-entrypoint.sh" "${version}/${variant}/docker-entrypoint.sh"
if [ "${update_version}" -eq 0 ] && [ "${update_variant}" -eq 0 ]; then
update_node_version "${baseuri}" "${versionnum}" "${template_file}" "${version}/${variant}/Dockerfile" "${variant}" &
pids+=($!)
fi
done
done

wait
# The reason we explicitly wait on each pid is so the return status of this script is set properly
# if one of the jobs fails. If we just called "wait", the exit status would always be 0
for pid in "${pids[@]}"; do
wait "$pid"
done

info "Done!"

0 comments on commit 3bfbca7

Please sign in to comment.