Fixed the update script not working properly with the -s flag or variant filter

This commit is contained in:
Laurent Goderre 2018-06-20 13:02:28 -04:00
parent 1458f3e0bf
commit 59cb6a317e
2 changed files with 34 additions and 7 deletions

View File

@ -58,7 +58,7 @@ function get_variants() {
local arch local arch
local availablevariants local availablevariants
local variantsfilter local variantsfilter
local variants local variants=()
arch=$(get_arch) arch=$(get_arch)
variantsfilter=("$@") variantsfilter=("$@")
@ -143,7 +143,7 @@ function get_versions() {
prefix=${1:-.} prefix=${1:-.}
shift shift
local versions local versions=()
local dirs=("$@") local dirs=("$@")
local default_variant local default_variant

View File

@ -29,6 +29,7 @@ while getopts "sh" opt; do
case "${opt}" in case "${opt}" in
s) s)
SKIP=true SKIP=true
shift
;; ;;
h) h)
usage usage
@ -46,7 +47,8 @@ done
cd "$(cd "${0%/*}" && pwd -P)" cd "$(cd "${0%/*}" && pwd -P)"
IFS=' ' read -ra versions <<<"$(get_versions .)" IFS=' ' read -ra versions <<<"$(get_versions .)"
IFS=' ' read -ra update_versions <<<"$(get_versions . "$@")" IFS=' ' read -ra update_versions <<<"$(get_versions . "${1-}")"
IFS=' ' read -ra update_variants <<<"$(get_variants . "${2-}")"
if [ ${#versions[@]} -eq 0 ]; then if [ ${#versions[@]} -eq 0 ]; then
fatal "No valid versions found!" fatal "No valid versions found!"
fi fi
@ -65,6 +67,11 @@ fi
function in_versions_to_update() { function in_versions_to_update() {
local version=$1 local version=$1
if [ "${#update_versions[@]}" -eq 0 ]; then
echo 0
return
fi
for version_to_update in "${update_versions[@]}"; do for version_to_update in "${update_versions[@]}"; do
if [ "${version_to_update}" = "${version}" ]; then if [ "${version_to_update}" = "${version}" ]; then
echo 0 echo 0
@ -75,6 +82,24 @@ function in_versions_to_update() {
echo 1 echo 1
} }
function in_variants_to_update() {
local variant=$1
if [ "${#update_variants[@]}" -eq 0 ]; then
echo 0
return
fi
for variant_to_update in "${update_variants[@]}"; do
if [ "${variant_to_update}" = "${variant}" ]; then
echo 0
return
fi
done
echo 1
}
function update_node_version() { function update_node_version() {
local baseuri=${1} local baseuri=${1}
@ -164,9 +189,9 @@ for version in "${versions[@]}"; do
parentpath=$(dirname "${version}") parentpath=$(dirname "${version}")
versionnum=$(basename "${version}") versionnum=$(basename "${version}")
baseuri=$(get_config "${parentpath}" "baseuri") baseuri=$(get_config "${parentpath}" "baseuri")
update=$(in_versions_to_update "${version}") update_version=$(in_versions_to_update "${version}")
[ "${update}" -eq 0 ] && info "Updating version ${version}..." [ "${update_version}" -eq 0 ] && info "Updating version ${version}..."
# Get supported variants according the target architecture # Get supported variants according the target architecture
# See details in function.sh # See details in function.sh
@ -175,7 +200,7 @@ for version in "${versions[@]}"; do
if [ -f "${version}/Dockerfile" ]; then if [ -f "${version}/Dockerfile" ]; then
add_stage "${baseuri}" "${version}" "default" add_stage "${baseuri}" "${version}" "default"
if [ "${update}" -eq 0 ]; then if [ "${update_version}" -eq 0 ]; then
update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile.template" "${version}/Dockerfile" & update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile.template" "${version}/Dockerfile" &
fi fi
fi fi
@ -185,7 +210,9 @@ for version in "${versions[@]}"; do
[ -f "${version}/${variant}/Dockerfile" ] || continue [ -f "${version}/${variant}/Dockerfile" ] || continue
add_stage "${baseuri}" "${version}" "${variant}" add_stage "${baseuri}" "${version}" "${variant}"
if [ "${update}" -eq 0 ]; then update_variant=$(in_variants_to_update "${variant}")
if [ "${update_version}" -eq 0 ] && [ "${update_variant}" -eq 0 ]; then
update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile-${variant}.template" "${version}/${variant}/Dockerfile" "${variant}" & update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile-${variant}.template" "${version}/${variant}/Dockerfile" "${variant}" &
fi fi
done done