From c72e3df8ded4e8e6d8330c008e999b4ff8dce758 Mon Sep 17 00:00:00 2001
From: Davide Gardenal <davide.gardenal@huawei.com>
Date: Tue, 14 Jun 2022 10:54:09 +0200
Subject: [PATCH] oniro-debug: create config files

Create bbclass files in meta-oniro-core
that enable the user to activate the debug mode
in local.conf.

Activating it is equivalent to build -dev images
as of this commit.

Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
---
 flavours/linux/local.conf.sample              | 35 +++++----------
 flavours/zephyr/local.conf.sample             | 29 +++---------
 .../classes/oniro-debug-common.bbclass        | 44 +++++++++++++++++++
 .../classes/oniro-debug-linux.bbclass         |  5 +++
 .../classes/oniro-debug-zephyr.bbclass        |  5 +++
 5 files changed, 72 insertions(+), 46 deletions(-)
 create mode 100644 meta-oniro-core/classes/oniro-debug-common.bbclass
 create mode 100644 meta-oniro-core/classes/oniro-debug-linux.bbclass
 create mode 100644 meta-oniro-core/classes/oniro-debug-zephyr.bbclass

diff --git a/flavours/linux/local.conf.sample b/flavours/linux/local.conf.sample
index 13636bc2..552d64a2 100644
--- a/flavours/linux/local.conf.sample
+++ b/flavours/linux/local.conf.sample
@@ -100,30 +100,17 @@ PACKAGE_CLASSES ?= "package_rpm"
 #SDKMACHINE ?= "i686"
 
 #
-# Extra image configuration defaults
-#
-# The EXTRA_IMAGE_FEATURES variable allows extra packages to be added to the generated
-# images. Some of these options are added to certain image types automatically. The
-# variable can contain the following options:
-#  "dbg-pkgs"       - add -dbg packages for all installed packages
-#                     (adds symbol information for debugging/profiling)
-#  "src-pkgs"       - add -src packages for all installed packages
-#                     (adds source code for debugging)
-#  "dev-pkgs"       - add -dev packages for all installed packages
-#                     (useful if you want to develop against libs in the image)
-#  "ptest-pkgs"     - add -ptest packages for all ptest-enabled packages
-#                     (useful if you want to run the package test suites)
-#  "tools-sdk"      - add development tools (gcc, make, pkgconfig etc.)
-#  "tools-debug"    - add debugging tools (gdb, strace)
-#  "eclipse-debug"  - add Eclipse remote debugging support
-#  "tools-profile"  - add profiling tools (oprofile, lttng, valgrind)
-#  "tools-testapps" - add useful testing tools (ts_print, aplay, arecord etc.)
-#  "debug-tweaks"   - make an image suitable for development
-#                     e.g. ssh root access has a blank password
-# There are other application targets that can be used here too, see
-# meta/classes/image.bbclass and meta/classes/core-image.bbclass for more details.
-# We default to enabling the debugging tweaks.
-EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
+# Debug mode
+#
+# Delete comment to enable the debug mode.
+# This enables a list of config to aid development.
+# Do not enable it in production systems.
+#
+#INHERIT += "oniro-debug-linux"
+
+# This class creates the "oniro" user to be used when debug mode is not enabled
+# More info in meta-oniro-core/classes/oniro-user.bbclass
+INHERIT += "oniro-user"
 
 #
 # Additional image features
diff --git a/flavours/zephyr/local.conf.sample b/flavours/zephyr/local.conf.sample
index c003bd9f..2c6d4ff5 100644
--- a/flavours/zephyr/local.conf.sample
+++ b/flavours/zephyr/local.conf.sample
@@ -104,28 +104,13 @@ PACKAGE_CLASSES ?= "package_rpm"
 #SDKMACHINE ?= "i686"
 
 #
-# Extra image configuration defaults
-#
-# The EXTRA_IMAGE_FEATURES variable allows extra packages to be added to the generated
-# images. Some of these options are added to certain image types automatically. The
-# variable can contain the following options:
-#  "dbg-pkgs"       - add -dbg packages for all installed packages
-#                     (adds symbol information for debugging/profiling)
-#  "src-pkgs"       - add -src packages for all installed packages
-#                     (adds source code for debugging)
-#  "dev-pkgs"       - add -dev packages for all installed packages
-#                     (useful if you want to develop against libs in the image)
-#  "ptest-pkgs"     - add -ptest packages for all ptest-enabled packages
-#                     (useful if you want to run the package test suites)
-#  "tools-sdk"      - add development tools (gcc, make, pkgconfig etc.)
-#  "tools-debug"    - add debugging tools (gdb, strace)
-#  "eclipse-debug"  - add Eclipse remote debugging support
-#  "tools-profile"  - add profiling tools (oprofile, lttng, valgrind)
-#  "tools-testapps" - add useful testing tools (ts_print, aplay, arecord etc.)
-#  "debug-tweaks"   - make an image suitable for development
-#                     e.g. ssh root access has a blank password
-# There are other application targets that can be used here too, see
-# meta/classes/image.bbclass and meta/classes/core-image.bbclass for more details.
+# Debug mode
+#
+# Delete comment to enable the debug mode.
+# This enables a list of config to aid development.
+# Do not enable it in production systems.
+#
+#INHERIT += "oniro-debug-zephyr"
 
 #
 # Additional image features
diff --git a/meta-oniro-core/classes/oniro-debug-common.bbclass b/meta-oniro-core/classes/oniro-debug-common.bbclass
new file mode 100644
index 00000000..e4a794f2
--- /dev/null
+++ b/meta-oniro-core/classes/oniro-debug-common.bbclass
@@ -0,0 +1,44 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+IMAGE_INSTALL:append = "\
+    packagegroup-net-tools \
+    "
+
+#
+# Extra image configuration defaults
+#
+# The EXTRA_IMAGE_FEATURES variable allows extra packages to be added to the generated
+# images. Some of these options are added to certain image types automatically. The
+# variable can contain the following options:
+#  "dbg-pkgs"       - add -dbg packages for all installed packages
+#                     (adds symbol information for debugging/profiling)
+#  "src-pkgs"       - add -src packages for all installed packages
+#                     (adds source code for debugging)
+#  "dev-pkgs"       - add -dev packages for all installed packages
+#                     (useful if you want to develop against libs in the image)
+#  "ptest-pkgs"     - add -ptest packages for all ptest-enabled packages
+#                     (useful if you want to run the package test suites)
+#  "tools-sdk"      - add development tools (gcc, make, pkgconfig etc.)
+#  "tools-debug"    - add debugging tools (gdb, strace)
+#  "eclipse-debug"  - add Eclipse remote debugging support
+#  "tools-profile"  - add profiling tools (oprofile, lttng, valgrind)
+#  "tools-testapps" - add useful testing tools (ts_print, aplay, arecord etc.)
+#  "debug-tweaks"   - make an image suitable for development
+#                     e.g. ssh root access has a blank password
+# There are other application targets that can be used here too, see
+# meta/classes/image.bbclass and meta/classes/core-image.bbclass for more details.
+# We default to enabling the debugging tweaks.
+EXTRA_IMAGE_FEATURES += "\
+    debug-tweaks \
+    dev-pkgs \
+    dbg-pkgs \
+    src-pkgs \
+    tools-sdk \
+    tools-debug \
+    tools-profile \
+    package-management \
+    "
+
+ROOT_PARTITION_SIZE = "2G"
diff --git a/meta-oniro-core/classes/oniro-debug-linux.bbclass b/meta-oniro-core/classes/oniro-debug-linux.bbclass
new file mode 100644
index 00000000..8d7ac807
--- /dev/null
+++ b/meta-oniro-core/classes/oniro-debug-linux.bbclass
@@ -0,0 +1,5 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+inherit oniro-debug-common
diff --git a/meta-oniro-core/classes/oniro-debug-zephyr.bbclass b/meta-oniro-core/classes/oniro-debug-zephyr.bbclass
new file mode 100644
index 00000000..8d7ac807
--- /dev/null
+++ b/meta-oniro-core/classes/oniro-debug-zephyr.bbclass
@@ -0,0 +1,5 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+inherit oniro-debug-common
-- 
GitLab