Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/fedora/isInstalled.sh')
-rwxr-xr-xbundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/fedora/isInstalled.sh70
1 files changed, 70 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/fedora/isInstalled.sh b/bundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/fedora/isInstalled.sh
new file mode 100755
index 000000000..3d0ffb0b3
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/nativePackageScripts/fedora/isInstalled.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# Check if a package whose name and version are specified as input is installed.
+# Return 0 if the package is installed, 1 if the version is not correct, 2 if the package is not installed
+#
+# Usage:
+# $ ./isInstalled param1 [param2, param3]
+# * param1: packageId
+# * param2: version comparator
+# * param3: version of the package
+
+is_equal () {
+ if [ "$1" = "$2" ]; then
+ echo 0
+ else
+ echo 1
+ fi
+}
+
+is_greater () {
+ if [ "$1" \> "$2" ]; then
+ echo 0
+ else
+ echo 1
+ fi
+}
+
+foundVersion=$(rpm -q --qf '%{version}' $1)
+
+#The package is found, check the version
+if [ $? -eq 0 ]; then
+
+case "$2" in
+ "gt")
+ great=$(is_greater $foundVersion $3)
+ exit $great
+ ;;
+ "ge")
+ equal=$(is_equal $foundVersion $3)
+ if [ "$equal" = "0" ]; then
+ exit 0
+ else
+ great=$(is_greater $foundVersion $3)
+ exit $great
+ fi
+ ;;
+ "eq")
+ equal=$(is_equal $foundVersion $3)
+ exit $equal
+ ;;
+ "le")
+ equal=$(is_equal $foundVersion $3)
+ if [ "$equal" = "0" ]; then
+ exit 0
+ else
+ great=$(is_greater $3 $foundVersion)
+ exit $great
+ fi
+ ;;
+ "lt")
+ great=$(is_greater $3 $foundVersion )
+ exit $great
+ ;;
+esac
+
+fi
+
+
+#We are here because the package is not found
+exit 2;

Back to the top