Converting builtin applications to be delivered in a self-contained manner via OAR files.
Change-Id: I5b7c6939aacc263248868fac2e0f69124c5f3609
diff --git a/tools/build/onos-package b/tools/build/onos-package
index 836ca9d..5ecb3ab 100755
--- a/tools/build/onos-package
+++ b/tools/build/onos-package
@@ -28,8 +28,8 @@
echo "Apache Karaf bits $KARAF_ZIP or $KARAF_TAR not found" && exit 1
# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
-[ -f $KARAF_ZIP ] && unzip -q $KARAF_ZIP && rm -rf $KARAF_DIST/demos
-[ -f $KARAF_TAR ] && tar zxf $KARAF_TAR && rm -rf $KARAF_DIST/demos
+[ -f $KARAF_ZIP ] && unzip -q $KARAF_ZIP && rm -rf $ONOS_STAGE/$KARAF_DIST/demos
+[ -f $KARAF_TAR ] && tar zxf $KARAF_TAR && rm -rf $ONOS_STAGE/$KARAF_DIST/demos
mkdir bin
# Stage the ONOS admin scripts and patch in Karaf service wrapper extras
@@ -38,14 +38,7 @@
cp -r $ONOS_ROOT/tools/package/etc/* $ONOS_STAGE/$KARAF_DIST/etc
# Stage all builtin ONOS apps for factory install
-mkdir $ONOS_STAGE/apps
-find $ONOS_ROOT -name 'app.xml' | egrep -v '/src/test/|/target/|org\.foo\.' | \
- xargs grep 'name=' | sed 's/<app name="//g;s/".*//g' | while read line; do
- appxml=${line%:*}
- app=${line#*:}
- mkdir $ONOS_STAGE/apps/$app
- cp $appxml $ONOS_STAGE/apps/$app/app.xml
- done
+onos-stage-apps $ONOS_STAGE/apps $ONOS_STAGE/$KARAF_DIST/system
# Patch-in proper Karaf version into the startup script
sed "s/\$KARAF_VERSION/$KARAF_VERSION/g" \
@@ -54,14 +47,13 @@
$ONOS_ROOT/tools/package/bin/onos > bin/onos
# Stage the ONOS bundles, but only those that match the version
-mkdir -p $KARAF_DIST/system/org/onosproject
-# cp -r $M2_REPO/org/onosproject/ $KARAF_DIST/system/org/
+mkdir -p $ONOS_STAGE/$KARAF_DIST/system/org/onosproject
find $M2_REPO/org/onosproject/ -type d -name $ONOS_POM_VERSION | while read line; do
path=${line#*/onosproject/}
artifact=${path%/$ONOS_POM_VERSION}
- mkdir -p $KARAF_DIST/system/org/onosproject/$artifact
+ mkdir -p $ONOS_STAGE/$KARAF_DIST/system/org/onosproject/$artifact
cp -r $M2_REPO/org/onosproject/$artifact/$ONOS_POM_VERSION \
- $KARAF_DIST/system/org/onosproject/$artifact/$ONOS_POM_VERSION
+ $ONOS_STAGE/$KARAF_DIST/system/org/onosproject/$artifact/$ONOS_POM_VERSION
done
# ONOS Patching ----------------------------------------------------------------
@@ -84,6 +76,7 @@
# Now package up the ONOS tar file
cd $ONOS_STAGE_ROOT
+rm -f $ONOS_TAR $ONOS_ZIP
COPYFILE_DISABLE=1 tar zcf $ONOS_TAR $ONOS_BITS
which zip >/dev/null && zip -rq $ONOS_ZIP $ONOS_BITS
ls -l $ONOS_TAR $ONOS_ZIP 2>/dev/null
diff --git a/tools/test/bin/onos-setup-karaf b/tools/test/bin/onos-setup-karaf
index 930fdf7..56102cb 100755
--- a/tools/test/bin/onos-setup-karaf
+++ b/tools/test/bin/onos-setup-karaf
@@ -56,7 +56,7 @@
if ! grep -q ",onos-api," $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then
# Patch the Apache Karaf distribution file to load default ONOS boot features
- export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow"
+ export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-cli,onos-rest,onos-gui"
echo "Adding ONOS boot features $BOOT_FEATURES..."
perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \
$KARAF_ROOT/etc/org.apache.karaf.features.cfg
@@ -89,19 +89,11 @@
perl -pi.old -e "s/192.168.56/$SUBNET/" $KARAF_ROOT/etc/hazelcast.xml
perl -pi.old -e "s/ <name>onos</ <name>$IP</" $KARAF_ROOT/etc/hazelcast.xml
-
echo "Staging builtin apps..."
rm -fr $STAGE/apps
-mkdir -p $STAGE/apps
-find $ONOS_ROOT -name 'app.xml' | egrep -v '/src/test/|/target/|org\.foo\.' | \
- xargs grep 'name=' | sed 's/<app name="//g;s/".*//g' | while read line; do
- appxml=${line%:*}
- app=${line#*:}
- mkdir $STAGE/apps/$app
- cp $appxml $STAGE/apps/$app/app.xml
- done
+onos-stage-apps $STAGE/apps $KARAF_ROOT/system
echo "Customizing apps to be auto-activated..."
-for app in $(echo $ONOS_APPS | tr ',' ' '); do
+for app in $(echo ${ONOS_APPS:-openflow} | tr ',' ' '); do
touch $STAGE/apps/org.onosproject.$app/active
done
diff --git a/tools/test/bin/onos-stage-apps b/tools/test/bin/onos-stage-apps
new file mode 100755
index 0000000..4c2c230
--- /dev/null
+++ b/tools/test/bin/onos-stage-apps
@@ -0,0 +1,29 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Stages builtin ONOS apps into the specified directory for packaging.
+# -----------------------------------------------------------------------------
+
+[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
+. $ONOS_ROOT/tools/build/envDefaults
+
+export APPS=${1:-/tmp/apps}
+export KARAF_M2=${2:-/tmp/karaf/system}
+export AUX=$APPS/aux
+
+# Bail on any errors
+set -e
+
+mkdir -p $APPS $KARAF_M2
+rm -fr $AUX
+
+find $M2_REPO/org/onosproject/ -name "*.oar" -path "*/${ONOS_POM_VERSION}/*" | while read line; do
+ mkdir -p $AUX && cd $AUX
+ cp $line $AUX
+ jar -xf $AUX/*.oar
+ name=$(grep "name=" $AUX/app.xml | sed 's/<app name="//g;s/".*//g')
+ mkdir -p $APPS/$name
+ cp $AUX/app.xml $APPS/$name/app.xml
+ cp $AUX/*.oar $APPS/$name/$name.oar
+ cp -rf $AUX/m2/* $KARAF_M2
+ rm -fr $AUX
+done