From 25801b6e70321cb2ec56fc49ac1dd455af789ff8 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Thu, 28 Jan 2021 16:59:54 +0000 Subject: [PATCH] Detect distribution and support install on Fedora --- Sming/Arch/Esp32/Tools/install.sh | 24 ++++++-- Sming/Arch/Esp8266/Tools/install.sh | 4 +- Sming/Arch/Host/Tools/install.sh | 2 +- Tools/install.sh | 91 +++++++++++++++++++++-------- docs/Tools/install.sh | 23 +++++++- 5 files changed, 111 insertions(+), 33 deletions(-) diff --git a/Sming/Arch/Esp32/Tools/install.sh b/Sming/Arch/Esp32/Tools/install.sh index 3d693d13c4..92417574ea 100755 --- a/Sming/Arch/Esp32/Tools/install.sh +++ b/Sming/Arch/Esp32/Tools/install.sh @@ -2,15 +2,31 @@ if [ -n "$IDF_PATH" ] && [ -n "$IDF_TOOLS_PATH" ]; then -sudo apt-get install -y \ +PACKAGES=(\ bison \ ccache \ dfu-util \ flex \ gperf \ - libffi-dev \ - libssl-dev \ - ninja-build + ninja-build \ + ) + +case $DIST in + debian) + PACKAGES+=(\ + libffi-dev \ + libssl-dev \ + ) + ;; + + fedora) + PACKAGES+=(\ + libffi-devel \ + ) + ;; +esac + +$PKG_INSTALL ${PACKAGES[*]} git clone -b release/v4.1 https://github.com/espressif/esp-idf.git $IDF_PATH diff --git a/Sming/Arch/Esp8266/Tools/install.sh b/Sming/Arch/Esp8266/Tools/install.sh index 7031c45627..35c74298f4 100755 --- a/Sming/Arch/Esp8266/Tools/install.sh +++ b/Sming/Arch/Esp8266/Tools/install.sh @@ -8,7 +8,7 @@ if [ -n "$UDK_ROOT" ]; then mkdir -p $UDK_ROOT ln -s $(pwd)/esp-open-sdk/xtensa-lx106-elf $UDK_ROOT/. if [ -z "$KEEP_DOWNLOADS" ]; then - rm $TOOLCHAIN + rm -f $TOOLCHAIN fi fi @@ -19,6 +19,6 @@ if [ -n "$EQT_ROOT" ]; then mkdir -p $EQT_ROOT tar -zxf $TOOLCHAIN -C $EQT_ROOT --totals if [ -z "$KEEP_DOWNLOADS" ]; then - rm $TOOLCHAIN + rm -f $TOOLCHAIN fi fi diff --git a/Sming/Arch/Host/Tools/install.sh b/Sming/Arch/Host/Tools/install.sh index 6bd3e1a0b3..4b21178d6b 100755 --- a/Sming/Arch/Host/Tools/install.sh +++ b/Sming/Arch/Host/Tools/install.sh @@ -2,7 +2,7 @@ # Required by deployment script if [ -n "$APPVEYOR" ]; then - sudo apt-get install -y \ + $PKG_INSTALL \ jq \ xmlstarlet fi diff --git a/Tools/install.sh b/Tools/install.sh index c5fbefb284..866bd61d45 100755 --- a/Tools/install.sh +++ b/Tools/install.sh @@ -5,6 +5,8 @@ # . /opt/sming/Tools/install.sh # +set -e + [ "$0" = "$BASH_SOURCE" ]; sourced=$? inst_host=0 @@ -48,25 +50,34 @@ if [[ $err -eq 1 ]] || [ $# -eq 0 ]; then fi fi -if [ $sourced != 1 ]; then - echo "Please source this script:" - echo " source $0" - exit 1 -fi - SMINGTOOLS=https://github.com/SmingHub/SmingTools/releases/download/1.0 if [ -z "$APPVEYOR" ]; then source $(dirname $BASH_SOURCE)/export.sh fi -# Common install +# At present we can only +if [ -n "$(grep debian /etc/os-release)" ]; then + DIST=debian + PKG_INSTALL="sudo apt-get install -y" +elif [ -n "$(grep fedora /etc/os-release)" ]; then + DIST=fedora + PKG_INSTALL="sudo dnf install -y" +else + echo "Unsupported distribution" + if [ $sourced = 1 ]; then + return 1 + else + exit 1 + fi +fi -sudo apt-get -y update +# Common install if [ -n "$APPVEYOR" ]; then - sudo apt-get install -y \ + sudo apt-get -y update + $PKG_INSTALL \ clang-format-6.0 \ g++-9-multilib \ python3-setuptools @@ -75,19 +86,43 @@ if [ -n "$APPVEYOR" ]; then else - sudo apt-get install -y \ - clang-format-6.0 \ - cmake \ - curl \ - git \ - make \ - unzip \ - g++ \ - g++-multilib \ - python3 \ - python3-pip \ - python3-setuptools \ - wget + case $DIST in + debian) + sudo apt-get -y update + $PKG_INSTALL \ + clang-format-6.0 \ + cmake \ + curl \ + git \ + make \ + unzip \ + g++ \ + g++-multilib \ + python3 \ + python3-pip \ + python3-setuptools \ + wget + ;; + + fedora) + $PKG_INSTALL \ + cmake \ + gawk \ + gcc \ + gcc-c++ \ + gettext \ + git \ + glibc-devel.i686 \ + libstdc++.i686 \ + make \ + python3 \ + python3-pip \ + sed \ + unzip \ + wget + ;; + + esac sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 100 @@ -114,5 +149,15 @@ if [ $inst_esp8266 -eq 1 ]; then fi if [ $inst_esp32 -eq 1 ]; then -echo install Esp32 + install Esp32 +fi + +echo +echo Installation complete +echo + +if [ $sourced != 1 ]; then + echo "You may need to set environment variables:" + echo " source $SMING_HOME/../Tools/export.sh" + echo fi diff --git a/docs/Tools/install.sh b/docs/Tools/install.sh index 54b3b00a1f..e1137a71e7 100644 --- a/docs/Tools/install.sh +++ b/docs/Tools/install.sh @@ -1,9 +1,26 @@ # Documentation build tools -sudo apt-get install -y \ +PACKAGES=(\ doxygen \ - graphviz-dev \ python3-sphinx \ - python3-cairocffi + python3-cairocffi \ + ) + +case $DIST in + debian) + PACKAGES+=(\ + graphviz-dev \ + ) + ;; + + fedora) + PACKAGES+=(\ + python-wheel \ + graphviz-devel \ + ) + ;; +esac + +$PKG_INSTALL ${PACKAGES[*]} python3 -m pip install -r $SMING_HOME/../docs/requirements.txt