Merge "Move dlux Sonar scan to Sonarcloud"
[releng/builder.git] / jjb / packaging / uninstall-rpm.sh
1 #!/bin/bash
2
3 # Options:
4 #   -x: Echo commands
5 #   -e: Fail on errors
6 #   -o pipefail: Fail on errors in scripts this calls, give stacktrace
7 set -ex -o pipefail
8
9 if [ -f /usr/bin/yum ]; then
10   # Uninstall ODL
11   sudo yum remove -y opendaylight
12
13   # Verify ODL not installed
14   if yum list installed opendaylight; then
15     # Fail if exit code 0, ie ODL is still installed
16     echo "OpenDaylight unexpectedly still installed"
17     exit 1
18   else
19     echo "OpenDaylight not installed, as expected"
20   fi
21 elif [ -f /usr/bin/zypper ]; then
22   # Uninstall ODL
23   sudo zypper -n remove opendaylight
24
25   # Verify ODL not installed
26   if zypper search --installed-only opendaylight; then
27     # Fail if exit code 0, ie ODL is still installed
28     echo "OpenDaylight unexpectedly still installed"
29     exit 1
30   else
31     echo "OpenDaylight not installed, as expected"
32   fi
33 else
34   echo "The package manager is not supported (not yum or zypper)"
35   exit 1
36 fi