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 | |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 8 | |
| 9 | # Bail on any errors |
| 10 | set -e |
| 11 | |
| 12 | rm -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 |
tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 16 | [ ! -f $KARAF_ZIP -a ! -f $KARAF_TAR ] && echo "Apache Karaf bits $KARAF_ZIP or $KARAF_TAR not found" && exit 1 |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 17 | [ -d $ONOS_STAGE ] && echo "ONOS stage $ONOS_STAGE already exists" && exit 1 |
| 18 | |
| 19 | # Create the stage directory and warp into it |
| 20 | mkdir -p $ONOS_STAGE |
| 21 | cd $ONOS_STAGE |
| 22 | |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 23 | # Unroll the Apache Karaf bits, prune them and make ONOS top-level directories. |
tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 24 | [ -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 |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 26 | mkdir bin |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 27 | |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 28 | # Stage the ONOS admin scripts and patch in Karaf service wrapper extras |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 29 | cp -r $ONOS_ROOT/tools/package/bin . |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 30 | cp -r $ONOS_ROOT/tools/package/debian $ONOS_STAGE/debian |
tom | 5a18e80 | 2014-09-18 12:38:15 -0700 | [diff] [blame] | 31 | cp -r $ONOS_ROOT/tools/package/etc/* $KARAF_DIST/etc |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 32 | |
| 33 | # Stage the ONOS bundles |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 34 | mkdir -p $KARAF_DIST/system/org/onlab |
| 35 | cp -r $M2_REPO/org/onlab $KARAF_DIST/system/org/ |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 36 | |
tom | e797a5d | 2014-09-30 11:57:50 -0700 | [diff] [blame] | 37 | export ONOS_FEATURES="${ONOS_FEATURES:-webconsole,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-fwd,onos-app-foo}" |
| 38 | |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 39 | # Cellar Patching -------------------------------------------------------------- |
tom | 7e02cda | 2014-09-18 12:05:46 -0700 | [diff] [blame] | 40 | |
| 41 | # Patch the Apache Karaf distribution file to add Cellar features repository |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 42 | #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 |
tom | 7e02cda | 2014-09-18 12:05:46 -0700 | [diff] [blame] | 44 | |
| 45 | # Patch the Apache Karaf distribution file to load ONOS features |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 46 | #perl -pi.old -e 's|^(featuresBoot=.*)|\1,cellar|' \ |
| 47 | # $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
tom | 7e02cda | 2014-09-18 12:05:46 -0700 | [diff] [blame] | 48 | |
| 49 | # ONOS Patching ---------------------------------------------------------------- |
| 50 | |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 51 | # Patch the Apache Karaf distribution file to add ONOS features repository |
| 52 | perl -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 | |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 55 | # Patch the Apache Karaf distribution file to load ONOS features |
tom | e797a5d | 2014-09-30 11:57:50 -0700 | [diff] [blame] | 56 | perl -pi.old -e "s|^(featuresBoot=.*)|\1,$ONOS_FEATURES|" \ |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 57 | $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
| 58 | |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 59 | # Patch the Apache Karaf distribution with ONOS branding bundle |
| 60 | cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \ |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 61 | $ONOS_STAGE/$KARAF_DIST/lib |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 62 | |
tom | 53efab5 | 2014-10-07 17:43:48 -0700 | [diff] [blame] | 63 | # 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. |
tom | c5a5abc | 2014-10-07 18:26:14 -0700 | [diff] [blame] | 65 | build=${BUILD_NUMBER:-$(id -un)~$(date +'%Y/%m/%d@%H:%M')} |
tom | 53efab5 | 2014-10-07 17:43:48 -0700 | [diff] [blame] | 66 | grep '<version>' $ONOS_ROOT/pom.xml | head -n1 | \ |
tom | c5a5abc | 2014-10-07 18:26:14 -0700 | [diff] [blame] | 67 | sed 's:.*<version>::g;s:</version>.*::g' | sed "s#SNAPSHOT#$build#g" \ |
tom | 53efab5 | 2014-10-07 17:43:48 -0700 | [diff] [blame] | 68 | >> $ONOS_STAGE/VERSION |
| 69 | |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 70 | # Now package up the ONOS tar file |
| 71 | cd $ONOS_STAGE_ROOT |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 72 | COPYFILE_DISABLE=1 tar zcf $ONOS_TAR $ONOS_BITS |
| 73 | ls -l $ONOS_TAR >&2 |