Debian Codegraph @

bundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/debian/isInstalled.sh

raw
1 #!/bin/sh
2
3 # Check if a package whose name and version are specified as input is installed.
4 # Return 0 if the package is installed, 1 if the version is not correct, 2 if the package is not installed
5 #
6 # Usage:
7 # $ ./isInstalled param1 [param2, param3]
8 # * param1: packageId
9 # * param2: version comparator
10 # * param3: version of the package
11
12 foundVersion=$(dpkg-query -f='${version}' --show $1)
13
14 #The package is found, check the version
15 if [ $? -eq 0 ]; then
16 if [ "$#" -eq 1 ]; then
17 return 0;
18 fi
19 dpkg --compare-versions $foundVersion $2 $3
20 if [ $? -eq 0 ]; then
21 return 0;
22 else
23 return 1;
24 fi
25 fi
26
27 #We are here because the package is not found
28 return 2;