[AETHER-255] Collection of missing cherry-picks and other fixes

Includes following commits
- ca05e1fd9d95f6e8801279c19fbf3377b200474c
- 0033dcb99e5bd8e8e7203a349a8dfb9cc4190bc9
- bdf39a75600df007e08234f89b8f8834e00f1b2a

Additionally:
- Removes zte and onos-topo bundles which are not present in 2.2.
- Removes general provider from minimal and seba

Change-Id: Ic078482d1ff465c5b301adee98f0ad98a08c0fdb
diff --git a/BUILD b/BUILD
index 02c1b1d..65bf497 100644
--- a/BUILD
+++ b/BUILD
@@ -1,14 +1,40 @@
 load("//tools/build/bazel:variables.bzl", "ONOS_VERSION")
-load("//tools/build/bazel:modules.bzl", "APPS", "CORE", "FEATURES")
+load(
+    "//tools/build/bazel:modules.bzl",
+    "CORE",
+    "FEATURES",
+    "apps",
+    "extensions",
+    "profiles",
+)
+
+#
+# ONOS Package Profiles
+# Usage: bazel build onos-package --define profile=<profile name>
+# Example: bazel build onos-package --define profile=minimal
+#
+# To view or update which apps and features are included in each
+# profile, open: tools/build/bazel/modules.bzl
+#
+profiles([
+    "minimal",
+    "seba",
+    "stratum",
+])
 
 filegroup(
     name = "onos",
-    srcs = CORE + APPS + [
+    srcs = CORE + [
         "//tools/build/conf:onos-build-conf",
         ":onos-package-admin",
         ":onos-package-test",
         ":onos-package",
-    ],
+    ] + select({
+        ":minimal_profile": extensions("minimal") + apps("minimal"),
+        ":seba_profile": extensions("seba") + apps("seba"),
+        ":stratum_profile": extensions("stratum") + apps("stratum"),
+        "//conditions:default": extensions() + apps(),
+    }),
     visibility = ["//visibility:public"],
 )
 
@@ -43,7 +69,12 @@
     srcs = [
         "//tools/package/features:onos-features",
         ":onos-karaf",
-    ] + APPS + FEATURES,
+    ] + FEATURES + select({
+        ":minimal_profile": apps("minimal"),
+        ":seba_profile": apps("seba"),
+        ":stratum_profile": apps("stratum"),
+        "//conditions:default": apps(),
+    }),
     outs = ["onos.tar.gz"],
     cmd = "$(location tools/package/onos_stage.py) $(location onos.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
     output_to_bindir = True,
@@ -51,45 +82,6 @@
     tools = ["tools/package/onos_stage.py"],
 )
 
-# Generates the minimal onos-minimal.tar.gz bundle
-genrule(
-    name = "onos-package-minimal",
-    srcs = [
-        "//tools/package/features:onos-features",
-        ":onos-karaf",
-        "//drivers/default:onos-drivers-default-oar",
-    ] + FEATURES,
-    outs = ["onos-minimal.tar.gz"],
-    cmd = "$(location tools/package/onos_stage.py) $(location onos-minimal.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
-    output_to_bindir = True,
-    tags = ["local"],
-    tools = ["tools/package/onos_stage.py"],
-)
-
-# Generates SEBA-specific onos-seba.tar.gz bundle
-genrule(
-    name = "onos-package-seba",
-    srcs = [
-        "//tools/package/features:onos-features",
-        ":onos-karaf",
-        "//drivers/default:onos-drivers-default-oar",
-        "//apps/optical-model:onos-apps-optical-model-oar",
-        "//providers/openflow/app:onos-providers-openflow-app-oar",
-        "//providers/openflow/base:onos-providers-openflow-base-oar",
-        "//providers/host:onos-providers-host-oar",
-        "//providers/lldp:onos-providers-lldp-oar",
-        "//apps/mcast:onos-apps-mcast-oar",
-        "//providers/netcfghost:onos-providers-netcfghost-oar",
-        "//apps/segmentrouting:onos-apps-segmentrouting-oar",
-        "//apps/route-service:onos-apps-route-service-oar",
-    ] + FEATURES,
-    outs = ["onos-seba.tar.gz"],
-    cmd = "$(location tools/package/onos_stage.py) $(location onos-seba.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
-    output_to_bindir = True,
-    tags = ["local"],
-    tools = ["tools/package/onos_stage.py"],
-)
-
 # Generates the onos-admin.tar.gz file with remote admin tools
 genrule(
     name = "onos-package-admin",