summaryrefslogtreecommitdiffstats
path: root/prepTestBundle.sh
diff options
context:
space:
mode:
Diffstat (limited to 'prepTestBundle.sh')
-rwxr-xr-xprepTestBundle.sh40
1 files changed, 35 insertions, 5 deletions
diff --git a/prepTestBundle.sh b/prepTestBundle.sh
index 694857f..53981e0 100755
--- a/prepTestBundle.sh
+++ b/prepTestBundle.sh
@@ -30,6 +30,36 @@
# --> target/classes/**.class
# --> resources/
+function readBSN () {
+
+bsn=
+manEntryPat="^[a-zA-Z-]*:"
+foundBSNLine=0
+
+while read line; do
+if [ ${foundBSNLine} -eq 1 ]; then
+ echo ${line} | grep -qE ${manEntryPat}
+ if [ $? -eq 0 ]; then
+ break
+ else
+ bsn=${bsn}"`echo ${line} | sed 's/\([a-zA-Z0-9_.-]*\)\(;\)\?.*/\1/'`"
+ fi
+fi
+
+echo ${line} | grep -q "Bundle-SymbolicName:"
+if [ $? -eq 0 ]; then
+ bsn=`echo ${line} | grep 'Bundle-SymbolicName:' | sed 's/Bundle-SymbolicName: \([a-zA-Z0-9_.-]*\)\(;\)\?.*/\1/'`
+ echo ${line} | grep "Bundle-SymbolicName:" | grep -q ";"
+ if [ $? -eq 0 ]; then
+ break
+ fi
+ foundBSNLine=1
+fi
+done < <(unzip -p $1 'META-INF/MANIFEST.MF')
+
+echo ${bsn}
+}
+
if [ ! $# -eq 1 ]; then
echo "USAGE : $0 /PATH/TO/JAR"
exit 1
@@ -38,10 +68,10 @@ fi
jarLoc=$1
jarPomPath=`jar -tf ${jarLoc} | grep 'pom.xml'`
-bsname=`unzip -p ${jarLoc} 'META-INF/MANIFEST.MF' | grep 'Bundle-SymbolicName' | sed 's/Bundle-SymbolicName: \([a-zA-Z.]*\)\(;\)\?.*/\1/'`
+bsname=`readBSN ${jarLoc}`
mkdir ${bsname}
-pushd ${bsname}
+pushd ${bsname} >/dev/null
# place manifest and pom
jar -xf ${jarLoc} 'META-INF/MANIFEST.MF' ${jarPomPath}
@@ -57,15 +87,15 @@ sed -i '/<parent>/,/<\/parent>/ s/<version>.*<\/version>/<version>1.0.0-SNAPSHOT
# place classes
# non-classes will just be ignored
mkdir -p target/classes
-pushd target/classes
+pushd target/classes >/dev/null
jar -xf ${jarLoc}
-popd
+popd >/dev/null
# place resources and other files
# non-resources will just be ignored
jar -xf ${jarLoc}
-popd
+popd >/dev/null
if [ ! -e pom.xml ]; then
cp pom.xml{.orig,}