Skip to content

Commit

Permalink
Applied latest code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
berhoel committed Sep 24, 2024
1 parent d3d2490 commit b9b4426
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 43 deletions.
1 change: 0 additions & 1 deletion Sming/Arch/Esp32/Tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=()
;;
Expand Down
84 changes: 42 additions & 42 deletions Tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=()

Expand Down Expand Up @@ -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
Expand All @@ -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 \
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b9b4426

Please sign in to comment.