Format shell scripts with shfmt -i 2 -ci -l -w -f
This commit is contained in:
parent
0d0dcfd379
commit
f384c2b6f1
64
functions.sh
64
functions.sh
|
@ -61,13 +61,13 @@ function get_variants() {
|
||||||
local variants
|
local variants
|
||||||
|
|
||||||
arch=$(get_arch)
|
arch=$(get_arch)
|
||||||
variantsfilter=( "$@" )
|
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
|
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
|
||||||
|
@ -88,26 +88,28 @@ function get_variants() {
|
||||||
# default architectures. This will give us some benefits:
|
# default architectures. This will give us some benefits:
|
||||||
# - a specific version may or may not support some architectures
|
# - a specific version may or may not support some architectures
|
||||||
# - if there is no specialization for a version, just don't provide local architectures
|
# - if there is no specialization for a version, just don't provide local architectures
|
||||||
function get_supported_arches () {
|
function get_supported_arches() {
|
||||||
local version
|
local version
|
||||||
local variant
|
local variant
|
||||||
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)
|
||||||
|
|
||||||
# Get version specific supported architectures if there is specialized information
|
# Get version specific supported architectures if there is specialized information
|
||||||
if [ -a "$version"/architectures ]; then
|
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
|
fi
|
||||||
|
|
||||||
while IFS='' read -r line; do
|
while IFS='' read -r line; do
|
||||||
arches+=( "$line" )
|
arches+=("$line")
|
||||||
done <<< "$lines"
|
done <<<"$lines"
|
||||||
|
|
||||||
echo "${arches[@]}"
|
echo "${arches[@]}"
|
||||||
}
|
}
|
||||||
|
@ -115,7 +117,7 @@ function get_supported_arches () {
|
||||||
# Get configuration values from the config file
|
# Get configuration values from the config file
|
||||||
#
|
#
|
||||||
# The configuration entries are simple key/value pairs which are whitespace separated.
|
# The configuration entries are simple key/value pairs which are whitespace separated.
|
||||||
function get_config () {
|
function get_config() {
|
||||||
local dir
|
local dir
|
||||||
dir=${1:-.}
|
dir=${1:-.}
|
||||||
shift
|
shift
|
||||||
|
@ -136,26 +138,26 @@ function get_config () {
|
||||||
# chakracore entry and found it to be a fork rather than a complete version.
|
# chakracore entry and found it to be a fork rather than a complete version.
|
||||||
#
|
#
|
||||||
# The result is a list of valid versions.
|
# The result is a list of valid versions.
|
||||||
function get_versions () {
|
function get_versions() {
|
||||||
local prefix
|
local prefix
|
||||||
prefix=${1:-.}
|
prefix=${1:-.}
|
||||||
shift
|
shift
|
||||||
|
|
||||||
local versions
|
local versions
|
||||||
local dirs=( "$@" )
|
local dirs=("$@")
|
||||||
if [ ${#dirs[@]} -eq 0 ]; then
|
if [ ${#dirs[@]} -eq 0 ]; then
|
||||||
IFS=' ' read -ra dirs <<< "$(echo "${prefix%/}/"*/)"
|
IFS=' ' read -ra dirs <<<"$(echo "${prefix%/}/"*/)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for dir in "${dirs[@]}"; do
|
for dir in "${dirs[@]}"; do
|
||||||
if [ -a "$dir/config" ]; then
|
if [ -a "$dir/config" ]; then
|
||||||
local subdirs
|
local subdirs
|
||||||
IFS=' ' read -ra subdirs <<< "$(get_versions "${dir#./}")"
|
IFS=' ' read -ra subdirs <<<"$(get_versions "${dir#./}")"
|
||||||
for subdir in "${subdirs[@]}"; do
|
for subdir in "${subdirs[@]}"; do
|
||||||
versions+=( "$subdir" )
|
versions+=("$subdir")
|
||||||
done
|
done
|
||||||
elif [ -a "$dir/Dockerfile" ]; then
|
elif [ -a "$dir/Dockerfile" ]; then
|
||||||
versions+=( "${dir#./}" )
|
versions+=("${dir#./}")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -164,18 +166,18 @@ function get_versions () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_fork_name () {
|
function get_fork_name() {
|
||||||
local version
|
local version
|
||||||
version=$1
|
version=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
IFS='/' read -ra versionparts <<< "$version"
|
IFS='/' read -ra versionparts <<<"$version"
|
||||||
if [ ${#versionparts[@]} -gt 1 ]; then
|
if [ ${#versionparts[@]} -gt 1 ]; then
|
||||||
echo "${versionparts[0]}"
|
echo "${versionparts[0]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_full_version () {
|
function get_full_version() {
|
||||||
local version
|
local version
|
||||||
version=$1
|
version=$1
|
||||||
shift
|
shift
|
||||||
|
@ -183,7 +185,7 @@ function get_full_version () {
|
||||||
grep -m1 'ENV NODE_VERSION ' "$version/Dockerfile" | cut -d' ' -f3
|
grep -m1 'ENV NODE_VERSION ' "$version/Dockerfile" | cut -d' ' -f3
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_major_minor_version () {
|
function get_major_minor_version() {
|
||||||
local version
|
local version
|
||||||
version=$1
|
version=$1
|
||||||
shift
|
shift
|
||||||
|
@ -194,7 +196,7 @@ function get_major_minor_version () {
|
||||||
echo "$(echo "$fullversion" | cut -d'.' -f1).$(echo "$fullversion" | cut -d'.' -f2)"
|
echo "$(echo "$fullversion" | cut -d'.' -f1).$(echo "$fullversion" | cut -d'.' -f2)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_tag () {
|
function get_tag() {
|
||||||
local version
|
local version
|
||||||
version=$1
|
version=$1
|
||||||
shift
|
shift
|
||||||
|
@ -211,12 +213,14 @@ function get_tag () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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() {
|
||||||
local versions=( "$@" )
|
local versions=("$@")
|
||||||
local sorted
|
local sorted
|
||||||
local lines
|
local lines
|
||||||
local line
|
local line
|
||||||
|
@ -226,12 +230,12 @@ function sort_versions () {
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
while IFS='' read -r line; do
|
while IFS='' read -r line; do
|
||||||
sorted+=( "$line" )
|
sorted+=("$line")
|
||||||
done <<< "$(echo "$lines" | grep "^[0-9]" | sort -r)"
|
done <<<"$(echo "$lines" | grep "^[0-9]" | sort -r)"
|
||||||
|
|
||||||
while IFS='' read -r line; do
|
while IFS='' read -r line; do
|
||||||
sorted+=( "$line" )
|
sorted+=("$line")
|
||||||
done <<< "$(echo "$lines" | grep -v "^[0-9]" | sort -r)"
|
done <<<"$(echo "$lines" | grep -v "^[0-9]" | sort -r)"
|
||||||
|
|
||||||
echo "${sorted[@]}"
|
echo "${sorted[@]}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,24 +6,24 @@ 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]}")"
|
||||||
|
|
||||||
IFS=' ' read -ra versions <<< "$(get_versions)"
|
IFS=' ' read -ra versions <<<"$(get_versions)"
|
||||||
IFS=' ' read -ra versions <<< "$(sort_versions "${versions[@]}")"
|
IFS=' ' read -ra versions <<<"$(sort_versions "${versions[@]}")"
|
||||||
url='https://github.com/nodejs/docker-node'
|
url='https://github.com/nodejs/docker-node'
|
||||||
|
|
||||||
# get the most recent commit which modified any of "$@"
|
# get the most recent commit which modified any of "$@"
|
||||||
|
@ -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"
|
||||||
IFS='/' read -ra versionparts <<< "$version"
|
shift
|
||||||
local stub; eval stub="$(join '_' "${versionparts[@]}" | awk -F. '{ print "$array_" $1 }')";
|
IFS='/' read -ra versionparts <<<"$version"
|
||||||
|
local stub
|
||||||
|
eval stub="$(join '_' "${versionparts[@]}" | awk -F. '{ print "$array_" $1 }')"
|
||||||
echo "$stub"
|
echo "$stub"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +64,9 @@ for version in "${versions[@]}"; do
|
||||||
fullVersion="$(get_tag "$version" full)"
|
fullVersion="$(get_tag "$version" full)"
|
||||||
majorMinorVersion="$(get_tag "$version" majorminor)"
|
majorMinorVersion="$(get_tag "$version" majorminor)"
|
||||||
|
|
||||||
IFS=' ' read -ra versionAliases <<< "$fullVersion $majorMinorVersion $stub"
|
IFS=' ' read -ra versionAliases <<<"$fullVersion $majorMinorVersion $stub"
|
||||||
# Get supported architectures for a specific version. See details in function.sh
|
# 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 "Tags: $(join ', ' "${versionAliases[@]}")"
|
||||||
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
|
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
|
||||||
|
@ -72,7 +76,7 @@ for version in "${versions[@]}"; do
|
||||||
|
|
||||||
# Get supported variants according to the target architecture.
|
# Get supported variants according to the target architecture.
|
||||||
# See details in function.sh
|
# 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
|
for variant in "${variants[@]}"; do
|
||||||
# Skip non-docker directories
|
# Skip non-docker directories
|
||||||
[ -f "$version/$variant/Dockerfile" ] || continue
|
[ -f "$version/$variant/Dockerfile" ] || continue
|
||||||
|
@ -80,11 +84,11 @@ for version in "${versions[@]}"; do
|
||||||
commit="$(fileCommit "$version/$variant")"
|
commit="$(fileCommit "$version/$variant")"
|
||||||
|
|
||||||
slash='/'
|
slash='/'
|
||||||
variantAliases=( "${versionAliases[@]/%/-${variant//$slash/-}}" )
|
variantAliases=("${versionAliases[@]/%/-${variant//$slash/-}}")
|
||||||
variantAliases=( "${variantAliases[@]//latest-/}" )
|
variantAliases=("${variantAliases[@]//latest-/}")
|
||||||
# Get supported architectures for a specific version and variant.
|
# Get supported architectures for a specific version and variant.
|
||||||
# See details in function.sh
|
# 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 "Tags: $(join ', ' "${variantAliases[@]}")"
|
||||||
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
|
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
|
||||||
|
|
|
@ -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
|
||||||
|
@ -109,19 +112,19 @@ if updated; then
|
||||||
setup_git_author
|
setup_git_author
|
||||||
|
|
||||||
info "Cloning..."
|
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)"
|
stackbrew="$(./generate-stackbrew-library.sh)"
|
||||||
|
|
||||||
cd $gitpath
|
cd $gitpath
|
||||||
|
|
||||||
echo "$stackbrew" > "$IMAGES_FILE"
|
echo "$stackbrew" >"$IMAGES_FILE"
|
||||||
git checkout -b "$BRANCH_NAME"
|
git checkout -b "$BRANCH_NAME"
|
||||||
git add "$IMAGES_FILE"
|
git add "$IMAGES_FILE"
|
||||||
git commit -m "$(message)"
|
git commit -m "$(message)"
|
||||||
|
|
||||||
info "Pushing..."
|
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
|
cd - && rm -rf $gitpath
|
||||||
|
|
||||||
|
|
|
@ -9,18 +9,21 @@ set -uo pipefail
|
||||||
# Convert comma delimited cli arguments to arrays
|
# Convert comma delimited cli arguments to arrays
|
||||||
# E.g. ./test-build.sh 8,10 slim,onbuild
|
# E.g. ./test-build.sh 8,10 slim,onbuild
|
||||||
# "8,10" becomes "8 10" and "slim,onbuild" becomes "slim onbuild"
|
# "8,10" becomes "8 10" and "slim,onbuild" becomes "slim onbuild"
|
||||||
IFS=',' read -ra versions_arg <<< "${1:-}"
|
IFS=',' read -ra versions_arg <<<"${1:-}"
|
||||||
IFS=',' read -ra variant_arg <<< "${2:-}"
|
IFS=',' read -ra variant_arg <<<"${2:-}"
|
||||||
|
|
||||||
function build () {
|
function build() {
|
||||||
local version
|
local version
|
||||||
local tag
|
local tag
|
||||||
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,9 +44,9 @@ 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
|
||||||
fatal "No valid versions found!"
|
fatal "No valid versions found!"
|
||||||
fi
|
fi
|
||||||
|
@ -57,10 +60,10 @@ for version in "${versions[@]}"; do
|
||||||
|
|
||||||
# Get supported variants according to the target architecture.
|
# Get supported variants according to the target architecture.
|
||||||
# See details in function.sh
|
# 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[@]}")"
|
||||||
|
|
||||||
# Only build the default Dockerfile if "default" is in the variant list
|
# Only build the default Dockerfile if "default" is in the variant list
|
||||||
if [[ "${variants[*]}" =~ "default" ]] || [[ "${variants[*]}" =~ "onbuild" ]] ; then
|
if [[ "${variants[*]}" =~ "default" ]] || [[ "${variants[*]}" =~ "onbuild" ]]; then
|
||||||
build "$version" "" "$tag"
|
build "$version" "" "$tag"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@ if [ "$(node -e "process.stdout.write(process.versions.node)")" != "$1" ]; then
|
||||||
fi
|
fi
|
||||||
echo "Test for node succeeded."
|
echo "Test for node succeeded."
|
||||||
|
|
||||||
if ! npm --version > /dev/null; then
|
if ! npm --version >/dev/null; then
|
||||||
echo "Test for npm failed!"
|
echo "Test for npm failed!"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
echo "Test for npm succeeded."
|
echo "Test for npm succeeded."
|
||||||
|
|
||||||
if ! yarn --version > /dev/null; then
|
if ! yarn --version >/dev/null; then
|
||||||
echo "Test of yarn failed!"
|
echo "Test of yarn failed!"
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
30
update.sh
30
update.sh
|
@ -3,9 +3,9 @@ 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
|
||||||
fatal "No valid versions found!"
|
fatal "No valid versions found!"
|
||||||
fi
|
fi
|
||||||
|
@ -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,16 +28,16 @@ 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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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,27 +51,25 @@ 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"
|
||||||
sed -E -i.bak "/$pattern/d" "$dockerfile" && rm "$dockerfile".bak
|
sed -E -i.bak "/$pattern/d" "$dockerfile" && rm "$dockerfile".bak
|
||||||
done
|
done
|
||||||
|
|
||||||
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
|
||||||
|
@ -83,11 +81,11 @@ function add_stage {
|
||||||
env:
|
env:
|
||||||
- NODE_VERSION: "'"$version"'"
|
- NODE_VERSION: "'"$version"'"
|
||||||
- VARIANT: "'"$variant"'"
|
- VARIANT: "'"$variant"'"
|
||||||
' >> .travis.yml
|
' >>.travis.yml
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '#### DO NOT MODIFY. THIS FILE IS AUTOGENERATED ####
|
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
|
for version in "${versions[@]}"; do
|
||||||
# Skip "docs" and other non-docker directories
|
# Skip "docs" and other non-docker directories
|
||||||
|
@ -104,7 +102,7 @@ for version in "${versions[@]}"; do
|
||||||
|
|
||||||
# Get supported variants according the target architecture
|
# Get supported variants according the target architecture
|
||||||
# See details in function.sh
|
# See details in function.sh
|
||||||
IFS=' ' read -ra variants <<< "$(get_variants "$parentpath")"
|
IFS=' ' read -ra variants <<<"$(get_variants "$parentpath")"
|
||||||
|
|
||||||
for variant in "${variants[@]}"; do
|
for variant in "${variants[@]}"; do
|
||||||
# Skip non-docker directories
|
# Skip non-docker directories
|
||||||
|
|
Loading…
Reference in New Issue