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 # FIXME: make this tuneable
17 OUTPUT="opendaylight-models"
20 JARS=`find $INPUT/system/org/opendaylight -type f -name '*.jar' | sort -u`
22 # FIXME: also wipe output?
23 [ -d "$OUTPUT" ] || mkdir "$OUTPUT"
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" \
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"`
36 # FIXME: better duplicate detection
37 mv -n "$file" "$OUTPUT"