From 2fa2f89167ad2d0a6a5b66ea7fce242b2261249e Mon Sep 17 00:00:00 2001
From: Stefan Schmidt <stefan.schmidt@huawei.com>
Date: Tue, 15 Jun 2021 17:08:37 +0200
Subject: [PATCH] packagegroup-base: Add DISTRO_FEATURES and groups for Thread
 feature

Thread connectivity is a feature that can come as a full border router
or simple client flavour. They both drag in different dependencies
through the matching packagegroup. Demonstrate the use in our gateway
blueprint.

Fixes: https://git.ostc-eu.org/OSTC/planning/blueprints/-/issues/7

Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com>
---
 .../allscenarios-linux-blueprint-gateway.conf |  7 +++++++
 .../images/blueprint-gateway-image.bb         |  7 -------
 .../packagegroup-connectivity.bbappend        | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+), 7 deletions(-)
 create mode 100644 meta-ohos-blueprints/recipes-core/packagegroups/packagegroup-connectivity.bbappend

diff --git a/meta-ohos-blueprints/conf/distro/allscenarios-linux-blueprint-gateway.conf b/meta-ohos-blueprints/conf/distro/allscenarios-linux-blueprint-gateway.conf
index 9ac8e674..ac4dff75 100644
--- a/meta-ohos-blueprints/conf/distro/allscenarios-linux-blueprint-gateway.conf
+++ b/meta-ohos-blueprints/conf/distro/allscenarios-linux-blueprint-gateway.conf
@@ -12,6 +12,13 @@ DISTRO_NAME = "All Scenarios OS Gateway Blueprint Linux Distro"
 # Custom hostnames for easy DNS resolution for this blueprint.
 hostname_base-files = "blueprint-gateway"
 
+#DISTRO_FEATURES_append = " thread-client"
+DISTRO_FEATURES_append = " thread-border-router"
+
+IMAGE_INSTALL_append = "\
+    packagegroup-thread-br \
+    packagegroup-thread-client \
+    "
 # Avoid build warning(s) for ununsed extra partitions.
 ST_VENDORFS = "0"
 ST_USERFS = "0"
diff --git a/meta-ohos-blueprints/recipes-core/images/blueprint-gateway-image.bb b/meta-ohos-blueprints/recipes-core/images/blueprint-gateway-image.bb
index 08ba5664..2c31d8e6 100644
--- a/meta-ohos-blueprints/recipes-core/images/blueprint-gateway-image.bb
+++ b/meta-ohos-blueprints/recipes-core/images/blueprint-gateway-image.bb
@@ -7,10 +7,3 @@ require recipes-core/images/allscenarios-image-base.bb
 SUMMARY = "Gateway blueprint image"
 DESCRIPTION = "Smart home gateway device"
 LICENSE = "Apache-2.0"
-
-IMAGE_INSTALL_append = "\
-        ot-br-posix \
-        wpantund \
-        hostapd \
-        iptables \
-	"
diff --git a/meta-ohos-blueprints/recipes-core/packagegroups/packagegroup-connectivity.bbappend b/meta-ohos-blueprints/recipes-core/packagegroups/packagegroup-connectivity.bbappend
new file mode 100644
index 00000000..d011e3ee
--- /dev/null
+++ b/meta-ohos-blueprints/recipes-core/packagegroups/packagegroup-connectivity.bbappend
@@ -0,0 +1,19 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+PACKAGES_append = "\
+    packagegroup-thread-br \
+    packagegroup-thread-client \
+    "
+
+RDEPENDS_packagegroup-thread-br = "\
+    ${@bb.utils.contains("DISTRO_FEATURES", "thread-border-router", "ot-br-posix", "", d)} \
+    ${@bb.utils.contains("DISTRO_FEATURES", "thread-border-router", "wpantund", "", d)} \
+    hostapd \
+    iptables \
+    "
+
+RDEPENDS_packagegroup-thread-client = "\
+    ${@bb.utils.contains("DISTRO_FEATURES", "thread-client", "ot-daemon", "", d)} \
+    "
-- 
GitLab