Tools: Give a better chance on default install to get the right package version

This commit is contained in:
Pierre Kancir 2021-01-21 15:07:41 +01:00 committed by Peter Barker
parent b02f868793
commit 881e42c337
1 changed files with 17 additions and 7 deletions

View File

@ -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"