Release netconf
[netconf.git] / netconf / shaded-exificient-jar / check_jar.sh
1 #!/bin/bash
2 #
3 # Copyright (c) 2019 Pantheon Technologies, s.r.o. and others.  All rights reserved.
4 #
5 # This program and the accompanying materials are made available under the
6 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 # and is available at http://www.eclipse.org/legal/epl-v10.html
8
9 # Simple script to check consistency of the shaded artifact. It is by no means perfect,
10 # but it's better than nothing.
11 #
12 # Quick usage:
13 #
14 # nite@nitebug : ~/netconf/netconf/shaded-exificient-jar $ mvn clean install
15 # nite@nitebug : ~/netconf/netconf/shaded-exificient-jar $ mkdir x
16 # nite@nitebug : ~/netconf/netconf/shaded-exificient-jar $ cd x
17 # nite@nitebug : ~/netconf/netconf/shaded-exificient-jar/x $ rm -rf * && unzip ../target/shaded-exificient-jar-*-SNAPSHOT.jar && ../check_jar.sh .
18
19 root="$1"
20 if [ ! -d "$1" ]; then
21     echo "Directory $root does not exist"
22     exit 1
23 fi
24
25 if [ ! -f check_strings1.txt ]; then
26     echo "Looking for strings ..."
27     find "$root" -name \*.class | xargs strings | sort -u | fgrep shaded/ | sed 's/;/ /g' | sed "s/'//g"> check_strings1.txt
28     rm -f check_strings2.txt
29 fi
30
31 if [ ! -f check_strings2.txt ]; then
32     echo "Splitting strings ..."
33     sort -u check_strings1.txt | xargs -n1 | fgrep shaded/ | sort -u > check_strings2.txt
34     rm -f check_strings3.txt
35 fi
36
37 if [ ! -f check_strings3.txt ]; then
38     echo "Cleaning strings ..."
39     sed 's#.*shaded/##' check_strings2.txt | sort -u > check_strings3.txt
40 fi
41
42 for i in `cat check_strings3.txt`; do
43     dir=`dirname "$i"`
44     name=`basename "$i"`
45     count=`find "$root/org/opendaylight/netconf/shaded/$dir" -name $name\* -printf . | wc -c`
46     if [ $count -eq 0 ]; then
47         echo ">>> Missing $i"
48         echo "    References:"
49         find "$root" -name \*.class | xargs fgrep -l "$i"
50     fi
51 done
52