blob: ac5b52d5923ad10767f8d4a10c1663a40b6d9532 [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
tom2d7acb72014-09-22 22:13:00 -070016[ ! -f $KARAF_ZIP -a ! -f $KARAF_TAR ] && echo "Apache Karaf bits $KARAF_ZIP or $KARAF_TAR not found" && exit 1
tom4d0c6632014-09-15 23:27:01 -070017[ -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.
tom2d7acb72014-09-22 22:13:00 -070024[ -f $KARAF_ZIP ] && unzip -q $KARAF_ZIP && rm -rf $KARAF_DIST/demos
25[ -f $KARAF_TAR ] && tar zxf $KARAF_TAR && rm -rf $KARAF_DIST/demos
tom4d0c6632014-09-15 23:27:01 -070026mkdir bin
tom4d0c6632014-09-15 23:27:01 -070027
tom5c255702014-09-18 06:57:39 -070028# Stage the ONOS admin scripts and patch in Karaf service wrapper extras
tom4d0c6632014-09-15 23:27:01 -070029cp -r $ONOS_ROOT/tools/package/bin .
tom0eaa97f2014-09-22 16:13:06 -070030cp -r $ONOS_ROOT/tools/package/debian $ONOS_STAGE/debian
tom5a18e802014-09-18 12:38:15 -070031cp -r $ONOS_ROOT/tools/package/etc/* $KARAF_DIST/etc
tom4d0c6632014-09-15 23:27:01 -070032
33# Stage the ONOS bundles
tom5c255702014-09-18 06:57:39 -070034mkdir -p $KARAF_DIST/system/org/onlab
35cp -r $M2_REPO/org/onlab $KARAF_DIST/system/org/
tom4d0c6632014-09-15 23:27:01 -070036
tome797a5d2014-09-30 11:57:50 -070037export ONOS_FEATURES="${ONOS_FEATURES:-webconsole,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-fwd,onos-app-foo}"
38
tome4729872014-09-23 00:37:37 -070039# Cellar Patching --------------------------------------------------------------
tom7e02cda2014-09-18 12:05:46 -070040
41# Patch the Apache Karaf distribution file to add Cellar features repository
tome4729872014-09-23 00:37:37 -070042#perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.apache.karaf.cellar/apache-karaf-cellar/3.0.0/xml/features|" \
43# $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
tom7e02cda2014-09-18 12:05:46 -070044
45# Patch the Apache Karaf distribution file to load ONOS features
tome4729872014-09-23 00:37:37 -070046#perl -pi.old -e 's|^(featuresBoot=.*)|\1,cellar|' \
47# $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
tom7e02cda2014-09-18 12:05:46 -070048
49# ONOS Patching ----------------------------------------------------------------
50
tom4d0c6632014-09-15 23:27:01 -070051# Patch the Apache Karaf distribution file to add ONOS features repository
52perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-features/$ONOS_VERSION/xml/features|" \
53 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
54
tome4729872014-09-23 00:37:37 -070055# Patch the Apache Karaf distribution file to load ONOS features
tome797a5d2014-09-30 11:57:50 -070056perl -pi.old -e "s|^(featuresBoot=.*)|\1,$ONOS_FEATURES|" \
tome4729872014-09-23 00:37:37 -070057 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
58
tom4d0c6632014-09-15 23:27:01 -070059# Patch the Apache Karaf distribution with ONOS branding bundle
60cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \
tom73d6d1e2014-09-17 20:08:01 -070061 $ONOS_STAGE/$KARAF_DIST/lib
tom4d0c6632014-09-15 23:27:01 -070062
tom53efab52014-10-07 17:43:48 -070063# Patch in the ONOS version file use the build number or the user name for
64# build postfix in place of the SNAPSHOT post-fix.
65build=${BUILD_NUMBER:-$(id -un)}
66grep '<version>' $ONOS_ROOT/pom.xml | head -n1 | \
67 sed 's:.*<version>::g;s:</version>.*::g' | sed "s/SNAPSHOT/$build/g" \
68 >> $ONOS_STAGE/VERSION
69
tom4d0c6632014-09-15 23:27:01 -070070# Now package up the ONOS tar file
71cd $ONOS_STAGE_ROOT
tom5c255702014-09-18 06:57:39 -070072COPYFILE_DISABLE=1 tar zcf $ONOS_TAR $ONOS_BITS
73ls -l $ONOS_TAR >&2