Merge pull request #817 from nodejs/update-shfmt-and-sh-files
Update shfmt parameter and shell script files
This commit is contained in:
commit
a9bcfe822a
|
@ -56,7 +56,7 @@ jobs:
|
|||
env:
|
||||
- TEST: shfmt check
|
||||
script:
|
||||
- docker run -it --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:2.5.0 -i 2 -l -w -ci .
|
||||
- docker run -it --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:2.5.0 -sr -i 2 -l -w -ci .
|
||||
- git diff --color
|
||||
- git diff --stat=220 --color --exit-code
|
||||
|
||||
|
|
22
functions.sh
22
functions.sh
|
@ -62,7 +62,7 @@ function get_variants() {
|
|||
|
||||
arch=$(get_arch)
|
||||
variantsfilter=("$@")
|
||||
IFS=' ' read -ra availablevariants <<<"$(grep "^${arch}" "${dir}/architectures" | sed -E 's/'"${arch}"'[[:space:]]*//' | sed -E 's/,/ /g')"
|
||||
IFS=' ' read -ra availablevariants <<< "$(grep "^${arch}" "${dir}/architectures" | sed -E 's/'"${arch}"'[[:space:]]*//' | sed -E 's/,/ /g')"
|
||||
|
||||
if [ ${#variantsfilter[@]} -gt 0 ]; then
|
||||
for variant1 in "${availablevariants[@]}"; do
|
||||
|
@ -100,16 +100,16 @@ function get_supported_arches() {
|
|||
shift
|
||||
|
||||
# Get default supported arches
|
||||
lines=$(grep "${variant}" "$(dirname "${version}")"/architectures 2>/dev/null | cut -d' ' -f1)
|
||||
lines=$(grep "${variant}" "$(dirname "${version}")"/architectures 2> /dev/null | cut -d' ' -f1)
|
||||
|
||||
# Get version specific supported architectures if there is specialized information
|
||||
if [ -a "${version}"/architectures ]; then
|
||||
lines=$(grep "${variant}" "${version}"/architectures 2>/dev/null | cut -d' ' -f1)
|
||||
lines=$(grep "${variant}" "${version}"/architectures 2> /dev/null | cut -d' ' -f1)
|
||||
fi
|
||||
|
||||
while IFS='' read -r line; do
|
||||
arches+=("${line}")
|
||||
done <<<"${lines}"
|
||||
done <<< "${lines}"
|
||||
|
||||
echo "${arches[@]}"
|
||||
}
|
||||
|
@ -149,13 +149,13 @@ function get_versions() {
|
|||
local default_variant
|
||||
default_variant=$(get_config "./" "default_variant")
|
||||
if [ ${#dirs[@]} -eq 0 ]; then
|
||||
IFS=' ' read -ra dirs <<<"$(echo "${prefix%/}/"*/)"
|
||||
IFS=' ' read -ra dirs <<< "$(echo "${prefix%/}/"*/)"
|
||||
fi
|
||||
|
||||
for dir in "${dirs[@]}"; do
|
||||
if [ -a "${dir}/config" ]; then
|
||||
local subdirs
|
||||
IFS=' ' read -ra subdirs <<<"$(get_versions "${dir#./}")"
|
||||
IFS=' ' read -ra subdirs <<< "$(get_versions "${dir#./}")"
|
||||
for subdir in "${subdirs[@]}"; do
|
||||
versions+=("${subdir}")
|
||||
done
|
||||
|
@ -174,7 +174,7 @@ function get_fork_name() {
|
|||
version=$1
|
||||
shift
|
||||
|
||||
IFS='/' read -ra versionparts <<<"${version}"
|
||||
IFS='/' read -ra versionparts <<< "${version}"
|
||||
if [ ${#versionparts[@]} -gt 1 ]; then
|
||||
echo "${versionparts[0]}"
|
||||
fi
|
||||
|
@ -260,7 +260,7 @@ function get_tag() {
|
|||
fi
|
||||
|
||||
local tagparts
|
||||
IFS=' ' read -ra tagparts <<<"$(get_fork_name "${version}") ${tagversion}"
|
||||
IFS=' ' read -ra tagparts <<< "$(get_fork_name "${version}") ${tagversion}"
|
||||
IFS='-'
|
||||
echo "${tagparts[*]}"
|
||||
unset IFS
|
||||
|
@ -278,11 +278,11 @@ function sort_versions() {
|
|||
|
||||
while IFS='' read -r line; do
|
||||
sorted+=("${line}")
|
||||
done <<<"$(echo "${lines}" | grep "^[0-9]" | sort -r)"
|
||||
done <<< "$(echo "${lines}" | grep "^[0-9]" | sort -r)"
|
||||
|
||||
while IFS='' read -r line; do
|
||||
sorted+=("${line}")
|
||||
done <<<"$(echo "${lines}" | grep -v "^[0-9]" | sort -r)"
|
||||
done <<< "$(echo "${lines}" | grep -v "^[0-9]" | sort -r)"
|
||||
|
||||
echo "${sorted[@]}"
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ function images_updated() {
|
|||
|
||||
commit_range="$(commit_range "$@")"
|
||||
|
||||
IFS=' ' read -ra versions <<<"$(
|
||||
IFS=' ' read -ra versions <<< "$(
|
||||
IFS=','
|
||||
get_versions
|
||||
)"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
set -e
|
||||
. functions.sh
|
||||
|
||||
hash git 2>/dev/null || { echo >&2 "git not found, exiting."; }
|
||||
hash git 2> /dev/null || { echo >&2 "git not found, exiting."; }
|
||||
|
||||
# Used dynamically: print "$array_" $1
|
||||
# shellcheck disable=SC2034
|
||||
|
@ -23,8 +23,8 @@ cd "$(cd "${0%/*}" && pwd -P)"
|
|||
|
||||
self="$(basename "${BASH_SOURCE[0]}")"
|
||||
|
||||
IFS=' ' read -ra versions <<<"$(get_versions)"
|
||||
IFS=' ' read -ra versions <<<"$(sort_versions "${versions[@]}")"
|
||||
IFS=' ' read -ra versions <<< "$(get_versions)"
|
||||
IFS=' ' read -ra versions <<< "$(sort_versions "${versions[@]}")"
|
||||
url='https://github.com/nodejs/docker-node'
|
||||
|
||||
# get the most recent commit which modified any of "$@"
|
||||
|
@ -50,7 +50,7 @@ join() {
|
|||
get_stub() {
|
||||
local version="${1}"
|
||||
shift
|
||||
IFS='/' read -ra versionparts <<<"${version}"
|
||||
IFS='/' read -ra versionparts <<< "${version}"
|
||||
local stub
|
||||
eval stub="$(join '_' "${versionparts[@]}" | awk -F. '{ print "$array_" $1 }')"
|
||||
echo "${stub}"
|
||||
|
@ -65,11 +65,11 @@ for version in "${versions[@]}"; do
|
|||
fullVersion="$(get_tag "${version}" full)"
|
||||
majorMinorVersion="$(get_tag "${version}" majorminor)"
|
||||
|
||||
IFS=' ' read -ra versionAliases <<<"$fullVersion $majorMinorVersion $stub"
|
||||
IFS=' ' read -ra versionAliases <<< "$fullVersion $majorMinorVersion $stub"
|
||||
|
||||
if [ -f "${version}/Dockerfile" ]; then
|
||||
# Get supported architectures for a specific version. See details in function.sh
|
||||
IFS=' ' read -ra supportedArches <<<"$(get_supported_arches "${version}" "default")"
|
||||
IFS=' ' read -ra supportedArches <<< "$(get_supported_arches "${version}" "default")"
|
||||
|
||||
echo "Tags: $(join ', ' "${versionAliases[@]}")"
|
||||
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
|
||||
|
@ -80,7 +80,7 @@ for version in "${versions[@]}"; do
|
|||
|
||||
# Get supported variants according to the target architecture.
|
||||
# See details in function.sh
|
||||
IFS=' ' read -ra variants <<<"$(get_variants "$(dirname "${version}")")"
|
||||
IFS=' ' read -ra variants <<< "$(get_variants "$(dirname "${version}")")"
|
||||
for variant in "${variants[@]}"; do
|
||||
# Skip non-docker directories
|
||||
[ -f "${version}/${variant}/Dockerfile" ] || continue
|
||||
|
@ -96,7 +96,7 @@ for version in "${versions[@]}"; do
|
|||
|
||||
# Get supported architectures for a specific version and variant.
|
||||
# See details in function.sh
|
||||
IFS=' ' read -ra supportedArches <<<"$(get_supported_arches "${version}" "${variant}")"
|
||||
IFS=' ' read -ra supportedArches <<< "$(get_supported_arches "${version}" "${variant}")"
|
||||
|
||||
echo "Tags: $(join ', ' "${variantAliases[@]}")"
|
||||
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
|
||||
|
|
|
@ -96,19 +96,19 @@ if images_updated "${COMMIT_ID}"; then
|
|||
setup_git_author
|
||||
|
||||
info "Cloning..."
|
||||
git clone --depth 50 "https://github.com/${UPSTREAM_SLUG}.git" ${gitpath} 2>/dev/null
|
||||
git clone --depth 50 "https://github.com/${UPSTREAM_SLUG}.git" ${gitpath} 2> /dev/null
|
||||
|
||||
stackbrew="$(./generate-stackbrew-library.sh)"
|
||||
|
||||
cd ${gitpath}
|
||||
|
||||
echo "${stackbrew}" >"${IMAGES_FILE}"
|
||||
echo "${stackbrew}" > "${IMAGES_FILE}"
|
||||
git checkout -b "${BRANCH_NAME}"
|
||||
git add "${IMAGES_FILE}"
|
||||
git commit -m "$(message)"
|
||||
|
||||
info "Pushing..."
|
||||
git push "https://${GITHUB_API_TOKEN}:x-oauth-basic@github.com/${ORIGIN_SLUG}.git" -f "${BRANCH_NAME}" 2>/dev/null || fatal "Error pushing the updated stackbrew"
|
||||
git push "https://${GITHUB_API_TOKEN}:x-oauth-basic@github.com/${ORIGIN_SLUG}.git" -f "${BRANCH_NAME}" 2> /dev/null || fatal "Error pushing the updated stackbrew"
|
||||
|
||||
cd - && rm -rf ${gitpath}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ set -euo pipefail
|
|||
# Convert comma delimited cli arguments to arrays
|
||||
# E.g. ./test-build.sh 8,10 slim,onbuild
|
||||
# "8,10" becomes "8 10" and "slim,onbuild" becomes "slim onbuild"
|
||||
IFS=',' read -ra versions_arg <<<"${1:-}"
|
||||
IFS=',' read -ra variant_arg <<<"${2:-}"
|
||||
IFS=',' read -ra versions_arg <<< "${1:-}"
|
||||
IFS=',' read -ra variant_arg <<< "${2:-}"
|
||||
|
||||
default_variant=$(get_config "./" "default_variant")
|
||||
|
||||
|
@ -62,7 +62,7 @@ function test_image() {
|
|||
|
||||
cd "$(cd "${0%/*}" && pwd -P)" || exit
|
||||
|
||||
IFS=' ' read -ra versions <<<"$(get_versions . "${versions_arg[@]}")"
|
||||
IFS=' ' read -ra versions <<< "$(get_versions . "${versions_arg[@]}")"
|
||||
if [ ${#versions[@]} -eq 0 ]; then
|
||||
fatal "No valid versions found!"
|
||||
fi
|
||||
|
@ -82,7 +82,7 @@ for version in "${versions[@]}"; do
|
|||
|
||||
# Get supported variants according to the target architecture.
|
||||
# See details in function.sh
|
||||
IFS=' ' read -ra variants <<<"$(get_variants "$(dirname "${version}")" "${variant_arg[@]}")"
|
||||
IFS=' ' read -ra variants <<< "$(get_variants "$(dirname "${version}")" "${variant_arg[@]}")"
|
||||
|
||||
for variant in "${variants[@]}"; do
|
||||
# Skip non-docker directories
|
||||
|
|
|
@ -54,7 +54,7 @@ jobs:
|
|||
env:
|
||||
- TEST: shfmt check
|
||||
script:
|
||||
- docker run -it --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:2.5.0 -i 2 -l -w -ci .
|
||||
- docker run -it --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:2.5.0 -sr -i 2 -l -w -ci .
|
||||
- git diff --color
|
||||
- git diff --stat=220 --color --exit-code
|
||||
|
||||
|
|
20
update.sh
20
update.sh
|
@ -2,7 +2,7 @@
|
|||
set -ue
|
||||
|
||||
function usage() {
|
||||
cat <<EOF
|
||||
cat << EOF
|
||||
|
||||
Update the node docker images.
|
||||
|
||||
|
@ -47,12 +47,12 @@ done
|
|||
|
||||
cd "$(cd "${0%/*}" && pwd -P)"
|
||||
|
||||
IFS=',' read -ra versions_arg <<<"${1:-}"
|
||||
IFS=',' read -ra variant_arg <<<"${2:-}"
|
||||
IFS=',' read -ra versions_arg <<< "${1:-}"
|
||||
IFS=',' read -ra variant_arg <<< "${2:-}"
|
||||
|
||||
IFS=' ' read -ra versions <<<"$(get_versions .)"
|
||||
IFS=' ' read -ra update_versions <<<"$(get_versions . "${versions_arg[@]:-}")"
|
||||
IFS=' ' read -ra update_variants <<<"$(get_variants . "${variant_arg[@]:-}")"
|
||||
IFS=' ' read -ra versions <<< "$(get_versions .)"
|
||||
IFS=' ' read -ra update_versions <<< "$(get_versions . "${versions_arg[@]:-}")"
|
||||
IFS=' ' read -ra update_variants <<< "$(get_variants . "${variant_arg[@]:-}")"
|
||||
if [ ${#versions[@]} -eq 0 ]; then
|
||||
fatal "No valid versions found!"
|
||||
fi
|
||||
|
@ -151,7 +151,7 @@ function update_node_version() {
|
|||
while read -r line; do
|
||||
pattern='"\$\{'$(echo "${key_type}" | tr '[:lower:]' '[:upper:]')'_KEYS\[@\]\}"'
|
||||
sed -Ei -e "s/([ \\t]*)(${pattern})/\\1${line}${new_line}\\1\\2/" "${dockerfile}-tmp"
|
||||
done <"keys/${key_type}.keys"
|
||||
done < "keys/${key_type}.keys"
|
||||
sed -Ei -e "/${pattern}/d" "${dockerfile}-tmp"
|
||||
done
|
||||
|
||||
|
@ -183,11 +183,11 @@ function add_stage() {
|
|||
- stage: Build
|
||||
env:
|
||||
- NODE_VERSION: "'"${version}"'"
|
||||
- VARIANT: "'"${variant}"'"' >>.travis.yml
|
||||
- VARIANT: "'"${variant}"'"' >> .travis.yml
|
||||
}
|
||||
|
||||
echo '#### DO NOT MODIFY. THIS FILE IS AUTOGENERATED ####
|
||||
' | cat - travis.yml.template >.travis.yml
|
||||
' | cat - travis.yml.template > .travis.yml
|
||||
|
||||
for version in "${versions[@]}"; do
|
||||
parentpath=$(dirname "${version}")
|
||||
|
@ -199,7 +199,7 @@ for version in "${versions[@]}"; do
|
|||
|
||||
# Get supported variants according the target architecture
|
||||
# See details in function.sh
|
||||
IFS=' ' read -ra variants <<<"$(get_variants "${parentpath}")"
|
||||
IFS=' ' read -ra variants <<< "$(get_variants "${parentpath}")"
|
||||
|
||||
if [ -f "${version}/Dockerfile" ]; then
|
||||
add_stage "${baseuri}" "${version}" "default"
|
||||
|
|
Loading…
Reference in New Issue