From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Mon, 18 Nov 2024 08:54:54 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-qv1-f60.google.com (mail-qv1-f60.google.com [209.85.219.60]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 4AI7souF025637 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Nov 2024 08:54:51 +0100 Received: by mail-qv1-f60.google.com with SMTP id 6a1803df08f44-6d419e1e6e2sf32116976d6.1 for ; Sun, 17 Nov 2024 23:54:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1731916485; x=1732521285; darn=ilbers.de; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-sender:mime-version :subject:references:in-reply-to:message-id:to:from:date:sender:from :to:cc:subject:date:message-id:reply-to; bh=6IE8sYT+wN+NrpvEjutRSXiw6MTqfJa1KowLMvOu3jo=; b=eOId1u6wMIC+wiQQzor1DYtZx+oxhUlw83UJydVHX9shLz2pUaXlydU3It6xsIKg2T 9N46+ijEOcnKPr7LMZAPp+olWn7o9OlW9wv7wZ0qqJLraFYY+ZcvA2mMQGY9DQ06+Dbx nAeEVMVTMD1HujOuCKZwEKatvcxcYso53iy8gS9qFbmhCTYkcmsSvWs3ao7g3LPaYNgE Jg+glfA7nnfa8W2+ysfegrrLp2nWudU35TKSnFxeoHN5te4v3cugV3g+iTHqB2L/QBhI FQGf9BQOIBbFPaI8M54B8T27vc2tWnGjxj4EtWtyWWbiVN/tjbTBfLV3aa8MNRwbzPT1 gO0w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731916485; x=1732521285; darn=ilbers.de; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-sender:mime-version :subject:references:in-reply-to:message-id:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=6IE8sYT+wN+NrpvEjutRSXiw6MTqfJa1KowLMvOu3jo=; b=dv5OFZPpPt+67Bs7A2a23mW/m8hoVfCuH6xdlaKuc38JD5QuaSabe57KwhyMK1LWCW VAIZ7r8J7UKYunltcXtgxsUbuMzZik+pVCSzes/u+qbigjfhi5y3Fk9e2IfD/fMXowFk WLcH7FS/gN38CA1gxdkL1p9TOazFJ5yrxD4xfXaiiMj33746X8Bbcmst8e55piWGdFSH Oo9f3XjxrBQmbMO3zUKBEWn0S7RJIXVf3Br5+MMhdzF+p9KNjQrs4DtqHC4C/8Seg9dx BUmA5MrMPrq+jkzP+9rU3xcXifwj8aRVR2ZArkKJDoJ/KEqSLduInkDWnpTpPnjDlDQ0 wdpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731916485; x=1732521285; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=6IE8sYT+wN+NrpvEjutRSXiw6MTqfJa1KowLMvOu3jo=; b=RJ3kTIOUW619lWi7QoseQO0atBnn+OOMWTkPqkyLqx5eCo9Gbt/Wf4iUi3GeA88MVS 5wHEMtD6cAtnMjRqfxmPVeKlRK8i06BdMPg5571u9e/2JVD9KsfT8iP7sdv7KVfeqfiG QaWyAv0ScA+E8WnSYd16bcijRwoFz2BBhthGTQK0Bf8I9XA6UE/3uCGWu2QguDN3u9qa igWZjnzqvRv+HhZEM2wN6CEXr/Q5SOaAASSxx/wv85LA8pTKpNdTNTLUdsd3bpViHB1H z5b+jHvXFi8rH2uBLJgZm+Dz1W7cEijE+OaXFjojuWuFk44EWEvCxche6t69SrsCD+45 wQ3Q== Sender: isar-users@googlegroups.com X-Forwarded-Encrypted: i=1; AJvYcCXg7qSN6XCNmzCVbtzF6BxXlr70d5K3kPGsy1mCusqkvb/HzqraATblxnhndnN/BvNJLhHs@ilbers.de X-Gm-Message-State: AOJu0YzSja7YUlWXT6SbC7cAkLJVAjIUl9hQ1rtJ48pJTkvi2KFFk4pz Bl71Vy7m8PKm9h+3sVUvT7jeUicIGlxbmF6gW9qV0eTr6+M0I5uv X-Google-Smtp-Source: AGHT+IGDT2cu1vQBS6hcCLtuZy8OSVw7s6sAIIfP0dh3Kz/ei6I6ZBaSNlPa2/HJ/Xdu/idwuJ+kPw== X-Received: by 2002:a05:6214:2e49:b0:6d3:9f80:eee1 with SMTP id 6a1803df08f44-6d3fb733b0dmr171035326d6.8.1731916485136; Sun, 17 Nov 2024 23:54:45 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6214:224e:b0:6b7:8ba3:a39a with SMTP id 6a1803df08f44-6d40dc05d3dls17234986d6.1.-pod-prod-04-us; Sun, 17 Nov 2024 23:54:44 -0800 (PST) X-Received: by 2002:a05:620a:2911:b0:7b1:45ac:86be with SMTP id af79cd13be357-7b3622dc0c3mr1687152285a.23.1731916483763; Sun, 17 Nov 2024 23:54:43 -0800 (PST) Date: Sun, 17 Nov 2024 23:54:43 -0800 (PST) From: Herbert Bernecker To: isar-users Message-Id: <5b51a525-2a0e-4fe0-873d-5d66c2b38ae5n@googlegroups.com> In-Reply-To: <2d7a8dac-8696-4523-a963-a54f7ee1fbbf@siemens.com> References: <939743ed-7e16-43e9-9869-1e3de655301dn@googlegroups.com> <2d7a8dac-8696-4523-a963-a54f7ee1fbbf@siemens.com> Subject: Re: wic fails with mkhybridiso.wks/isoimage-isohybrid MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_173102_1377162621.1731916483559" X-Original-Sender: herbert.bernecker.siemens@gmail.com 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=-4.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,RCVD_IN_RP_CERTIFIED, RCVD_IN_RP_RNBL,RCVD_IN_RP_SAFE,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-TUID: QDenyCrm90tv ------=_Part_173102_1377162621.1731916483559 Content-Type: multipart/alternative; boundary="----=_Part_173103_837955881.1731916483559" ------=_Part_173103_837955881.1731916483559 Content-Type: text/plain; charset="UTF-8" I can't say it's ready for production as I don't have comprehensive test cases. But I think it makes sense to start with it. Just my 2 cents. What is a real isar patch? >>> isoimage-isohybrid-isar.py patch <<< >>> support payload from recipe - ISOPAYLOADDIR <<< >>> live boot content removal <<< diff --git a/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py b/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py new file mode 100644 index 00000000..21e8a004 --- /dev/null +++ b/meta/scripts/lib/wic/plugins/source/isoimage-isohybrid-isar.py @@ -0,0 +1,482 @@ +# +# SPDX-License-Identifier: GPL-2.0-only +# +# DESCRIPTION +# This implements the 'isoimage-isohybrid-isar' source plugin class for 'wic' +# +# AUTHORS +# Mihaly Varga + +import glob +import logging +import os +import re +import shutil +import subprocess + +from wic import WicError +from wic.engine import get_custom_config +from wic.pluginbase import SourcePlugin +from wic.misc import exec_cmd, exec_native_cmd, get_bitbake_var + +# allow plugins to import from isarpluginbase +if '__file__' in globals(): + import sys + sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/..") +from isarpluginbase import (isar_get_filenames, isar_populate_boot_cmd) + +logger = logging.getLogger('wic') + +class IsoImagePlugin(SourcePlugin): + """ + Create a bootable ISO image + + This plugin creates a hybrid, legacy and EFI bootable ISO image. The + generated image can be used on optical media as well as USB media. + + Legacy boot uses syslinux and EFI boot uses grub or gummiboot (not + implemented yet) as bootloader. The plugin creates the directories required + by bootloaders and populates them by creating and configuring the + bootloader files. + + Example kickstart file: + part /boot --source isoimage-isohybrid --sourceparams="loader=grub-efi, \\ + image_name= IsoImage" --ondisk cd --label LIVECD + bootloader --timeout=10 --append=" " + + In --sourceparams "loader" specifies the bootloader used for booting in EFI + mode, while "image_name" specifies the name of the generated image. In the + example above, wic creates an ISO image named IsoImage-cd.direct (default + extension added by direct imeger plugin) and a file named IsoImage-cd.iso + """ + + name = 'isoimage-isohybrid-isar' + + @classmethod + def do_configure_syslinux(cls, creator, cr_workdir): + """ + Create loader-specific (syslinux) config + """ + splash = os.path.join(cr_workdir, "ISO/boot/splash.jpg") + if os.path.exists(splash): + splashline = "menu background splash.jpg" + else: + splashline = "" + + bootloader = creator.ks.bootloader + + syslinux_conf = "" + syslinux_conf += "PROMPT 0\n" + syslinux_conf += "TIMEOUT %s \n" % (bootloader.timeout or 10) + syslinux_conf += "\n" + syslinux_conf += "ALLOWOPTIONS 1\n" + syslinux_conf += "SERIAL 0 115200\n" + syslinux_conf += "\n" + if splashline: + syslinux_conf += "%s\n" % splashline + syslinux_conf += "DEFAULT boot\n" + syslinux_conf += "LABEL boot\n" + + kernel = get_bitbake_var("KERNEL_IMAGETYPE") + if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1": + if get_bitbake_var("INITRAMFS_IMAGE"): + kernel = "%s-%s.bin" % \ + (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME")) + + syslinux_conf += "KERNEL /" + kernel + "\n" + syslinux_conf += "APPEND initrd=/initrd LABEL=boot %s\n" \ + % bootloader.append + + logger.debug("Writing syslinux config %s/ISO/isolinux/isolinux.cfg", + cr_workdir) + + with open("%s/ISO/isolinux/isolinux.cfg" % cr_workdir, "w") as cfg: + cfg.write(syslinux_conf) + + @classmethod + def do_configure_grubefi(cls, part, creator, target_dir): + """ + Create loader-specific (grub-efi) config + """ + configfile = creator.ks.bootloader.configfile + if configfile: + grubefi_conf = get_custom_config(configfile) + if grubefi_conf: + logger.debug("Using custom configuration file %s for grub.cfg", + configfile) + else: + raise WicError("configfile is specified " + "but failed to get it from %s", configfile) + else: + splash = os.path.join(target_dir, "splash.jpg") + if os.path.exists(splash): + splashline = "menu background splash.jpg" + else: + splashline = "" + + bootloader = creator.ks.bootloader + + grubefi_conf = "" + grubefi_conf += "serial --unit=0 --speed=115200 --word=8 " + grubefi_conf += "--parity=no --stop=1\n" + grubefi_conf += "default=boot\n" + grubefi_conf += "timeout=%s\n" % (bootloader.timeout or 10) + grubefi_conf += "\n" + grubefi_conf += "search --set=root --label %s " % part.label + grubefi_conf += "\n" + grubefi_conf += "menuentry 'boot'{\n" + + kernel = get_bitbake_var("KERNEL_IMAGETYPE") + if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1": + if get_bitbake_var("INITRAMFS_IMAGE"): + kernel = "%s-%s.bin" % \ + (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME")) + + grubefi_conf += "linux /%s rootwait %s\n" \ + % (kernel, bootloader.append) + grubefi_conf += "initrd /initrd \n" + grubefi_conf += "}\n" + + if splashline: + grubefi_conf += "%s\n" % splashline + + cfg_path = os.path.join(target_dir, "grub.cfg") + logger.debug("Writing grubefi config %s", cfg_path) + + with open(cfg_path, "w") as cfg: + cfg.write(grubefi_conf) + + @staticmethod + def _build_initramfs_path(rootfs_dir, cr_workdir): + """ + Create path for initramfs image + """ + + initrd = get_bitbake_var("INITRD_LIVE") or get_bitbake_var("INITRD_IMG") + if not initrd: + logger.debug("INITRD_LIVE or INITRD_IMG not defined") + initrd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") + if not initrd_dir: + raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting.") + + image_name = get_bitbake_var("IMAGE_BASENAME") + if not image_name: + raise WicError("Couldn't find IMAGE_BASENAME, exiting.") + + image_type = get_bitbake_var("INITRAMFS_FSTYPES") + if not image_type: + raise WicError("Couldn't find INITRAMFS_FSTYPES, exiting.") + + machine = os.path.basename(initrd_dir) + + pattern = '%s/%s*%s.%s' % (initrd_dir, image_name, machine, image_type) + files = glob.glob(pattern) + if files: + initrd = files[0] + logger.debug("initrd from deploy directory: %s", initrd) + + if not initrd or not os.path.exists(initrd): + # Create initrd from rootfs directory + logger.debug("Create initrd from rootfs directory") + initrd = "%s/initrd.cpio.gz" % cr_workdir + initrd_dir = "%s/INITRD" % cr_workdir + cmd = "rsync -avP --numeric-ids --exclude='/dev' --exclude='/proc' --exclude='/sys' %s %s" % (rootfs_dir, initrd_dir) + subprocess.call(cmd.split()) + + if os.path.isfile("%s/init" % rootfs_dir): + shutil.copy2("%s/init" % rootfs_dir, "%s/init" % initrd_dir) + elif os.path.lexists("%s/init" % rootfs_dir): + os.symlink(os.readlink("%s/init" % rootfs_dir), \ + "%s/init" % initrd_dir) + elif os.path.isfile("%s/sbin/init" % rootfs_dir): + shutil.copy2("%s/sbin/init" % rootfs_dir, \ + "%s" % initrd_dir) + elif os.path.lexists("%s/sbin/init" % rootfs_dir): + os.symlink(os.readlink("%s/sbin/init" % rootfs_dir), \ + "%s/init" % initrd_dir) + else: + raise WicError("Couldn't find or build initrd, exiting.") + + exec_cmd("cd %s && find . | cpio -o -H newc -R root:root >%s/initrd.cpio " \ + % (initrd_dir, cr_workdir), as_shell=True) + exec_cmd("gzip -f -9 %s/initrd.cpio" % cr_workdir, as_shell=True) + shutil.rmtree(initrd_dir) + + return initrd + + @classmethod + def do_configure_partition(cls, part, source_params, creator, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot): + """ + Called before do_prepare_partition(), creates loader-specific config + """ + isodir = "%s/ISO/" % cr_workdir + + if os.path.exists(isodir): + shutil.rmtree(isodir) + + install_cmd = "install -d %s " % isodir + exec_cmd(install_cmd) + + # Overwrite the name of the created image + logger.debug(source_params) + if 'image_name' in source_params and \ + source_params['image_name'].strip(): + creator.name = source_params['image_name'].strip() + logger.debug("The name of the image is: %s", creator.name) + + @staticmethod + def _install_payload(source_params, iso_dir): + """ + Copies contents of payload directory (as specified in 'payload_dir' param) into iso_dir + """ + + if source_params.get('payload_dir'): + payload_dir = source_params['payload_dir'] + logger.debug("Payload directory from wks file: %s", payload_dir) + shutil.copytree(payload_dir, iso_dir, symlinks=True, dirs_exist_ok=True) + + iso_payload_dir = get_bitbake_var("ISOPAYLOADDIR") + if iso_payload_dir: + logger.debug("Payload directory from image recipe: %s", iso_payload_dir) + shutil.copytree(iso_payload_dir, iso_dir, symlinks=True, dirs_exist_ok=True) + + @classmethod + def do_prepare_partition(cls, part, source_params, creator, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): + """ + Called to do the actual content population for a partition i.e. it + 'prepares' the partition to be incorporated into the image. + In this case, prepare content for a bootable ISO image. + """ + + isodir = "%s/ISO" % cr_workdir + + cls._install_payload(source_params, isodir) + + if part.rootfs_dir is None: + if not 'ROOTFS_DIR' in rootfs_dir: + raise WicError("Couldn't find --rootfs-dir, exiting.") + rootfs_dir = rootfs_dir['ROOTFS_DIR'] + else: + if part.rootfs_dir in rootfs_dir: + rootfs_dir = rootfs_dir[part.rootfs_dir] + elif part.rootfs_dir: + rootfs_dir = part.rootfs_dir + else: + raise WicError("Couldn't find --rootfs-dir=%s connection " + "or it is not a valid path, exiting." % + part.rootfs_dir) + + if not os.path.isdir(rootfs_dir): + rootfs_dir = get_bitbake_var("IMAGE_ROOTFS") + if not os.path.isdir(rootfs_dir): + raise WicError("Couldn't find IMAGE_ROOTFS, exiting.") + + part.rootfs_dir = rootfs_dir + deploy_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") + img_iso_dir = get_bitbake_var("ISODIR") + + # Remove the temporary file created by part.prepare_rootfs() + if os.path.isfile(part.source_file): + os.remove(part.source_file) + + # Support using a different initrd other than default + if not os.path.isfile("%s/initrd" % isodir): + if source_params.get('initrd'): + initrd = source_params['initrd'] + if not deploy_dir: + raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") + cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir) + exec_cmd(cp_cmd) + else: + # Prepare initial ramdisk + initrd = "%s/initrd" % deploy_dir + if not os.path.isfile(initrd): + initrd = "%s/initrd" % img_iso_dir + initrd = cls._build_initramfs_path(rootfs_dir, cr_workdir) + + install_cmd = "install -m 0644 %s %s/initrd" % (initrd, isodir) + exec_cmd(install_cmd) + else: + logger.debug("initrd already installed (payload dir)") + + # Remove the temporary file created by _build_initramfs_path function + if os.path.isfile("%s/initrd.cpio.gz" % cr_workdir): + os.remove("%s/initrd.cpio.gz" % cr_workdir) + + kernel = get_bitbake_var("KERNEL_IMAGETYPE") + if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1": + if get_bitbake_var("INITRAMFS_IMAGE"): + kernel = "%s-%s.bin" % \ + (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME")) + + kernel_path = "%s/%s" % (isodir, kernel) + if not os.path.isfile(kernel_path): + logger.debug("Install kernel image %s", kernel) + install_cmd = "install -m 0644 %s/%s %s/%s" % \ + (kernel_dir, kernel, isodir, kernel) + exec_cmd(install_cmd) + else: + logger.debug("Kernel image %s already installed (payload dir)", kernel) + + #Create bootloader for efi boot + try: + target_dir = "%s/EFI/BOOT" % isodir + if os.path.exists(target_dir): + shutil.rmtree(target_dir) + + os.makedirs(target_dir) + + if source_params['loader'] == 'grub-efi': + # Builds bootx64.efi/bootia32.efi if ISODIR didn't exist or + # didn't contains it + target_arch = get_bitbake_var("TARGET_SYS") + if not target_arch: + raise WicError("Coludn't find target architecture") + + if re.match("x86_64", target_arch): + grub_src_image = "grubx64.efi" + grub_src = os.path.join("/usr/lib/grub/x86_64-efi/monolithic/", grub_src_image) + grub_dest_image = "bootx64.efi" + elif re.match('i.86', target_arch): + grub_src_image = "grubia32.efi" + grub_src = os.path.join("/usr/lib/grub/i386-efi/monolithic/", grub_src_image) + grub_dest_image = "bootia32.efi" + else: + raise WicError("grub-efi is incompatible with target %s" % + target_arch) + + grub_target = os.path.join(target_dir, grub_dest_image) + if not os.path.isfile(grub_target): + if not os.path.exists(grub_src): + raise WicError("Grub loader %s is not found in %s. " + "Please build grub-efi first" % (grub_src_image, deploy_dir)) + shutil.copy(grub_src, grub_target) + + if not os.path.isfile(os.path.join(target_dir, "boot.cfg")): + cls.do_configure_grubefi(part, creator, target_dir) + + else: + raise WicError("unrecognized bootimg-efi loader: %s" % + source_params['loader']) + except KeyError: + raise WicError("bootimg-efi requires a loader, none specified") + + # Create efi.img that contains bootloader files for EFI booting + # if ISODIR didn't exist or didn't contains it + if os.path.isfile("%s/efi.img" % img_iso_dir): + install_cmd = "install -m 0644 %s/efi.img %s/efi.img" % \ + (img_iso_dir, isodir) + exec_cmd(install_cmd) + else: + # Default to 100 blocks of extra space for file system overhead + esp_extra_blocks = int(source_params.get('esp_extra_blocks', '100')) + + du_cmd = "du -bks %s/EFI" % isodir + out = exec_cmd(du_cmd) + blocks = int(out.split()[0]) + blocks += esp_extra_blocks + logger.debug("Added 100 extra blocks to %s to get to %d " + "total blocks", part.mountpoint, blocks) + + # dosfs image for EFI boot + bootimg = "%s/efi.img" % isodir + + esp_label = source_params.get('esp_label', 'EFIimg') + + dosfs_cmd = 'mkfs.vfat -n \'%s\' -S 512 -C %s %d' \ + % (esp_label, bootimg, blocks) + exec_native_cmd(dosfs_cmd, native_sysroot) + + mmd_cmd = "mmd -i %s ::/EFI" % bootimg + exec_native_cmd(mmd_cmd, native_sysroot) + + mcopy_cmd = "mcopy -i %s -s %s/EFI/* ::/EFI/" \ + % (bootimg, isodir) + exec_native_cmd(mcopy_cmd, native_sysroot) + + chmod_cmd = "chmod 644 %s" % bootimg + exec_cmd(chmod_cmd) + + # Prepare files for legacy boot + syslinux_dir = get_bitbake_var("STAGING_DATADIR") + if not syslinux_dir: + raise WicError("Couldn't find STAGING_DATADIR, exiting.") + + if os.path.exists("%s/isolinux" % isodir): + shutil.rmtree("%s/isolinux" % isodir) + + install_cmd = "install -d %s/isolinux" % isodir + exec_cmd(install_cmd) + + cls.do_configure_syslinux(creator, cr_workdir) + + + install_cmd = "install -m 444 %s/ISOLINUX/isohdpfx.bin " % syslinux_dir + install_cmd += "%s/isolinux/isohdpfx.bin" % isodir + exec_cmd(install_cmd) + + install_cmd = "install -m 644 %s/ISOLINUX/isolinux.bin " % syslinux_dir + install_cmd += "%s/isolinux/isolinux.bin" % isodir + exec_cmd(install_cmd) + + install_cmd = "install -m 644 %s/syslinux/modules/bios/ldlinux.c32 " % syslinux_dir + install_cmd += "%s/isolinux/ldlinux.c32" % isodir + exec_cmd(install_cmd) + + #create ISO image + iso_img = "%s/tempiso_img.iso" % cr_workdir + iso_bootimg = "isolinux/isolinux.bin" + iso_bootcat = "isolinux/boot.cat" + efi_img = "efi.img" + + mkisofs_cmd = "xorriso -as mkisofs -V %s " % part.label + mkisofs_cmd += "-o %s -U " % iso_img + mkisofs_cmd += "-J -joliet-long -r -iso-level 2 -b %s " % iso_bootimg + mkisofs_cmd += "-c %s -no-emul-boot -boot-load-size 4 " % iso_bootcat + mkisofs_cmd += "-boot-info-table -eltorito-alt-boot " + mkisofs_cmd += "-eltorito-platform 0xEF -eltorito-boot %s " % efi_img + mkisofs_cmd += "-no-emul-boot %s " % isodir + + logger.debug("running command: %s", mkisofs_cmd) + exec_native_cmd(mkisofs_cmd, native_sysroot) + + shutil.rmtree(isodir) + + du_cmd = "du -Lbks %s" % iso_img + out = exec_cmd(du_cmd) + isoimg_size = int(out.split()[0]) + + part.size = isoimg_size + part.source_file = iso_img + + @classmethod + def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot): + """ + Called after all partitions have been prepared and assembled into a + disk image. In this case, we insert/modify the MBR using isohybrid + utility for booting via BIOS from disk storage devices. + """ + + iso_img = "%s.p1" % disk.path + iso_img2 = "%s" % disk.path + full_path = creator._full_path(workdir, disk_name, "direct") + full_path_iso = creator._full_path(workdir, disk_name, "iso") + + isohybrid_cmd = "isohybrid -u %s" % iso_img + logger.debug("running command: %s", isohybrid_cmd) + exec_native_cmd(isohybrid_cmd, native_sysroot) + + # Replace the image created by direct plugin with the one created by + # mkisofs command. This is necessary because the iso image created by + # mkisofs has a very specific MBR is system area of the ISO image, and + # direct plugin adds and configures an another MBR. + logger.debug("Replaceing the image created by direct plugin\n") + os.remove(disk.path) + shutil.copy2(iso_img, iso_img2) + shutil.copy2(iso_img, full_path_iso) + shutil.copy2(full_path_iso, full_path) >>> imagetypes_wic.bblass patch <<< >>> INITRD -> INITRD_IMG <<< >>> + ISOPAYLOADDIR <<< diff --git a/meta/classes/imagetypes_wic.bbclass b/meta/classes/imagetypes_wic.bbclass index 3b697cdd..0e36e8db 100644 --- a/meta/classes/imagetypes_wic.bbclass +++ b/meta/classes/imagetypes_wic.bbclass @@ -103,11 +103,12 @@ WIC_DEPLOY_PARTITIONS ?= "0" # taken from OE, do not touch directly WICVARS += "\ BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD IMAGE_BASENAME IMAGE_BOOT_FILES \ - IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD INITRD_LIVE ISODIR RECIPE_SYSROOT_NATIVE \ - ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS TRANSLATED_TARGET_ARCH" + IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD_IMG INITRD_LIVE ISODIR ISOPAYLOADDIR \ + RECIPE_SYSROOT_NATIVE ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS \ + TRANSLATED_TARGET_ARCH" # Isar specific vars used in our plugins -WICVARS += "DISTRO DISTRO_ARCH" +WICVARS += "DISTRO DISTRO_ARCH KERNEL_IMAGETYPE ROOTFS_PACKAGE_SUFFIX" python do_rootfs_wicenv () { wicvars = d.getVar('WICVARS') >>> imagetypes.bbclass patch <<< >>> + squashfs <<< >>> support live boot <<< diff --git a/meta/classes/imagetypes.bbclass b/meta/classes/imagetypes.bbclass index a3be0a1d..f65c2368 100644 --- a/meta/classes/imagetypes.bbclass +++ b/meta/classes/imagetypes.bbclass @@ -3,6 +3,13 @@ # # SPDX-License-Identifier: MIT +#image type: squashfs +IMAGER_INSTALL:squashfs += "squashfs-tools" +IMAGE_CMD:squashfs() { + ${SUDO_CHROOT} /bin/mksquashfs \ + '${PP_ROOTFS}' '${IMAGE_FILE_CHROOT}' -noappend +} + #image type: tar IMAGER_INSTALL:tar = "tar" TAR_TRANSFORM = "--transform='s|rootfs|.|'" Jan Kiszka schrieb am Dienstag, 5. November 2024 um 16:39:28 UTC+1: > On 05.11.24 10:29, Herbert Bernecker wrote: > > Hi, > > i copied/modified isoimage-isohybrid-isar.py from isoimage-isohybrid.py > > and used it to create a Debian Live ISO Image. > > Patches: > > > > Do you consider this ready for production already? If so, would you like > to submit a real patch for isar? > > Jan > > -- > Siemens AG, Technology > Linux Expert Center > -- 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/5b51a525-2a0e-4fe0-873d-5d66c2b38ae5n%40googlegroups.com. ------=_Part_173103_837955881.1731916483559 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I can't say it's ready for production as I don't have comprehensive test ca= ses.
But I think it makes sense to start with it.
Just my 2 cen= ts.
What is a real isar patch?

>>> isoimage-isohyb= rid-isar.py patch =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<<<
>>> support payload from recipe - ISOPAYLOADDIR <<<
>>> live boot content removal =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 <<<

diff --git a/meta/scri= pts/lib/wic/plugins/source/isoimage-isohybrid-isar.py b/meta/scripts/lib/wi= c/plugins/source/isoimage-isohybrid-isar.py
new file mode 100644
= index 00000000..21e8a004
--- /dev/null
+++ b/meta/scripts/lib/wic= /plugins/source/isoimage-isohybrid-isar.py
@@ -0,0 +1,482 @@
+#+# SPDX-License-Identifier: GPL-2.0-only
+#
+# DESCRIPTION+# This implements the 'isoimage-isohybrid-isar' source plugin class for= 'wic'
+#
+# AUTHORS
+# Mihaly Varga <mihaly.varga (at] n= i.com>
+
+import glob
+import logging
+import os
+import re
+import shutil
+import subprocess
+
+from = wic import WicError
+from wic.engine import get_custom_config
+fr= om wic.pluginbase import SourcePlugin
+from wic.misc import exec_cmd, = exec_native_cmd, get_bitbake_var
+
+# allow plugins to import fro= m isarpluginbase
+if '__file__' in globals():
+ =C2=A0 =C2=A0impo= rt sys
+ =C2=A0 =C2=A0sys.path.append(os.path.dirname(os.path.abspath(= __file__)) + "/..")
+from isarpluginbase import (isar_get_filenames, i= sar_populate_boot_cmd)
+
+logger =3D logging.getLogger('wic')
+
+class IsoImagePlugin(SourcePlugin):
+ =C2=A0 =C2=A0"""
= + =C2=A0 =C2=A0Create a bootable ISO image
+
+ =C2=A0 =C2=A0This = plugin creates a hybrid, legacy and EFI bootable ISO image. The
+ =C2= =A0 =C2=A0generated image can be used on optical media as well as USB media= .
+
+ =C2=A0 =C2=A0Legacy boot uses syslinux and EFI boot uses gr= ub or gummiboot (not
+ =C2=A0 =C2=A0implemented yet) as bootloader. Th= e plugin creates the directories required
+ =C2=A0 =C2=A0by bootloader= s and populates them by creating and configuring the
+ =C2=A0 =C2=A0bo= otloader files.
+
+ =C2=A0 =C2=A0Example kickstart file:
+ = =C2=A0 =C2=A0part /boot --source isoimage-isohybrid --sourceparams=3D"loade= r=3Dgrub-efi, \\
+ =C2=A0 =C2=A0image_name=3D IsoImage" --ondisk cd --= label LIVECD
+ =C2=A0 =C2=A0bootloader =C2=A0--timeout=3D10 =C2=A0--ap= pend=3D" "
+
+ =C2=A0 =C2=A0In --sourceparams "loader" specifies = the bootloader used for booting in EFI
+ =C2=A0 =C2=A0mode, while "ima= ge_name" specifies the name of the generated image. In the
+ =C2=A0 = =C2=A0example above, wic creates an ISO image named IsoImage-cd.direct (def= ault
+ =C2=A0 =C2=A0extension added by direct imeger plugin) and a fil= e named IsoImage-cd.iso
+ =C2=A0 =C2=A0"""
+
+ =C2=A0 =C2=A0= name =3D 'isoimage-isohybrid-isar'
+
+ =C2=A0 =C2=A0@classmethod<= br />+ =C2=A0 =C2=A0def do_configure_syslinux(cls, creator, cr_workdir):+ =C2=A0 =C2=A0 =C2=A0 =C2=A0"""
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0Creat= e loader-specific (syslinux) config
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0"""+ =C2=A0 =C2=A0 =C2=A0 =C2=A0splash =3D os.path.join(cr_workdir, "ISO/b= oot/splash.jpg")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if os.path.exists(splash= ):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0splashline =3D "menu bac= kground splash.jpg"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0else:
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0splashline =3D ""
+
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0bootloader =3D creator.ks.bootloader
+
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0syslinux_conf =3D ""
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0syslinux_conf +=3D "PROMPT 0\n"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0sys= linux_conf +=3D "TIMEOUT %s \n" % (bootloader.timeout or 10)
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0syslinux_conf +=3D "\n"
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0syslinux_conf +=3D "ALLOWOPTIONS 1\n"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= syslinux_conf +=3D "SERIAL 0 115200\n"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0sy= slinux_conf +=3D "\n"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if splashline:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0syslinux_conf +=3D "%s\n" % spl= ashline
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0syslinux_conf +=3D "DEFAULT boot\= n"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0syslinux_conf +=3D "LABEL boot\n"
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0kernel =3D get_bitbake_var("KERNEL_IMA= GETYPE")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if get_bitbake_var("INITRAMFS_IM= AGE_BUNDLE") =3D=3D "1":
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if= get_bitbake_var("INITRAMFS_IMAGE"):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0kernel =3D "%s-%s.bin" % \
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(get_bitbake_var("KERNE= L_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
+
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0syslinux_conf +=3D "KERNEL /" + kernel + "\n"
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0syslinux_conf +=3D "APPEND initrd=3D/initrd LABE= L=3Dboot %s\n" \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 % bootloader.append
+=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.debug("Writing syslinux config %s= /ISO/isolinux/isolinux.cfg",
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cr_workdir)
+
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0with open("%s/ISO/isolinux/isolinux.cfg" % cr_workdir, "w") as cf= g:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cfg.write(syslinux_conf)=
+
+ =C2=A0 =C2=A0@classmethod
+ =C2=A0 =C2=A0def do_configu= re_grubefi(cls, part, creator, target_dir):
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0"""
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0Create loader-specific (grub-efi) = config
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0"""
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0configfile =3D creator.ks.bootloader.configfile
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0if configfile:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0grubefi_conf =3D get_custom_config(configfile)
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0if grubefi_conf:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.debug("Using custom configuration file %= s for grub.cfg",
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 configfile)
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0raise WicError("configfile is specified "
+= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "but failed to get it from %s", configfile)=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0else:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0splash =3D os.path.join(target_dir, "splash.jpg")
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if os.path.exists(splash):
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0splashline =3D "menu ba= ckground splash.jpg"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else:<= br />+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0splashline = =3D ""
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bootloader = =3D creator.ks.bootloader
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0grubefi_conf =3D ""
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0g= rubefi_conf +=3D "serial --unit=3D0 --speed=3D115200 --word=3D8 "
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grubefi_conf +=3D "--parity=3Dno -= -stop=3D1\n"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grubefi_conf += =3D "default=3Dboot\n"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grub= efi_conf +=3D "timeout=3D%s\n" % (bootloader.timeout or 10)
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grubefi_conf +=3D "\n"
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grubefi_conf +=3D "search --set=3Droot --lab= el %s " % part.label
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grubef= i_conf +=3D "\n"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grubefi_co= nf +=3D "menuentry 'boot'{\n"
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0kernel =3D get_bitbake_var("KERNEL_IMAGETYPE")
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE")= =3D=3D "1":
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= if get_bitbake_var("INITRAMFS_IMAGE"):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0kernel =3D "%s-%s.bin" % \
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_= LINK_NAME"))
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grubefi= _conf +=3D "linux /%s rootwait %s\n" \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0% (ker= nel, bootloader.append)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0gru= befi_conf +=3D "initrd /initrd \n"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0grubefi_conf +=3D "}\n"
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0if splashline:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0grubefi_conf +=3D "%s\n" % splashline
+
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0cfg_path =3D os.path.join(target_dir, "grub.cfg")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.debug("Writing grubefi config %s", cfg= _path)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0with open(cfg_path, "w") as= cfg:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cfg.write(grubefi_con= f)
+
+ =C2=A0 =C2=A0@staticmethod
+ =C2=A0 =C2=A0def _build_= initramfs_path(rootfs_dir, cr_workdir):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0"= ""
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0Create path for initramfs image
+= =C2=A0 =C2=A0 =C2=A0 =C2=A0"""
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0in= itrd =3D get_bitbake_var("INITRD_LIVE") or get_bitbake_var("INITRD_IMG")+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if not initrd:
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0logger.debug("INITRD_LIVE or INITRD_IMG not defined")+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0initrd_dir =3D get_bitbake_v= ar("DEPLOY_DIR_IMAGE")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if n= ot initrd_dir:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting.")
+
+= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0image_name =3D get_bitbake_var("I= MAGE_BASENAME")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if not imag= e_name:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise= WicError("Couldn't find IMAGE_BASENAME, exiting.")
+
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0image_type =3D get_bitbake_var("INITRAMFS= _FSTYPES")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if not image_typ= e:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise WicE= rror("Couldn't find INITRAMFS_FSTYPES, exiting.")
+
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0machine =3D os.path.basename(initrd_dir)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pattern =3D '%s/%s*%s.%= s' % (initrd_dir, image_name, machine, image_type)
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0files =3D glob.glob(pattern)
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0if files:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0initrd =3D files[0]
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.debug("initrd from deploy directory: = %s", initrd)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if not initrd or not = os.path.exists(initrd):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# C= reate initrd from rootfs directory
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0logger.debug("Create initrd from rootfs directory")
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0initrd =3D "%s/initrd.cpio.gz" % cr_work= dir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0initrd_dir =3D "%s/INIT= RD" % cr_workdir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cmd =3D "r= sync -avP --numeric-ids --exclude=3D'/dev' --exclude=3D'/proc' --exclude=3D= '/sys' %s %s" % (rootfs_dir, initrd_dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0subprocess.call(cmd.split())
+
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0if os.path.isfile("%s/init" % rootfs_dir):
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0shutil.copy2("%s/ini= t" % rootfs_dir, "%s/init" % initrd_dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0elif os.path.lexists("%s/init" % rootfs_dir):
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0os.symlink(os.readlink("%s/= init" % rootfs_dir), \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"%s/init" % initrd_dir)=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0elif os.path.isfile("%s/sb= in/init" % rootfs_dir):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0shutil.copy2("%s/sbin/init" % rootfs_dir, \
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0"%s" % initrd_dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0elif os.path.lexists("%s/sbin/init" % rootfs_dir):
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0os.symlink(os.readlink("%s/sbi= n/init" % rootfs_dir), \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"%s/init" % initrd_d= ir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else:
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise WicError("Couldn't find = or build initrd, exiting.")
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0exec_cmd("cd %s && find . | cpio -o -H newc -R root:root = >%s/initrd.cpio " \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 % (initrd_dir, cr_workdir), as_shell=3DTrue)
= + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_cmd("gzip -f -9 %s/initrd.c= pio" % cr_workdir, as_shell=3DTrue)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0shutil.rmtree(initrd_dir)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0return initrd
+
+ =C2=A0 =C2=A0@classmethod
+ =C2=A0 =C2= =A0def do_configure_partition(cls, part, source_params, creator, cr_workdir= ,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 oe_builddir, bootimg_dir, kernel_dir= ,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 native_sysroot):
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0"""
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0Called before do_pre= pare_partition(), creates loader-specific config
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0"""
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0isodir =3D "%s/ISO/" % cr_w= orkdir
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if os.path.exists(isodir):<= br />+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0shutil.rmtree(isodir)
= +
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0install_cmd =3D "install -d %s " % isod= ir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_cmd(install_cmd)
+
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0# Overwrite the name of the created image
+= =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.debug(source_params)
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0if 'image_name' in source_params and \
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0source_params['i= mage_name'].strip():
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0creato= r.name =3D source_params['image_name'].strip()
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0logger.debug("The name of the image is: %s", creator.na= me)
+
+ =C2=A0 =C2=A0@staticmethod
+ =C2=A0 =C2=A0def _insta= ll_payload(source_params, iso_dir):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0"""+ =C2=A0 =C2=A0 =C2=A0 =C2=A0Copies contents of payload directory (as s= pecified in 'payload_dir' param) into iso_dir
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0"""
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if source_params.get('pa= yload_dir'):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0payload_dir = =3D source_params['payload_dir']
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0logger.debug("Payload directory from wks file: %s", payload_dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0shutil.copytree(payload_dir, is= o_dir, symlinks=3DTrue, dirs_exist_ok=3DTrue)
+
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0iso_payload_dir =3D get_bitbake_var("ISOPAYLOADDIR")
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0if iso_payload_dir:
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0logger.debug("Payload directory from image recipe: %s",= iso_payload_dir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0shutil.co= pytree(iso_payload_dir, iso_dir, symlinks=3DTrue, dirs_exist_ok=3DTrue)
+
+ =C2=A0 =C2=A0@classmethod
+ =C2=A0 =C2=A0def do_prepare_par= tition(cls, part, source_params, creator, cr_workdir,
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 oe_builddir, bootimg_dir, kernel_dir,
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 rootfs_dir, native_sysroot):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0"""+ =C2=A0 =C2=A0 =C2=A0 =C2=A0Called to do the actual content population= for a partition i.e. it
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0'prepares' the p= artition to be incorporated into the image.
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0In this case, prepare content for a bootable ISO image.
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0"""
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0isodir =3D= "%s/ISO" % cr_workdir
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0cls._instal= l_payload(source_params, isodir)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0i= f part.rootfs_dir is None:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= if not 'ROOTFS_DIR' in rootfs_dir:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0raise WicError("Couldn't find --rootfs-dir, exiting= .")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rootfs_dir =3D rootfs_d= ir['ROOTFS_DIR']
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0else:
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if part.rootfs_dir in rootfs_dir:
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rootfs_dir =3D rootfs_d= ir[part.rootfs_dir]
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0elif pa= rt.rootfs_dir:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0rootfs_dir =3D part.rootfs_dir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0else:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= raise WicError("Couldn't find --rootfs-dir=3D%s connection "
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 "or it is not a valid path, exiting." %
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 part.rootfs_dir)
+
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0if not os.path.isdir(rootfs_dir):
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0rootfs_dir =3D get_bitbake_var("IMAGE_ROOTFS")
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0if not os.path.isdir(rootfs_dir):
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise WicError("Couldn't find IMAGE_ROOTF= S, exiting.")
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0part.rootfs_dir =3D = rootfs_dir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0deploy_dir =3D get_bitbake_var= ("DEPLOY_DIR_IMAGE")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0img_iso_dir =3D get_= bitbake_var("ISODIR")
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0# Remove the= temporary file created by part.prepare_rootfs()
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0if os.path.isfile(part.source_file):
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0os.remove(part.source_file)
+
+ =C2=A0 =C2=A0= =C2=A0 =C2=A0# Support using a different initrd other than default
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0if not os.path.isfile("%s/initrd" % isodir):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if source_params.get('initrd')= :
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0initrd =3D = source_params['initrd']
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0if not deploy_dir:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise WicError("Couldn't find DEPLOY_DIR_= IMAGE, exiting")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0cp_cmd =3D "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir)
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_cmd(cp_cmd)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else:
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Prepare initial ramdisk
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0initrd =3D "%s/initrd" = % deploy_dir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= if not os.path.isfile(initrd):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0initrd =3D "%s/initrd" % img_iso_dir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ini= trd =3D cls._build_initramfs_path(rootfs_dir, cr_workdir)
+
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0install_cmd =3D "install -m 0644 %s %= s/initrd" % (initrd, isodir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0exec_cmd(install_cmd)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0else:
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.debug("initrd already installe= d (payload dir)")
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0# Remove the tem= porary file created by _build_initramfs_path function
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0if os.path.isfile("%s/initrd.cpio.gz" % cr_workdir):
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0os.remove("%s/initrd.cpio.gz" % cr= _workdir)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0kernel =3D get_bitbake_v= ar("KERNEL_IMAGETYPE")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if get_bitbake_var= ("INITRAMFS_IMAGE_BUNDLE") =3D=3D "1":
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0if get_bitbake_var("INITRAMFS_IMAGE"):
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0kernel =3D "%s-%s.bin" % \
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(get_b= itbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0kernel_path =3D "%s/%s" % (isodir, ke= rnel)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if not os.path.isfile(kernel_path):=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.debug("Install kern= el image %s", kernel)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0insta= ll_cmd =3D "install -m 0644 %s/%s %s/%s" % \
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(kernel_dir, kernel, isodir, kernel)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_cmd(install_cmd)
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0else:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0logger.debug("Kernel image %s already installed (payload dir)", kerne= l)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0#Create bootloader for efi boot=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0try:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0target_dir =3D "%s/EFI/BOOT" % isodir
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0if os.path.exists(target_dir):
+ =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0shutil.rmtree(target_dir)
+<= br />+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0os.makedirs(target_dir)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if source_params['loade= r'] =3D=3D 'grub-efi':
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0# Builds bootx64.efi/bootia32.efi if ISODIR didn't exist or
= + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# didn't contains = it
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0target_arc= h =3D get_bitbake_var("TARGET_SYS")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0if not target_arch:
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise WicError("Coludn't find = target architecture")
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0if re.match("x86_64", target_arch):
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grub_src_image =3D "= grubx64.efi"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0grub_src =3D os.path.join("/usr/lib/grub/x86_64-efi/monolithi= c/", grub_src_image)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0grub_dest_image =3D "bootx64.efi"
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0elif re.match('i.86', target_a= rch):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0grub_src_image =3D "grubia32.efi"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grub_src =3D os.path.join("/usr/l= ib/grub/i386-efi/monolithic/", grub_src_image)
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grub_dest_image =3D "bootia= 32.efi"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else:=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0raise WicError("grub-efi is incompatible with target %s" %
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 target_arch)
+
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0grub_target =3D os.path.joi= n(target_dir, grub_dest_image)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0if not os.path.isfile(grub_target):
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if not os.path.e= xists(grub_src):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise WicError("Grub loader %s is not fou= nd in %s. "
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 "Please build grub-efi first" % (grub_src_image, deploy_dir))
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0shutil= .copy(grub_src, grub_target)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0if not os.path.isfile(os.path.join(target_dir, "boo= t.cfg")):
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0cls.do_configure_grubefi(part, creator, target_dir)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else:
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise WicError("unrecognized bootimg-= efi loader: %s" %
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 source_params['load= er'])
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0except KeyError:
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise WicError("bootimg-efi requires a loade= r, none specified")
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0# Create efi.i= mg that contains bootloader files for EFI booting
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0# if ISODIR didn't exist or didn't contains it
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0if os.path.isfile("%s/efi.img" % img_iso_dir):
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0install_cmd =3D "install -m 0644 %s/e= fi.img %s/efi.img" % \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(img_iso_dir, isodir)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0exec_cmd(install_cmd)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0else:
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Default to 100 blocks of extra s= pace for file system overhead
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0esp_extra_blocks =3D int(source_params.get('esp_extra_blocks', '100'))+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0du_cmd =3D "du -bks %= s/EFI" % isodir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0out =3D exe= c_cmd(du_cmd)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0blocks =3D in= t(out.split()[0])
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0blocks += =3D esp_extra_blocks
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logger= .debug("Added 100 extra blocks to %s to get to %d "
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "tota= l blocks", part.mountpoint, blocks)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0# dosfs image for EFI boot
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0bootimg =3D "%s/efi.img" % isodir
+
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0esp_label =3D source_params.get('esp_label',= 'EFIimg')
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dosfs_cmd= =3D 'mkfs.vfat -n \'%s\' -S 512 -C %s %d' \
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0% (esp_label,= bootimg, blocks)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_nati= ve_cmd(dosfs_cmd, native_sysroot)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0mmd_cmd =3D "mmd -i %s ::/EFI" % bootimg
+ =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_native_cmd(mmd_cmd, native_sysroot)
+=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0mcopy_cmd =3D "mcopy -i %s= -s %s/EFI/* ::/EFI/" \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0% (bootimg, isodir)
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_native_cmd(mcopy_cmd, native_sysroot= )
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0chmod_cmd =3D "chm= od 644 %s" % bootimg
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_c= md(chmod_cmd)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0# Prepare files for = legacy boot
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0syslinux_dir =3D get_bitbake_= var("STAGING_DATADIR")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if not syslinux_di= r:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise WicError("Couldn't= find STAGING_DATADIR, exiting.")
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= if os.path.exists("%s/isolinux" % isodir):
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0shutil.rmtree("%s/isolinux" % isodir)
+
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0install_cmd =3D "install -d %s/isolinux" % isodir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_cmd(install_cmd)
+
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0cls.do_configure_syslinux(creator, cr_workdir)
++
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0install_cmd =3D "install -m 444 %s/= ISOLINUX/isohdpfx.bin " % syslinux_dir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0in= stall_cmd +=3D "%s/isolinux/isohdpfx.bin" % isodir
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0exec_cmd(install_cmd)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0in= stall_cmd =3D "install -m 644 %s/ISOLINUX/isolinux.bin " % syslinux_dir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0install_cmd +=3D "%s/isolinux/isolinux.bin" = % isodir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_cmd(install_cmd)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0install_cmd =3D "install -m 644 %s/syslinux/= modules/bios/ldlinux.c32 " % syslinux_dir
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0install_cmd +=3D "%s/isolinux/ldlinux.c32" % isodir
+ =C2=A0 =C2=A0= =C2=A0 =C2=A0exec_cmd(install_cmd)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0#create ISO image
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0iso_img =3D "%s/temp= iso_img.iso" % cr_workdir
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0iso_bootimg =3D= "isolinux/isolinux.bin"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0iso_bootcat =3D = "isolinux/boot.cat"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0efi_img =3D "efi.img"=
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mkisofs_cmd =3D "xorriso -as mkis= ofs -V %s " % part.label
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mkisofs_cmd +=3D= "-o %s -U " % iso_img
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mkisofs_cmd +=3D "= -J -joliet-long -r -iso-level 2 -b %s " % iso_bootimg
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0mkisofs_cmd +=3D "-c %s -no-emul-boot -boot-load-size 4 " % is= o_bootcat
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mkisofs_cmd +=3D "-boot-info-ta= ble -eltorito-alt-boot "
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mkisofs_cmd +=3D= "-eltorito-platform 0xEF -eltorito-boot %s " % efi_img
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0mkisofs_cmd +=3D "-no-emul-boot %s " % isodir
+
= + =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.debug("running command: %s", mkisofs_cm= d)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0exec_native_cmd(mkisofs_cmd, native_sy= sroot)
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0shutil.rmtree(isodir)
= +
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0du_cmd =3D "du -Lbks %s" % iso_img
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0out =3D exec_cmd(du_cmd)
+ =C2=A0 =C2=A0= =C2=A0 =C2=A0isoimg_size =3D int(out.split()[0])
+
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0part.size =3D isoimg_size
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0part.source_file =3D iso_img
+
+ =C2=A0 =C2=A0@classmethod
+ =C2=A0 =C2=A0def do_install_disk(cls, disk, disk_name, creator, workdir= , oe_builddir,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bootimg_dir, kernel_dir, native_sysroot):+ =C2=A0 =C2=A0 =C2=A0 =C2=A0"""
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0Calle= d after all partitions have been prepared and assembled into a
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0disk image. =C2=A0In this case, we insert/modify th= e MBR using isohybrid
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0utility for booting= via BIOS from disk storage devices.
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0"""<= br />+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0iso_img =3D "%s.p1" % disk.path+ =C2=A0 =C2=A0 =C2=A0 =C2=A0iso_img2 =3D "%s" % disk.path
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0full_path =3D creator._full_path(workdir, disk_name, "= direct")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0full_path_iso =3D creator._full_= path(workdir, disk_name, "iso")
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0is= ohybrid_cmd =3D "isohybrid -u %s" % iso_img
+ =C2=A0 =C2=A0 =C2=A0 =C2= =A0logger.debug("running command: %s", isohybrid_cmd)
+ =C2=A0 =C2=A0 = =C2=A0 =C2=A0exec_native_cmd(isohybrid_cmd, native_sysroot)
+
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0# Replace the image created by direct plugin wit= h the one created by
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0# mkisofs command. T= his is necessary because the iso image created by
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0# mkisofs has a very specific MBR is system area of the ISO image= , and
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0# direct plugin adds and configures= an another MBR.
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.debug("Replaceing= the image created by direct plugin\n")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0o= s.remove(disk.path)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0shutil.copy2(iso_img,= iso_img2)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0shutil.copy2(iso_img, full_pat= h_iso)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0shutil.copy2(full_path_iso, full_p= ath)
=C2=A0

>>> imagetypes_wic.bblass patch <&l= t;<
>>> INITRD -> INITRD_IMG =C2=A0 =C2=A0 =C2=A0 =C2= =A0<<<
>>> + ISOPAYLOADDIR =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 <<<

diff --git a/meta/classes/imagety= pes_wic.bbclass b/meta/classes/imagetypes_wic.bbclass
index 3b697cdd..= 0e36e8db 100644
--- a/meta/classes/imagetypes_wic.bbclass
+++ b/m= eta/classes/imagetypes_wic.bbclass
@@ -103,11 +103,12 @@ WIC_DEPLOY_PA= RTITIONS ?=3D "0"
=C2=A0# taken from OE, do not touch directly
= =C2=A0WICVARS +=3D "\
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BBLAYE= RS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD IMAGE_BASENAME IMAGE_BOOT_FILE= S \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 IMAGE_LINK_NAME IMAGE_ROOTFS = INITRAMFS_FSTYPES INITRD INITRD_LIVE ISODIR RECIPE_SYSROOT_NATIVE \
- = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ROOTFS_SIZE STAGING_DATADIR STAGING_DIR = STAGING_LIBDIR TARGET_SYS TRANSLATED_TARGET_ARCH"
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD_IMG= INITRD_LIVE ISODIR ISOPAYLOADDIR \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 RECIPE_SYSROOT_NATIVE ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_L= IBDIR TARGET_SYS \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 TRANSLATED_TAR= GET_ARCH"
=C2=A0
=C2=A0# Isar specific vars used in our plugins-WICVARS +=3D "DISTRO DISTRO_ARCH"
+WICVARS +=3D "DISTRO DISTRO_AR= CH KERNEL_IMAGETYPE ROOTFS_PACKAGE_SUFFIX"
=C2=A0
=C2=A0python do= _rootfs_wicenv () {
=C2=A0 =C2=A0 =C2=A0wicvars =3D d.getVar('WICVARS'= )


>>> imagetypes.bbclass patch <<<
= >>> + squashfs =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &l= t;<<
>>> support live boot =C2=A0 =C2=A0 =C2=A0 =C2=A0&= lt;<<

diff --git a/meta/classes/imagetypes.bbclass b/meta/= classes/imagetypes.bbclass
index a3be0a1d..f65c2368 100644
--- a/= meta/classes/imagetypes.bbclass
+++ b/meta/classes/imagetypes.bbclass<= br />@@ -3,6 +3,13 @@
=C2=A0#
=C2=A0# SPDX-License-Identifier: MI= T
=C2=A0
+#image type: squashfs
+IMAGER_INSTALL:squashfs += =3D "squashfs-tools"
+IMAGE_CMD:squashfs() {
+ =C2=A0 =C2=A0${SUD= O_CHROOT} /bin/mksquashfs \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0'${PP_ROOTFS}= ' '${IMAGE_FILE_CHROOT}' -noappend
+}
+
=C2=A0#image type: t= ar
=C2=A0IMAGER_INSTALL:tar =3D "tar"
=C2=A0TAR_TRANSFORM =3D "--= transform=3D's|rootfs|.|'"


Jan Kiszka schrieb am Dienstag, 5. Novem= ber 2024 um 16:39:28 UTC+1:
On 05.11.24 10:29, Herbert Bernecker wrote:
> Hi,
> i copied/modified isoimage-isohybrid-isar.py from isoimage-isohybr= id.py
> and used it to create a Debian Live ISO Image.
> Patches:
>=20

Do you consider this ready for production already? If so, would you lik= e
to submit a real patch for isar?

Jan

--=20
Siemens AG, Technology
Linux Expert Center

--
You received this message because you are subscribed to the Google Groups &= quot;isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to isar-use= rs+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-use= rs/5b51a525-2a0e-4fe0-873d-5d66c2b38ae5n%40googlegroups.com.
------=_Part_173103_837955881.1731916483559-- ------=_Part_173102_1377162621.1731916483559--