blob: d35a48b22acba5cb29ad094a416de4d5400ba5da [file] [log] [blame]
tom4d0c6632014-09-15 23:27:01 -07001#!/bin/bash
2#-------------------------------------------------------------------------------
3# Packages ONOS distributable into onos.tar.gz
4#-------------------------------------------------------------------------------
5
tom5c255702014-09-18 06:57:39 -07006[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
tom4d0c6632014-09-15 23:27:01 -07008
9# Bail on any errors
10set -e
11
12rm -fr $ONOS_STAGE # Remove this when package script is completed
13
14# Make sure we have the original apache karaf bits first
15[ ! -d $M2_REPO ] && echo "M2 repository $M2_REPO not found" && exit 1
16[ ! -f $KARAF_ZIP ] && echo "Apache Karaf bits $KARAF_ZIP not found" && exit 1
17[ -d $ONOS_STAGE ] && echo "ONOS stage $ONOS_STAGE already exists" && exit 1
18
19# Create the stage directory and warp into it
20mkdir -p $ONOS_STAGE
21cd $ONOS_STAGE
22
tom5c255702014-09-18 06:57:39 -070023# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
24unzip -q $KARAF_ZIP && rm -rf $KARAF_DIST/demos
tom4d0c6632014-09-15 23:27:01 -070025mkdir bin
tom4d0c6632014-09-15 23:27:01 -070026
tom5c255702014-09-18 06:57:39 -070027# Stage the ONOS admin scripts and patch in Karaf service wrapper extras
tom4d0c6632014-09-15 23:27:01 -070028cp -r $ONOS_ROOT/tools/package/bin .
tom5c255702014-09-18 06:57:39 -070029cp -r $ONOS_ROOT/tools/package/wrapper/* $KARAF_DIST
tom5a18e802014-09-18 12:38:15 -070030cp -r $ONOS_ROOT/tools/package/etc/* $KARAF_DIST/etc
tom4d0c6632014-09-15 23:27:01 -070031
32# Stage the ONOS bundles
tom5c255702014-09-18 06:57:39 -070033mkdir -p $KARAF_DIST/system/org/onlab
34cp -r $M2_REPO/org/onlab $KARAF_DIST/system/org/
tom4d0c6632014-09-15 23:27:01 -070035
tom7e02cda2014-09-18 12:05:46 -070036# Wrapper & Cellar Patching ----------------------------------------------------
37
38# Patch the Apache Karaf distribution file to add Cellar features repository
39perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.apache.karaf.cellar/apache-karaf-cellar/3.0.0/xml/features|" \
40 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
41
42# Patch the Apache Karaf distribution file to load ONOS features
43perl -pi.old -e 's|^(featuresBoot=.*)|\1,wrapper,cellar|' \
44 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
45
46# ONOS Patching ----------------------------------------------------------------
47
tom4d0c6632014-09-15 23:27:01 -070048# Patch the Apache Karaf distribution file to add ONOS features repository
49perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-features/$ONOS_VERSION/xml/features|" \
50 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
51
52# Patch the Apache Karaf distribution file to load ONOS features
tomecd0fbd2014-09-19 08:47:05 -070053#perl -pi.old -e 's|^(featuresBoot=.*)|\1,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-tvue,onos-app-fwd|' \
54# $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
tom4d0c6632014-09-15 23:27:01 -070055
56# Patch the Apache Karaf distribution with ONOS branding bundle
57cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \
tom73d6d1e2014-09-17 20:08:01 -070058 $ONOS_STAGE/$KARAF_DIST/lib
tom4d0c6632014-09-15 23:27:01 -070059
tom7e02cda2014-09-18 12:05:46 -070060
tom4d0c6632014-09-15 23:27:01 -070061# Now package up the ONOS tar file
62cd $ONOS_STAGE_ROOT
tom5c255702014-09-18 06:57:39 -070063COPYFILE_DISABLE=1 tar zcf $ONOS_TAR $ONOS_BITS
64ls -l $ONOS_TAR >&2