3 # Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
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
11 # This script visits all jars within the OpenDaylight karaf distribution and extracts
12 # all production YANG modules (as located in META-INF/yang)
16 OUTPUT="$BIN_DIR/../opendaylight-models"
19 # FIXME: also wipe output?
20 [ -d "$OUTPUT" ] || mkdir "$OUTPUT"
22 PROJECTS=`ls -d $INPUT/system/org/opendaylight/*`
23 for proj in $PROJECTS; do
25 echo "Extracting yang modules from $proj"
26 JARS=`find $INPUT/system/org/opendaylight/$proj -type f -name '*.jar' | sort -u`
27 [ -d "$OUTPUT/$proj" ] || mkdir $OUTPUT/$proj
29 unzip -l "$jar" | grep -q -e "\.yang$" &&
30 unzip -q "$jar" 'META-INF/yang/*' -d "$OUTPUT/$proj"
32 if [ -z "$(ls -A $OUTPUT/$proj)" ]; then
35 rm -f $OUTPUT/$proj/*.yang
36 YANGS=`find $OUTPUT/$proj/META-INF/yang/ -type f -name '*.yang'`
37 for yang in $YANGS; do
39 less $yang | grep -q namespace.*opendaylight &&
40 mv $OUTPUT/$proj/META-INF/yang/$name $OUTPUT/$proj &&
43 rm -rf $OUTPUT/$proj/META-INF
46 echo -e "\nYang Modules are extracted to `readlink -f $OUTPUT`"