From: Quirin Gylstorff <Quirin.Gylstorff@siemens.com>
To: felix.moessbauer@siemens.com, isar-users@googlegroups.com
Subject: [PATCH v3 1/2] add new class to add files directly to the rootfs
Date: Mon, 25 Mar 2024 16:34:58 +0100 [thread overview]
Message-ID: <20240325153522.2104345-2-Quirin.Gylstorff@siemens.com> (raw)
In-Reply-To: <20240325153522.2104345-1-Quirin.Gylstorff@siemens.com>
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
This allows to add files like the installer target directly
to rootfs without compressing the target file. It also reduces
the sstate size.
Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
meta/classes/rootfs-add-files.bbclass | 45 +++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 meta/classes/rootfs-add-files.bbclass
diff --git a/meta/classes/rootfs-add-files.bbclass b/meta/classes/rootfs-add-files.bbclass
new file mode 100644
index 00000000..4125caf5
--- /dev/null
+++ b/meta/classes/rootfs-add-files.bbclass
@@ -0,0 +1,45 @@
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2024
+# This class allows to add a file directly to
+# the rootfs.
+# An example usecase would be an installer which
+# contains an complete rootfs added with multiconfig.
+ROOTFS_INSTALL_COMMAND =+ "rootfs_add_files"
+ROOTFS_ADDITIONAL_FILES ??= ""
+
+# ROOTFS_ADDITIONAL_FILES ??= "installer-target"
+#
+# ROOTFS_ADDITIONAL_FILE_installer-target[source] = \
+# "${DEPLOY_DIR_IMAGE}/${IMG_DATA_FILE}.${IMAGE_DATA_POSTFIX}"
+# ROOTFS_ADDITIONAL_FILE_installer-target[destination] = \
+# "/install/${IMG_DATA_FILE}.${IMAGE_DATA_POSTFIX}"
+
+
+python rootfs_add_files() {
+ import os
+ if d.getVar("SOURCE_DATE_EPOCH") != None:
+ os.environ["SOURCE_DATE_EPOCH"] = d.getVar("SOURCE_DATE_EPOCH")
+
+ postprocess_additional_files = d.getVar('ROOTFS_ADDITIONAL_FILES').split()
+ rootfsdir = d.getVar("ROOTFSDIR")
+
+ for entry in postprocess_additional_files:
+ additional_file_entry = f"ROOTFS_ADDITIONAL_FILE_{entry}"
+ destination = d.getVarFlag(additional_file_entry, "destination") or ""
+ source = d.getVarFlag(additional_file_entry, "source") or ""
+ if os.path.exists(f"{rootfsdir}/{destination}"):
+ bb.process.run([ "/usr/bin/rm", "-f", f"{destination}"])
+
+ dest_dir = os.path.dirname(destination)
+ bb.process.run(["sudo", "-E", "/usr/bin/mkdir", "-p", f"{rootfsdir}/{dest_dir}" ])
+ # empty source creates only an empty destination file
+ if not source:
+ bb.process.run(["sudo", "-E", "/usr/bin/touch", f"{rootfsdir}/{destination}" ])
+ return
+
+ if not os.path.exists(f"{source}"):
+ bb.error(f"{source} does not exists and cannot be copied to the rootfs!")
+ # no recursive copy only single files
+ bb.process.run(["sudo", "-E", "/usr/bin/cp", "-a", f"{source}", f"{rootfsdir}/{destination}" ])
+}
+ROOTFS_INSTALL_COMMAND += "rootfs_add_files"
--
2.43.0
next prev parent reply other threads:[~2024-03-25 15:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-25 15:34 [PATCH v3 0/2] Isar installer copy installer-target direct to rootfs Quirin Gylstorff
2024-03-25 15:34 ` Quirin Gylstorff [this message]
2024-03-25 15:34 ` [PATCH v3 2/2] isar-installer: use rootfs-add-files class instead of seperate package Quirin Gylstorff
2024-04-09 5:22 ` [PATCH v3 0/2] Isar installer copy installer-target direct to rootfs 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=20240325153522.2104345-2-Quirin.Gylstorff@siemens.com \
--to=quirin.gylstorff@siemens.com \
--cc=felix.moessbauer@siemens.com \
--cc=isar-users@googlegroups.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