From 08c86dc8ace433bd1efacc807357dc92661510ab Mon Sep 17 00:00:00 2001 From: Lyndon Brown Date: Mon, 4 May 2020 23:11:27 +0100 Subject: [PATCH] arches: fix some Check_architectures() mess - the comparison with LB_ARCHITECTURE seems to be based upon an old idea of it potentially being intended in the past to hold more than one arch (when it's name as also plural), but it in fact only holds one. - similarly LB_BOOTSTRAP_QEMU_ARCHITECTURE is singular, so the comparison with the set of params is bad. - storing $@ in a variable before then looping is not a good idea - script name was not being passed to the warnings - can simplify by just returning in the valid case i'm very suspicious about the correctness of the qemu bits, but that can wait for now. Gbp-Dch: Short --- functions/architectures.sh | 57 ++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/functions/architectures.sh b/functions/architectures.sh index 62b7b15d7..b7f8b979c 100755 --- a/functions/architectures.sh +++ b/functions/architectures.sh @@ -11,43 +11,34 @@ Check_architectures () { - local ARCHITECTURES - ARCHITECTURES="${@}" #must be on separate line to 'local' declaration to avoid error - local VALID=false - local ARCHITECTURE - for ARCHITECTURE in ${ARCHITECTURES} + for ARCHITECTURE in "${@}" do - if [ "$(echo ${LB_ARCHITECTURE} | grep ${ARCHITECTURE})" ] + if [ "${ARCHITECTURE}" = "${LB_ARCHITECTURE}" ] then - VALID=true - break + return + fi + + if [ "${ARCHITECTURE}" = "${LB_BOOTSTRAP_QEMU_ARCHITECTURE}" ] + then + if [ ! -e "${LB_BOOTSTRAP_QEMU_STATIC}" ] + then + Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_ARCHITECTURE} was not found" "${0}" + continue + fi + + if [ ! -x "${LB_BOOTSTRAP_QEMU_STATIC}" ] + then + Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_STATIC} is not executable" "${0}" + continue + fi + + return fi done - if [ "${ARCHITECTURES}" = "${LB_BOOTSTRAP_QEMU_ARCHITECTURE}" ] - then - VALID=true - - if [ ! -e "${LB_BOOTSTRAP_QEMU_STATIC}" ] - then - Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_ARCHITECTURE} was not found" - VALID=false - fi - - if [ ! -x "${LB_BOOTSTRAP_QEMU_STATIC}" ] - then - Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_STATIC} is not executable" - VALID=false - fi - - fi - - if ! $VALID - then - Echo_warning "skipping %s, foreign architecture(s)." "${0}" - exit 0 - fi + Echo_warning "skipping %s, foreign architecture(s)." "${0}" + exit 0 } Check_crossarchitectures () @@ -80,13 +71,13 @@ Check_crossarchitectures () if [ ! -e "${LB_BOOTSTRAP_QEMU_STATIC}" ] then - Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_ARCHITECTURE} was not found" + Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_ARCHITECTURE} was not found" "${0}" exit 0 fi if [ ! -x "${LB_BOOTSTRAP_QEMU_STATIC}" ] then - Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_STATIC} is not executable" + Echo_warning "skipping %s, qemu-static binary ${LB_BOOTSTRAP_QEMU_STATIC} is not executable" "${0}" exit 0 fi return