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
|
||||
for variant1 in "${availablevariants[@]}"; do
|
||||
for variant2 in "${variantsfilter[@]}"; do
|
||||
if [[ "$variant1" = "$variant2" ]]; then
|
||||
if [[ "$variant1" == "$variant2" ]]; then
|
||||
variants+=("$variant1")
|
||||
fi
|
||||
done
|
||||
|
@ -94,8 +94,10 @@ function get_supported_arches () {
|
|||
local arches
|
||||
local lines
|
||||
local line
|
||||
version="$1"; shift
|
||||
variant="$1"; shift
|
||||
version="$1"
|
||||
shift
|
||||
variant="$1"
|
||||
shift
|
||||
|
||||
# Get default supported arches
|
||||
lines=$(grep "$variant" "$(dirname "$version")"/architectures 2>/dev/null | cut -d' ' -f1)
|
||||
|
@ -212,7 +214,9 @@ function get_tag () {
|
|||
|
||||
local tagparts
|
||||
IFS=' ' read -ra tagparts <<<"$(get_fork_name "$version") $tagversion"
|
||||
IFS='-'; echo "${tagparts[*]}"; unset IFS
|
||||
IFS='-'
|
||||
echo "${tagparts[*]}"
|
||||
unset IFS
|
||||
}
|
||||
|
||||
function sort_versions() {
|
||||
|
|
|
@ -6,19 +6,19 @@ hash git 2>/dev/null || { echo >&2 "git not found, exiting."; }
|
|||
|
||||
# Used dynamically: print "$array_" $1
|
||||
# shellcheck disable=SC2034
|
||||
array_6='6 boron';
|
||||
array_6='6 boron'
|
||||
# shellcheck disable=SC2034
|
||||
array_8='8 carbon';
|
||||
array_8='8 carbon'
|
||||
# shellcheck disable=SC2034
|
||||
array_9='9';
|
||||
array_9='9'
|
||||
# shellcheck disable=SC2034
|
||||
array_10='10 latest';
|
||||
array_10='10 latest'
|
||||
# shellcheck disable=SC2034
|
||||
array_chakracore_8='chakracore-8';
|
||||
array_chakracore_8='chakracore-8'
|
||||
# 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]}")"
|
||||
|
||||
|
@ -39,15 +39,19 @@ echo
|
|||
|
||||
# prints "$2$1$3$1...$N"
|
||||
join() {
|
||||
local sep="$1"; shift
|
||||
local out; printf -v out "${sep//%/%%}%s" "$@"
|
||||
local sep="$1"
|
||||
shift
|
||||
local out
|
||||
printf -v out "${sep//%/%%}%s" "$@"
|
||||
echo "${out#$sep}"
|
||||
}
|
||||
|
||||
get_stub() {
|
||||
local version="$1"; shift
|
||||
local version="$1"
|
||||
shift
|
||||
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"
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,10 @@ function updated() {
|
|||
local versions
|
||||
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[@]}")
|
||||
|
||||
if [ -z "$images_changed" ]; then
|
||||
|
|
|
@ -18,9 +18,12 @@ function build () {
|
|||
local variant
|
||||
local full_tag
|
||||
local path
|
||||
version="$1"; shift
|
||||
variant="$1"; shift
|
||||
tag="$1"; shift
|
||||
version="$1"
|
||||
shift
|
||||
variant="$1"
|
||||
shift
|
||||
tag="$1"
|
||||
shift
|
||||
|
||||
if [ -z "$variant" ]; then
|
||||
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"
|
||||
}
|
||||
|
||||
cd "$(cd "${0%/*}" && pwd -P)" || exit;
|
||||
cd "$(cd "${0%/*}" && pwd -P)" || exit
|
||||
|
||||
IFS=' ' read -ra versions <<<"$(get_versions . "${versions_arg[@]}")"
|
||||
if [ ${#versions[@]} -eq 0 ]; then
|
||||
|
|
18
update.sh
18
update.sh
|
@ -3,7 +3,7 @@ set -ue
|
|||
|
||||
. functions.sh
|
||||
|
||||
cd "$(cd "${0%/*}" && pwd -P)";
|
||||
cd "$(cd "${0%/*}" && pwd -P)"
|
||||
|
||||
IFS=' ' read -ra versions <<<"$(get_versions . "$@")"
|
||||
if [ ${#versions[@]} -eq 0 ]; then
|
||||
|
@ -18,7 +18,7 @@ arch=$(get_arch)
|
|||
|
||||
yarnVersion="$(curl -sSL --compressed https://yarnpkg.com/latest-version)"
|
||||
|
||||
function update_node_version {
|
||||
function update_node_version() {
|
||||
|
||||
local baseuri=$1
|
||||
shift
|
||||
|
@ -28,7 +28,7 @@ function update_node_version {
|
|||
shift
|
||||
local dockerfile=$1
|
||||
shift
|
||||
local variant=
|
||||
local variant
|
||||
if [[ $# -eq 1 ]]; then
|
||||
variant=$1
|
||||
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)"
|
||||
(
|
||||
cp "$template" "$dockerfile"
|
||||
local fromprefix=
|
||||
local fromprefix
|
||||
if [[ "$arch" != "amd64" && "$variant" != "onbuild" ]]; then
|
||||
fromprefix="$arch\\/"
|
||||
fi
|
||||
|
@ -51,10 +51,8 @@ function update_node_version {
|
|||
'
|
||||
|
||||
# Add GPG keys
|
||||
for key_type in "node" "yarn"
|
||||
do
|
||||
while read -r line
|
||||
do
|
||||
for key_type in "node" "yarn"; do
|
||||
while read -r line; do
|
||||
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
|
||||
done <"keys/$key_type.keys"
|
||||
|
@ -64,14 +62,14 @@ function update_node_version {
|
|||
if [[ "${version/.*/}" -ge 10 ]]; then
|
||||
sed -E -i.bak 's/FROM (.*)alpine:3.4/FROM \1alpine:3.7/' "$dockerfile"
|
||||
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"
|
||||
rm "$dockerfile.bak"
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
function add_stage {
|
||||
function add_stage() {
|
||||
local baseuri=$1
|
||||
shift
|
||||
local version=$1
|
||||
|
|
Loading…
Reference in New Issue