Remove karaf plugin overrides
[integration/distribution.git] / scripts / extract_modules.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2018 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
10 #
11 # This script visits all jars within the OpenDaylight karaf distribution and extracts
12 # all production YANG modules (as located in META-INF/yang)
13 #
14 set -e
15
16 # FIXME: make this tuneable
17 OUTPUT="opendaylight-models"
18 INPUT="."
19
20 JARS=`find $INPUT/system/org/opendaylight -type f -name '*.jar' | sort -u`
21
22 # FIXME: also wipe output?
23 [ -d "$OUTPUT" ] || mkdir "$OUTPUT"
24 for jar in $JARS; do
25     artifact=`basename $jar | sed 's/.jar$//'`
26     echo "Extracting modules from $artifact"
27     # FIXME: better control over unzip errors
28     unzip -q "$jar" 'META-INF/yang/*' -d "$artifact" \
29         2>/dev/null || true
30
31     dir="$artifact/META-INF/yang"
32     if [ -d "$dir" ]; then
33         for file in `find $dir -type f -name '*.yang'`; do
34             module=`basename "$file"`
35             echo -e "\t$module"
36             # FIXME: better duplicate detection
37             mv -n "$file" "$OUTPUT"
38         done
39     fi
40
41     rm -rf "$artifact"
42 done
43