public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "'Felix Moessbauer' via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: clara.kowalsky@siemens.com, florian.bezdeka@siemens.com,
	jan.kiszka@siemens.com,
	Felix Moessbauer <felix.moessbauer@siemens.com>
Subject: [PATCH v3 3/7] move squashfs imagetype class from CIP to ISAR
Date: Fri, 24 Jan 2025 13:35:41 +0100	[thread overview]
Message-ID: <20250124123545.3500274-4-felix.moessbauer@siemens.com> (raw)
In-Reply-To: <20250124123545.3500274-1-felix.moessbauer@siemens.com>

As a preparation for live images, we move the squashfs class from
isar-cip-core to ISAR and register it as always included.

ISAR-cip-core revision: 0e85378341fb7b37cf95b1c910ca0260cf4f5cf4

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta-isar/classes/squashfs.bbclass | 47 ++++++++++++++++++++++++++++++
 meta/classes/image.bbclass         |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 meta-isar/classes/squashfs.bbclass

diff --git a/meta-isar/classes/squashfs.bbclass b/meta-isar/classes/squashfs.bbclass
new file mode 100644
index 00000000..9cd7ed3d
--- /dev/null
+++ b/meta-isar/classes/squashfs.bbclass
@@ -0,0 +1,47 @@
+# squashfs image rootfs
+#
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2021-2025
+#
+# SPDX-License-Identifier: MIT
+
+def get_free_mem():
+    try:
+        with open('/proc/meminfo') as meminfo:
+            lines = meminfo.readlines()
+            for line in lines:
+                if line.startswith('MemAvailable:'):
+                    return int(line.split()[1]) * 1024
+    except FileNotFoundError:
+        pass
+    return 4*1024*1024*1024  # 4G
+
+IMAGER_INSTALL:squashfs += "squashfs-tools"
+
+SQUASHFS_EXCLUDE_DIRS ?= ""
+SQUASHFS_CONTENT ?= "${PP_ROOTFS}"
+SQUASHFS_CREATION_ARGS ?= ""
+
+SQUASHFS_THREADS ?= "${@oe.utils.cpu_count(at_least=2)}"
+SQUASHFS_MEMLIMIT ?= "${@int(get_free_mem() * 3/4)}"
+SQUASHFS_CREATION_LIMITS = "-mem ${SQUASHFS_MEMLIMIT} -processors ${SQUASHFS_THREADS}"
+
+python __anonymous() {
+    exclude_directories = d.getVar('SQUASHFS_EXCLUDE_DIRS').split()
+    if len(exclude_directories) == 0:
+        return
+    # Use wildcard to exclude only content of the directory.
+    # This allows to use the directory as a mount point.
+    args = " -wildcards"
+    for dir in exclude_directories:
+        args += " -e '{dir}/*' ".format(dir=dir)
+    d.appendVar('SQUASHFS_CREATION_ARGS', args)
+}
+
+IMAGE_CMD:squashfs[depends] = "${PN}:do_transform_template"
+IMAGE_CMD:squashfs[vardepsexclude] += "SQUASHFS_CREATION_LIMITS"
+IMAGE_CMD:squashfs() {
+    ${SUDO_CHROOT} /bin/mksquashfs \
+        '${SQUASHFS_CONTENT}' '${IMAGE_FILE_CHROOT}' \
+        -noappend ${SQUASHFS_CREATION_LIMITS} ${SQUASHFS_CREATION_ARGS}
+}
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index db21cc76..49861b75 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -129,7 +129,7 @@ IMAGE_BASETYPES = "${@get_image_basetypes(d)}"
 
 # image types
 IMAGE_CLASSES ??= ""
-IMGCLASSES = "imagetypes imagetypes_wic imagetypes_vm imagetypes_container"
+IMGCLASSES = "imagetypes imagetypes_wic imagetypes_vm imagetypes_container squashfs"
 IMGCLASSES += "${IMAGE_CLASSES}"
 inherit ${IMGCLASSES}
 
-- 
2.39.5

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20250124123545.3500274-4-felix.moessbauer%40siemens.com.

  parent reply	other threads:[~2025-01-24 12:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-24 12:35 [PATCH v3 0/7] Add iso9660 image support for ISAR 'Felix Moessbauer' via isar-users
2025-01-24 12:35 ` [PATCH v3 1/7] Import isoimage-isohybrid from oe 'Felix Moessbauer' via isar-users
2025-01-24 12:35 ` [PATCH v3 2/7] wic: add ISAR version of isohybrid-efi plugin 'Felix Moessbauer' via isar-users
2025-01-24 12:35 ` 'Felix Moessbauer' via isar-users [this message]
2025-01-24 12:35 ` [PATCH v3 4/7] add qemuamd64-iso target for hybrid iso9660 image 'Felix Moessbauer' via isar-users
2025-01-24 12:35 ` [PATCH v3 5/7] add kas menu target for qemuamd64-iso machine 'Felix Moessbauer' via isar-users
2025-01-24 12:35 ` [PATCH v3 6/7] testsuite: add qemuamd64-iso machine to start_vm script 'Felix Moessbauer' via isar-users
2025-01-24 12:35 ` [PATCH v3 7/7] testsuite: test mc:qemuamd64-iso-bookworm:isar-image-base 'Felix Moessbauer' via isar-users
2025-02-06  7:33 ` [PATCH v3 0/7] Add iso9660 image support for ISAR Uladzimir Bely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250124123545.3500274-4-felix.moessbauer@siemens.com \
    --to=isar-users@googlegroups.com \
    --cc=clara.kowalsky@siemens.com \
    --cc=felix.moessbauer@siemens.com \
    --cc=florian.bezdeka@siemens.com \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox