From patchwork Tue Jun 4 06:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schneider X-Patchwork-Id: 44640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D53EFC27C52 for ; Tue, 4 Jun 2024 06:50:48 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.77]) by mx.groups.io with SMTP id smtpd.web10.15188.1717483847654714346 for ; Mon, 03 Jun 2024 23:50:48 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@leica-geosystems.com header.s=selector1 header.b=RiPyp6i0; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: leica-geosystems.com, ip: 40.107.21.77, mailfrom: johannes.schneider@leica-geosystems.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kuaDvosgSiGRzJGFQHpeXiXoiMIkwxxxoMlx6KX9PLkeiojX2AEw/1AHh1Aa3SlibMWG1XACQ1M4EdsSjhKX80JzBvW0RabuA40PCBQyBQ+NhL8P0AdBwpAEGi4zzHwXo0MqXr3FuzxnGEzltG2AlKHqAu1QbrdiW5KP1lclukXa+U3XG4ylgHLgaKMcwZeLsicSCrXzJuX5hltidPsz4SfeMT3RKJUt0JRrSv/4zN/mObz6aFWpDK01T40U9RYPG0SOvwdRIsM0zWqwK4O+te7Vmg4OE6FIealRvZ0EPXKBwVk8O8Omd8g6Qlb/pVsnuRYtu8ZAiA/eEnIR0qydvQ== 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=S5sUXZjuJJyH9SPgxPwP7m6kjyu1rW4wJIucNRlRZu8=; b=PFHuUJS2gQP9R4geFdR/zyubHPrWQBk+9ogPbYQSk9yOxoV3qAC8xUahhWMIvo3stFTIxANI0052/w9hLJUoseWOMZpwYMRH0evORCmc8G8pBcWNxBuu/k4vqsnWWaufOoerKotFhNgHOnVHYogSzpLWxQVDn8//8WTkMOSp/l2LWEUgc6G6pp4w0t5c5LKRyZXGls3ZrR3pvbwtq4UqOAl7aC+0g2ePjhpD6rx+lw8A4HpQ6OUO8LvTuZWotyKOkTlwfnlRTJutRydkR+Ne/yNoMxXzXTQNtO2zj13BWyJfTiAtp/267vHo3L8CQY0uDBsxJur329pmn6Fl0ojzLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 193.8.40.94) smtp.rcpttodomain=lists.openembedded.org smtp.mailfrom=leica-geosystems.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=leica-geosystems.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leica-geosystems.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S5sUXZjuJJyH9SPgxPwP7m6kjyu1rW4wJIucNRlRZu8=; b=RiPyp6i0h9hvQWbPm3fzpz1WYq1mm0IwIE//Fbwq/pVpJUNqyVVA38hMIVDe+sGMW5/Jh1lSenN2Z/FH93Zt/k10Ja0eLGWIxtIquMzFYFwftt5J8SrfMIo9a/kA+OJZRXxSznvCHWBQ3GaNpX2YXlI9moal2azV5Z+gD6RVB1k= Received: from AM8P191CA0010.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::15) by DB9PR06MB8156.eurprd06.prod.outlook.com (2603:10a6:10:290::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.27; Tue, 4 Jun 2024 06:50:43 +0000 Received: from AM3PEPF0000A795.eurprd04.prod.outlook.com (2603:10a6:20b:21a:cafe::8) by AM8P191CA0010.outlook.office365.com (2603:10a6:20b:21a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31 via Frontend Transport; Tue, 4 Jun 2024 06:50:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 193.8.40.94) smtp.mailfrom=leica-geosystems.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=leica-geosystems.com; Received-SPF: Pass (protection.outlook.com: domain of leica-geosystems.com designates 193.8.40.94 as permitted sender) receiver=protection.outlook.com; client-ip=193.8.40.94; helo=hexagon.com; pr=C Received: from hexagon.com (193.8.40.94) by AM3PEPF0000A795.mail.protection.outlook.com (10.167.16.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Tue, 4 Jun 2024 06:50:42 +0000 Received: from aherlnxbspsrv01.lgs-net.com ([10.60.34.116]) by hexagon.com with Microsoft SMTPSVC(10.0.17763.1697); Tue, 4 Jun 2024 08:50:41 +0200 From: Johannes Schneider To: openembedded-core@lists.openembedded.org, richard.purdie@linuxfoundation.org, alex.kanavin@gmail.com, alexandre.belloni@bootlin.com CC: Johannes Schneider Subject: [PATCH v11 1/3] image.bbclass/rootfs: archive and deploy package database Date: Tue, 4 Jun 2024 08:50:38 +0200 Message-ID: <20240604065040.2771-2-johannes.schneider@leica-geosystems.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604065040.2771-1-johannes.schneider@leica-geosystems.com> References: <20240604065040.2771-1-johannes.schneider@leica-geosystems.com> MIME-Version: 1.0 X-OriginalArrivalTime: 04 Jun 2024 06:50:41.0844 (UTC) FILETIME=[843FFF40:01DAB64B] X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM3PEPF0000A795:EE_|DB9PR06MB8156:EE_ X-MS-Office365-Filtering-Correlation-Id: d6fc6bba-1363-4a12-c91a-08dc8462a76a X-SET-LOWER-SCL-SCANNER: YES X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|1800799015|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: oqVLotuHR9CkSMY84H0HTiNtD6kj11o19bU2DRkarXZqdDR5diZUEfkaupPca84hQPY6rn4rfkCHge1CI1paI6z/fPEldGCgN0t+pSHEY2yjVvGM3T/IZWVw4P4fZ9OCXPAHyVYhz77lXpLV8vADqY0/sdmq0K8gToyadFOQrRMbgfbVA0mHBHj3j25pAo6it8G5EKIkXCkZ64ix8rtUn6v58WyNQIQFKAxFBTDOUqltCfSNmQrUU9bCjzFEgyZdHLFWqivHXvfYEtUbQxwKkQ8FK06RpfStL+m4wwJGsUWfJ4tXxxyzZofK97miZEsN4K1s0OTYJuVjAi8pD1Y8AKH1DVda1SnsxwkXLYaZqn9s2Se79/K4U0F2WQuA2qyJoCrRZwfYhXwN9WUdY4f3nqmI6yg0WMMwFA3em4Vo3vuLtdOcUwHeqRfibfD1ovVX3ROMN49SrZhPEGPD6abyg9zUSHn4BX0d8Lx3CMzuERKd0DuguH9OS25pm0kaeE/8QsFrCOObte2ft+8XMGLk+nax3QvNY/EdNgMGo4UgdZnu2fqzysp22ciw5e5BXQUznMJPiuE0RafCgYNNZNMQ9uoABk6HbsOewt5oG3Pdpd5bVj++fopyna+XsAtxwNyLfsHrfvvr3VQaHkFzo2EjoOLMKhO7cDCgl6YzEwu/GRM10RRsjDXjD2qpxyrBt1V4EyLF6rcFAUqcbaH3JPeOsZVoxSgHzVVWIjD4Rj4qJvOBwrFGSNLd7LoJcGHphcSZ3WRizijoTBF+yQdDAKptxq+qSO6EbhZVUsrwJCyBTr4FbFQzh+wVmkeTnR0o7hZ8aEsBjQ4i1DNwuAo7aXZqF2SEUnpr93kzVw2XkJDwLNNclqz0BorSVl31nqD8UPsqZveY++hLVSK1sHWKJ1XjMa7K36Szp2izzbuPNN/rleTuY/8PiHaGGxWJQOYxb/J/v9Aqpb5ogYZ9GEWsq0SEKqqXFNxFwU9SWCjbNVaxoKQJRR+DIcTg3Pb8rMOLTmpfGruEzrjiZpbOcMjV0IjzSqNFC8rGHnkVw5lVWWtx1kEOgC4v+fjr5Yr6M8/bj+Mzwy+ekkORDqyEVxzljOEYAVAB33b3I0FjP81e2FRt/gYjM68f+Z0cMBvm/iIpUfgDTVkOBzD/HwweajH/DJiiK3L3DPdrRU+3F/uXtQBQnf4qMxnaStxt7Ccp5D8cCldtigfg+SdQ0Jjlw42GDIOzUCeqCRa7XgTZIvTgV+2yaQxnTGu6GPdUkHhWOUc7T4MwhkdfcaN6oOt4QH5VXM5dNAx1IDaHvIN0vOowGsddmJRMub/AwQo9BTmZRTYc2+jT X-Forefront-Antispam-Report: CIP:193.8.40.94;CTRY:CH;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:hexagon.com;PTR:ahersrvdom50.leica-geosystems.com;CAT:NONE;SFS:(13230031)(376005)(1800799015)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: leica-geosystems.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2024 06:50:42.9753 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d6fc6bba-1363-4a12-c91a-08dc8462a76a X-MS-Exchange-CrossTenant-Id: 1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a;Ip=[193.8.40.94];Helo=[hexagon.com] X-MS-Exchange-CrossTenant-AuthSource: AM3PEPF0000A795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR06MB8156 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 04 Jun 2024 06:50:48 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/200294 archive the package database after the rootfs has been put together as *rootfs-pkdbfs.tar.gz, and put it into the deploy folder. This creates a snapshot of the package mangers state at the point in time when all dependencies have been resolved and installed; which could be used by "extension images" to built upon. Signed-off-by: Johannes Schneider --- meta/classes-recipe/image.bbclass | 44 +++++- meta/classes-recipe/image_types.bbclass | 1 + meta/conf/documentation.conf | 1 + meta/lib/oe/package_manager/deb/rootfs.py | 1 + meta/lib/oe/package_manager/ipk/rootfs.py | 1 + meta/lib/oe/package_manager/rpm/rootfs.py | 1 + meta/lib/oe/rootfs.py | 20 +++ meta/lib/oeqa/selftest/cases/imagefeatures.py | 146 ++++++++++++++++++ 8 files changed, 214 insertions(+), 1 deletion(-) diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass index 28be6c6362..3ccaaa17b8 100644 --- a/meta/classes-recipe/image.bbclass +++ b/meta/classes-recipe/image.bbclass @@ -42,6 +42,9 @@ IMAGE_FEATURES ?= "" IMAGE_FEATURES[type] = "list" IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs read-only-rootfs-delayed-postinsts stateless-rootfs empty-root-password allow-empty-password allow-root-login serial-autologin-root post-install-logging overlayfs-etc" +# Generate snapshot of the package database? +IMAGE_GEN_PKGDBFS ?= "0" + # Generate companion debugfs? IMAGE_GEN_DEBUGFS ?= "0" @@ -131,7 +134,8 @@ def rootfs_variables(d): 'IMAGE_ROOTFS_MAXSIZE','IMAGE_NAME','IMAGE_LINK_NAME','IMAGE_MANIFEST','DEPLOY_DIR_IMAGE','IMAGE_FSTYPES','IMAGE_INSTALL_COMPLEMENTARY','IMAGE_LINGUAS', 'IMAGE_LINGUAS_COMPLEMENTARY', 'IMAGE_LOCALES_ARCHIVE', 'MULTILIBRE_ALLOW_REP','MULTILIB_TEMP_ROOTFS','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS', 'PACKAGE_ARCHS','PACKAGE_CLASSES','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','OVERRIDES','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI','INTERCEPT_DIR','USE_DEVFS', - 'CONVERSIONTYPES', 'IMAGE_GEN_DEBUGFS', 'ROOTFS_RO_UNNEEDED', 'IMGDEPLOYDIR', 'PACKAGE_EXCLUDE_COMPLEMENTARY', 'REPRODUCIBLE_TIMESTAMP_ROOTFS', 'IMAGE_INSTALL_DEBUGFS'] + 'CONVERSIONTYPES', 'IMAGE_GEN_PKGDBFS', 'IMAGE_GEN_DEBUGFS', 'ROOTFS_RO_UNNEEDED', 'IMGDEPLOYDIR', 'PACKAGE_EXCLUDE_COMPLEMENTARY', 'REPRODUCIBLE_TIMESTAMP_ROOTFS', + 'IMAGE_INSTALL_DEBUGFS'] variables.extend(rootfs_command_variables(d)) variables.extend(variable_depends(d)) return " ".join(variables) @@ -337,6 +341,17 @@ python do_image_qa_setscene () { } addtask do_image_qa_setscene +def setup_pkgdbfs_variables(d): + d.appendVar('IMAGE_ROOTFS', '-pkgdb') + if d.getVar('IMAGE_LINK_NAME'): + d.appendVar('IMAGE_LINK_NAME', '-pkgdb') + d.appendVar('IMAGE_NAME','-pkgdb') + d.setVar('IMAGE_FSTYPES', 'tar.gz') + +python setup_pkgdbfs () { + setup_pkgdbfs_variables(d) +} + def setup_debugfs_variables(d): d.appendVar('IMAGE_ROOTFS', '-dbg') if d.getVar('IMAGE_LINK_NAME'): @@ -381,6 +396,11 @@ python () { alltypes = d.getVar('IMAGE_FSTYPES').split() typedeps = {} + if d.getVar('IMAGE_GEN_PKGDBFS') == "1": + pkgdbfs_fstypes = ['tar.gz'] + for t in pkgdbfs_fstypes: + alltypes.append("pkgdbfs_" + t) + if d.getVar('IMAGE_GEN_DEBUGFS') == "1": debugfs_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS').split() for t in debugfs_fstypes: @@ -393,6 +413,10 @@ python () { basetypes[baset]= [] if t not in basetypes[baset]: basetypes[baset].append(t) + pkgdb = "" + if t.startswith("pkgdbfs_"): + t = t[8:] + pkgdb = "pkgdbfs_" debug = "" if t.startswith("debugfs_"): t = t[8:] @@ -401,6 +425,13 @@ python () { vardeps.add('IMAGE_TYPEDEP:' + t) if baset not in typedeps: typedeps[baset] = set() + deps = [pkgdb + dep for dep in deps] + for dep in deps: + if dep not in alltypes: + alltypes.append(dep) + _add_type(dep) + basedep = _image_base_type(dep) + typedeps[baset].add(basedep) deps = [debug + dep for dep in deps] for dep in deps: if dep not in alltypes: @@ -419,6 +450,7 @@ python () { maskedtypes = (d.getVar('IMAGE_TYPES_MASKED') or "").split() maskedtypes = [dbg + t for t in maskedtypes for dbg in ("", "debugfs_")] + maskedtypes = [pkgdb + t for t in maskedtypes for pkgdb in ("", "pkgdbfs_")] for t in basetypes: vardeps = set() @@ -430,6 +462,11 @@ python () { continue localdata = bb.data.createCopy(d) + pkgdb = "" + if t.startswith("pkgdbfs_"): + setup_pkgdbfs_variables(localdata) + pkgdb = "setup_pkgdbfs " + realt = t[8:] debug = "" if t.startswith("debugfs_"): setup_debugfs_variables(localdata) @@ -468,6 +505,8 @@ python () { for ctype in sorted(ctypes): if bt.endswith("." + ctype): type = bt[0:-len(ctype) - 1] + if type.startswith("pkgdbfs_"): + type = type[8:] if type.startswith("debugfs_"): type = type[8:] # Create input image first. @@ -509,6 +548,9 @@ python () { d.setVarFlag(task, 'fakeroot', '1') d.appendVarFlag(task, 'prefuncs', ' ' + debug + ' set_image_size') + if pkgdb: + d.appendVarFlag(task, 'prefuncs', ' ' + pkgdb + ' set_image_size') + d.prependVarFlag(task, 'postfuncs', 'create_symlinks ') d.appendVarFlag(task, 'subimages', ' ' + ' '.join(subimages)) d.appendVarFlag(task, 'vardeps', ' ' + ' '.join(vardeps)) diff --git a/meta/classes-recipe/image_types.bbclass b/meta/classes-recipe/image_types.bbclass index 2f948ecbf8..42842bb44a 100644 --- a/meta/classes-recipe/image_types.bbclass +++ b/meta/classes-recipe/image_types.bbclass @@ -25,6 +25,7 @@ def imagetypes_getdepends(d): fstypes = set((d.getVar('IMAGE_FSTYPES') or "").split()) fstypes |= set((d.getVar('IMAGE_FSTYPES_DEBUGFS') or "").split()) + fstypes |= set('tar.gz') # hardcoded for 'pkgdbfs' deprecated = set() deps = set() diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf index b0591881ba..36aebb59ab 100644 --- a/meta/conf/documentation.conf +++ b/meta/conf/documentation.conf @@ -215,6 +215,7 @@ IMAGE_FEATURES[doc] = "The primary list of features to include in an image. Conf IMAGE_FSTYPES[doc] = "Formats of root filesystem images that you want to have created." IMAGE_FSTYPES_DEBUGFS[doc] = "Formats of the debug root filesystem images that you want to have created." IMAGE_GEN_DEBUGFS[doc] = "When set to '1', generate a companion debug object/source filesystem image." +IMAGE_GEN_PKGDBFS[doc] = "When set to '1', create a snapshot of the package-manager state after the rootfs has been assembled." IMAGE_INSTALL[doc] = "Specifies the packages to install into an image. Image recipes set IMAGE_INSTALL to specify the packages to install into an image through image.bbclass." IMAGE_LINGUAS[doc] = "Specifies the list of locales to install into the image during the root filesystem construction process." IMAGE_NAME[doc] = "The name of the output image files minus the extension." diff --git a/meta/lib/oe/package_manager/deb/rootfs.py b/meta/lib/oe/package_manager/deb/rootfs.py index 1e25b64ed9..43107c8663 100644 --- a/meta/lib/oe/package_manager/deb/rootfs.py +++ b/meta/lib/oe/package_manager/deb/rootfs.py @@ -178,6 +178,7 @@ class PkgRootfs(DpkgOpkgRootfs): if self.progress_reporter: self.progress_reporter.next_stage() + self._setup_pkg_db_rootfs(['/var/lib/dpkg']) self._setup_dbg_rootfs(['/var/lib/dpkg']) self.pm.fix_broken_dependencies() diff --git a/meta/lib/oe/package_manager/ipk/rootfs.py b/meta/lib/oe/package_manager/ipk/rootfs.py index ba93eb62ea..64d9bc7969 100644 --- a/meta/lib/oe/package_manager/ipk/rootfs.py +++ b/meta/lib/oe/package_manager/ipk/rootfs.py @@ -319,6 +319,7 @@ class PkgRootfs(DpkgOpkgRootfs): opkg_lib_dir = self.d.getVar('OPKGLIBDIR') opkg_dir = os.path.join(opkg_lib_dir, 'opkg') + self._setup_pkg_db_rootfs([opkg_dir]) self._setup_dbg_rootfs([opkg_dir]) execute_pre_post_process(self.d, opkg_post_process_cmds) diff --git a/meta/lib/oe/package_manager/rpm/rootfs.py b/meta/lib/oe/package_manager/rpm/rootfs.py index 3ba5396320..673006c131 100644 --- a/meta/lib/oe/package_manager/rpm/rootfs.py +++ b/meta/lib/oe/package_manager/rpm/rootfs.py @@ -110,6 +110,7 @@ class PkgRootfs(Rootfs): if self.progress_reporter: self.progress_reporter.next_stage() + self._setup_pkg_db_rootfs(['/etc/rpm', '/etc/rpmrc', '/etc/dnf', '/var/lib/rpm', '/var/cache/dnf', '/var/lib/dnf']) self._setup_dbg_rootfs(['/etc/rpm', '/etc/rpmrc', '/etc/dnf', '/var/lib/rpm', '/var/cache/dnf', '/var/lib/dnf']) execute_pre_post_process(self.d, rpm_post_process_cmds) diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py index 8cd48f9450..6d6e888a30 100644 --- a/meta/lib/oe/rootfs.py +++ b/meta/lib/oe/rootfs.py @@ -106,6 +106,26 @@ class Rootfs(object, metaclass=ABCMeta): def _cleanup(self): pass + def _setup_pkg_db_rootfs(self, package_paths): + gen_pkg_db_fs = bb.utils.to_boolean(self.d.getVar('IMAGE_GEN_PKGDBFS')) + if not gen_pkg_db_fs: + return + + bb.note(" Creating pkg-db rootfs...") + try: + shutil.rmtree(self.image_rootfs + '-pkgdb') + except (FileNotFoundError, NotADirectoryError): + pass + bb.utils.mkdirhier(self.image_rootfs + "-pkgdb") + + bb.note(" Copying back package database...") + for path in package_paths: + bb.utils.mkdirhier(self.image_rootfs + os.path.dirname(path)) + if os.path.isdir(self.image_rootfs + path): + shutil.copytree(self.image_rootfs + path, self.image_rootfs + '-pkgdb' + path, symlinks=True) + elif os.path.isfile(self.image_rootfs + path): + shutil.copyfile(self.image_rootfs + path, self.image_rootfs + '-pkgdb' + path) + def _setup_dbg_rootfs(self, package_paths): gen_debugfs = self.d.getVar('IMAGE_GEN_DEBUGFS') or '0' if gen_debugfs != '1': diff --git a/meta/lib/oeqa/selftest/cases/imagefeatures.py b/meta/lib/oeqa/selftest/cases/imagefeatures.py index dc88c222bd..3c65087afd 100644 --- a/meta/lib/oeqa/selftest/cases/imagefeatures.py +++ b/meta/lib/oeqa/selftest/cases/imagefeatures.py @@ -302,6 +302,152 @@ SKIP_RECIPE[busybox] = "Don't build this" result = runCmd('objdump --syms %s | grep debug' % t) self.assertTrue("debug" in result.output, msg='Failed to find debug symbol: %s' % result.output) + def test_image_gen_pkgdbfs_ipk(self): + """ + Summary: Check pkgdb snapshot + Expected: 1. core-image-minimal can be build with IMAGE_GEN_PKGDBFS variable set + 2. *rootfs-pkgdb.tar.gz snapshot of the package manager state is created, + after the rootfs of the core-image-minimal is put together + 3. check that the restored package index is usable by the default packagemanager + PACKAGE_CLASS=package_ipk -> opkg in this case. + """ + + image = 'core-image-minimal' + features = 'IMAGE_GEN_PKGDBFS = "1"\n' + features += 'PACKAGE_CLASSES = "package_ipk"\n' + self.write_config(features) + + # forcing the regeneration of the rootfs to have an up-to-date package index + # then creating the backup = pkgdbfs + # and finally forcing the deploy step, to have the pkgdb.tar.gz available in the DEPLOY_DIR_IMAGE + bitbake(image + ' -c rootfs -f -c image_pkgdbfs_tar -f -c image_complete -f') + + img_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME', 'MACHINE', 'DEFAULTTUNE'], image) + + tar_file = os.path.join(img_vars['DEPLOY_DIR_IMAGE'], "%s-pkgdb.tar.gz" % (img_vars['IMAGE_LINK_NAME'])) + self.assertTrue(os.path.exists(tar_file), 'pkgdb filesystem not generated at %s' % tar_file) + result = runCmd('cd %s; tar xvf %s' % (img_vars['DEPLOY_DIR_IMAGE'], tar_file)) + self.assertEqual(result.status, 0, msg='Failed to extract %s: %s' % (tar_file, result.output)) + self.assertTrue(os.path.exists(os.path.join(img_vars['DEPLOY_DIR_IMAGE'], 'var/lib/opkg/status')), 'opkg\'s status file was not present in: %s' % tar_file) + + bitbake('opkg-native -c addto_recipe_sysroot') + + sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "opkg-native") + # some 'add-arch' have '-' replaced by '_', some not; adding both does not hurt + cmd = 'opkg --volatile-cache --offline-root=%s --add-arch %s:11 --add-arch %s:12 list-installed' \ + % (img_vars['DEPLOY_DIR_IMAGE'], img_vars["MACHINE"], img_vars["MACHINE"].replace('-','_')) + self.logger.debug('in native_sysroot %s, running cmd: %s' % (sysroot, cmd)) + result = runCmd(cmd, native_sysroot=sysroot) + self.logger.debug("list-installed:\n%s" % result.output) + self.assertEqual(result.status, 0, msg='Failed to run package manager on unpacked pkgdb %s: %s' % (tar_file, result.output)) + # check for a 'random, very architecture specific' package + if 'qemux86' in img_vars['MACHINE']: + self.assertTrue("kernel-image" in result.output, msg='Failed query installed packages') + if 'qemuarm' in img_vars['MACHINE']: + self.assertTrue("core-boot" in result.output, msg='Failed query installed packages') + + cmd = 'opkg --volatile-cache --offline-root=%s --add-arch %s:11 --add-arch %s:12 list-installed' \ + % (img_vars['DEPLOY_DIR_IMAGE'], img_vars["DEFAULTTUNE"], img_vars["DEFAULTTUNE"].replace('-','_')) + self.logger.debug('in native_sysroot %s, running cmd: %s' % (sysroot, cmd)) + result = runCmd(cmd, native_sysroot=sysroot) + self.logger.debug("list-installed:\n%s" % result.output) + self.assertEqual(result.status, 0, msg='Failed to run package manager on unpacked pkgdb %s: %s' % (tar_file, result.output)) + # check for a common base package, a random library for example: + self.assertTrue("libc6" in result.output, msg='Failed query installed packages') + + def test_image_gen_pkgdbfs_deb(self): + """ + Summary: Check pkgdb snapshot + Expected: 1. core-image-minimal can be build with IMAGE_GEN_PKGDBFS variable set + 2. *rootfs-pkgdb.tar.gz snapshot of the package manager state is created, + after the rootfs of the core-image-minimal is put together + 3. check that the restored package index is usable by the packagemanager + PACKAGE_CLASS=package_deb -> dpkg in this case. + """ + + image = 'core-image-minimal' + features = 'IMAGE_GEN_PKGDBFS = "1"\n' + features += 'PACKAGE_CLASSES = "package_deb"\n' + self.write_config(features) + + # forcing the regeneration of the rootfs to have an up-to-date package index + # then creating the backup = pkgdbfs + # and finally forcing the deploy step, to have the pkgdb.tar.gz available in the DEPLOY_DIR_IMAGE + bitbake(image + ' -c rootfs -f -c image_pkgdbfs_tar -f -c image_complete -f') + + img_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME', 'MACHINE', 'DEFAULTTUNE'], image) + + tar_file = os.path.join(img_vars['DEPLOY_DIR_IMAGE'], "%s-pkgdb.tar.gz" % (img_vars['IMAGE_LINK_NAME'])) + self.assertTrue(os.path.exists(tar_file), 'pkgdb filesystem not generated at %s' % tar_file) + result = runCmd('cd %s; tar xvf %s' % (img_vars['DEPLOY_DIR_IMAGE'], tar_file)) + self.assertEqual(result.status, 0, msg='Failed to extract %s: %s' % (tar_file, result.output)) + self.assertTrue(os.path.exists(os.path.join(img_vars['DEPLOY_DIR_IMAGE'], 'var/lib/dpkg/status')), 'dpkg\'s status file was not present in: %s' % tar_file) + + bitbake('dpkg-native -c addto_recipe_sysroot') + + sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "dpkg-native") + cmd = 'dpkg --admindir=%s/var/lib/dpkg --get-selections' \ + % (img_vars['DEPLOY_DIR_IMAGE']) + self.logger.debug('in native_sysroot %s, running cmd: %s' % (sysroot, cmd)) + result = runCmd(cmd, native_sysroot=sysroot) + self.logger.debug("list-installed:\n%s" % result.output) + self.assertEqual(result.status, 0, msg='Failed to run package manager on unpacked pkgdb %s: %s' % (tar_file, result.output)) + + # check for a 'random, very architecture specific' package + if 'qemux86' in img_vars['MACHINE']: + self.assertTrue("kernel-image" in result.output, msg='Failed query installed packages') + if 'qemuarm' in img_vars['MACHINE']: + self.assertTrue("core-boot" in result.output, msg='Failed query installed packages') + # check for a common base package, a random library for example: + self.assertTrue("libc6" in result.output, msg='Failed query installed packages') + + def test_image_gen_pkgdbfs_rpm(self): + """ + Summary: Check pkgdb snapshot + Expected: 1. core-image-minimal can be build with IMAGE_GEN_PKGDBFS variable set + 2. *rootfs-pkgdb.tar.gz snapshot of the package manager state is created, + after the rootfs of the core-image-minimal is put together + 3. check that the restored package index is usable by the packagemanager + PACKAGE_CLASS=package_rpm -> dnf in this case. + """ + + image = 'core-image-minimal' + features = 'IMAGE_GEN_PKGDBFS = "1"\n' + features += 'PACKAGE_CLASSES = "package_rpm"\n' + self.write_config(features) + + # forcing the regeneration of the rootfs to have an up-to-date package index + # then creating the backup = pkgdbfs + # and finally forcing the deploy step, to have the pkgdb.tar.gz available in the DEPLOY_DIR_IMAGE + bitbake(image + ' -c rootfs -f -c image_pkgdbfs_tar -f -c image_complete -f') + + img_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME', 'MACHINE', 'DEFAULTTUNE'], image) + + tar_file = os.path.join(img_vars['DEPLOY_DIR_IMAGE'], "%s-pkgdb.tar.gz" % (img_vars['IMAGE_LINK_NAME'])) + self.assertTrue(os.path.exists(tar_file), 'pkgdb filesystem not generated at %s' % tar_file) + result = runCmd('cd %s; tar xvf %s' % (img_vars['DEPLOY_DIR_IMAGE'], tar_file)) + self.assertEqual(result.status, 0, msg='Failed to extract %s: %s' % (tar_file, result.output)) + self.assertTrue(os.path.exists(os.path.join(img_vars['DEPLOY_DIR_IMAGE'], 'var/lib/rpm/rpmdb.sqlite')), 'rpms\'s database file was not present in: %s' % tar_file) + + bitbake('rpm-native -c addto_recipe_sysroot') + + sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "rpm-native") + # some 'add-arch' have '-' replaced by '_', some not; adding both does not hurt + cmd = 'rpm --dbpath=%s/var/lib/rpm/ --query --all' \ + % (img_vars['DEPLOY_DIR_IMAGE']) + self.logger.debug('in native_sysroot %s, running cmd: %s' % (sysroot, cmd)) + result = runCmd(cmd, native_sysroot=sysroot) + self.logger.debug("list-installed:\n%s" % result.output) + self.assertEqual(result.status, 0, msg='Failed to run package manager on unpacked pkgdb %s: %s' % (tar_file, result.output)) + + # check for a 'random, very architecture specific' package + if 'qemux86' in img_vars['MACHINE']: + self.assertTrue("kernel-image" in result.output, msg='Failed query installed packages') + if 'qemuarm' in img_vars['MACHINE']: + self.assertTrue("core-boot" in result.output, msg='Failed query installed packages') + # check for a common base package, a random library for example: + self.assertTrue("libc6" in result.output, msg='Failed query installed packages') + def test_empty_image(self): """Test creation of image with no packages""" image = 'test-empty-image'