6 # -o pipefail: Fail on errors in scripts this calls, give stacktrace
9 # Verify exactly 1 RPM is in the path we expect
10 set -- /home/$USER/rpmbuild/RPMS/noarch/*.rpm
12 echo "Found one RPM in build out dir, as expected"
14 echo "Expected 1 RPM, found $#"
18 # If path is globbed (/path/to/*.rpm), expand it
19 path=$(sudo find / -wholename /home/$USER/rpmbuild/RPMS/noarch/*.rpm)
21 # If no RPM found, fail clearly
27 # Requirements for package where SRPM was built into noarch on CentOS CBS
28 # rpm -qp opendaylight-8.0.0-0.1.20171125rel2049.el7.noarch.rpm --requires
29 # shellcheck disable=SC2034
30 declare -a expected_deps=( "/bin/bash"
33 "rpmlib(CompressedFileNames) <= 3.0.4-1"
34 "rpmlib(FileDigests) <= 4.6.0-1"
35 "rpmlib(PartialHardlinkSets) <= 4.0.4-1"
36 "rpmlib(PayloadFilesHavePrefix) <= 4.0-1"
38 "rpmlib(PayloadIsXz) <= 5.2-1" )
40 # Karaf 4 distros also have a /usr/bin/env requirement INTPAK-120
41 if [[ ! $path == *opendaylight-6* ]]; then
42 expected_deps+=( "/usr/bin/env" )
45 # shellcheck disable=SC2034
46 mapfile -t actual_deps < <( rpm -qp /home/$USER/rpmbuild/RPMS/noarch/*.rpm --requires )
47 # shellcheck disable=SC2154 disable=SC2145
48 printf 'Dependency found: %s\n' "${actual_deps[@]}"
50 # shellcheck disable=SC2154,SC2145,SC2034,SC2207
51 diff_deps=(`echo "${expected_deps[@]}" "${actual_deps[@]}" | tr ' ' '\n' | sort | uniq -u`)
52 # shellcheck disable=SC2154 disable=SC2145 disable=SC2068 disable=SC2170 disable=SC1083
53 if [ ${#diff_deps[*]} -eq 0 ]; then
54 echo "RPM requirements are as expected"
56 echo "RPM requirements don't match the expected requirements"
57 # shellcheck disable=SC2154 disable=SC2145
58 printf 'Dependency mismatch: %s\n' ${diff_deps[@]}