From patchwork Tue Aug 20 20:35:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Kjellerstedt X-Patchwork-Id: 48014 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 28994C531DC for ; Tue, 20 Aug 2024 20:35:49 +0000 (UTC) Received: from AM0PR83CU005.outbound.protection.outlook.com (AM0PR83CU005.outbound.protection.outlook.com [52.101.69.11]) by mx.groups.io with SMTP id smtpd.web10.4785.1724186147775523259 for ; Tue, 20 Aug 2024 13:35:48 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@axis.com header.s=selector1 header.b=TG0PzHdR; spf=pass (domain: axis.com, ip: 52.101.69.11, mailfrom: peter.kjellerstedt@axis.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RV8ynB3mn11nocVHjFFKRyBByhyJedREGxEesuBbuT7o4kjv2+Rs9LgWvUB+zaTTEzIBv0MhYtYaBowUaeeIPTfHTWiTl19JA73UJxTzy4mxYcrrSqP3vs7K36GgzL7grN6xK2GrNM+SS986JRONWscILBSNkKZoiORiSHrJSrBPTV69y55RFY/hRONv4g6IsNBr1ja00Vn8dOZ784y6aJdTtdQOd+OMfzwSzu7IGf5tFaPrHGD2UwcPSTNHtAfMMs87MzqNBTUYXI6u2MNaqKXXOX2KfMQyG0KfEHRmo4K6zX+ub9sQyE6r4sajr+NgYNxIfqo7liGR4+Iukt7FNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=r/aGQWboarU/YiNF9WHRCkFNnHjXyCz4TMUE5cg//Ik=; b=eAYN98g5XHMg/Kj/NFXjeck5U0PgV7EFEb2qb2qDh1CI3ppS6AguecS+UTeEQvZeoUArA4I8GMOQFMY8MREPpSa/HzoYaSdFTOIdRtJ+ljyvTnV3okNEHvABvOdcbmNxB2YCTVopi5QYd23tPeTGO4TkG7DkMJH5n3yqC9102R4Fhx5kQR03yM7Jw9Jcqhm2AEWSPw12FsL3I2YfutaFsrHK2f0t33gQbYytClpq5f4vV7+JprnLclBLWbNK1wF1IIkW2zVsLZ0LUbc3nfAjBITGJhTgMmd9Qy4RD+gbkBEma7vWfmCwb9/JeD7Jtp99zFuGymvUpINMXjV2wqtkww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=lists.openembedded.org smtp.mailfrom=axis.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r/aGQWboarU/YiNF9WHRCkFNnHjXyCz4TMUE5cg//Ik=; b=TG0PzHdRZCBoQlaC18DMjh4xofvogcCMjLU1Te+iq7tJXoBO2llgqEUme5R2LEhkDN4PSDbLzQTsny7Q1m4pIJARTeqy1lmu0VhmQ0EUIZSZIBbMCxm+3vTnL/ZlKASN4hf3QIzyOv+R7ZIpq9O1zm4RDmnJcMWAuz2erziOQt4= Received: from AS9PR06CA0731.eurprd06.prod.outlook.com (2603:10a6:20b:487::22) by PAWPR02MB10321.eurprd02.prod.outlook.com (2603:10a6:102:365::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Tue, 20 Aug 2024 20:35:42 +0000 Received: from AMS0EPF000001A4.eurprd05.prod.outlook.com (2603:10a6:20b:487:cafe::f1) by AS9PR06CA0731.outlook.office365.com (2603:10a6:20b:487::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.25 via Frontend Transport; Tue, 20 Aug 2024 20:35:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001A4.mail.protection.outlook.com (10.167.16.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Tue, 20 Aug 2024 20:35:41 +0000 Received: from SE-MAILARCH01W.axis.com (10.20.40.15) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 20 Aug 2024 22:35:41 +0200 Received: from se-mail02w.axis.com (10.20.40.8) by SE-MAILARCH01W.axis.com (10.20.40.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 20 Aug 2024 22:35:41 +0200 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 20 Aug 2024 22:35:41 +0200 Received: from saur (saur.se.axis.com [10.92.3.10]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id EAAB81C3 for ; Tue, 20 Aug 2024 22:35:40 +0200 (CEST) Received: from saur.se.axis.com (localhost [127.0.0.1]) by saur (8.17.1/8.15.2) with ESMTPS id 47KKZeTe4166674 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Tue, 20 Aug 2024 22:35:40 +0200 Received: (from pkj@localhost) by saur.se.axis.com (8.17.1/8.17.1/Submit) id 47KKZehh4166673 for openembedded-core@lists.openembedded.org; Tue, 20 Aug 2024 22:35:40 +0200 From: Peter Kjellerstedt To: Subject: [PATCH 1/2] systemd.bbclass: Clean up empty parent directories Date: Tue, 20 Aug 2024 22:35:32 +0200 Message-ID: <20240820203533.4166641-1-pkj@axis.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A4:EE_|PAWPR02MB10321:EE_ X-MS-Office365-Filtering-Correlation-Id: eff355f4-a5f4-48b3-983f-08dcc157a8a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: Nn5bAE1mzlGx6XftTLrTFpO/quQEgxM5yf2DolssjEM27FJUPg3hf6XGab3P2c5pA2jvilTPyTEdkKIzdp5RMc4RBUMDZC2FcSQ3hzqwLjz/M5Njz4xmcKpinTsU20sQmEq3khzkTRiHcY2fTwf7huPZjT8l4vLmTZORp2VKy0INIvkyKDnDJAKtqLwupUrDA66IlCMRgreos60jmVknYVkUMuiEXvmvnKRFOI9M7PAArbq7HSFbMIGJZzX1wpcyk+tnX296DF20vlqEM1MwFJgQEzrW7C2+OEdrQpeLBT467cSx78MfyMasGxJgc48Ppfv75s3RaoNk0NPl09SkMvBpxguGt+0IC8UzQTGTs7OdmSC1w7DKWeD+0xqbX/iZPGqrtHXFdsjMWf3HpQIVCB701kmcgji2as86J0aGly/4zufRDIbRPUXqYTat+f/jE8ugK1fz4t41LwE5L4qH8d9GnuU2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;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 20:35:41.4908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eff355f4-a5f4-48b3-983f-08dcc157a8a3 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A4.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR02MB10321 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, 20 Aug 2024 20:35:49 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/203569 Previously, rm_systemd_unitdir() would remove one parent directory of ${systemd_unitdir} if it was empty after removing ${systemd_unitdir}. rm_sysvinit_initddir() would not remove any parent directory. Thus, if the only directory created in /etc was /etc/init.d, an empty /etc would remain after the cleanup and would be packaged. Simplify rm_systemd_unitdir() and rm_sysvinit_initddir() by rewriting them in shell, and use rmdir -p to remove all empty parent directories. Signed-off-by: Peter Kjellerstedt --- meta/classes-recipe/systemd.bbclass | 46 +++++++++++++---------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass index 0f7e3b5a08..987b3fc0c7 100644 --- a/meta/classes-recipe/systemd.bbclass +++ b/meta/classes-recipe/systemd.bbclass @@ -208,33 +208,29 @@ python systemd_populate_packages() { PACKAGESPLITFUNCS =+ "systemd_populate_packages" -python rm_systemd_unitdir (){ - import shutil - if not bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d): - systemd_unitdir = oe.path.join(d.getVar("D"), d.getVar('systemd_unitdir')) - if os.path.exists(systemd_unitdir): - shutil.rmtree(systemd_unitdir) - systemd_libdir = os.path.dirname(systemd_unitdir) - if (os.path.exists(systemd_libdir) and not os.listdir(systemd_libdir)): - os.rmdir(systemd_libdir) +rm_systemd_unitdir() { + rm -rf ${D}${systemd_unitdir} + rmdir -p $(dirname ${D}${systemd_unitdir}) 2>/dev/null || : + # Make sure ${D} still exists since rmdir -p may have removed it in + # case ${systemd_unitdir} was the only directory present. + [ -d ${D} ] || mkdir -p ${D} } -python rm_sysvinit_initddir (){ - import shutil - sysv_initddir = oe.path.join(d.getVar("D"), (d.getVar('INIT_D_DIR') or "/etc/init.d")) - - if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and \ - not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d) and \ - os.path.exists(sysv_initddir): - systemd_system_unitdir = oe.path.join(d.getVar("D"), d.getVar('systemd_system_unitdir')) +rm_sysvinit_initddir() { + local sysv_initddir=${INIT_D_DIR} + : ${sysv_initddir:=${sysconfdir}/init.d} - # If systemd_system_unitdir contains anything, delete sysv_initddir - if (os.path.exists(systemd_system_unitdir) and os.listdir(systemd_system_unitdir)): - shutil.rmtree(sysv_initddir) + # If systemd_system_unitdir contains anything, delete sysv_initddir + if find ${D}${systemd_system_unitdir} -mindepth 1 -maxdepth 1 2>/dev/null | read; then + rm -rf ${D}$sysv_initddir + rmdir -p $(dirname ${D}$sysv_initddir) 2>/dev/null || : + fi } -do_install[postfuncs] += "${RMINITDIR} " -RMINITDIR:class-target = " rm_sysvinit_initddir rm_systemd_unitdir " -RMINITDIR:class-nativesdk = " rm_sysvinit_initddir rm_systemd_unitdir " -RMINITDIR = "" - +do_install[postfuncs] += "${RMINITDIR}" +RMINITDIR = " \ + ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', 'rm_systemd_unitdir', d)} \ + ${@'rm_sysvinit_initddir' if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and \ + not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d) else ''} \ +" +RMINITDIR:class-native = "" From patchwork Tue Aug 20 20:35:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Kjellerstedt X-Patchwork-Id: 48015 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 E71D4C3DA4A for ; Tue, 20 Aug 2024 20:35:48 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (EUR03-DBA-obe.outbound.protection.outlook.com [40.107.104.68]) by mx.groups.io with SMTP id smtpd.web11.4707.1724186147227318555 for ; Tue, 20 Aug 2024 13:35:47 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@axis.com header.s=selector1 header.b=o7yv9VMI; spf=pass (domain: axis.com, ip: 40.107.104.68, mailfrom: peter.kjellerstedt@axis.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f+AA5LZTzOuKZTU4506x8InmfBE3HABul5c0bX2md13hu442YRuD3RcRAdS3sj/l+vuoSFCvomp5eBmgLiklRCsZr+zGovhSoYs63QibysSYYmXMJMSukKx2BPeDLppRVJS3zfxGezcMOmWbkszJa+HmL5f35uogbMfDgFDHyEuD+Eswztioggo8bAR93U1ZigBHosX5Xg11/ESuXm+65cWMkn+3UPnRlYzdrA8b3tGdvPjsvDKkF9aqfJCjG23KrlJCWdYXJ6vKws08FFJeQVxQ93JaZMV+GbmmHVi/lq6zxU/smTlyBr49M7m51xw6reT+9LuHPSE3Zl0FSdS6Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=qYQa6+Ss4uZO4mnNgBHG56j4fcsRAhn8gxnOnu78FoA=; b=pqcRe795Zb0Pa/fV0tfYny8rTvOvcibVaD0Izz4SRNKsSpsKHofipYfO+QtdyoYG2IOw2ot7sZCEQ+pF4Mxi3AH9p0U0tEdb49F0x+oaQL/hW1fpoNxn3OT7ugcxpcPg89sozhCAdZ3g6m6J+DRMU1KBK99J21sDvwQjsUg2tavbMUzkSX1XqIKmXRyzBdwtpqowVkezbPjNgy9OLL5J/5saxaeGW0VQElcjI6aZb60KAfn5TjPMmq9mXFNZTSpxxb6/le8IlBAFIZJ3Xq8KUtYL3SQlBByRB8xKL4mDS4rCDkDE5GLIFpi7F4FCX5I7o95OaU4CQznGGcB6y49BpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=lists.openembedded.org smtp.mailfrom=axis.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qYQa6+Ss4uZO4mnNgBHG56j4fcsRAhn8gxnOnu78FoA=; b=o7yv9VMIe8VeYF9ldf0AhS6+tEfap05yYZvY9FSh7qtetCw5nYPe0kCNKPcxTyPYlEJyXaZ3oPhpdJHeExGOJz03LHbyffSDssTKPtMsbKpfAj65liBPFT1unM4o59VqzRUg0kCEPQ3L0jyLYUZax27LXfQKldQgKha8bBU7G7Y= Received: from AS9PR06CA0747.eurprd06.prod.outlook.com (2603:10a6:20b:487::27) by PAXPR02MB7912.eurprd02.prod.outlook.com (2603:10a6:102:28d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16; Tue, 20 Aug 2024 20:35:43 +0000 Received: from AMS0EPF000001A4.eurprd05.prod.outlook.com (2603:10a6:20b:487:cafe::55) by AS9PR06CA0747.outlook.office365.com (2603:10a6:20b:487::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.25 via Frontend Transport; Tue, 20 Aug 2024 20:35:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001A4.mail.protection.outlook.com (10.167.16.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Tue, 20 Aug 2024 20:35:43 +0000 Received: from se-mail02w.axis.com (10.20.40.8) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 20 Aug 2024 22:35:41 +0200 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 20 Aug 2024 22:35:41 +0200 Received: from saur (saur.se.axis.com [10.92.3.10]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 231BB1C3 for ; Tue, 20 Aug 2024 22:35:41 +0200 (CEST) Received: from saur.se.axis.com (localhost [127.0.0.1]) by saur (8.17.1/8.15.2) with ESMTPS id 47KKZfq14166678 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Tue, 20 Aug 2024 22:35:41 +0200 Received: (from pkj@localhost) by saur.se.axis.com (8.17.1/8.17.1/Submit) id 47KKZffS4166677 for openembedded-core@lists.openembedded.org; Tue, 20 Aug 2024 22:35:41 +0200 From: Peter Kjellerstedt To: Subject: [PATCH 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction Date: Tue, 20 Aug 2024 22:35:33 +0200 Message-ID: <20240820203533.4166641-2-pkj@axis.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240820203533.4166641-1-pkj@axis.com> References: <20240820203533.4166641-1-pkj@axis.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A4:EE_|PAXPR02MB7912:EE_ X-MS-Office365-Filtering-Correlation-Id: fa1a7648-cae3-4c55-9c69-08dcc157a9ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: mPEx9ueSuD/0hV8rJ50w4sbK0wVwXTYoFuF5u8tgWB1GfWItu/2o2iUDsoqfL5n7mHJlWgBxJ+E+Hh7nzgjHuvAcImeN5lhQC6THboZ6Y9lmxcy3Ny0fNZLU48Uts+raSaO4vTECs4y2kss6skmSbjfYaru3nW3RUhKp3ad6b3UmOgJKfr4scYTYyNmEkX1Tggp0LkaHFjZpJ510rCTPi1hbiIkDh2rCv91ogZLAgTw0pJCEk3LkW0seM5L/LMBH4U/+P0Idle6hTyWwQRKEU73L/BJvNDa9ZrlHk6T8MMISZftvyzfYE2MHYmvIyKWbUJZtqL33NwC9cvyceyVv+LGeRU3aYwbF+7cbWGz4BKZFAhFzGiZCzldyY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efront-Antispam-Report: CIP:195.60.68.100;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 20:35:43.6470 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa1a7648-cae3-4c55-9c69-08dcc157a9ec X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A4.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR02MB7912 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, 20 Aug 2024 20:35:48 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/203568 These tests verify that the correct files are left behind when systemd is inherited and depending on whether the systemd and/or sysvinit distro features are enabled. Signed-off-by: Peter Kjellerstedt --- .../bbclasses/systemd-and-sysvinit.bb | 15 +++ .../recipes-test/bbclasses/systemd-only.bb | 10 ++ meta/lib/oeqa/selftest/cases/bbclasses.py | 106 ++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-only.bb create mode 100644 meta/lib/oeqa/selftest/cases/bbclasses.py diff --git a/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb new file mode 100644 index 0000000000..b820a10528 --- /dev/null +++ b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb @@ -0,0 +1,15 @@ +LICENSE = "CLOSED" + +inherit allarch systemd update-rc.d + +do_install() { + install -d ${D}${systemd_system_unitdir} + touch ${D}${systemd_system_unitdir}/${BPN}.service + + install -d ${D}${INIT_D_DIR} + touch ${D}${INIT_D_DIR}/${BPN} +} + +INITSCRIPT_NAME = "${BPN}" + +SYSTEMD_SERVICE:${PN} = "${BPN}.service" diff --git a/meta-selftest/recipes-test/bbclasses/systemd-only.bb b/meta-selftest/recipes-test/bbclasses/systemd-only.bb new file mode 100644 index 0000000000..3a28713cb5 --- /dev/null +++ b/meta-selftest/recipes-test/bbclasses/systemd-only.bb @@ -0,0 +1,10 @@ +LICENSE = "CLOSED" + +inherit allarch systemd + +do_install() { + install -d ${D}${systemd_system_unitdir} + touch ${D}${systemd_system_unitdir}/${BPN}.service +} + +SYSTEMD_SERVICE:${PN} = "${BPN}.service" diff --git a/meta/lib/oeqa/selftest/cases/bbclasses.py b/meta/lib/oeqa/selftest/cases/bbclasses.py new file mode 100644 index 0000000000..10545ebe65 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/bbclasses.py @@ -0,0 +1,106 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +from oeqa.selftest.case import OESelftestTestCase +from oeqa.utils.commands import get_bb_vars, bitbake + +class Systemd(OESelftestTestCase): + """ + Tests related to the systemd bbclass. + """ + + def getVars(self, recipe): + self.bb_vars = get_bb_vars( + [ + 'BPN', + 'D', + 'INIT_D_DIR', + 'prefix', + 'systemd_system_unitdir', + 'sysconfdir', + ], + recipe, + ) + + def fileExists(self, filename): + self.assertExists(filename.format(**self.bb_vars)) + + def fileNotExists(self, filename): + self.assertNotExists(filename.format(**self.bb_vars)) + + def test_systemd_in_distro(self): + """ + Summary: Verify that no sysvinit files are installed when the + systemd distro feature is enabled, but sysvinit is not. + Expected: Systemd service file exists, but /etc does not. + Product: OE-Core + Author: Peter Kjellerstedt + """ + + self.write_config(""" +DISTRO_FEATURES:append = " systemd usrmerge" +DISTRO_FEATURES:remove = "sysvinit" +VIRTUAL-RUNTIME_init_manager = "systemd" +""") + bitbake("systemd-only systemd-and-sysvinit -c install") + + self.getVars("systemd-only") + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service") + + self.getVars("systemd-and-sysvinit") + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service") + self.fileNotExists("{D}{sysconfdir}") + + def test_systemd_and_sysvinit_in_distro(self): + """ + Summary: Verify that both systemd and sysvinit files are installed + when both the systemd and sysvinit distro features are + enabled. + Expected: Systemd service file and sysvinit initscript exist. + Product: OE-Core + Author: Peter Kjellerstedt + """ + + self.write_config(""" +DISTRO_FEATURES:append = " systemd sysvinit usrmerge" +VIRTUAL-RUNTIME_init_manager = "systemd" +""") + bitbake("systemd-only systemd-and-sysvinit -c install") + + self.getVars("systemd-only") + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service") + + self.getVars("systemd-and-sysvinit") + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service") + self.fileExists("{D}{INIT_D_DIR}/{BPN}") + + def test_sysvinit_in_distro(self): + """ + Summary: Verify that no systemd service files are installed when the + sysvinit distro feature is enabled, but systemd is not. + Expected: The systemd service file does not exist, nor does /usr. + The sysvinit initscript exists. + Product: OE-Core + Author: Peter Kjellerstedt + """ + + self.write_config(""" +DISTRO_FEATURES:remove = "systemd" +DISTRO_FEATURES:append = " sysvinit usrmerge" +VIRTUAL-RUNTIME_init_manager = "sysvinit" +""") + bitbake("systemd-only systemd-and-sysvinit -c install") + + self.getVars("systemd-only") + self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service") + self.fileNotExists("{D}{prefix}") + self.fileNotExists("{D}{sysconfdir}") + self.fileExists("{D}") + + self.getVars("systemd-and-sysvinit") + self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service") + self.fileNotExists("{D}{prefix}") + self.fileExists("{D}{INIT_D_DIR}/{BPN}")