diff mbox series

[isar-cip-core,4/6] Introduce class for generating EROFS images

Message ID 9e610c58e64d927b450fc246f5a271268c5c4d03.1730289107.git.jan.kiszka@siemens.com (mailing list archive)
State New
Headers show
Series Add support for EROFS | expand

Commit Message

Jan Kiszka Oct. 30, 2024, 11:51 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

This is analogous to the squashfs class.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 classes/erofs.bbclass | 34 ++++++++++++++++++++++++++++++++++
 conf/layer.conf       |  2 +-
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 classes/erofs.bbclass
diff mbox series

Patch

diff --git a/classes/erofs.bbclass b/classes/erofs.bbclass
new file mode 100644
index 00000000..95e7be35
--- /dev/null
+++ b/classes/erofs.bbclass
@@ -0,0 +1,34 @@ 
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Siemens AG, 2024
+#
+# Authors:
+#  Jan Kiszka <jan.kiszka@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+IMAGER_INSTALL:erofs += "erofs-utils"
+
+EROFS_EXCLUDE_DIRS ?= ""
+EROFS_CONTENT ?= "${PP_ROOTFS}"
+EROFS_CREATION_ARGS ?= "-z lz4hc,12"
+
+python __anonymous() {
+    exclude_directories = d.getVar('EROFS_EXCLUDE_DIRS').split()
+    if len(exclude_directories) == 0:
+        return
+    # Use regex to exclude only content of the directory.
+    # This allows to use the directory as a mount point.
+    for dir in exclude_directories:
+        args += " --exclude-regex {dir}/.* ".format(dir=dir)
+    d.appendVar('EROFS_CREATION_ARGS', args)
+}
+
+IMAGE_CMD:erofs[depends] = "${PN}:do_transform_template"
+IMAGE_CMD:erofs() {
+    ${SUDO_CHROOT} /bin/mkfs.erofs \
+        '${IMAGE_FILE_CHROOT}' '${EROFS_CONTENT}' \
+        ${EROFS_CREATION_ARGS}
+}
diff --git a/conf/layer.conf b/conf/layer.conf
index c652a61c..316f4a81 100644
--- a/conf/layer.conf
+++ b/conf/layer.conf
@@ -23,5 +23,5 @@  LAYERSERIES_COMPAT_cip-core = "next"
 LAYERDIR_cip-core = "${LAYERDIR}"
 LAYERDIR_cip-core[vardepvalue] = "isar-cip-core"
 
-IMAGE_CLASSES += "squashfs verity swupdate delta-update"
+IMAGE_CLASSES += "squashfs erofs verity swupdate delta-update"