From 59cb6a317edb004ce9c6dc97335351d985dbaf55 Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Wed, 20 Jun 2018 13:02:28 -0400 Subject: [PATCH] Fixed the update script not working properly with the -s flag or variant filter --- functions.sh | 4 ++-- update.sh | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/functions.sh b/functions.sh index acc2fd86..24d17aa3 100755 --- a/functions.sh +++ b/functions.sh @@ -58,7 +58,7 @@ function get_variants() { local arch local availablevariants local variantsfilter - local variants + local variants=() arch=$(get_arch) variantsfilter=("$@") @@ -143,7 +143,7 @@ function get_versions() { prefix=${1:-.} shift - local versions + local versions=() local dirs=("$@") local default_variant diff --git a/update.sh b/update.sh index c721ec14..013293a0 100755 --- a/update.sh +++ b/update.sh @@ -29,6 +29,7 @@ while getopts "sh" opt; do case "${opt}" in s) SKIP=true + shift ;; h) usage @@ -46,7 +47,8 @@ done cd "$(cd "${0%/*}" && pwd -P)" 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 fatal "No valid versions found!" fi @@ -65,6 +67,11 @@ fi function in_versions_to_update() { local version=$1 + if [ "${#update_versions[@]}" -eq 0 ]; then + echo 0 + return + fi + for version_to_update in "${update_versions[@]}"; do if [ "${version_to_update}" = "${version}" ]; then echo 0 @@ -75,6 +82,24 @@ function in_versions_to_update() { 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() { local baseuri=${1} @@ -164,9 +189,9 @@ for version in "${versions[@]}"; do parentpath=$(dirname "${version}") versionnum=$(basename "${version}") 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 # See details in function.sh @@ -175,7 +200,7 @@ for version in "${versions[@]}"; do if [ -f "${version}/Dockerfile" ]; then 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" & fi fi @@ -185,7 +210,9 @@ for version in "${versions[@]}"; do [ -f "${version}/${variant}/Dockerfile" ] || continue 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}" & fi done