blob: 870acc6094b6be1fd86cec5e332400dd35d6b713 [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
29# Unroll the Apache Karaf bits and make the ONOS top-level directories.
30unzip $KARAF_ZIP
31mkdir bin
32mkdir lib
33
34# Stage the ONOS admin scripts
35cp -r $ONOS_ROOT/tools/package/bin .
36
37# Stage the ONOS bundles
38mkdir -p lib/org/onlab
39cp -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
46perl -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
50perl -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
54cp $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
58cd $ONOS_STAGE_ROOT
59tar zcf $ONOS_BITS.tar.gz $ONOS_BITS