tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | #------------------------------------------------------------------------------- |
| 3 | # Packages ONOS distributable into onos.tar.gz |
| 4 | #------------------------------------------------------------------------------- |
| 5 | |
| 6 | export M2_REPO=${M2_REPO:-~/.m2/repository} |
| 7 | export KARAF_ZIP=${KARAF_ZIP:-~/Downloads/apache-karaf-3.0.1.zip} |
| 8 | export KARAF_DIST=$(basename $KARAF_ZIP .zip) |
| 9 | |
| 10 | export ONOS_VERSION=${ONOS_VERSION:-1.0.0-SNAPSHOT} |
| 11 | export ONOS_STAGE_ROOT=${ONOS_STAGE_ROOT:-/tmp} |
| 12 | export ONOS_BITS=onos-$ONOS_VERSION |
| 13 | export ONOS_STAGE=$ONOS_STAGE_ROOT/$ONOS_BITS |
| 14 | |
| 15 | # Bail on any errors |
| 16 | set -e |
| 17 | |
| 18 | rm -fr $ONOS_STAGE # Remove this when package script is completed |
| 19 | |
| 20 | # Make sure we have the original apache karaf bits first |
| 21 | [ ! -d $M2_REPO ] && echo "M2 repository $M2_REPO not found" && exit 1 |
| 22 | [ ! -f $KARAF_ZIP ] && echo "Apache Karaf bits $KARAF_ZIP not found" && exit 1 |
| 23 | [ -d $ONOS_STAGE ] && echo "ONOS stage $ONOS_STAGE already exists" && exit 1 |
| 24 | |
| 25 | # Create the stage directory and warp into it |
| 26 | mkdir -p $ONOS_STAGE |
| 27 | cd $ONOS_STAGE |
| 28 | |
| 29 | # Unroll the Apache Karaf bits and make the ONOS top-level directories. |
| 30 | unzip $KARAF_ZIP |
| 31 | mkdir bin |
| 32 | mkdir lib |
| 33 | |
| 34 | # Stage the ONOS admin scripts |
| 35 | cp -r $ONOS_ROOT/tools/package/bin . |
| 36 | |
| 37 | # Stage the ONOS bundles |
| 38 | mkdir -p lib/org/onlab |
| 39 | cp -r $M2_REPO/org/onlab lib/org |
| 40 | |
| 41 | |
| 42 | # Patch the Apache Karaf distribution file to point to the lib as maven repo |
| 43 | #perl -pi.old -e "s|^org.ops4j.pax.url.mvn.repositories= |org.ops4j.pax.url.mvn.repositories= \\\n file:../../lib, |" $ONOS_STAGE/$KARAF_DIST/etc/org.ops4j.pax.url.mvn.cfg |
| 44 | |
| 45 | # Patch the Apache Karaf distribution file to add ONOS features repository |
| 46 | perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-features/$ONOS_VERSION/xml/features|" \ |
| 47 | $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
| 48 | |
| 49 | # Patch the Apache Karaf distribution file to load ONOS features |
| 50 | perl -pi.old -e 's|^(featuresBoot=.*)|\1,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-tvue|' \ |
| 51 | /tmp/onos-1.0.0-SNAPSHOT/apache-karaf-3.0.1/etc/org.apache.karaf.features.cfg |
| 52 | |
| 53 | # Patch the Apache Karaf distribution with ONOS branding bundle |
| 54 | cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \ |
| 55 | $ONOS_STAGE/apache-karaf-*/lib |
| 56 | |
| 57 | # Now package up the ONOS tar file |
| 58 | cd $ONOS_STAGE_ROOT |
| 59 | tar zcf $ONOS_BITS.tar.gz $ONOS_BITS |