blob: dd63d295abf30d8eb6438ab12cef6a994126daad [file] [log] [blame]
tom4d0c6632014-09-15 23:27:01 -07001#!/bin/bash
2#-------------------------------------------------------------------------------
3# Packages ONOS distributable into onos.tar.gz
4#-------------------------------------------------------------------------------
5
6export M2_REPO=${M2_REPO:-~/.m2/repository}
7export KARAF_ZIP=${KARAF_ZIP:-~/Downloads/apache-karaf-3.0.1.zip}
8export KARAF_DIST=$(basename $KARAF_ZIP .zip)
9
10export ONOS_VERSION=${ONOS_VERSION:-1.0.0-SNAPSHOT}
11export ONOS_STAGE_ROOT=${ONOS_STAGE_ROOT:-/tmp}
12export ONOS_BITS=onos-$ONOS_VERSION
13export ONOS_STAGE=$ONOS_STAGE_ROOT/$ONOS_BITS
14
15# Bail on any errors
16set -e
17
18rm -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
26mkdir -p $ONOS_STAGE
27cd $ONOS_STAGE
28
tom73d6d1e2014-09-17 20:08:01 -070029# Unroll the Apache Karaf bits, prune them and make the ONOS top-level directories.
30unzip $KARAF_ZIP && rm -rm $KARAF_DIST/demos
tom4d0c6632014-09-15 23:27:01 -070031mkdir bin
tom4d0c6632014-09-15 23:27:01 -070032
33# Stage the ONOS admin scripts
34cp -r $ONOS_ROOT/tools/package/bin .
35
36# Stage the ONOS bundles
toma56d5fe2014-09-17 11:05:47 -070037mkdir -p system/org/onlab
38cp -r $M2_REPO/org/onlab system/org/
tom4d0c6632014-09-15 23:27:01 -070039
40# Patch the Apache Karaf distribution file to add ONOS features repository
41perl -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
45perl -pi.old -e 's|^(featuresBoot=.*)|\1,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-tvue|' \
tom73d6d1e2014-09-17 20:08:01 -070046 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
tom4d0c6632014-09-15 23:27:01 -070047
48# Patch the Apache Karaf distribution with ONOS branding bundle
49cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \
tom73d6d1e2014-09-17 20:08:01 -070050 $ONOS_STAGE/$KARAF_DIST/lib
tom4d0c6632014-09-15 23:27:01 -070051
52# Now package up the ONOS tar file
53cd $ONOS_STAGE_ROOT
54tar zcf $ONOS_BITS.tar.gz $ONOS_BITS