diff --git a/Tools/environment_install/install-prereqs-ubuntu.sh b/Tools/environment_install/install-prereqs-ubuntu.sh index 4a94bacbef..3ab34040d0 100755 --- a/Tools/environment_install/install-prereqs-ubuntu.sh +++ b/Tools/environment_install/install-prereqs-ubuntu.sh @@ -85,15 +85,26 @@ elif [ ${RELEASE_CODENAME} == 'trusty' ]; then SITLFML_VERSION="2" SITLCFML_VERSION="2" else - # Extract the floating point number that is the version of the libcsfml package. - SITLCFML_VERSION=`dpkg-query --search libcsfml-audio | cut -d":" -f1 | grep libcsfml-audio | head -1 | grep -Eo '[+-]?[0-9]+([.][0-9]+)?'` - # And same for libsfml-audio. - SITLFML_VERSION=`dpkg-query --search libsfml-audio | cut -d":" -f1 | grep libsfml-audio | head -1 | grep -Eo '[+-]?[0-9]+([.][0-9]+)?'` + # We assume APT based system, so let's try with apt-cache first. + SITLCFML_VERSION=$(apt-cache search -n '^libcsfml-audio' | cut -d" " -f1 | head -1 | grep -Eo '[+-]?[0-9]+([.][0-9]+)?') + SITLFML_VERSION=$(apt-cache search -n '^libsfml-audio' | cut -d" " -f1 | head -1 | grep -Eo '[+-]?[0-9]+([.][0-9]+)?') + # If we cannot retrieve the number with apt-cache, try a last time with dpkg-query + re='^[+-]?[0-9]+([.][0-9]+)?$' + if ! [[ $SITLCFML_VERSION =~ $re ]] || ! [[ $SITLFML_VERSION =~ $re ]] ; then + # Extract the floating point number that is the version of the libcsfml package. + SITLCFML_VERSION=$(dpkg-query --search libcsfml-audio | cut -d":" -f1 | grep libcsfml-audio | head -1 | grep -Eo '[+-]?[0-9]+([.][0-9]+)?') + # And same for libsfml-audio. + SITLFML_VERSION=$(dpkg-query --search libsfml-audio | cut -d":" -f1 | grep libsfml-audio | head -1 | grep -Eo '[+-]?[0-9]+([.][0-9]+)?') + fi fi # Check whether the specific ARM pkg-config package is available or whether we should emulate the effect of installing it. -ARM_PKG_CONFIG_NOT_PRESENT=`dpkg-query --search pkg-config-arm-linux-gnueabihf |& grep -c "no path found matching pattern"` -if [ $ARM_PKG_CONFIG_NOT_PRESENT -eq 1 ]; then +# Check if we need to manually install libtool-bin +ARM_PKG_CONFIG_NOT_PRESENT=0 +if [ -z "$(apt-cache search -n '^pkg-config-arm-linux-gnueabihf')" ]; then + ARM_PKG_CONFIG_NOT_PRESENT=$(dpkg-query --search pkg-config-arm-linux-gnueabihf |& grep -c "dpkg-query:") +fi +if [ "$ARM_PKG_CONFIG_NOT_PRESENT" -eq 1 ]; then INSTALL_PKG_CONFIG="" # No need to install Ubuntu's pkg-config-arm-linux-gnueabihf, instead install the base pkg-config. sudo apt-get install pkg-config @@ -115,7 +126,6 @@ PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect flake8" if [[ $SKIP_AP_EXT_ENV -ne 1 ]]; then PYTHON_PKGS="$PYTHON_PKGS pygame intelhex" fi -# Check for ARM_LINUX_PKGS="g++-arm-linux-gnueabihf $INSTALL_PKG_CONFIG" # python-wxgtk packages are added to SITL_PKGS below SITL_PKGS="libtool libxml2-dev libxslt1-dev ${PYTHON_V}-dev ${PYTHON_V}-pip ${PYTHON_V}-setuptools ${PYTHON_V}-numpy ${PYTHON_V}-pyparsing ${PYTHON_V}-psutil"