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 3/5] move squashfs imagetype class from CIP to ISAR
Date: Tue, 21 Jan 2025 11:12:50 +0100 [thread overview]
Message-ID: <20250121101252.324899-4-felix.moessbauer@siemens.com> (raw)
In-Reply-To: <20250121101252.324899-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/20250121101252.324899-4-felix.moessbauer%40siemens.com.
next prev parent reply other threads:[~2025-01-21 10:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-21 10:12 [PATCH 0/5] Add iso9660 image support for ISAR 'Felix Moessbauer' via isar-users
2025-01-21 10:12 ` [PATCH 1/5] Import isoimage-isohybrid from oe 'Felix Moessbauer' via isar-users
2025-01-21 10:12 ` [PATCH 2/5] wic: add ISAR version of isohybrid-efi plugin 'Felix Moessbauer' via isar-users
2025-01-21 10:12 ` 'Felix Moessbauer' via isar-users [this message]
2025-01-21 10:12 ` [PATCH 4/5] add qemuamd64 target for hybrid iso9660 image 'Felix Moessbauer' via isar-users
2025-01-22 12:22 ` Uladzimir Bely
2025-01-22 13:35 ` Uladzimir Bely
2025-01-21 10:12 ` [PATCH 5/5] add kas menu target for qemuamd64-iso machine 'Felix Moessbauer' via isar-users
2025-01-22 12:25 ` Uladzimir Bely
2025-01-21 10:24 ` [PATCH 0/5] Add iso9660 image support for ISAR 'Jan Kiszka' via isar-users
2025-01-21 11:42 ` 'MOESSBAUER, Felix' via isar-users
2025-01-21 13:17 ` 'Jan Kiszka' via isar-users
2025-01-22 14:11 ` Uladzimir Bely
2025-01-22 15:02 ` Uladzimir Bely
2025-01-23 7:53 ` 'MOESSBAUER, Felix' via isar-users
2025-01-23 8:49 ` 'MOESSBAUER, Felix' via isar-users
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=20250121101252.324899-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