diff mbox series

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

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

Commit Message

Jan Kiszka Nov. 5, 2024, 5:54 p.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"