From 5a0f77644463e701f3eddeca06e56fc8704777b4 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 28 Jun 2018 14:11:24 +0200 Subject: [PATCH] Add module extraction script This is a first, raw, cut at extracting models out an opendaylight distribution. Change-Id: I92c03634d660cc56ea20a81104e0bf10addb7526 Signed-off-by: Robert Varga --- scripts/extract_modules.sh | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 scripts/extract_modules.sh diff --git a/scripts/extract_modules.sh b/scripts/extract_modules.sh new file mode 100755 index 00000000..1a59d560 --- /dev/null +++ b/scripts/extract_modules.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# +# Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v1.0 which accompanies this distribution, +# and is available at http://www.eclipse.org/legal/epl-v10.html +# + +# +# This script visits all jars within the OpenDaylight karaf distribution and extracts +# all production YANG modules (as located in META-INF/yang) +# +set -e + +# FIXME: make this tuneable +OUTPUT="opendaylight-models" +INPUT="." + +JARS=`find $INPUT/system/org/opendaylight -type f -name '*.jar' | sort -u` + +# FIXME: also wipe output? +[ -d "$OUTPUT" ] || mkdir "$OUTPUT" +for jar in $JARS; do + artifact=`basename $jar | sed 's/.jar$//'` + echo "Extracting modules from $artifact" + # FIXME: better control over unzip errors + unzip -q "$jar" 'META-INF/yang/*' -d "$artifact" \ + 2>/dev/null || true + + dir="$artifact/META-INF/yang" + if [ -d "$dir" ]; then + for file in `find $dir -type f -name '*.yang'`; do + module=`basename "$file"` + echo -e "\t$module" + # FIXME: better duplicate detection + mv -n "$file" "$OUTPUT" + done + fi + + rm -rf "$artifact" +done + -- 2.36.6