From patchwork Fri Mar 22 13:25:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quirin Gylstorff X-Patchwork-Id: 3424 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Fri, 22 Mar 2024 14:27:12 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-yw1-f185.google.com (mail-yw1-f185.google.com [209.85.128.185]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 42MDRBj7030211 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Mar 2024 14:27:11 +0100 Received: by mail-yw1-f185.google.com with SMTP id 00721157ae682-607838c0800sf33456847b3.1 for ; Fri, 22 Mar 2024 06:27:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711114025; cv=pass; d=google.com; s=arc-20160816; b=qLXqQchVf2hDEg0MTgsyGYmdbVxWOB24liTAinbsPZPkzbK6zznwR4RxVUji3q7Y11 1/BRvObSCAc7aq3g1sMZvs4rEesicgMeDWg/eBARnZeiE+rpQ/Bysr7enkJdpdWffd5Y eFGKm6KElcytXBG3PeI32knbeFbVAd2pbEgWLxT3p9xUqXmFT7GA5ud2eyPKJ9sXzwlz LH3tPlZr0LjO8D7jajd/BLjxi6/cnKnG0Yj/uer6lmhsQBAcKGLcLT2cmkkG9v+SHBLG Gc4V+35iJUycfqRvvQb6MdEcgoWbv1GqgPYO2Y/leXrXiEnO2gD9BC0gH1v2h2QO3g8r 1vzw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:feedback-id:mime-version :message-id:date:subject:to:from:dkim-signature; bh=xgZSbWJpDCYiYNEll8Scy+bfTjW886lE+8T4cNR2eNE=; fh=ekgXM4h1rl0XgfLfBrEOm25iY7dbMnTcvRTntsmqP/0=; b=eLzQO0KO5gmpNGkgL8Pq4my3/6y9DaA98LKsItxA33v+0U0+H8+jbU8fvX76nS0EfK izJMsqQ5A/ot57bBF1itgwuvDvk/QZEfeJPc4aHqn0qFY8yNZi9ckLgV12vN5xQYxz53 gsRX15Cwhy/gtI2NVl0jiaTkAfotzY1U0NF1OSlPnmpLYt2c7EqLKrCB1GuJCoVC31t1 2JMydBObGDRmH+5g/DXV591iDIc6XE8uIb2xS6lNYplrlkTAZ3/mQ6tmS1bEAlEhqZno QK2z5y+1E+2m97F7jkKGP4Wey/HYmtIuBjTk+7KnNT0x4WfxkNr1I/tgTA8xV78r37bd 5zdg==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=AK8RtZav; spf=pass (google.com: domain of fm-51332-202403221327012944e38fd11c3ddf4b-b4lno0@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-51332-202403221327012944e38fd11c3ddf4b-B4lNO0@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1711114025; x=1711718825; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=xgZSbWJpDCYiYNEll8Scy+bfTjW886lE+8T4cNR2eNE=; b=LnX/c+tXl0Wghbt41IVmx8/adbUPRhTHz3ThZeZ9amIxCyfic4SkJ6er8+Hvsc9lsQ BKrUk3q4N+0j7I8UzgHuEaG6SsmWDDwOAx9zVzIXEH33vWxo5D00u3aKp58flCaY4vgX tH5ZPSytnaEou9t341xIAn+Kf/YQlEJ1oNWpFtN68l4nlUhzsV4979YOV9Jh2V8P/4Ed FlY80DtSJxfskQMVEF7vv/xqdx0uOCxemr883jShfiXy0ihnMeKLvkUbDJ4YMXPWysTZ E4Lt7678EazvXS8Omy+kitJ5y0LXhLuA15ZdBmFFPX88azrdMmy7tauKxD36PNQd9iK+ CAow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711114025; x=1711718825; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:message-id:date:subject:to:from:x-beenthere :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xgZSbWJpDCYiYNEll8Scy+bfTjW886lE+8T4cNR2eNE=; b=fDZBBgiDFw9p88V7VW0UGhoORFP09wH1ax6kf1jMkBAEqiY4OPPGMLieG176BG03G3 EDJOjYtJsrV45ILZfWybCFwojWAzcb+ISWcwtUsMXaPV9IUZUFWaGaT0CV0zA5EK+OWN jiWZJKln22d3V5nUdUUYr0cNZYFeDUkG+jxZzPAimbKG3KJKgj9Rh/DV53r9XbGesRfZ HETwzG3vnukFv7IlwS1y9uQhX0qq2Rky3blQ9fH6n+VUOGE4BO/uIrPSBteMEREUnu2q vxMQ422H+Jd6DZh9l4DdNMPELrnvGfl6D95ujBF/6tC2OxT9YICQwdtUvAbxQckUkdyc OFhw== X-Forwarded-Encrypted: i=2; AJvYcCVUaLppEhhh+bBS0HgMcFq/sRTOr3ltPbJYy+d4dRCI1kryneF1kUFSyqeyM96VILLjWkkZTwoEzOCWhLeox+05TrX9ETs= X-Gm-Message-State: AOJu0YznPoVjhCkqBskHUwOYRMpWFd8S9kPF/bnBcJ78D+8QOxuhb16A QIvE5gYcfODn3mUAwLOSa20EqqGDWCJy6u7i3aIByJmOtQSEHFR+ X-Google-Smtp-Source: AGHT+IHOC+tdaBW80uOlcOtER96QUy+ibILIdyKp68ZLjVokZPY/FBs1wx7tIr6lMYJBLQ1Y2UyG3w== X-Received: by 2002:a25:3fc2:0:b0:dd9:3ac0:5414 with SMTP id m185-20020a253fc2000000b00dd93ac05414mr1184242yba.7.1711114025281; Fri, 22 Mar 2024 06:27:05 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a25:df12:0:b0:dcc:4b24:c0de with SMTP id w18-20020a25df12000000b00dcc4b24c0dels54731ybg.0.-pod-prod-00-us; Fri, 22 Mar 2024 06:27:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWanuK6Bd25AjpPpXBiAbeORTJSlLsfAyKu3ggk8fdk5Ij2zGvlsuStTKXowbX5TFNGg+bM+29CSrKkVEj2rYZhhjJQ8GOzLfGz1VA= X-Received: by 2002:a25:4b83:0:b0:dc6:d513:cd3 with SMTP id y125-20020a254b83000000b00dc6d5130cd3mr1150889yba.31.1711114022835; Fri, 22 Mar 2024 06:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711114022; cv=none; d=google.com; s=arc-20160816; b=I5YTMBAe+uszsPpQfob/i3oswkjQgfAPlNH8vd0QftZPNgGfC+qWg4rSYEWoz7UKtS htYoN/kg+qJzuWtsrFMF87hxzZ5MlAUJ8Cdv/HGCbT9VgJxvYyhtxu0BSOMb0QTEfVXU LGfI6C1PJKMZ3+Z/n3f2Z6uymHsfk3vbJEgoJkTFomukFN4qhGJaYiKaoFC+8Ry0AluA Hm749YYWahuT2+cBSdFo+06UWdUEZ64G1/gRTVabiOyuHeLFc+kaxNDQpNLMWZyFI0LT J6sYNusRmvGNNZYuF2zFjcmUQdMngr80kiYJqVk9csFwzAYxcksn2CAvkt3gh0npiqyf Vzpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:message-id:date :subject:to:from:dkim-signature; bh=nxu9x1DOsKaKmx3SOR6tSlyd/x7n2+nqVkjrFbRJwEw=; fh=rpHsxb7lPfJJgFX8BDY3/IlKBNbRtI9Z0SHxGoqscuk=; b=N7L4M+HhVT5HmEnYRS4/ZQP/2wYZsnvn5n+2iDozfhVAFZWl7VpdwVvXc87He8y7QL RslS2+bID6Gd/E1Ox4OfIwMcNq0DKaAs568MMa+aDDspdRaOrmVACD0kSgiYNoR2Vlxe rlRRcNAcasn04ZUsB4FIFNNcHZ1BmNLW6cIcMhFoR3zpw2a0JOEZO6JnS3IgrWKrxx/O MqU93SAWVt6sjMHO5hQFevRXk2VKnrip8TR56gJtDpYJmIlh851Ns49AbOqcxcCSabET LEE+g7dTOr9XY11WHAi+vUduQAk3ON2iGrlHMDekPJD0j+Em8ba5ZN106EtDBda0a1fE jDbw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=AK8RtZav; spf=pass (google.com: domain of fm-51332-202403221327012944e38fd11c3ddf4b-b4lno0@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-51332-202403221327012944e38fd11c3ddf4b-B4lNO0@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-64-226.siemens.flowmailer.net (mta-64-226.siemens.flowmailer.net. [185.136.64.226]) by gmr-mx.google.com with ESMTPS id g193-20020a25dbca000000b00dcd162eec7esi113251ybf.2.2024.03.22.06.27.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2024 06:27:02 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-51332-202403221327012944e38fd11c3ddf4b-b4lno0@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) client-ip=185.136.64.226; Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 202403221327012944e38fd11c3ddf4b for ; Fri, 22 Mar 2024 14:27:01 +0100 X-Patchwork-Original-From: "'Quirin Gylstorff' via isar-users" From: Quirin Gylstorff To: felix.moessbauer@siemens.com, isar-users@googlegroups.com Subject: [PATCH] isar-installer: copy installer-target direct to rootfs Date: Fri, 22 Mar 2024 14:25:00 +0100 Message-ID: <20240322132700.218096-1-Quirin.Gylstorff@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-51332:519-21489:flowmailer X-Original-Sender: quirin.gylstorff@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=AK8RtZav; spf=pass (google.com: domain of fm-51332-202403221327012944e38fd11c3ddf4b-b4lno0@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-51332-202403221327012944e38fd11c3ddf4b-B4lNO0@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Quirin Gylstorff Reply-To: Quirin Gylstorff Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: Quirin Gylstorff It reduce the build time of the installer build as we don't apply gzip on an already zipped target. It also reduce the size of the sstate cache. Signed-off-by: Quirin Gylstorff --- .../classes/installer-add-rootfs.bbclass | 43 ++++++++++++++++++ .../images/isar-image-installer.bb | 2 +- .../store-target-image_0.1.bb | 25 ----------- meta/classes/rootfs-add-files.bbclass | 44 +++++++++++++++++++ 4 files changed, 88 insertions(+), 26 deletions(-) create mode 100644 meta-isar/classes/installer-add-rootfs.bbclass delete mode 100644 meta-isar/recipes-installer/store-target-image/store-target-image_0.1.bb create mode 100644 meta/classes/rootfs-add-files.bbclass diff --git a/meta-isar/classes/installer-add-rootfs.bbclass b/meta-isar/classes/installer-add-rootfs.bbclass new file mode 100644 index 00000000..4f6a2f92 --- /dev/null +++ b/meta-isar/classes/installer-add-rootfs.bbclass @@ -0,0 +1,43 @@ +# Copy the target image to the installer image +# +# This software is a part of ISAR. +# Copyright (C) Siemens AG, 2024 +# +# SPDX-License-Identifier: MIT + +inherit rootfs-add-files + +INSTALLER_MC ??= "isar-installer" +INSTALLER_TARGET_IMAGE ??= "isar-image-base" +INSTALLER_TARGET_MC ??= "installer-target" +INSTALLER_TARGET_DISTRO ??= "${DISTRO}" +INSTALLER_TARGET_MACHINE ??= "${MACHINE}" + +IMG_DATA_FILE ??= "${INSTALLER_TARGET_IMAGE}-${INSTALLER_TARGET_DISTRO}-${INSTALLER_TARGET_MACHINE}" +IMAGE_DATA_POSTFIX ??= "wic.zst" +IMAGE_DATA_POSTFIX:buster ??= "wic.xz" +IMAGE_DATA_POSTFIX:bullseye ??= "wic.xz" + +ROOTFS_POSTPROCESS_ADDITIONAL_FILES ??= "installer-target" + +def get_installer_source(d): + installer_target_image = d.getVar('INSTALLER_TARGET_IMAGE') or "" + if not installer_target_image: + return "" + deploy_dir = d.getVar('DEPLOY_DIR_IMAGE') + image_data = d.getVAR('IMAGE_DATA_FILE') + image_data_postfix = d.getVAR('IMAGE_DATA_POSTFIX') + return f"{deploy_dir}/{image_data}.{image_data_postfix}" + +def get_installer_destination(d): + installer_target_image = d.getVar('INSTALLER_TARGET_IMAGE') or "" + if not installer_target_image: + return "/install/keep" + image_data = d.getVAR('IMAGE_DATA_FILE') + image_data_postfix = d.getVAR('IMAGE_DATA_POSTFIX') + return f"/install/{image_data}.{image_data_postfix}" + +ROOTFS_POSTPROCESS_ADDITIONAL_FILE_installer-target[source] = "${@ get_installer_source(d)}" +ROOTFS_POSTPROCESS_ADDITIONAL_FILE_installer-target[destination] = "${@ get_installer_destination(d)}" + +rootfs_add_files[mcdepends] = "mc:${INSTALLER_MC}:${INSTALLER_TARGET_MC}:${INSTALLER_TARGET_IMAGE}:do_image_wic" diff --git a/meta-isar/recipes-core/images/isar-image-installer.bb b/meta-isar/recipes-core/images/isar-image-installer.bb index 27de03d5..34fb5daf 100644 --- a/meta-isar/recipes-core/images/isar-image-installer.bb +++ b/meta-isar/recipes-core/images/isar-image-installer.bb @@ -4,6 +4,7 @@ # SPDX-License-Identifier: MIT inherit image +inherit installer-add-rootfs DESCRIPTION = "Example of a ISAR based Installer Image" # Use variable to switch easily to another wks @@ -11,7 +12,6 @@ INSTALLER_WKS_FILE ??= "installer-efi.wks.in" WKS_FILE = "${INSTALLER_WKS_FILE}" IMAGER_INSTALL:wic:append = " systemd-boot" -IMAGE_INSTALL += "store-target-image" IMAGE_INSTALL += "deploy-image" IMAGE_INSTALL:remove = "expand-on-first-boot" diff --git a/meta-isar/recipes-installer/store-target-image/store-target-image_0.1.bb b/meta-isar/recipes-installer/store-target-image/store-target-image_0.1.bb deleted file mode 100644 index 2f72412b..00000000 --- a/meta-isar/recipes-installer/store-target-image/store-target-image_0.1.bb +++ /dev/null @@ -1,25 +0,0 @@ -# This software is a part of ISAR. -# Copyright (C) Siemens AG, 2024 -# -# SPDX-License-Identifier: MIT - -DESCRIPTION = "Add a given target image to rootfs" - -inherit dpkg-raw - -INSTALLER_TARGET_IMAGE ??= "isar-image-base" -IMG_DATA_FILE ??= "${INSTALLER_TARGET_IMAGE}-${DISTRO}-${MACHINE}" -IMG_DATA_POSTFIX ??= "wic.zst" -IMG_DATA_POSTFIX:buster ??= "wic.xz" -IMG_DATA_POSTFIX:bullseye ??= "wic.xz" -do_install[mcdepends] = "${@ 'mc:isar-installer:installer-target:' + d.getVar('INSTALLER_TARGET_IMAGE') + ':do_image_wic' if d.getVar('INSTALLER_TARGET_IMAGE') else ''}" -do_install[cleandirs] = "${D}/install/" -do_install() { - if [ -f ${DEPLOY_DIR_IMAGE}/${IMG_DATA_FILE}.${IMG_DATA_POSTFIX} ]; then - install -m 0600 ${DEPLOY_DIR_IMAGE}/${IMG_DATA_FILE}.${IMG_DATA_POSTFIX} ${D}/install/ - install -m 0600 ${DEPLOY_DIR_IMAGE}/${IMG_DATA_FILE}.wic.bmap ${D}/install/ - else - # mcopy cannot handle .keep or empty directory , therefore use visible file - touch ${D}/install/keep - fi -} diff --git a/meta/classes/rootfs-add-files.bbclass b/meta/classes/rootfs-add-files.bbclass new file mode 100644 index 00000000..e547c45a --- /dev/null +++ b/meta/classes/rootfs-add-files.bbclass @@ -0,0 +1,44 @@ +# 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_POSTPROCESS_ADDITIONAL_FILES ??= "installer-target" +# +# ROOTFS_POSTPROCESS_ADDITIONAL_FILE_installer-target[source] = \ +# "${DEPLOY_DIR_IMAGE}/${IMG_DATA_FILE}.${IMAGE_DATA_POSTFIX}" +# ROOTFS_POSTPROCESS_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}" ]) +}