Skip to content

Commit

Permalink
style: fix shfmt lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ttshivers committed Oct 22, 2020
1 parent 4a44c91 commit 818c8f4
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 61 deletions.
62 changes: 31 additions & 31 deletions functions.sh
Expand Up @@ -21,25 +21,25 @@ fatal() {
function get_arch() {
local arch
case $(uname -m) in
x86_64)
arch="amd64"
;;
ppc64le)
arch="ppc64le"
;;
s390x)
arch="s390x"
;;
aarch64)
arch="arm64"
;;
armv7l)
arch="arm32v7"
;;
*)
echo "$0 does not support architecture ${arch} ... aborting"
exit 1
;;
x86_64)
arch="amd64"
;;
ppc64le)
arch="ppc64le"
;;
s390x)
arch="s390x"
;;
aarch64)
arch="arm64"
;;
armv7l)
arch="arm32v7"
;;
*)
echo "$0 does not support architecture ${arch} ... aborting"
exit 1
;;
esac

echo "${arch}"
Expand All @@ -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
Expand Down Expand Up @@ -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[@]}"
}
Expand Down Expand Up @@ -140,7 +140,7 @@ function get_versions() {

local default_variant
default_variant=$(get_config "./" "default_variant")
IFS=' ' read -ra dirs <<< "$(echo "./"*/)"
IFS=' ' read -ra dirs <<<"$(echo "./"*/)"

for dir in "${dirs[@]}"; do
if [ -a "${dir}/Dockerfile" ] || [ -a "${dir}/${default_variant}/Dockerfile" ]; then
Expand Down Expand Up @@ -168,7 +168,7 @@ function is_debian() {
variant=$1
shift

IFS=' ' read -ra debianVersions <<< "$(get_config "./" "debian_versions")"
IFS=' ' read -ra debianVersions <<<"$(get_config "./" "debian_versions")"
for d in "${debianVersions[@]}"; do
if [ "${d}" = "${variant}" ]; then
return 0
Expand All @@ -182,7 +182,7 @@ function is_debian_slim() {
variant=$1
shift

IFS=' ' read -ra debianVersions <<< "$(get_config "./" "debian_versions")"
IFS=' ' read -ra debianVersions <<<"$(get_config "./" "debian_versions")"
for d in "${debianVersions[@]}"; do
if [ "${d}-slim" = "${variant}" ]; then
return 0
Expand All @@ -196,7 +196,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
Expand Down Expand Up @@ -282,7 +282,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
Expand All @@ -300,11 +300,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[@]}"
}
Expand Down Expand Up @@ -334,7 +334,7 @@ function images_updated() {

commit_range="$(commit_range "$@")"

IFS=' ' read -ra versions <<< "$(
IFS=' ' read -ra versions <<<"$(
IFS=','
get_versions
)"
Expand Down
16 changes: 8 additions & 8 deletions generate-stackbrew-library.sh
Expand Up @@ -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
Expand All @@ -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 "$@"
Expand All @@ -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}"
Expand All @@ -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[@]}")"
Expand All @@ -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
Expand All @@ -100,7 +100,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[@]}")"
Expand Down
2 changes: 1 addition & 1 deletion update-keys.sh
@@ -1,3 +1,3 @@
#!/bin/sh -ex

curl -fsSLo- --compressed https://github.com/nodejs/node/raw/master/README.md | awk '/^gpg --keyserver pool.sks-keyservers.net --recv-keys/ {print $NF}' > keys/node.keys
curl -fsSLo- --compressed https://github.com/nodejs/node/raw/master/README.md | awk '/^gpg --keyserver pool.sks-keyservers.net --recv-keys/ {print $NF}' >keys/node.keys
42 changes: 21 additions & 21 deletions update.sh
Expand Up @@ -3,7 +3,7 @@
set -ue

function usage() {
cat << EOF
cat <<EOF
Update the node docker images.
Expand All @@ -30,31 +30,31 @@ EOF
SKIP=false
while getopts "sh" opt; do
case "${opt}" in
s)
SKIP=true
shift
;;
h)
usage
exit
;;
\?)
usage
exit
;;
s)
SKIP=true
shift
;;
h)
usage
exit
;;
\?)
usage
exit
;;
esac
done

. functions.sh

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
Expand Down Expand Up @@ -150,7 +150,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

Expand Down Expand Up @@ -181,7 +181,7 @@ function update_node_version() {
rm "${dockerfile}-tmp-e"
fi

if diff -q "${dockerfile}-tmp" "${dockerfile}" > /dev/null; then
if diff -q "${dockerfile}-tmp" "${dockerfile}" >/dev/null; then
echo "${dockerfile} is already up to date!"
else
echo "${dockerfile} updated!"
Expand All @@ -201,7 +201,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
if [ "${update_version}" -eq 0 ]; then
Expand Down

0 comments on commit 818c8f4

Please sign in to comment.