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 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame^] | 29 | # Unroll the Apache Karaf bits, prune them and make the ONOS top-level directories. |
| 30 | unzip $KARAF_ZIP && rm -rm $KARAF_DIST/demos |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 31 | mkdir bin |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 32 | |
| 33 | # Stage the ONOS admin scripts |
| 34 | cp -r $ONOS_ROOT/tools/package/bin . |
| 35 | |
| 36 | # Stage the ONOS bundles |
tom | a56d5fe | 2014-09-17 11:05:47 -0700 | [diff] [blame] | 37 | mkdir -p system/org/onlab |
| 38 | cp -r $M2_REPO/org/onlab system/org/ |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 39 | |
| 40 | # Patch the Apache Karaf distribution file to add ONOS features repository |
| 41 | perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-features/$ONOS_VERSION/xml/features|" \ |
| 42 | $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
| 43 | |
| 44 | # Patch the Apache Karaf distribution file to load ONOS features |
| 45 | perl -pi.old -e 's|^(featuresBoot=.*)|\1,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-tvue|' \ |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame^] | 46 | $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 47 | |
| 48 | # Patch the Apache Karaf distribution with ONOS branding bundle |
| 49 | cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \ |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame^] | 50 | $ONOS_STAGE/$KARAF_DIST/lib |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 51 | |
| 52 | # Now package up the ONOS tar file |
| 53 | cd $ONOS_STAGE_ROOT |
| 54 | tar zcf $ONOS_BITS.tar.gz $ONOS_BITS |