From b997c8a4f9956af62d2d513cb9772681db4724f8 Mon Sep 17 00:00:00 2001
From: Andrei Gherzan <andrei.gherzan@huawei.com>
Date: Wed, 7 Apr 2021 14:24:26 +0100
Subject: [PATCH] ohos-sanity.bbclass: Add support for deprecated DISTRO
 configurations

The mechanism and value format of OHOS_DEPRECATED_DISTROS is identical
to OHOS_DEPRECATED_COLLECTIONS.

Deprecated distro configurations can be either completely removed or
replaced by another configuration. The format of OHOS_DEPRECATED_DISTROS
is a list of <DEPRECATED_DISTRO>:<REPLACEMENT_DISTRO>. When
<REPLACEMENT_DISTRO> is not provided, the distro was removed without a
replacement.

Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
---
 meta-ohos-core/classes/ohos-sanity.bbclass | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/meta-ohos-core/classes/ohos-sanity.bbclass b/meta-ohos-core/classes/ohos-sanity.bbclass
index 0cd20a73..8d22531a 100644
--- a/meta-ohos-core/classes/ohos-sanity.bbclass
+++ b/meta-ohos-core/classes/ohos-sanity.bbclass
@@ -11,6 +11,10 @@ OHOS_DEPRECATED_COLLECTIONS = " \
     meta-ohos-demo:meta-ohos-blueprints \
     "
 
+# Same format as for OHOS_DEPRECATED_COLLECTIONS but for DISTRO configurations.
+OHOS_DEPRECATED_DISTROS = " \
+    "
+
 def unpack_deprecation(elem) -> 'Tuple[str, str]':
     elem_split = elem.split(sep=':', maxsplit=1)
     return (elem_split[0], elem_split[1] if len(elem_split) == 2 else '')
@@ -42,7 +46,21 @@ def ohos_is_valid_config() -> bool:
                 msg = "{0} is a deprecated layer. Adapt your bblayers.conf " \
                       "accordingly.".format(deprecated)
             bb.warn(msg)
-    
+
+    #
+    # DISTRO deprecation
+    #
+    for deprecation in d.getVar('OHOS_DEPRECATED_DISTROS').split():
+        (deprecated, new) = unpack_deprecation(deprecation)
+        if deprecated == d.getVar('DISTRO'):
+            if new:
+                msg = "{0} is a deprecated distro configuration. Use the {1} " \
+                      "replacement.".format(deprecated, new)
+            else:
+                msg = "{0} is a deprecated distro configuration." \
+                       .format(deprecated)
+            bb.warn(msg)
+
     return success
 
 python ohos_sanity_handler() {
-- 
GitLab