Format shell scripts with shfmt -i 2 -ci -l -w -f
This commit is contained in:
parent
0d0dcfd379
commit
f384c2b6f1
12
functions.sh
12
functions.sh
|
@ -67,7 +67,7 @@ function get_variants() {
|
||||||
if [ ${#variantsfilter[@]} -gt 0 ]; then
|
if [ ${#variantsfilter[@]} -gt 0 ]; then
|
||||||
for variant1 in "${availablevariants[@]}"; do
|
for variant1 in "${availablevariants[@]}"; do
|
||||||
for variant2 in "${variantsfilter[@]}"; do
|
for variant2 in "${variantsfilter[@]}"; do
|
||||||
if [[ "$variant1" = "$variant2" ]]; then
|
if [[ "$variant1" == "$variant2" ]]; then
|
||||||
variants+=("$variant1")
|
variants+=("$variant1")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -94,8 +94,10 @@ function get_supported_arches () {
|
||||||
local arches
|
local arches
|
||||||
local lines
|
local lines
|
||||||
local line
|
local line
|
||||||
version="$1"; shift
|
version="$1"
|
||||||
variant="$1"; shift
|
shift
|
||||||
|
variant="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
# Get default supported arches
|
# 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)
|
||||||
|
@ -212,7 +214,9 @@ function get_tag () {
|
||||||
|
|
||||||
local tagparts
|
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
|
IFS='-'
|
||||||
|
echo "${tagparts[*]}"
|
||||||
|
unset IFS
|
||||||
}
|
}
|
||||||
|
|
||||||
function sort_versions() {
|
function sort_versions() {
|
||||||
|
|
|
@ -6,19 +6,19 @@ hash git 2>/dev/null || { echo >&2 "git not found, exiting."; }
|
||||||
|
|
||||||
# Used dynamically: print "$array_" $1
|
# Used dynamically: print "$array_" $1
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
array_6='6 boron';
|
array_6='6 boron'
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
array_8='8 carbon';
|
array_8='8 carbon'
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
array_9='9';
|
array_9='9'
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
array_10='10 latest';
|
array_10='10 latest'
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
array_chakracore_8='chakracore-8';
|
array_chakracore_8='chakracore-8'
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
array_chakracore_10='chakracore-10 chakracore';
|
array_chakracore_10='chakracore-10 chakracore'
|
||||||
|
|
||||||
cd "$(cd "${0%/*}" && pwd -P)";
|
cd "$(cd "${0%/*}" && pwd -P)"
|
||||||
|
|
||||||
self="$(basename "${BASH_SOURCE[0]}")"
|
self="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
|
@ -39,15 +39,19 @@ echo
|
||||||
|
|
||||||
# prints "$2$1$3$1...$N"
|
# prints "$2$1$3$1...$N"
|
||||||
join() {
|
join() {
|
||||||
local sep="$1"; shift
|
local sep="$1"
|
||||||
local out; printf -v out "${sep//%/%%}%s" "$@"
|
shift
|
||||||
|
local out
|
||||||
|
printf -v out "${sep//%/%%}%s" "$@"
|
||||||
echo "${out#$sep}"
|
echo "${out#$sep}"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_stub() {
|
get_stub() {
|
||||||
local version="$1"; shift
|
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 }')";
|
local stub
|
||||||
|
eval stub="$(join '_' "${versionparts[@]}" | awk -F. '{ print "$array_" $1 }')"
|
||||||
echo "$stub"
|
echo "$stub"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,10 @@ function updated() {
|
||||||
local versions
|
local versions
|
||||||
local images_changed
|
local images_changed
|
||||||
|
|
||||||
IFS=' ' read -ra versions <<< "$(IFS=','; get_versions)"
|
IFS=' ' read -ra versions <<<"$(
|
||||||
|
IFS=','
|
||||||
|
get_versions
|
||||||
|
)"
|
||||||
images_changed=$(git diff --name-only "$COMMIT_ID".."$COMMIT_ID"~1 "${versions[@]}")
|
images_changed=$(git diff --name-only "$COMMIT_ID".."$COMMIT_ID"~1 "${versions[@]}")
|
||||||
|
|
||||||
if [ -z "$images_changed" ]; then
|
if [ -z "$images_changed" ]; then
|
||||||
|
|
|
@ -18,9 +18,12 @@ function build () {
|
||||||
local variant
|
local variant
|
||||||
local full_tag
|
local full_tag
|
||||||
local path
|
local path
|
||||||
version="$1"; shift
|
version="$1"
|
||||||
variant="$1"; shift
|
shift
|
||||||
tag="$1"; shift
|
variant="$1"
|
||||||
|
shift
|
||||||
|
tag="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
if [ -z "$variant" ]; then
|
if [ -z "$variant" ]; then
|
||||||
full_tag="$tag"
|
full_tag="$tag"
|
||||||
|
@ -41,7 +44,7 @@ function build () {
|
||||||
docker run --rm -v "$PWD/test-image.sh:/usr/local/bin/test.sh" node:"$full_tag" test.sh "$full_version"
|
docker run --rm -v "$PWD/test-image.sh:/usr/local/bin/test.sh" node:"$full_tag" test.sh "$full_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
cd "$(cd "${0%/*}" && pwd -P)" || exit;
|
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
|
if [ ${#versions[@]} -eq 0 ]; then
|
||||||
|
|
18
update.sh
18
update.sh
|
@ -3,7 +3,7 @@ set -ue
|
||||||
|
|
||||||
. functions.sh
|
. functions.sh
|
||||||
|
|
||||||
cd "$(cd "${0%/*}" && pwd -P)";
|
cd "$(cd "${0%/*}" && pwd -P)"
|
||||||
|
|
||||||
IFS=' ' read -ra versions <<<"$(get_versions . "$@")"
|
IFS=' ' read -ra versions <<<"$(get_versions . "$@")"
|
||||||
if [ ${#versions[@]} -eq 0 ]; then
|
if [ ${#versions[@]} -eq 0 ]; then
|
||||||
|
@ -18,7 +18,7 @@ arch=$(get_arch)
|
||||||
|
|
||||||
yarnVersion="$(curl -sSL --compressed https://yarnpkg.com/latest-version)"
|
yarnVersion="$(curl -sSL --compressed https://yarnpkg.com/latest-version)"
|
||||||
|
|
||||||
function update_node_version {
|
function update_node_version() {
|
||||||
|
|
||||||
local baseuri=$1
|
local baseuri=$1
|
||||||
shift
|
shift
|
||||||
|
@ -28,7 +28,7 @@ function update_node_version {
|
||||||
shift
|
shift
|
||||||
local dockerfile=$1
|
local dockerfile=$1
|
||||||
shift
|
shift
|
||||||
local variant=
|
local variant
|
||||||
if [[ $# -eq 1 ]]; then
|
if [[ $# -eq 1 ]]; then
|
||||||
variant=$1
|
variant=$1
|
||||||
shift
|
shift
|
||||||
|
@ -37,7 +37,7 @@ function update_node_version {
|
||||||
fullVersion="$(curl -sSL --compressed "$baseuri" | grep '<a href="v'"$version." | sed -E 's!.*<a href="v([^"/]+)/?".*!\1!' | cut -d'.' -f2,3 | sort -n | tail -1)"
|
fullVersion="$(curl -sSL --compressed "$baseuri" | grep '<a href="v'"$version." | sed -E 's!.*<a href="v([^"/]+)/?".*!\1!' | cut -d'.' -f2,3 | sort -n | tail -1)"
|
||||||
(
|
(
|
||||||
cp "$template" "$dockerfile"
|
cp "$template" "$dockerfile"
|
||||||
local fromprefix=
|
local fromprefix
|
||||||
if [[ "$arch" != "amd64" && "$variant" != "onbuild" ]]; then
|
if [[ "$arch" != "amd64" && "$variant" != "onbuild" ]]; then
|
||||||
fromprefix="$arch\\/"
|
fromprefix="$arch\\/"
|
||||||
fi
|
fi
|
||||||
|
@ -51,10 +51,8 @@ function update_node_version {
|
||||||
'
|
'
|
||||||
|
|
||||||
# Add GPG keys
|
# Add GPG keys
|
||||||
for key_type in "node" "yarn"
|
for key_type in "node" "yarn"; do
|
||||||
do
|
while read -r line; do
|
||||||
while read -r line
|
|
||||||
do
|
|
||||||
pattern="\"\\$\\{$(echo "$key_type" | tr '[:lower:]' '[:upper:]')_KEYS\\[@\\]\\}\""
|
pattern="\"\\$\\{$(echo "$key_type" | tr '[:lower:]' '[:upper:]')_KEYS\\[@\\]\\}\""
|
||||||
sed -E -i.bak -e "s/([ \\t]*)($pattern)/\\1${line}${new_line}\\1\\2/" "$dockerfile" && rm "$dockerfile".bak
|
sed -E -i.bak -e "s/([ \\t]*)($pattern)/\\1${line}${new_line}\\1\\2/" "$dockerfile" && rm "$dockerfile".bak
|
||||||
done <"keys/$key_type.keys"
|
done <"keys/$key_type.keys"
|
||||||
|
@ -64,14 +62,14 @@ function update_node_version {
|
||||||
if [[ "${version/.*/}" -ge 10 ]]; then
|
if [[ "${version/.*/}" -ge 10 ]]; then
|
||||||
sed -E -i.bak 's/FROM (.*)alpine:3.4/FROM \1alpine:3.7/' "$dockerfile"
|
sed -E -i.bak 's/FROM (.*)alpine:3.4/FROM \1alpine:3.7/' "$dockerfile"
|
||||||
rm "$dockerfile.bak"
|
rm "$dockerfile.bak"
|
||||||
elif [[ "${version/.*/}" -ge 8 || "$arch" = "ppc64le" || "$arch" = "s390x" || "$arch" = "arm64" || "$arch" = "arm32v7" ]]; then
|
elif [[ "${version/.*/}" -ge 8 || "$arch" == "ppc64le" || "$arch" == "s390x" || "$arch" == "arm64" || "$arch" == "arm32v7" ]]; then
|
||||||
sed -E -i.bak 's/FROM (.*)alpine:3.4/FROM \1alpine:3.6/' "$dockerfile"
|
sed -E -i.bak 's/FROM (.*)alpine:3.4/FROM \1alpine:3.6/' "$dockerfile"
|
||||||
rm "$dockerfile.bak"
|
rm "$dockerfile.bak"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_stage {
|
function add_stage() {
|
||||||
local baseuri=$1
|
local baseuri=$1
|
||||||
shift
|
shift
|
||||||
local version=$1
|
local version=$1
|
||||||
|
|
Loading…
Reference in New Issue