From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7071266692367646720 X-Received: by 2002:adf:f646:0:b0:1f0:4e5b:f423 with SMTP id x6-20020adff646000000b001f04e5bf423mr6605660wrp.2.1646407579540; Fri, 04 Mar 2022 07:26:19 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6000:2a9:b0:1ef:8a00:36a with SMTP id l9-20020a05600002a900b001ef8a00036als118940wry.0.gmail; Fri, 04 Mar 2022 07:26:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJ9nZ8NyhNaHLVIF4CYYkEj0H6JdSio1IRHMxXKM+5OW0OUZioYx/WZ4QHYC5wXZOlUSnD X-Received: by 2002:a5d:6d04:0:b0:1f0:7a8b:297a with SMTP id e4-20020a5d6d04000000b001f07a8b297amr2424779wrq.498.1646407578633; Fri, 04 Mar 2022 07:26:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646407578; cv=pass; d=google.com; s=arc-20160816; b=xuRr4ELf0darP4uKtqncsQwUpXjZuWUYAWUIXUZhtWJHFhUj6Ac4pBxtNASi1imEa3 RiuUBrOzcrCmXSYNDnGt8jiT6Qesu+IFD7l7iRaHMze83ziHBF4BTUiMMBfbvv7NYxQj Hh2Gh6m6QsbJcLPEvhjjage/6vrXVcRN5cYBik19uTlYubwPFl42rb3Hru7zRVGEkDyS fZ+bJzBImV6bA14AHQBZzfq94/o2p4WgQevSrY2ehhsVCbfGQzd8QAnVFGwAHUFT5KJ2 bngJ/Jp96VuHI4CDMt3f0wPP6Xii+GYqESiDxyzm8+r/N6LUqteeCDECbhRw6MJTFq0p wLKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ZYVGkh6tU8XV6ea3Ro8/Muw5yRj+82evvaILfYityIA=; b=sHOKpvrUXjOT4TfK7ecM/0xSoQKWvQ7vUDbqwdCcAMZd4ECcbxjpKiwiPrD5gjMnqa +sRiR4dUiEtZ6PeVw1zXxhouLmyDcz4ckiHny0+Nnv3lZZaPg7lM1WP36qmDNb7UVmRb c1D0B12u+USnXYjr+73+74XbAPMtYi6FC5UDbYERfAbOhe//0EO2iISYscjmt0YyIacB KpC7IdYBvazuXpcy+BrRfxCRQQAJvLVMMz2TXxk+9Ygj7D/y8cqKISC4cixXBJmxfff2 f6uS8J42khh1jfNwzR6beLjcHVCl/D1/KitoMTepJBydViMcqmbC57Og9JDtHwwZ8eBg AkZQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=J1FRPkI6; arc=pass (i=1 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of felix.moessbauer@siemens.com designates 2a01:111:f400:fe0e::622 as permitted sender) smtp.mailfrom=felix.moessbauer@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on0622.outbound.protection.outlook.com. [2a01:111:f400:fe0e::622]) by gmr-mx.google.com with ESMTPS id v193-20020a1cacca000000b003816971af44si155050wme.1.2022.03.04.07.26.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Mar 2022 07:26:18 -0800 (PST) Received-SPF: pass (google.com: domain of felix.moessbauer@siemens.com designates 2a01:111:f400:fe0e::622 as permitted sender) client-ip=2a01:111:f400:fe0e::622; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=J1FRPkI6; arc=pass (i=1 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of felix.moessbauer@siemens.com designates 2a01:111:f400:fe0e::622 as permitted sender) smtp.mailfrom=felix.moessbauer@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bbBJV0cod1Gs+bY2ATYYL2Af0/JRMDz24TYS0I0aD5pQ0A1gJziqqihR3QG6ltve5rhUtirBOfeMRNP/a75ibj48BqNbVsvqAyM53qUFH6ODh5mS7C8O3BN1MuTiWEkLiXsrPsZloEHUWdiaM9wrsII3rMqmCq1Q0UrmMltHbegdNQ2d87ojGjE4U2tQsgbStbAHZE3uSBqvf8T/rkBGOi3Iz1zqa3WHr2ZhxPVaL/gnSQLx7S+/2AvmFvBDqx88sm6aeSGOnvQiZhFkeJAAd+9D5Bm4FqKT/iWpqta7D5LmQJ1/WsmRrbZEWBbZo7ii80NKOlxYwRqWykzhbFf7MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZYVGkh6tU8XV6ea3Ro8/Muw5yRj+82evvaILfYityIA=; b=gs3fBgAAZGeLoD1sH3gLwLfQDP32CdVfj6VHmGoGJq7Us/7pHXEZ5B7x9m5F2DfY/w7aQbOg3GtE0D4FyKoxtDzUDXTr5B8rOtZAdtUNKEjKQS4O10DDxoF4UNJ9/rdqEDol+BZnU9y1q82BXBVI/9cA1K/vnZbyqOdDt6VHEWTaOyh96FudMk96tZspEg/VI0K+Ir5QUJI7yzsvCIfAp6ztoI+QGUQbCSeNw31d6LMC2HYxSFRFrRLAwqn/0YLkcicz00yCeoKhUgq5MhGdumkzSTQzuM6AgrYmgPO5p8IKlT6Ympki3DJyfn9vJRBnIe+hzbUd/jbXFzpjZfoTgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.73) smtp.rcpttodomain=googlegroups.com smtp.mailfrom=siemens.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZYVGkh6tU8XV6ea3Ro8/Muw5yRj+82evvaILfYityIA=; b=J1FRPkI6qxETSKd9nCJxIR6d2rwQ4n8FOs0rU3cIKB/2tJRQXwD6/x4GEe+LwJeIWTzRWQyahiZozfrG992KJ9YIzo1ihzOzlmJrfS1iA8qmpcN/yyTp/cG1IiIBmMTcPVILoJe7gt/+1xIEC4JCMmR8GiVh9bRWhHF8BvwCHIk4sSOcvemODtSd5Qj8Bgtuc/y5T7CE/m6Njo4H8hTYxhILQfj3anf8dJh0BuBdr3IYI22VYr/+p6BBouCjVcf5Qb4nrVPEzRjYDnOvwfhLFGoUQ/wmJ7Pd2VK3RSyj1PiaTuoSlKDWGQyKVjvvoGs5n1mHpa4AqSYfZgKjNT+wKw== Received: from DB6PR0802CA0033.eurprd08.prod.outlook.com (2603:10a6:4:a3::19) by AM4PR1001MB1236.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:200:98::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Fri, 4 Mar 2022 15:26:16 +0000 Received: from DB5EUR01FT046.eop-EUR01.prod.protection.outlook.com (2603:10a6:4:a3:cafe::7) by DB6PR0802CA0033.outlook.office365.com (2603:10a6:4:a3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.14 via Frontend Transport; Fri, 4 Mar 2022 15:26:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.73) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.73 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.73; helo=hybrid.siemens.com; Received: from hybrid.siemens.com (194.138.21.73) by DB5EUR01FT046.mail.protection.outlook.com (10.152.5.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Fri, 4 Mar 2022 15:26:16 +0000 Received: from DEMCHDC8A1A.ad011.siemens.net (139.25.226.107) by DEMCHDC9SNA.ad011.siemens.net (194.138.21.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Fri, 4 Mar 2022 16:26:16 +0100 Received: from felix-dev.test (139.21.146.184) by DEMCHDC8A1A.ad011.siemens.net (139.25.226.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Fri, 4 Mar 2022 16:26:15 +0100 From: Felix Moessbauer To: CC: , , , Felix Moessbauer Subject: [PATCH 1/4] Copy efi-plus-pcbios script from OE Date: Fri, 4 Mar 2022 16:25:50 +0100 Message-ID: <20220304152553.584534-2-felix.moessbauer@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220304152553.584534-1-felix.moessbauer@siemens.com> References: <20220304152553.584534-1-felix.moessbauer@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Return-Path: felix.moessbauer@siemens.com X-Originating-IP: [139.21.146.184] X-ClientProxiedBy: DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) To DEMCHDC8A1A.ad011.siemens.net (139.25.226.107) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 38b069b1-df71-4c73-ca91-08d9fdf3537a X-MS-TrafficTypeDiagnostic: AM4PR1001MB1236:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xEp/1qOzfDMLhDuiMU+aOgVEE2mYHEDWghN7795wqpmqedsdtpqNxeuXDTP2VwM3JTtwjnlp48uebJEIuhKqLkon6xubxYuItAlm/LOm1vWeHMJwG82/pMq5HVs+LOwxsNKXo4fCnZei4TIuD1pT8JtM+rOuYBpqWkrFIAN1C/l8em9PdEbFL641KTbffw2Lp6sCHaK5Wp+GllV0xEUoOEBsdyKKzunEPVMGayDFGoyuYvlW2XGH2DEDeF4eb+x0qlx1vGeheL42izox7gaYiByayUEwVrtSqvGFyo7uuKjHVDGb05cj+B8zSonaYroOhIi7MnulQs20Ja6+FITXdLO77Y7ALsm4hMoxyUBKiyrxbL0dgdWfxia9xfDtfs+utJuUiBGSWfXZXEm082r9V42gy9InJ0dz6BqTYWS38XYSqCG9K4WMwsslsZcVCF4ZXdCNkUKFPpCLtslVY64LKtOrHoFDdTWykPpml0qOtg5Z5fa3jq85aOhpgW6B9LR/NdA5JRsM33kknFiQcXTj2qUuRRYJ6hEaTmNm/6EtMo0SvXSuZ03tZk3jqPqRzRNQj0nBcJ/mJVpn2LN7dIWsTWEQ0e8QMQ1hU1HGSMZL0skGWpRJncO32gpVOCEPBIE5ygFVphYkimSxlojuYj1379oBjzpQuJuTtGWcznOy8RgBPAF07win3ImjJlsIxswsRr9AGs4KjAquX0zdiI6CL+ZrrDk3iOHiqc/d1OwG/5ryWEHdE+DCfvqFXIYzJ3mv X-Forefront-Antispam-Report: CIP:194.138.21.73;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:hybrid.siemens.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(44832011)(1076003)(6666004)(316002)(86362001)(83380400001)(8936002)(47076005)(6916009)(16526019)(36756003)(54906003)(336012)(36860700001)(40460700003)(26005)(186003)(2616005)(81166007)(5660300002)(956004)(82960400001)(356005)(82310400004)(107886003)(2906002)(4326008)(70206006)(70586007)(508600001)(8676002)(21314003)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2022 15:26:16.8291 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38b069b1-df71-4c73-ca91-08d9fdf3537a X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a;Ip=[194.138.21.73];Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR01FT046.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR1001MB1236 X-TUID: 9x9hoIBlzLht This adds a baseline for further modification to the efi-plus-pcbios WIC script. It helps to keep track of the ISAR related changes. Signed-off-by: Felix Moessbauer --- .../source/bootimg-biosplusefi-isar.py | 213 ++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 meta/scripts/lib/wic/plugins/source/bootimg-biosplusefi-isar.py diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-biosplusefi-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-biosplusefi-isar.py new file mode 100644 index 00000000..5bd73906 --- /dev/null +++ b/meta/scripts/lib/wic/plugins/source/bootimg-biosplusefi-isar.py @@ -0,0 +1,213 @@ +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# DESCRIPTION +# This implements the 'bootimg-biosplusefi' source plugin class for 'wic' +# +# AUTHORS +# William Bourque + +import types + +from wic.pluginbase import SourcePlugin +from importlib.machinery import SourceFileLoader + +class BootimgBiosPlusEFIPlugin(SourcePlugin): + """ + Create MBR + EFI boot partition + + This plugin creates a boot partition that contains both + legacy BIOS and EFI content. It will be able to boot from both. + This is useful when managing PC fleet with some older machines + without EFI support. + + Note it is possible to create an image that can boot from both + legacy BIOS and EFI by defining two partitions : one with arg + --source bootimg-efi and another one with --source bootimg-pcbios. + However, this method has the obvious downside that it requires TWO + partitions to be created on the storage device. + Both partitions will also be marked as "bootable" which does not work on + most BIOS, has BIOS often uses the "bootable" flag to determine + what to boot. If you have such a BIOS, you need to manually remove the + "bootable" flag from the EFI partition for the drive to be bootable. + Having two partitions also seems to confuse wic : the content of + the first partition will be duplicated into the second, even though it + will not be used at all. + + Also, unlike "isoimage-isohybrid" that also does BIOS and EFI, this plugin + allows you to have more than only a single rootfs partitions and does + not turn the rootfs into an initramfs RAM image. + + This plugin is made to put everything into a single /boot partition so it + does not have the limitations listed above. + + The plugin is made so it does tries not to reimplement what's already + been done in other plugins; as such it imports "bootimg-pcbios" + and "bootimg-efi". + Plugin "bootimg-pcbios" is used to generate legacy BIOS boot. + Plugin "bootimg-efi" is used to generate the UEFI boot. Note that it + requires a --sourceparams argument to know which loader to use; refer + to "bootimg-efi" code/documentation for the list of loader. + + Imports are handled with "SourceFileLoader" from importlib as it is + otherwise very difficult to import module that has hyphen "-" in their + filename. + The SourcePlugin() methods used in the plugins (do_install_disk, + do_configure_partition, do_prepare_partition) are then called on both, + beginning by "bootimg-efi". + + Plugin options, such as "--sourceparams" can still be passed to a + plugin, as long they does not cause issue in the other plugin. + + Example wic configuration: + part /boot --source bootimg-biosplusefi --sourceparams="loader=grub-efi"\\ + --ondisk sda --label os_boot --active --align 1024 --use-uuid + """ + + name = 'bootimg-biosplusefi' + + __PCBIOS_MODULE_NAME = "bootimg-pcbios" + __EFI_MODULE_NAME = "bootimg-efi" + + __imgEFIObj = None + __imgBiosObj = None + + @classmethod + def __init__(cls): + """ + Constructor (init) + """ + + # XXX + # For some reasons, __init__ constructor is never called. + # Something to do with how pluginbase works? + cls.__instanciateSubClasses() + + @classmethod + def __instanciateSubClasses(cls): + """ + + """ + + # Import bootimg-pcbios (class name "BootimgPcbiosPlugin") + modulePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), + cls.__PCBIOS_MODULE_NAME + ".py") + loader = SourceFileLoader(cls.__PCBIOS_MODULE_NAME, modulePath) + mod = types.ModuleType(loader.name) + loader.exec_module(mod) + cls.__imgBiosObj = mod.BootimgPcbiosPlugin() + + # Import bootimg-efi (class name "BootimgEFIPlugin") + modulePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), + cls.__EFI_MODULE_NAME + ".py") + loader = SourceFileLoader(cls.__EFI_MODULE_NAME, modulePath) + mod = types.ModuleType(loader.name) + loader.exec_module(mod) + cls.__imgEFIObj = mod.BootimgEFIPlugin() + + @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. + """ + + if ( (not cls.__imgEFIObj) or (not cls.__imgBiosObj) ): + cls.__instanciateSubClasses() + + cls.__imgEFIObj.do_install_disk( + disk, + disk_name, + creator, + workdir, + oe_builddir, + bootimg_dir, + kernel_dir, + native_sysroot) + + cls.__imgBiosObj.do_install_disk( + disk, + disk_name, + creator, + workdir, + oe_builddir, + bootimg_dir, + kernel_dir, + native_sysroot) + + @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() + """ + + if ( (not cls.__imgEFIObj) or (not cls.__imgBiosObj) ): + cls.__instanciateSubClasses() + + cls.__imgEFIObj.do_configure_partition( + part, + source_params, + creator, + cr_workdir, + oe_builddir, + bootimg_dir, + kernel_dir, + native_sysroot) + + cls.__imgBiosObj.do_configure_partition( + part, + source_params, + creator, + cr_workdir, + oe_builddir, + bootimg_dir, + kernel_dir, + native_sysroot) + + @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. + """ + + if ( (not cls.__imgEFIObj) or (not cls.__imgBiosObj) ): + cls.__instanciateSubClasses() + + cls.__imgEFIObj.do_prepare_partition( + part, + source_params, + creator, + cr_workdir, + oe_builddir, + bootimg_dir, + kernel_dir, + rootfs_dir, + native_sysroot) + + cls.__imgBiosObj.do_prepare_partition( + part, + source_params, + creator, + cr_workdir, + oe_builddir, + bootimg_dir, + kernel_dir, + rootfs_dir, + native_sysroot) -- 2.30.2