Brian O'Connor

Adding onos packaging buck rule and script

Change-Id: I0c909e6bf45197061f81f1705de05561c4c91d8d
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
7 7
8 [alias] 8 [alias]
9 onos = //:onos 9 onos = //:onos
10 + package = //tools/package:onos-package
10 11
11 [download] 12 [download]
12 maven_repo = https://repo1.maven.org/maven2 13 maven_repo = https://repo1.maven.org/maven2
......
1 +KARAF = '//lib:apache-karaf'
2 +BRANDING = '//tools/package/branding:onos-tools-package-branding'
3 +
4 +FEATURES = [
5 + '//features:onos-thirdparty-base',
6 + '//features:onos-thirdparty-web',
7 + '//features:onos-api',
8 + '//features:onos-core',
9 + '//features:onos-incubator',
10 + '//features:onos-rest',
11 + '//features:onos-gui',
12 + '//features:onos-cli',
13 +#'//features:onos-security',
14 +]
15 +
16 +#FIXME this list is currently mirrored from the root Buck file
17 +APPS = [
18 + #Drivers
19 + '//drivers/default:onos-drivers-default-oar',
20 +
21 + # Providers
22 + '//providers/bgp:onos-providers-bgp-oar',
23 + '//providers/host:onos-providers-host-oar',
24 + '//providers/lldp:onos-providers-lldp-oar',
25 + '//providers/netcfghost:onos-providers-netcfghost-oar',
26 + '//providers/netcfglinks:onos-providers-netcfglinks-oar',
27 + '//providers/netconf:onos-providers-netconf-oar',
28 + '//providers/openflow/message:onos-providers-openflow-message-oar',
29 + '//providers/ovsdb:onos-providers-ovsdb-oar',
30 + '//providers/pcep:onos-providers-pcep-oar',
31 + '//providers/null:onos-providers-null-oar',
32 + '//providers/openflow/base:onos-providers-openflow-base-oar',
33 + '//providers/rest:onos-providers-rest-oar',
34 + '//providers/isis:onos-providers-isis-oar',
35 +
36 + # Apps
37 + '//apps/dhcp:onos-apps-dhcp-oar',
38 + '//apps/fwd:onos-apps-fwd-oar',
39 + '//apps/aaa:onos-apps-aaa-oar',
40 + '//apps/acl:onos-apps-acl-oar',
41 + '//apps/bgprouter:onos-apps-bgprouter-oar',
42 + '//apps/proxyarp:onos-apps-proxyarp-oar',
43 + '//apps/segmentrouting:onos-apps-segmentrouting-oar',
44 + '//apps/gangliametrics:onos-apps-gangliametrics-oar',
45 + '//apps/graphitemetrics:onos-apps-graphitemetrics-oar',
46 + '//apps/igmp:onos-apps-igmp-oar',
47 + '//apps/cordmcast:onos-apps-cordmcast-oar',
48 + '//apps/olt:onos-apps-olt-oar',
49 + '//apps/influxdbmetrics:onos-apps-influxdbmetrics-oar',
50 + '//apps/metrics:onos-apps-metrics-oar',
51 + '//apps/mfwd:onos-apps-mfwd-oar',
52 + '//apps/mlb:onos-apps-mlb-oar',
53 + '//apps/openstackinterface:onos-apps-openstackinterface-oar',
54 + '//apps/openstacknetworking:onos-apps-openstacknetworking-oar',
55 + '//apps/openstacknetworking/openstackrouting:onos-apps-openstacknetworking-openstackrouting-oar',
56 + '//apps/openstacknetworking/openstackswitching:onos-apps-openstacknetworking-openstackswitching-oar',
57 + '//apps/mobility:onos-apps-mobility-oar',
58 + '//apps/optical:onos-apps-optical-oar',
59 + '//apps/pathpainter:onos-apps-pathpainter-oar',
60 + '//apps/pcep-api:onos-apps-pcep-api-oar',
61 + '//apps/pim:onos-apps-pim-oar',
62 + '//apps/reactive-routing:onos-apps-reactive-routing-oar',
63 + '//apps/sdnip:onos-apps-sdnip-oar',
64 + '//apps/virtualbng:onos-apps-virtualbng-oar',
65 + '//apps/cordvtn:onos-apps-cordvtn-oar',
66 + '//apps/vpls:onos-apps-vpls-oar',
67 + '//apps/vrouter:onos-apps-vrouter-oar',
68 + '//apps/vtn:onos-apps-vtn-oar',
69 + '//apps/faultmanagement:onos-apps-faultmanagement-oar',
70 + '//apps/openstacknode:onos-apps-openstacknode-oar',
71 + '//apps/cpman/app:onos-apps-cpman-app-oar',
72 + '//apps/xosclient:onos-apps-xosclient-oar',
73 +]
74 +
75 +#TODO move to buck-tools
76 +export_file (
77 + name = 'onos-prep-karaf',
78 +)
79 +
80 +genrule(
81 + name = 'onos-karaf',
82 + srcs = glob(['bin/*', 'etc/*', 'init/*']),
83 + bash = '$(location :onos-prep-karaf) $OUT $(location %s) %s $(location %s)'\
84 + % (KARAF, ONOS_VERSION, BRANDING),
85 + out = 'karaf.zip',
86 +)
87 +
88 +compile_features(
89 + name = 'onos-features',
90 + features = FEATURES,
91 +)
92 +
93 +staged_repos = ['$(location %s-repo)' % f for f in FEATURES]
94 +staged_apps = ['$(location %s)' % a for a in APPS]
95 +
96 +# feature_coords = 'foo:bar:1.3'
97 +sources = [ '$(location :onos-features)', ]
98 +sources += staged_repos + staged_apps
99 +
100 +genrule(
101 + name = 'onos-package',
102 + out = 'onos.zip',
103 + bash = 'cp $(location :onos-karaf) $OUT && $(exe //buck-tools:onos-stage) $OUT ' + ' '.join(sources),
104 + visibility = [ 'PUBLIC' ],
105 +)
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/bash
2 +# -----------------------------------------------------------------------------
3 +# Packages ONOS distributable into onos.tar.gz, onos.zip or a deb file
4 +# -----------------------------------------------------------------------------
5 +
6 +set -e
7 +
8 +OUT=$1
9 +KARAF_TAR=$2
10 +ONOS_VERSION=$3
11 +BRANDING=$4
12 +
13 +# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
14 +tar xf $KARAF_TAR
15 +
16 +# Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
17 +KARAF_DIR=$(ls -d apache*)
18 +rm -rf $KARAF_DIR/demos
19 +
20 +# Patch the log-file size in place to increase it to 10 MB
21 +perl -pi.old -e "s/maxFileSize=1MB/maxFileSize=10MB/g" \
22 + $KARAF_DIR/etc/org.ops4j.pax.logging.cfg
23 +
24 +# Patch-in proper Karaf version into the startup script
25 +sed -i '' "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" bin/onos-service
26 +sed -i '' "s/apache-karaf-\$KARAF_VERSION/$KARAF_DIR/g" bin/onos-client
27 +mv bin/onos-client bin/onos
28 +chmod a+x bin/onos-service bin/onos
29 +
30 +# Stage the ONOS admin scripts and patch in Karaf service wrapper extras
31 +cp -r bin $KARAF_DIR
32 +cp -r init $KARAF_DIR
33 +cp -r etc $KARAF_DIR
34 +
35 +export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui"
36 +#FIXME
37 +#[ "$ONOS_SECURITY_MODE" = true ] && enable_security_mode
38 +
39 +# Patch the Apache Karaf distribution file to add ONOS features repository
40 +perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onosproject/onos-features/$ONOS_VERSION/xml/features|" \
41 + $KARAF_DIR/etc/org.apache.karaf.features.cfg
42 +
43 +# Patch the Apache Karaf distribution file to load default ONOS boot features
44 +perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \
45 + $KARAF_DIR/etc/org.apache.karaf.features.cfg
46 +
47 +# Patch the Apache Karaf distribution with ONOS branding bundle
48 +cp $BRANDING $KARAF_DIR/lib
49 +
50 +zip -q -0 -r $OUT $KARAF_DIR
51 +
52 +#FIXME
53 +# Stage all builtin ONOS apps for factory install
54 +#onos-stage-apps $ONOS_STAGE/apps $ONOS_STAGE/$KARAF_DIST/system
55 +# Mark the org.onosproject.drivers app active by default
56 +#touch $ONOS_STAGE/apps/org.onosproject.drivers/active
57 +
58 +# copy in features and repos
59 +# Patch in the ONOS version file
60 +#echo $ONOS_VERSION > $ONOS_STAGE/VERSION
61 +
62 +
63 +#function enable_security_mode() {
64 +# echo "Enabling security mode ONOS..."
65 +#
66 +# # SM-ONOS step 1: downgrade felix config admin
67 +# FELIX_CFG_ADMIN=${FELIX_CFG_ADMIN:-~/Downloads/org.apache.felix.configadmin-1.6.0.jar}
68 +# if [ ! -f $FELIX_CFG_ADMIN ]; then
69 +# echo "Downloading $FELIX_CFG_ADMIN..."
70 +# curl -sL http://archive.apache.org/dist/felix/org.apache.felix.configadmin-1.6.0.jar > $FELIX_CFG_ADMIN
71 +# fi
72 +# [ ! -f $FELIX_CFG_ADMIN ] && \
73 +# echo "Felix config admin not found: $FELIX_CFG_ADMIN" && exit 1
74 +#
75 +# mkdir -p $ONOS_STAGE/$KARAF_DIST/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
76 +# cp $FELIX_CFG_ADMIN $ONOS_STAGE/$KARAF_DIST/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
77 +# perl -pi.old -e "s|org.apache.felix.configadmin/1.8.0|org.apache.felix.configadmin/1.6.0|g" \
78 +# $ONOS_STAGE/$KARAF_DIST/etc/startup.properties
79 +#
80 +# # SM-ONOS step 2: stage ONOS Felix framework security (this is already done by karaf assembly); end
81 +#
82 +# # SM-ONOS step 3.1: configure karaf
83 +# perl -pi.old -e "s|#java.security.policy|java.security.policy|" \
84 +# $ONOS_STAGE/$KARAF_DIST/etc/system.properties
85 +# perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \
86 +# $ONOS_STAGE/$KARAF_DIST/etc/system.properties
87 +#
88 +# # SM-ONOS step 3.2: update featuresBoot
89 +# export BOOT_FEATURES="onos-security,$BOOT_FEATURES"
90 +#}
91 +