Moved /features to /tools/package/features.

Change-Id: I6b52c92b688a833b9e3813416b785533cb4dd829
diff --git a/tools/package/BUCK b/tools/package/BUCK
index 9324c2c..b7adf19 100644
--- a/tools/package/BUCK
+++ b/tools/package/BUCK
@@ -2,19 +2,6 @@
 BRANDING = '//tools/package/branding:onos-tools-package-branding'
 PATCHES = '//lib:apache-karaf-patches'
 
-FEATURES = [
-  '//features:onos-thirdparty-base',
-  '//features:onos-thirdparty-web',
-  '//features:onos-api',
-  '//features:onos-core',
-  '//features:onos-incubator',
-  '//features:onos-rest',
-  '//features:onos-gui',
-  '//features:onos-gui2',
-  '//features:onos-cli',
-  '//features:onos-security',
-]
-
 #TODO move to buck-tools
 export_file (
   name = 'onos-prep-karaf',
@@ -28,17 +15,11 @@
   out = 'karaf.zip',
 )
 
-compile_features(
-  name = 'onos-features',
-  features = FEATURES,
-  maven_coords = 'org.onosproject:onos-features:xml:features:' + ONOS_VERSION,
-)
-
 staged_repos = ['$(location %s-repo)' % f for f in FEATURES]
 staged_apps = ['$(location %s)' % a for a in APPS]
 
 # feature_coords = 'foo:bar:1.3'
-sources = [ '$(location :onos-features)', ]
+sources = [ '$(location //tools/package/features:onos-features)', ]
 sources += staged_repos + staged_apps
 
 tar_file(
diff --git a/tools/package/BUILD b/tools/package/BUILD
index 93a0e1c..2067140 100644
--- a/tools/package/BUILD
+++ b/tools/package/BUILD
@@ -22,7 +22,7 @@
 
 # FIXME: Move /features to under tools/package/features
 PACKAGING_REQUIREMENTS = [
-    "//features:onos-features",
+    "//tools/package/features:onos-features",
     ":onos-karaf",
 ]
 
@@ -35,6 +35,7 @@
     cmd = "$(location onos_stage.py) $(location onos.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
     visibility = ["//visibility:public"],
     tools = ["onos_stage.py"],
+    output_to_bindir = True,
 )
 
 filegroup(
@@ -50,6 +51,7 @@
     cmd = "mkdir onos-admin-%s; cp $(SRCS) onos-admin-%s; tar zcf $(location onos-admin.tar.gz) onos-admin-%s"\
           % (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
     visibility = ["//visibility:public"],
+    output_to_bindir = True,
 )
 
 # Generates the onos-test.tar.gz file with test tools
@@ -60,6 +62,7 @@
     cmd = "mkdir onos-test-%s; cp -r tools onos-test-%s; tar zcf $(location onos-test.tar.gz) onos-test-%s"\
           % (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
     visibility = ["//visibility:public"],
+    output_to_bindir = True,
 )
 
 # Runs ONOS as a single instance from the /tmp directory
@@ -70,7 +73,7 @@
     srcs = ["onos-run-karaf", "onos-package"],
     cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" $(location onos-run-karaf) > $(location onos-runner); chmod +x $(location onos-runner)",
     executable = True,
-    local = True,
+    output_to_bindir = True,
     visibility = ["//visibility:public"],
 )
 
diff --git a/tools/package/features/BUCK b/tools/package/features/BUCK
new file mode 100644
index 0000000..479d488
--- /dev/null
+++ b/tools/package/features/BUCK
@@ -0,0 +1,166 @@
+osgi_feature (
+  name="onos-thirdparty-base",
+  title="ONOS 3rd party dependencies",
+  required_features = [],
+  included_bundles = [
+    '//lib:atomix',
+    '//lib:commons-lang',
+    '//lib:commons-lang3',
+    '//lib:commons-text',
+    '//lib:commons-configuration',
+    '//lib:guava',
+    '//lib:netty',
+    '//lib:netty-common',
+    '//lib:netty-buffer',
+    '//lib:netty-transport',
+    '//lib:netty-handler',
+    '//lib:netty-codec',
+    '//lib:netty-transport-native-epoll',
+    '//lib:netty-resolver',
+    '//lib:commons-pool',
+    '//lib:commons-math3',
+    '//lib:joda-time',
+    '//lib:metrics-core',
+    '//lib:metrics-json',
+    '//lib:minimal-json',
+    '//lib:kryo',
+    '//lib:reflectasm',
+    '//lib:asm',
+    '//lib:minlog',
+    '//lib:objenesis',
+    '//lib:jackson-core',
+    '//lib:jackson-annotations',
+    '//lib:jackson-databind',
+    '//lib:commons-collections',
+    '//lib:typesafe-config',
+    '//lib:concurrent-trees',
+    '//lib:commons-io',
+    '//lib:jersey-client',
+    '//lib:mapdb',
+    '//lib:bcpkix-jdk15on',
+    '//lib:bcprov-jdk15on',
+    '//lib:commons-jxpath', # FIXME: move xpath lib dependency to the right place
+    '//lib:commons-beanutils', # jxpath dependency
+    '//lib:jdom',  # jxpath dependency
+    '//lib:sigar',
+  ]
+)
+
+osgi_feature (
+  name="onos-thirdparty-web",
+  title="ONOS 3rd party dependencies for web apps",
+  required_features = [ 'war', 'onos-thirdparty-base' ],
+  included_bundles = [
+    '//lib:jersey-common',
+    '//lib:javax.annotation-api',
+    '//lib:javax.ws.rs-api',
+    '//lib:hk2-api',
+    '//lib:hk2-locator',
+    '//lib:hk2-osgi-resource-locator',
+    '//lib:javax.inject',
+    '//lib:jersey-server',
+    '//lib:jersey-hk2',
+    '//lib:aopalliance-repackaged',
+    '//lib:hk2-utils',
+    '//lib:validation-api',
+    '//lib:javassist',
+    '//lib:jersey-container-servlet',
+    '//lib:jersey-container-servlet-core',
+    '//lib:jersey-media-multipart',
+    '//lib:mimepull',
+  ]
+)
+
+osgi_feature (
+  name = 'onos-api',
+  title = 'ONOS services and model API',
+  required_features = ['scr', 'onos-thirdparty-base'],
+  included_bundles =[
+    '//utils/misc:onlab-misc',
+    '//utils/osgi:onlab-osgi',
+    '//core/api:onos-api',
+    '//incubator/api:onos-incubator-api',
+  ]
+)
+
+osgi_feature (
+  name='onos-core',
+  title='ONOS core components',
+  required_features = ['onos-api'],
+  included_bundles = [
+    '//core/net:onos-core-net',
+    '//core/common:onos-core-common',
+    '//core/store/dist:onos-core-dist',
+    '//core/store/primitives:onos-core-primitives',
+    '//core/store/persistence:onos-core-persistence',
+    '//core/store/serializers:onos-core-serializers',
+  ]
+)
+
+osgi_feature (
+  name='onos-incubator',
+  title='ONOS core incubator components',
+  required_features = ['onos-core'],
+  included_bundles = [
+    '//incubator/net:onos-incubator-net',
+    '//incubator/store:onos-incubator-store',
+    '//incubator/rpc:onos-incubator-rpc',
+  ]
+)
+
+osgi_feature (
+  name="onos-rest",
+  title="ONOS REST API components",
+  required_features = ['onos-api', 'onos-thirdparty-web'],
+  included_bundles = [
+    '//utils/rest:onlab-rest',
+    '//web/api:onos-rest',
+  ]
+)
+
+osgi_feature (
+  name = 'onos-gui',
+  title = 'ONOS GUI console components',
+  required_features = ['onos-api', 'onos-thirdparty-web'],
+  included_bundles = [
+    '//lib:jetty-websocket',
+    '//utils/rest:onlab-rest',
+    '//web/gui:onos-gui',
+  ]
+)
+
+osgi_feature (
+  name = 'onos-gui2',
+  title = 'ONOS GUI2 console components',
+  required_features = ['onos-api', 'onos-thirdparty-web'],
+  included_bundles = [
+    '//lib:jetty-websocket',
+    '//utils/rest:onlab-rest',
+    '//web/gui2:onos-gui2',
+  ]
+)
+
+osgi_feature (
+  name = 'onos-cli',
+  title="ONOS admin command console components",
+  required_features = ['onos-api'],
+  included_bundles = [
+    '//cli:onos-cli',
+  ]
+)
+
+osgi_feature (
+  name = 'onos-security',
+  title="Security-Mode ONOS",
+  required_features = ['onos-api'],
+  included_bundles = [
+    '//lib:org.apache.felix.framework.security',
+    '//core/security:onos-security',
+  ]
+)
+
+compile_features(
+  name = 'onos-features',
+  features = FEATURES,
+  maven_coords = 'org.onosproject:onos-features:xml:features:' + ONOS_VERSION,
+)
diff --git a/tools/package/features/BUILD b/tools/package/features/BUILD
new file mode 100644
index 0000000..5443842
--- /dev/null
+++ b/tools/package/features/BUILD
@@ -0,0 +1,188 @@
+load("//tools/build/bazel:osgi_features.bzl", "osgi_feature", "osgi_feature_repo")
+
+osgi_feature(
+    name = "onos-thirdparty-base",
+    description = "ONOS 3rd party dependencies",
+    included_bundles = [
+        "@atomix//jar",
+        "@commons_lang//jar",
+        "@commons_lang3//jar",
+        "@commons_text//jar",
+        "@commons_configuration//jar",
+        "@guava//jar",
+        "@netty//jar",
+        "@netty_common//jar",
+        "@netty_buffer//jar",
+        "@netty_transport//jar",
+        "@netty_handler//jar",
+        "@netty_codec//jar",
+        "@netty_transport_native_epoll//jar",
+        "@netty_resolver//jar",
+        "@commons_pool//jar",
+        "@commons_math3//jar",
+        "@joda_time//jar",
+        "@metrics_core//jar",
+        "@metrics_json//jar",
+        "@minimal_json//jar",
+        "@kryo//jar",
+        "@reflectasm//jar",
+        "@asm//jar",
+        "@minlog//jar",
+        "@objenesis//jar",
+        "@jackson_core//jar",
+        "@jackson_annotations//jar",
+        "@jackson_databind//jar",
+        "@commons_collections//jar",
+        "@typesafe_config//jar",
+        "@concurrent_trees//jar",
+        "@commons_io//jar",
+        "@jersey_client//jar",
+        "@mapdb//jar",
+        "@bcpkix_jdk15on//jar",
+        "@bcprov_jdk15on//jar",
+        "@commons_jxpath//jar",
+        "@commons_beanutils//jar",
+        "@jdom//jar",
+        "@sigar//jar",
+    ],
+    required_features = [],
+)
+
+osgi_feature(
+    name = "onos-thirdparty-web",
+    description = "ONOS 3rd party dependencies for web apps",
+    included_bundles = [
+        "@jersey_common//jar",
+        "@javax_annotation_api//jar",
+        "@javax_ws_rs_api//jar",
+        "@hk2_api//jar",
+        "@hk2_locator//jar",
+        "@hk2_osgi_resource_locator//jar",
+        "@javax_inject//jar",
+        "@jersey_server//jar",
+        "@jersey_hk2//jar",
+        "@aopalliance_repackaged//jar",
+        "@hk2_utils//jar",
+        "@validation_api//jar",
+        "@javassist//jar",
+        "@jersey_container_servlet//jar",
+        "@jersey_container_servlet_core//jar",
+        "@jersey_media_multipart//jar",
+        "@mimepull//jar",
+    ],
+    required_features = [
+        "war",
+        "onos-thirdparty-base",
+    ],
+)
+
+osgi_feature(
+    name = "onos-api",
+    description = "ONOS services and model API",
+    included_bundles = [
+        "//utils/misc:onlab-misc",
+        "//utils/osgi:onlab-osgi",
+        "//core/api:onos-api",
+        "//incubator/api:onos-incubator-api",
+    ],
+    required_features = [
+        "scr",
+        "onos-thirdparty-base",
+    ],
+)
+
+osgi_feature(
+    name = "onos-core",
+    description = "ONOS core components",
+    included_bundles = [
+        "//core/net:onos-core-net",
+        "//core/common:onos-core-common",
+        "//core/store/dist:onos-core-dist",
+        #        "//core/store/primitives:onos-core-primitives",
+        #        "//core/store/persistence:onos-core-persistence",
+        #        "//core/store/serializers:onos-core-serializers",
+    ],
+    required_features = ["onos-api"],
+)
+
+
+FEATURES = [
+    "//tools/package/features:onos-thirdparty-base",
+    "//tools/package/features:onos-thirdparty-web",
+    "//tools/package/features:onos-api",
+    "//tools/package/features:onos-core",
+#    "//tools/package/features:onos-incubator",
+#    "//tools/package/features:onos-rest",
+#    "//tools/package/features:onos-gui",
+#    "//tools/package/features:onos-gui2",
+#    "//tools/package/features:onos-cli",
+#    "//tools/package/features:onos-security",
+]
+
+osgi_feature_repo(
+    name = "onos-features",
+    exported_features = FEATURES,
+    visibility = ["//visibility:public"],
+)
+
+#osgi_feature (
+#  name = "onos-incubator",
+#  description = "ONOS core incubator components",
+#  required_features = ["onos-core"],
+#  included_bundles = [
+#    "//incubator/net:onos-incubator-net",
+#    "//incubator/store:onos-incubator-store",
+#    "//incubator/rpc:onos-incubator-rpc",
+#  ]
+#)
+#
+#osgi_feature (
+#  name = "onos-rest",
+#  description = "ONOS REST API components",
+#  required_features = ["onos-api", "onos-thirdparty-web"],
+#  included_bundles = [
+#    "//utils/rest:onlab-rest",
+#    "//web/api:onos-rest",
+#  ]
+#)
+#
+#osgi_feature (
+#  name = "onos-gui",
+#  description = "ONOS GUI console components",
+#  required_features = ["onos-api", "onos-thirdparty-web"],
+#  included_bundles = [
+#    "//lib:jetty_websocket",
+#    "//utils/rest:onlab-rest",
+#    "//web/gui:onos-gui",
+#  ]
+#)
+#
+#osgi_feature (
+#  name = "onos-gui2",
+#  description = "ONOS GUI2 console components",
+#  required_features = ["onos-api", "onos-thirdparty-web"],
+#  included_bundles = [
+#    "//lib:jetty_websocket",
+#    "//utils/rest:onlab-rest",
+#    "//web/gui2:onos-gui2",
+#  ]
+#)
+#
+#osgi_feature (
+#  name = "onos-cli",
+#  description ="ONOS admin command console components",
+#  required_features = ["onos-api"],
+#  included_bundles = [
+#    "//cli:onos-cli",
+#  ]
+#)
+#
+#osgi_feature (
+#  name = "onos-security",
+#  description ="Security-Mode ONOS",
+#  required_features = ["onos-api"],
+#  included_bundles = [
+#    "//lib:org.apache.felix.framework.security",
+#    "//core/security:onos-security",
+#  ]
+#)
diff --git a/tools/package/features/features.xml b/tools/package/features/features.xml
new file mode 100644
index 0000000..979f8b8
--- /dev/null
+++ b/tools/package/features/features.xml
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+  ~ Copyright 2014-present Open Networking Foundation
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+          name="onos-@FEATURE-VERSION">
+    <repository>mvn:org.apache.karaf.features/standard/3.0.8/xml/features</repository>
+
+    <feature name="onos-thirdparty-base" version="@FEATURE-VERSION"
+             description="ONOS 3rd party dependencies">
+        <bundle>mvn:commons-lang/commons-lang/2.6</bundle>
+        <bundle>mvn:org.apache.commons/commons-lang3/3.5</bundle>
+        <bundle>mvn:commons-configuration/commons-configuration/1.10</bundle>
+        <bundle>mvn:com.google.guava/guava/22.0</bundle>
+        <bundle>mvn:io.netty/netty/3.10.5.Final</bundle>
+        <bundle>mvn:io.netty/netty-common/4.1.8.Final</bundle>
+        <bundle>mvn:io.netty/netty-buffer/4.1.8.Final</bundle>
+        <bundle>mvn:io.netty/netty-transport/4.1.8.Final</bundle>
+        <bundle>mvn:io.netty/netty-handler/4.1.8.Final</bundle>
+        <bundle>mvn:io.netty/netty-codec/4.1.8.Final</bundle>
+        <bundle>mvn:io.netty/netty-transport-native-epoll/4.1.8.Final</bundle>
+        <bundle>mvn:io.netty/netty-resolver/4.1.8.Final</bundle>
+        <bundle>mvn:io.netty/netty-codec-http2/4.1.8.Final</bundle>
+        <bundle>mvn:io.netty/netty-codec-http/4.1.8.Final</bundle>
+        <bundle>mvn:commons-pool/commons-pool/1.6</bundle>
+        <bundle>mvn:org.apache.commons/commons-math3/3.6.1</bundle>
+
+        <bundle>mvn:joda-time/joda-time/2.9.3</bundle>
+
+        <bundle>mvn:io.dropwizard.metrics/metrics-core/3.2.2</bundle>
+        <bundle>mvn:io.dropwizard.metrics/metrics-json/3.2.2</bundle>
+        <bundle>mvn:com.eclipsesource.minimal-json/minimal-json/0.9.4</bundle>
+
+        <bundle>mvn:com.esotericsoftware/kryo/4.0.0</bundle>
+        <bundle>mvn:com.esotericsoftware/reflectasm/1.11.3</bundle>
+        <bundle>mvn:org.ow2.asm/asm/5.0.4</bundle>
+        <bundle>mvn:com.esotericsoftware/minlog/1.3.0</bundle>
+        <bundle>mvn:org.objenesis/objenesis/2.2</bundle>
+
+        <bundle>mvn:com.fasterxml.jackson.core/jackson-core/2.8.8</bundle>
+        <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/2.8.8</bundle>
+        <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/2.8.8</bundle>
+
+        <bundle>mvn:commons-configuration/commons-configuration/1.10</bundle>
+        <bundle>mvn:commons-collections/commons-collections/3.2.2</bundle>
+
+        <bundle>mvn:com.typesafe/config/1.2.1</bundle>
+        <bundle>mvn:com.googlecode.concurrent-trees/concurrent-trees/2.6.0</bundle>
+        <bundle>mvn:commons-io/commons-io/2.4</bundle>
+        <bundle>mvn:io.atomix/atomix/2.0.22</bundle>
+
+        <bundle>mvn:org.glassfish.jersey.core/jersey-client/2.26</bundle>
+
+        <bundle>mvn:org.mapdb/mapdb/1.0.7</bundle>
+    </feature>
+
+    <feature name="onos-thirdparty-web" version="@FEATURE-VERSION"
+             description="ONOS 3rd party dependencies for web apps">
+        <feature>war</feature>
+        <feature>onos-thirdparty-base</feature>
+        <!-- Bundles for jersey-common 2.x -->
+        <bundle>mvn:org.glassfish.jersey.core/jersey-common/2.26</bundle>
+        <bundle>mvn:javax.annotation/javax.annotation-api/1.2</bundle>
+        <bundle>mvn:javax.ws.rs/javax.ws.rs-api/2.1</bundle>
+        <bundle>mvn:org.glassfish.hk2/hk2-api/2.5.0-b42</bundle>
+        <bundle>mvn:org.glassfish.hk2/hk2-locator/2.5.0-b42</bundle>
+        <bundle>mvn:org.glassfish.hk2/osgi-resource-locator/1.0.1</bundle>
+        <bundle>mvn:org.glassfish.hk2.external/javax.inject/2.5.0-b42</bundle>
+        <bundle>mvn:org.glassfish.jersey.inject/jersey-hk2/2.26</bundle>
+        <!-- Bundles for jersey-server -->
+        <bundle>mvn:org.glassfish.jersey.core/jersey-server/2.26</bundle>
+        <bundle>mvn:org.glassfish.hk2.external/aopalliance-repackaged/2.5.0-b42</bundle>
+        <bundle>mvn:org.glassfish.hk2/hk2-utils/2.5.0-b42</bundle>
+        <bundle>mvn:javax.validation/validation-api/1.1.0.Final</bundle>
+        <bundle>mvn:org.javassist/javassist/3.22.0-GA</bundle>
+        <!-- Bundles for jersey-servlet -->
+        <bundle>mvn:org.glassfish.jersey.containers/jersey-container-servlet/2.26</bundle>
+        <bundle>mvn:org.glassfish.jersey.containers/jersey-container-servlet-core/2.26</bundle>
+        <!-- Bundles for jersey-media-multipart -->
+        <bundle>mvn:org.glassfish.jersey.media/jersey-media-multipart/2.26</bundle>
+        <bundle>mvn:org.jvnet.mimepull/mimepull/1.9.6</bundle>
+    </feature>
+
+    <feature name="onos-api" version="@FEATURE-VERSION"
+             description="ONOS services and model API">
+        <feature>scr</feature>
+        <feature>onos-thirdparty-base</feature>
+        <bundle>mvn:org.onosproject/onlab-misc/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onlab-osgi/@ONOS-VERSION</bundle>
+
+        <bundle>mvn:org.onosproject/onos-api/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-incubator-api/@ONOS-VERSION</bundle>
+    </feature>
+
+    <feature name="onos-core" version="@FEATURE-VERSION"
+             description="ONOS core components">
+        <feature>onos-api</feature>
+        <bundle>mvn:org.onosproject/onos-core-net/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-core-common/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-core-dist/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-core-primitives/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-core-persistence/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-core-serializers/@ONOS-VERSION</bundle>
+    </feature>
+
+    <feature name="onos-incubator" version="@FEATURE-VERSION"
+             description="ONOS core incubator components">
+        <feature>onos-core</feature>
+        <bundle>mvn:org.onosproject/onos-incubator-net/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-incubator-core/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-incubator-store/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-incubator-rpc/@ONOS-VERSION</bundle>
+    </feature>
+
+    <feature name="onos-rest" version="@FEATURE-VERSION"
+             description="ONOS REST API components">
+        <feature>onos-api</feature>
+        <feature>onos-thirdparty-web</feature>
+        <bundle>mvn:org.onosproject/onlab-rest/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-rest/@ONOS-VERSION</bundle>
+    </feature>
+
+    <feature name="onos-gui" version="@FEATURE-VERSION"
+             description="ONOS GUI console components">
+        <feature>onos-api</feature>
+        <feature>onos-thirdparty-web</feature>
+        <bundle>mvn:org.eclipse.jetty/jetty-websocket/8.1.19.v20160209</bundle>
+        <bundle>mvn:org.onosproject/onlab-rest/@ONOS-VERSION</bundle>
+        <bundle>mvn:org.onosproject/onos-gui/@ONOS-VERSION</bundle>
+    </feature>
+
+    <feature name="onos-cli" version="@FEATURE-VERSION"
+             description="ONOS admin command console components">
+        <feature>onos-api</feature>
+        <bundle>mvn:org.onosproject/onos-cli/@ONOS-VERSION</bundle>
+    </feature>
+
+    <feature name="onos-security" version="@FEATURE-VERSION"
+             description="Security-Mode ONOS">
+        <feature>onos-api</feature>
+        <bundle>mvn:org.onosproject/org.apache.felix.framework.security/2.2.0.onos</bundle>
+        <bundle>mvn:org.onosproject/onos-security/@ONOS-VERSION</bundle>
+    </feature>
+
+</features>
diff --git a/tools/package/features/pom.xml b/tools/package/features/pom.xml
new file mode 100644
index 0000000..18dd3c4
--- /dev/null
+++ b/tools/package/features/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2014-present Open Networking Foundation
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos</artifactId>
+        <version>1.14.0-SNAPSHOT</version>
+        <relativePath>../../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-features</artifactId>
+    <packaging>pom</packaging>
+
+    <description>ONOS Apache Karaf feature definitions</description>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>com.google.code.maven-replacer-plugin</groupId>
+                <artifactId>replacer</artifactId>
+                <version>1.5.3</version>
+                <executions>
+                    <execution>
+                        <phase>prepare-package</phase>
+                        <goals>
+                            <goal>replace</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <file>${pom.basedir}/features.xml</file>
+                    <outputFile>${pom.basedir}/target/features.xml</outputFile>
+                    <replacements>
+                        <replacement>
+                            <token>@ONOS-VERSION</token>
+                            <value>${project.version}</value>
+                        </replacement>
+                        <replacement>
+                            <token>@FEATURE-VERSION</token>
+                            <value>${project.version}</value>
+                        </replacement>
+                    </replacements>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.9</version>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>target/features.xml</file>
+                                    <type>xml</type>
+                                    <classifier>features</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/tools/test/bin/onos-check-bits b/tools/test/bin/onos-check-bits
index cc08746..2b0acd3 100755
--- a/tools/test/bin/onos-check-bits
+++ b/tools/test/bin/onos-check-bits
@@ -12,6 +12,12 @@
   rm -f $ONOS_TAR >/dev/null; ln -s $BUCK_TAR $ONOS_TAR
 fi
 
+# If the Bazel-built bits are newer than the BUCK-built bits, use the former.
+# BAZEL_TAR=$ONOS_ROOT/bazel-bin/tools/package/onos.tar.gz
+# if [ -f $BAZEL_TAR ] && [ $BAZEL_TAR -nt $BUCK_TAR ]; then
+#   rm -f $ONOS_TAR >/dev/null; ln -s $BAZEL_TAR $ONOS_TAR
+# fi
+
 ls -lL $ONOS_TAR  && cksum $ONOS_TAR
 if [ $? -ne 0 ]; then
   echo "ONOS archive is unreadable" && exit 1