Remove all refs to carbon from AR jobs
[releng/builder.git] / jjb / autorelease / compare-autorelease-projects.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11
12 # This script performs version bumping activities for an ODL release.
13 echo "---> compare-autorelease-projects.sh"
14
15 # The purpose of this script is to compare list of projects in autorelease
16 # are equal to the list of projects in integration/distribution.
17
18 # Note: int/dist pom files uses templates only since Oxygen release.
19 # Todo: Remove this check after Nitrogen EOL
20 if [[ $STREAM =~ nitrogen ]]; then
21     exit 0
22 fi
23
24 mapfile -t PROJECTS_INT_DIST < <(xmlstarlet sel\
25      -N "x=http://maven.apache.org/POM/4.0.0"\
26      -t -m "/x:project/x:profiles/x:profile[x:activation/x:activeByDefault='true']/x:dependencies/x:dependency/x:groupId"\
27      -v .\
28      -n integration/distribution/features/repos/index/pom.xml 2>/dev/null | sort -u)
29
30 # process projects in int/dist read from pom.xml file
31 declare -a project_int_dist
32 for project in "${PROJECTS_INT_DIST[@]}"; do
33     if [[ $project =~ project.groupId ]] || [[ $project =~ odlparent ]]; then
34         continue
35     elif [[ $project =~ org.opendaylight ]]; then
36         project=$(echo "${project/org.opendaylight./}")
37         project_int_dist+=( "$(echo "${project/.//}" )" )
38     fi
39 done
40
41 project_int_dist+=("mdsal")
42 project_int_dist+=("integration/distribution")
43
44 # Get a list of all the projects from releng/autorelease repo
45 declare -a project_AR
46 mapfile -t project_AR < <(git submodule status | awk -e '{print $2}' | sort | uniq)
47
48 # Use associative arrays to get diff in the projects lists
49 declare -A map_AR map_intdist
50 for project in "${project_AR[@]}"
51 do
52     ((map_AR[$project]++))
53 done
54
55 for project in "${project_int_dist[@]-0}"
56 do
57     ((map_intdist[$project]++))
58 done
59
60 for project in "${!map_AR[@]}"
61 do
62     if (( ${map_AR[$project]} >= 1 && ${map_intdist[$project]-0} >= 1 )); then
63         unset "map_AR[$project]" "map_intdist[$project]"
64     fi
65 done
66
67 result=("${!map_AR[@]}" "${!map_intdist[@]}")
68
69 if [ "${#result[@]}" != "0" ]; then
70     if [ "${#map_AR[@]}" != "0"  ]; then
71         echo "WARNING: List of projects in releng/autorelease but NOT in integration/distribution: ${!map_AR[*]}"
72     elif [ "${#map_intdist[@]}" != "0"  ]; then
73         echo "ERROR: List of projects in integration/distribution but NOT in releng/autorelease: ${!map_intdist[*]}"
74         exit 1
75     fi
76 else
77     echo "List of projects releng/autorelease and integration/distribution repositories are equal"
78 fi