Merge "Use Karaf test script that avoids ODLPARENT-139"
[releng/builder.git] / jjb / packaging / install-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 # Update mirror list to avoid slow/hung one
10 sudo yum update -y yum-plugin-fastestmirror
11
12 # Use local RPM in build-out dir if URL not passed
13 URL=${URL:-"$HOME/rpmbuild/RPMS/noarch/*.rpm"}
14
15 # Install ODL from RPM path, RPM URL or .repo file url
16 # NB: Paths must be anchored at root
17 if [[ $URL == /*  ]]; then
18   # If path is globbed (/path/to/*.rpm), expand it
19   path=$(sudo find / -wholename $URL)
20   sudo yum install -y "$path"
21 elif [[ $URL == *.rpm ]]; then
22   sudo yum install -y "$URL"
23 elif [[ $URL == *.repo ]]; then
24   # shellcheck disable=SC2154
25   repo_file="${URL##*/}"
26   sudo curl --silent -o /etc/yum.repos.d/"$repo_file" "$URL"
27   sudo yum install -y opendaylight
28 else
29   echo "URL is not a link to .rpm or .repo"
30   exit 1
31 fi