Skip to content

Commit 8bd6d48

Browse files
Fixed the update script not working properly with the -s flag or variant filter
1 parent 14ad500 commit 8bd6d48

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

functions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function get_variants() {
5858
local arch
5959
local availablevariants
6060
local variantsfilter
61-
local variants
61+
local variants=()
6262

6363
arch=$(get_arch)
6464
variantsfilter=("$@")
@@ -143,7 +143,7 @@ function get_versions() {
143143
prefix=${1:-.}
144144
shift
145145

146-
local versions
146+
local versions=()
147147
local dirs=("$@")
148148

149149
local default_variant

update.sh

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ while getopts "sh" opt; do
2929
case "${opt}" in
3030
s)
3131
SKIP=true
32+
shift
3233
;;
3334
h)
3435
usage
@@ -46,7 +47,8 @@ done
4647
cd "$(cd "${0%/*}" && pwd -P)"
4748

4849
IFS=' ' read -ra versions <<<"$(get_versions .)"
49-
IFS=' ' read -ra update_versions <<<"$(get_versions . "$@")"
50+
IFS=' ' read -ra update_versions <<<"$(get_versions . "${1-}")"
51+
IFS=' ' read -ra update_variants <<<"$(get_variants . "${2-}")"
5052
if [ ${#versions[@]} -eq 0 ]; then
5153
fatal "No valid versions found!"
5254
fi
@@ -65,6 +67,11 @@ fi
6567
function in_versions_to_update() {
6668
local version=$1
6769

70+
if [ "${#update_versions[@]}" -eq 0 ]; then
71+
echo 0
72+
return
73+
fi
74+
6875
for version_to_update in "${update_versions[@]}"; do
6976
if [ "${version_to_update}" = "${version}" ]; then
7077
echo 0
@@ -75,6 +82,24 @@ function in_versions_to_update() {
7582
echo 1
7683
}
7784

85+
function in_variants_to_update() {
86+
local variant=$1
87+
88+
if [ "${#update_variants[@]}" -eq 0 ]; then
89+
echo 0
90+
return
91+
fi
92+
93+
for variant_to_update in "${update_variants[@]}"; do
94+
if [ "${variant_to_update}" = "${variant}" ]; then
95+
echo 0
96+
return
97+
fi
98+
done
99+
100+
echo 1
101+
}
102+
78103
function update_node_version() {
79104

80105
local baseuri=${1}
@@ -164,9 +189,9 @@ for version in "${versions[@]}"; do
164189
parentpath=$(dirname "${version}")
165190
versionnum=$(basename "${version}")
166191
baseuri=$(get_config "${parentpath}" "baseuri")
167-
update=$(in_versions_to_update "${version}")
192+
update_version=$(in_versions_to_update "${version}")
168193

169-
[ "${update}" -eq 0 ] && info "Updating version ${version}..."
194+
[ "${update_version}" -eq 0 ] && info "Updating version ${version}..."
170195

171196
# Get supported variants according the target architecture
172197
# See details in function.sh
@@ -175,7 +200,7 @@ for version in "${versions[@]}"; do
175200
if [ -f "${version}/Dockerfile" ]; then
176201
add_stage "${baseuri}" "${version}" "default"
177202

178-
if [ "${update}" -eq 0 ]; then
203+
if [ "${update_version}" -eq 0 ]; then
179204
update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile.template" "${version}/Dockerfile" &
180205
fi
181206
fi
@@ -185,7 +210,9 @@ for version in "${versions[@]}"; do
185210
[ -f "${version}/${variant}/Dockerfile" ] || continue
186211
add_stage "${baseuri}" "${version}" "${variant}"
187212

188-
if [ "${update}" -eq 0 ]; then
213+
update_variant=$(in_variants_to_update "${variant}")
214+
215+
if [ "${update_version}" -eq 0 ] && [ "${update_variant}" -eq 0 ]; then
189216
update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile-${variant}.template" "${version}/${variant}/Dockerfile" "${variant}" &
190217
fi
191218
done

0 commit comments

Comments
 (0)