tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 2 | # ----------------------------------------------------------------------------- |
Thomas Vachuska | 734b749 | 2015-03-11 20:42:07 -0700 | [diff] [blame] | 3 | # Packages ONOS distributable into onos.tar.gz and onos.zip |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 4 | # ----------------------------------------------------------------------------- |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 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 | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 16 | [ -d $ONOS_STAGE ] && echo "ONOS stage $ONOS_STAGE already exists" && exit 1 |
| 17 | |
| 18 | # Create the stage directory and warp into it |
| 19 | mkdir -p $ONOS_STAGE |
| 20 | cd $ONOS_STAGE |
| 21 | |
Thomas Vachuska | b105fd4 | 2014-10-20 09:02:27 -0700 | [diff] [blame] | 22 | # Check if Apache Karaf bits are available and if not, fetch them. |
| 23 | if [ ! -f $KARAF_ZIP -a ! -f $KARAF_TAR ]; then |
| 24 | echo "Downloading $KARAF_TAR..." |
Thomas Vachuska | 84ca6e7 | 2015-03-18 14:31:29 -0700 | [diff] [blame] | 25 | curl -sL http://downloads.onosproject.org/third-party/apache-karaf-$KARAF_VERSION.tar.gz > $KARAF_TAR |
Thomas Vachuska | b105fd4 | 2014-10-20 09:02:27 -0700 | [diff] [blame] | 26 | fi |
| 27 | [ ! -f $KARAF_ZIP -a ! -f $KARAF_TAR ] && \ |
| 28 | echo "Apache Karaf bits $KARAF_ZIP or $KARAF_TAR not found" && exit 1 |
| 29 | |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 30 | # Unroll the Apache Karaf bits, prune them and make ONOS top-level directories. |
Thomas Vachuska | a7a0f56 | 2015-04-14 23:27:44 -0700 | [diff] [blame] | 31 | [ -f $KARAF_ZIP ] && unzip -q $KARAF_ZIP && rm -rf $ONOS_STAGE/$KARAF_DIST/demos |
| 32 | [ -f $KARAF_TAR ] && tar zxf $KARAF_TAR && rm -rf $ONOS_STAGE/$KARAF_DIST/demos |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 33 | mkdir bin |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 34 | |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 35 | # Stage the ONOS admin scripts and patch in Karaf service wrapper extras |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 36 | cp -r $ONOS_ROOT/tools/package/bin . |
tom | 0eaa97f | 2014-09-22 16:13:06 -0700 | [diff] [blame] | 37 | cp -r $ONOS_ROOT/tools/package/debian $ONOS_STAGE/debian |
Thomas Vachuska | b105fd4 | 2014-10-20 09:02:27 -0700 | [diff] [blame] | 38 | cp -r $ONOS_ROOT/tools/package/etc/* $ONOS_STAGE/$KARAF_DIST/etc |
| 39 | |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 40 | # Stage all builtin ONOS apps for factory install |
Thomas Vachuska | a7a0f56 | 2015-04-14 23:27:44 -0700 | [diff] [blame] | 41 | onos-stage-apps $ONOS_STAGE/apps $ONOS_STAGE/$KARAF_DIST/system |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 42 | |
Thomas Vachuska | 82e60a9 | 2015-04-30 01:15:58 -0700 | [diff] [blame] | 43 | # Mark the org.onosproject.drivers app active by default |
| 44 | touch $ONOS_STAGE/apps/org.onosproject.drivers/active |
| 45 | |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 46 | # Patch-in proper Karaf version into the startup script |
Thomas Vachuska | b105fd4 | 2014-10-20 09:02:27 -0700 | [diff] [blame] | 47 | sed "s/\$KARAF_VERSION/$KARAF_VERSION/g" \ |
| 48 | $ONOS_ROOT/tools/package/bin/onos-service > bin/onos-service |
| 49 | sed "s/\$KARAF_VERSION/$KARAF_VERSION/g" \ |
| 50 | $ONOS_ROOT/tools/package/bin/onos > bin/onos |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 51 | |
Thomas Vachuska | ebf5e54 | 2015-02-03 19:38:13 -0800 | [diff] [blame] | 52 | # Stage the ONOS bundles, but only those that match the version |
Thomas Vachuska | a7a0f56 | 2015-04-14 23:27:44 -0700 | [diff] [blame] | 53 | mkdir -p $ONOS_STAGE/$KARAF_DIST/system/org/onosproject |
Thomas Vachuska | b23fad2 | 2015-05-05 15:20:58 -0700 | [diff] [blame] | 54 | find $M2_REPO/org/onosproject -type f -path "*/$ONOS_POM_VERSION/*" \ |
Thomas Vachuska | 97a7033 | 2015-05-20 09:29:55 -0700 | [diff] [blame] | 55 | -name '*.jar' -o -name '*.pom' -o -name '*-features.xml' \ |
Thomas Vachuska | 8eb12a2 | 2015-05-05 16:20:19 -0700 | [diff] [blame] | 56 | | grep -v -Ee '-tests.jar|-[0-9]{8}.[0-9]{6}-' \ |
| 57 | | while read src; do |
Thomas Vachuska | b23fad2 | 2015-05-05 15:20:58 -0700 | [diff] [blame] | 58 | dst=$ONOS_STAGE/$KARAF_DIST/system/${src#$M2_REPO/*} |
| 59 | mkdir -p $(dirname $dst) |
| 60 | cp $src $dst |
Thomas Vachuska | ebf5e54 | 2015-02-03 19:38:13 -0800 | [diff] [blame] | 61 | done |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 62 | |
tom | 7e02cda | 2014-09-18 12:05:46 -0700 | [diff] [blame] | 63 | # ONOS Patching ---------------------------------------------------------------- |
| 64 | |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 65 | # Patch the Apache Karaf distribution file to add ONOS features repository |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 66 | perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onosproject/onos-features/$ONOS_POM_VERSION/xml/features|" \ |
Brian O'Connor | 014e221 | 2015-05-05 22:46:36 +0000 | [diff] [blame] | 67 | $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 68 | |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 69 | # Patch the Apache Karaf distribution file to load default ONOS boot features |
| 70 | export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-cli,onos-rest,onos-gui" |
| 71 | perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \ |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 72 | $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
| 73 | |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 74 | # Patch the Apache Karaf distribution with ONOS branding bundle |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 75 | cp $M2_REPO/org/onosproject/onos-branding/$ONOS_POM_VERSION/onos-branding-*.jar \ |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 76 | $ONOS_STAGE/$KARAF_DIST/lib |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 77 | |
tom | 61e317d | 2014-10-08 11:18:02 -0700 | [diff] [blame] | 78 | # Patch in the ONOS version file |
| 79 | echo $ONOS_VERSION > $ONOS_STAGE/VERSION |
tom | 53efab5 | 2014-10-07 17:43:48 -0700 | [diff] [blame] | 80 | |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 81 | # Now package up the ONOS tar file |
| 82 | cd $ONOS_STAGE_ROOT |
Thomas Vachuska | a7a0f56 | 2015-04-14 23:27:44 -0700 | [diff] [blame] | 83 | rm -f $ONOS_TAR $ONOS_ZIP |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 84 | COPYFILE_DISABLE=1 tar zcf $ONOS_TAR $ONOS_BITS |
Thomas Vachuska | aab3559 | 2015-05-18 14:12:53 -0700 | [diff] [blame] | 85 | |
| 86 | # Figure out whether we should build ONOS zip file and if so, build it. |
| 87 | which zip >/dev/null && [ -z "$ONOS_TAR_ONLY" ] && buildZip=true || unset buildZip |
| 88 | [ -n "$buildZip" ] && zip -rq $ONOS_ZIP $ONOS_BITS |
| 89 | |
| 90 | # Report on the archives that were built and clean-up |
| 91 | [ -n "$buildZip" ] && ls -lh $ONOS_TAR $ONOS_ZIP || ls -lh $ONOS_TAR |
tom | 61e317d | 2014-10-08 11:18:02 -0700 | [diff] [blame] | 92 | rm -r $ONOS_STAGE |