From b9b44264985a26f53ceb413d6542a5b8b662ee92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berthold=20H=C3=B6llmann?= Date: Tue, 24 Sep 2024 12:19:16 +0200 Subject: [PATCH] Applied latest code review comments --- Sming/Arch/Esp32/Tools/install.sh | 1 - Tools/install.sh | 84 +++++++++++++++---------------- 2 files changed, 42 insertions(+), 43 deletions(-) diff --git a/Sming/Arch/Esp32/Tools/install.sh b/Sming/Arch/Esp32/Tools/install.sh index f16026df59..3ead67befc 100755 --- a/Sming/Arch/Esp32/Tools/install.sh +++ b/Sming/Arch/Esp32/Tools/install.sh @@ -33,7 +33,6 @@ case $DIST in *) check_for_installed_tools dfu-util bison flex gperf - check_for_installed_files "/usr/include/ffi.h" "/usr/include/ssl/ssl.h" PACKAGES=() ;; diff --git a/Tools/install.sh b/Tools/install.sh index 2131453916..f43d0cd56b 100755 --- a/Tools/install.sh +++ b/Tools/install.sh @@ -22,46 +22,6 @@ FONT_PACKAGES=(\ fonts-droid-fallback \ ) -check_for_installed_tools () { - REQUIRED_TOOLS="${@}" - echo -e "Checking for installed tools.\nrequirded tools: ${REQUIRED_TOOLS}" - TOOLS_MISSING=0 - for TOOL in ${REQUIRED_TOOLS}; do - if ! command -v "${TOOL}" > /dev/null ; then - TOOLS_MISSING=1 - echo "Install required tool ${TOOL}" - fi - done - if [ $TOOLS_MISSING != 0 ]; then - echo "ABORTING" - if [ $sourced = 1 ]; then - return 1 - else - exit 1 - fi - fi -} - -check_for_installed_files () { - REQUIRED_FILES="${@}" - echo -e "Checking for installed files.\nrequirded files: ${REQUIRED_FILES}" - FILES_MISSING=0 - for FILE in ${REQUIRED_FILES}; do - if ! [ -f "${FILE}" ]; then - FILES_MISSING=1 - echo "Install required FILE ${FILE}" - fi - done - if [ $FILES_MISSING != 0 ]; then - echo "ABORTING" - if [ $sourced = 1 ]; then - return 1 - else - exit 1 - fi - fi -} - EXTRA_PACKAGES=() OPTIONAL_PACKAGES=() @@ -124,6 +84,47 @@ source "$(dirname "${BASH_SOURCE[0]}")/export.sh" export WGET="wget --no-verbose" +# Scripts for checking for required resources + +abort () { + echo "ABORTING" + if [ $sourced = 1 ]; then + return 1 + else + exit 1 + fi +} + +check_for_installed_tools() { + REQUIRED_TOOLS=( "$@" ) + echo -e "Checking for installed tools.\nRequired tools: ${REQUIRED_TOOLS[*]}" + TOOLS_MISSING=0 + for TOOL in "${REQUIRED_TOOLS[@]}"; do + if ! command -v "$TOOL" > /dev/null ; then + TOOLS_MISSING=1 + echo "Install required tool $TOOL" + fi + done + if [ $TOOLS_MISSING != 0 ]; then + abort + fi +} + +check_for_installed_files() { + REQUIRED_FILES=( "$@" ) + echo -e "Checking for installed files.\nRequired files: ${REQUIRED_FILES[*]}" + FILES_MISSING=0 + for FILE in "${REQUIRED_FILES[@]}"; do + if ! [ -f "$FILE" ]; then + FILES_MISSING=1 + echo "Install required FILE $FILE" + fi + done + if [ $FILES_MISSING != 0 ]; then + abort + fi +} + # Installers put downloaded archives here DOWNLOADS="downloads" mkdir -p $DOWNLOADS @@ -139,7 +140,6 @@ elif [ -n "$(command -v dnf)" ]; then DIST=fedora PKG_INSTALL="sudo dnf install -y" else - TOOLS_MISSING=0 echo "Unsupported distribution" check_for_installed_tools \ ccache \ @@ -231,7 +231,7 @@ case $DIST in esac -if [ $(/usr/bin/python -c "import sys;print(sys.version_info[0])") != 3 ]; then +if [ "$(/usr/bin/python -c 'import sys;print(sys.version_info[0])')" != 3 ]; then if [ "$DIST" != "darwin" ]; then sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 100 fi