3 ##############################################################################
4 ## Copyright (c) 2018 Intracom Telecom and others.
6 ## All rights reserved. This program and the accompanying materials
7 ## are made available under the terms of the Apache License, Version 2.0
8 ## which accompanies this distribution, and is available at
9 ## http://www.apache.org/licenses/LICENSE-2.0
10 ###############################################################################
15 # -o pipefail: Fail on errors in scripts this calls, give stacktrace
18 # Verify exactly 1 deb is in the path we expect
19 set -- "$WORKSPACE"/packaging/packages/deb/opendaylight/*.deb
21 echo "Found one deb in build out dir, as expected"
23 echo "Expected 1 deb, found $#"
27 # If path is globbed (/path/to/*.deb), expand it
28 path=$(sudo find / -wholename "$WORKSPACE"/packaging/packages/deb/opendaylight/*.deb)
30 # If no deb found, fail clearly
31 if [ -z "$path" ]; then
37 if [ -f /usr/bin/dpkg ]; then
38 declare -a expected_deps=( "init-system-helpers (>= 1.18~)"
39 "lsb-base (>= 4.1+Debian11ubuntu7)"
41 "openjdk-8-jre-headless" )
45 # shellcheck disable=SC2034
46 mapfile -t actual_deps < <( dpkg -I "$WORKSPACE"/packaging/packages/deb/opendaylight/*.deb | grep Depends | sed 's/Depends: //g' | sed 's/,/\n/g' )
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))
53 # shellcheck disable=SC2154 disable=SC2145 disable=SC2068 disable=SC2170 disable=SC1083
54 if [ ${#diff_deps[*]} -eq 0 ]; then
55 echo "deb requirements are as expected"
57 echo "deb requirements don't match the expected requirements"
58 # shellcheck disable=SC2154 disable=SC2145
59 printf 'Dependency mismatch: %s\n' ${diff_deps[@]}