Tools: fix install-prereqs-ubuntu

make a function to return 1 if a dpkg find that a package is installed, O otherwise
This commit is contained in:
Pierre Kancir 2020-05-23 17:40:50 +02:00 committed by Andrew Tridgell
parent a8c8f192b4
commit f199ca54bd

View File

@ -40,8 +40,12 @@ fi
# update apt package list
$APT_GET update
function package_is_installed() {
return $(dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed")
}
# Install lsb-release as it is needed to check Ubuntu version
if ! dpkg-query -l "lsb-release"; then
if package_is_installed "lsb-release" -ne 1; then
echo "$sep"
echo "Installing lsb-release"
echo "$sep"
@ -150,7 +154,7 @@ echo "Done!"
echo "$sep"
echo "Removing modemmanager package that could conflict with firmware uploading"
echo "$sep"
if dpkg-query -l "modemmanager"; then
if package_is_installed "modemmanager" -ne 1; then
$APT_GET remove modemmanager
fi
echo "Done!"