public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "MOESSBAUER, Felix" <felix.moessbauer@siemens.com>
To: "quirin.gylstorff@siemens.com" <quirin.gylstorff@siemens.com>,
	"isar-users@googlegroups.com" <isar-users@googlegroups.com>
Subject: Re: [PATCH v2 1/2] add new class to add files directly to the rootfs
Date: Mon, 25 Mar 2024 14:45:11 +0000	[thread overview]
Message-ID: <a0e05fac4bd7f6fde500d644cb5765c6ee6aa9e6.camel@siemens.com> (raw)
In-Reply-To: <20240322141050.256793-2-Quirin.Gylstorff@siemens.com>

On Fri, 2024-03-22 at 15:10 +0100, Quirin Gylstorff wrote:
> 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..dfee440f
> --- /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}"])
> +
> +        # empty source creates only an empty destination file
> +        if not source:
> +            dest_dir = os.path.dirname(destination)
> +            bb.process.run(["sudo", "-E", "/usr/bin/install", "-d",
> "-m", "600", f"{rootfsdir}/{dest_dir}" ])
> +            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/install", "-D", "-
> m", "600", f"{source}", f"{rootfsdir}/{destination}" ])

Hi Quirin,

we also need to copy the .bmap file (if available):

bmaptool: info: no bmap given, copy entire image to '/dev/sda'

Felix

> +}
> +ROOTFS_INSTALL_COMMAND += "rootfs_add_files"

-- 
Siemens AG, Technology
Linux Expert Center



  reply	other threads:[~2024-03-25 14:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 14:10 [PATCH v2 0/2] Isar installer copy installer-target direct to rootfs Quirin Gylstorff
2024-03-22 14:10 ` [PATCH v2 1/2] add new class to add files directly to the rootfs Quirin Gylstorff
2024-03-25 14:45   ` MOESSBAUER, Felix [this message]
2024-03-22 14:10 ` [PATCH v2 2/2] isar-installer: use rootfs-add-files class instead of seperate package Quirin Gylstorff

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=a0e05fac4bd7f6fde500d644cb5765c6ee6aa9e6.camel@siemens.com \
    --to=felix.moessbauer@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=quirin.gylstorff@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