Use lf-infra-pre-build for pip and setuptools
[releng/builder.git] / jjb / autorelease / compare-autorelease-projects.sh
1 #!/bin/bash -l
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 mapfile -t PROJECTS_INT_DIST < <(xmlstarlet sel\
19      -N "x=http://maven.apache.org/POM/4.0.0"\
20      -t -m "/x:project/x:profiles/x:profile[x:activation/x:activeByDefault='true']/x:dependencies/x:dependency/x:groupId"\
21      -v .\
22      -n integration/distribution/features/repos/index/pom.xml 2>/dev/null | sort -u)
23
24 # process projects in int/dist read from pom.xml file
25 declare -a project_int_dist
26 for project in "${PROJECTS_INT_DIST[@]}"; do
27     if [[ $project =~ project.groupId ]] || [[ $project =~ odlparent ]]; then
28         continue
29     elif [[ $project =~ org.opendaylight ]]; then
30         project=$(echo "${project/org.opendaylight./}")
31         project_int_dist+=( "$(echo "${project/.//}" )" )
32     fi
33 done
34
35 project_int_dist+=("mdsal")
36 project_int_dist+=("integration/distribution")
37
38 # Get a list of all the projects from releng/autorelease repo
39 declare -a project_AR
40 mapfile -t project_AR < <(git submodule status | awk -e '{print $2}' | sort | uniq)
41
42 # Use associative arrays to get diff in the projects lists
43 declare -A map_AR map_intdist
44 for project in "${project_AR[@]}"
45 do
46     ((map_AR[$project]++))
47 done
48
49 for project in "${project_int_dist[@]-0}"
50 do
51     ((map_intdist[$project]++))
52 done
53
54 for project in "${!map_AR[@]}"
55 do
56     if (( ${map_AR[$project]} >= 1 && ${map_intdist[$project]-0} >= 1 )); then
57         unset "map_AR[$project]" "map_intdist[$project]"
58     fi
59 done
60
61 result=("${!map_AR[@]}" "${!map_intdist[@]}")
62
63 if [ "${#result[@]}" != "0" ]; then
64     if [ "${#map_AR[@]}" != "0"  ]; then
65         echo "WARNING: List of projects in releng/autorelease but NOT in integration/distribution: ${!map_AR[*]}"
66     elif [ "${#map_intdist[@]}" != "0"  ]; then
67         echo "ERROR: List of projects in integration/distribution but NOT in releng/autorelease: ${!map_intdist[*]}"
68         exit 1
69     fi
70 else
71     echo "List of projects releng/autorelease and integration/distribution repositories are equal"
72 fi