From patchwork Tue Aug 20 22:31:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Kjellerstedt X-Patchwork-Id: 48020 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 676D3C3DA4A for ; Tue, 20 Aug 2024 22:31:59 +0000 (UTC) Received: from DUZPR83CU001.outbound.protection.outlook.com (DUZPR83CU001.outbound.protection.outlook.com [52.101.67.48]) by mx.groups.io with SMTP id smtpd.web10.7246.1724193109302940632 for ; Tue, 20 Aug 2024 15:31:49 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@axis.com header.s=selector1 header.b=ksopad+Q; spf=pass (domain: axis.com, ip: 52.101.67.48, mailfrom: peter.kjellerstedt@axis.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RY+XEvo39SROJhDZlRalvAmMz8+iY7sMCOoVIsjPi3YT8cZBtH5SNnNnXMeF/JyZdsBX7U7RtLcChtub6x+2lLzg2hPu/ChJE/S0ROsjYMxyKljrivHPu7ybiDxSw58DSbDU3Wf4A34q0xF6RAeFI6B/wja6xTNfgVsEV/bFFATazY3ti7r1xQnvJokwOE2Qh3K0bazWDJhRpwL/LMXolpdcdOZX50rdE8FbOjyV24Kadmbbdvg4O8IE+PsbBVrcKTlZp9dq8T/xNs0LGiQB4iZhVMUPmE9/+7sshDoKp17vnHqmsnwERZ8i5yBHpJ5/3gT2M825VewLbnAWti4+Wg== 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=7snkz8Q5qdIpwzBUgDZKYNhwC5T3uJmWla8ox0okcZ0=; b=tH4ZUgwJhLtV9nBlTtwq06oVvVq/aAljqg4UNKajAYmdqD0oAkoO3ctTR8x6opBE6VcVUhtz7yJNIey4PmCPHvWGxIo1cmPANOm97pcbm7DiM5mnC1BaQJE1du1ukNfO4O4861Z/rMBwlbOntupl151d6XE6xlSeQtMTGUE3LvWfKEQm5RInBEH5XAHi/0WHV8yVrryTjiEsgYYIThCaK3M8uAL1Oai1RQ3HJJivvyuZ7A66yltHYS+KH37PnNyL8Am/awUZUolTXj1PJFnYGz8j8VkZVHKYg2CChxW4c85ez1PNLtxnljg3hi3SUwXM8sM/iNzfiiyVeOJlYb0HMQ== 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=7snkz8Q5qdIpwzBUgDZKYNhwC5T3uJmWla8ox0okcZ0=; b=ksopad+QnIIUhPGqrqeHig2UM+/SXOaf1Cit46+Yzk1N+jVSLuEWgN/wRDh/r/tVh8q8JmJ+/6Dis95pjQR4T9iujW2F7k7L8OyMTrvK2+0TWzYRISmnDacodOzJ2W56/B+MCtGcPQjFFIU2ZbQxFf2zv/XL/ylyWNLWO5y+sxc= Received: from PR1P264CA0042.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2cb::7) by DB9PR02MB7290.eurprd02.prod.outlook.com (2603:10a6:10:25f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.20; Tue, 20 Aug 2024 22:31:44 +0000 Received: from AM4PEPF00025F96.EURPRD83.prod.outlook.com (2603:10a6:102:2cb:cafe::79) by PR1P264CA0042.outlook.office365.com (2603:10a6:102:2cb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.17 via Frontend Transport; Tue, 20 Aug 2024 22:31:44 +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 AM4PEPF00025F96.mail.protection.outlook.com (10.167.16.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.0 via Frontend Transport; Tue, 20 Aug 2024 22:31:43 +0000 Received: from SE-MAILARCH01W.axis.com (10.20.40.15) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 21 Aug 2024 00:31:42 +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; Wed, 21 Aug 2024 00:31:42 +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; Wed, 21 Aug 2024 00:31:42 +0200 Received: from saur (saur.se.axis.com [10.92.3.10]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 4ED771B3 for ; Wed, 21 Aug 2024 00:31:42 +0200 (CEST) Received: from saur.se.axis.com (localhost [127.0.0.1]) by saur (8.17.1/8.15.2) with ESMTPS id 47KMVg4A770606 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Wed, 21 Aug 2024 00:31:42 +0200 Received: (from pkj@localhost) by saur.se.axis.com (8.17.1/8.17.1/Submit) id 47KMVgMW770603 for openembedded-core@lists.openembedded.org; Wed, 21 Aug 2024 00:31:42 +0200 From: Peter Kjellerstedt To: Subject: [PATCHv2 1/2] systemd.bbclass: Clean up empty parent directories Date: Wed, 21 Aug 2024 00:31:39 +0200 Message-ID: <20240820223140.770567-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: AM4PEPF00025F96:EE_|DB9PR02MB7290:EE_ X-MS-Office365-Filtering-Correlation-Id: 15773a14-5f68-4404-c654-08dcc167de15 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: k+HdqMnzrEOXq0OBcgnMujZJx1QGAta6I5zSpT+snzMDWqluHWGm5sFrv+9t7RiQtnJdlstjVfXNVx6XNec4s/IaPVXV0S54kdqVl4pmr6m4T3eDztXyQr6hEQav4ZF/hKTCfAbYV0P+lOA6TnIfxJyYP/wt1iZ5rgu5AC+FGEP9F4/lDqapMrwZhUQvCrrMaVXSp1p7aFtdN+Z78tbp76WGMxO/D4QMU2RpXlvdd52fJ1ZjOKifLgW2bV5FZ1ub+kSIesDZ8eenn0bFFlW1vcchjaLC3HwKJsMxlAkFQ1R3ls9lcsto37xXikVeLmowEf2FSGVhukfYGVCFONsyDZlaTh31fM54PAVy1NJBYHv5rnc4Mx/dyTQmtdBM4Py2c8x6PjZ+ZSgSB2opNVu4M+tqAzJfCidHq91w6E6Ix4Z2ju9zWgJIXmUe6kBwaM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L:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 22:31:43.1060 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15773a14-5f68-4404-c654-08dcc167de15 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: AM4PEPF00025F96.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR02MB7290 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 22:31:59 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/203572 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 --- PATCHv2: No changes. 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 22:31:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Kjellerstedt X-Patchwork-Id: 48019 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 7E790C5320E for ; Tue, 20 Aug 2024 22:31:49 +0000 (UTC) Received: from DU2PR03CU002.outbound.protection.outlook.com (DU2PR03CU002.outbound.protection.outlook.com [52.101.66.57]) by mx.groups.io with SMTP id smtpd.web10.7245.1724193108010351671 for ; Tue, 20 Aug 2024 15:31: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=q1X0irPc; spf=pass (domain: axis.com, ip: 52.101.66.57, mailfrom: peter.kjellerstedt@axis.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bS8eHHATAIhNNWMBEvqrJo0VkwfV0+wfwXlvHHtc48kBrSs4c//JC7x1iimPZnc5l6aDw4iFPWNHyZmlnk8FtJ4WJU2nGkhKwSsvHq7CclpRRWTtp0wwkh/X6zi1vVYHiHeHdmg4Np0haoRgC7i0AdVCJetYo8/AzgK9uDxvAudgL8dn5NyYl5CBhsgNxcQJHp165GrPeXFjruEcOFQMfGAsz28Gc+JmJPrDjaIrRRMmmlnw+JfzUjILoA0lC4hP/h03LyvZzExhaB8+DgIBu6v7ohvBrz8jvRSVYeGvBUFQRqrjQdDe6QM+PtYSjU92oHx12gkjkAQvmAKWIqCMkg== 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=/ZkOPqrB2RHdaow/+G5H3D71d716vKHnrO8+1wVBkUQ=; b=D0GkgKM3PQvFOmTN5BpdiN0hKSI71sBA/yBLREjD945E4afr+TsHZP5ng/gr/yTolPth+5lSQ/i10d+YRqemmMY42qgF2/b0Om8ryW+qsEUhk5QEj8EtWbcuukuqdrs2zYHSFguHKBxCfgy9/SyVqtgp2+/6cG1SFogobSXwOfQiAQplIHVDr6Q7w/SREWWyrNrz1P6bxmSwTYpspLCpMeswtZfDuQxgxM6UPw/VifrAw8HvEsYucA7tnNOUt2j+WEDHD1LZdV6y2hUyv3YgZLFKYpXi289UWw3WX4GW8PqVe35moUNtntojAW51qOxqM+umY6uRlLILSeFtPjKo1w== 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=/ZkOPqrB2RHdaow/+G5H3D71d716vKHnrO8+1wVBkUQ=; b=q1X0irPc3yVHvADrzne+/Y/xtcfFvc7w+OeojSzHWEgExgHB7apg+GK6l8FXLLT62tICVu1AdEb08v8eXwpsQORLngCqK89pKWPbqkMWQz5NaGjl2LMtaFikLssZVcVuDC4SAN2hBoDoEIV0GRnFy1+1tJpyrbNn9tiyWQYY4oo= Received: from AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) by PA6PR02MB10756.eurprd02.prod.outlook.com (2603:10a6:102:3d7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.20; Tue, 20 Aug 2024 22:31:43 +0000 Received: from AMS0EPF0000019B.eurprd05.prod.outlook.com (2603:10a6:20b:31e:cafe::cd) by AS8PR04CA0108.outlook.office365.com (2603:10a6:20b:31e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.22 via Frontend Transport; Tue, 20 Aug 2024 22:31: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 AMS0EPF0000019B.mail.protection.outlook.com (10.167.16.247) 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 22:31: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; Wed, 21 Aug 2024 00:31:42 +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; Wed, 21 Aug 2024 00:31:42 +0200 Received: from saur (saur.se.axis.com [10.92.3.10]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 732FF1B3 for ; Wed, 21 Aug 2024 00:31:42 +0200 (CEST) Received: from saur.se.axis.com (localhost [127.0.0.1]) by saur (8.17.1/8.15.2) with ESMTPS id 47KMVgul770610 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Wed, 21 Aug 2024 00:31:42 +0200 Received: (from pkj@localhost) by saur.se.axis.com (8.17.1/8.17.1/Submit) id 47KMVglL770609 for openembedded-core@lists.openembedded.org; Wed, 21 Aug 2024 00:31:42 +0200 From: Peter Kjellerstedt To: Subject: [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction Date: Wed, 21 Aug 2024 00:31:40 +0200 Message-ID: <20240820223140.770567-2-pkj@axis.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240820223140.770567-1-pkj@axis.com> References: <20240820223140.770567-1-pkj@axis.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF0000019B:EE_|PA6PR02MB10756:EE_ X-MS-Office365-Filtering-Correlation-Id: e1defadf-842c-4cdf-5068-08dcc167de28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: fUAuRUqRIKXy+ePanOGnvrCPd6ZIrV3uHTDxqlS59vll+vRIqgp/V9PGIWOoJ/ydA6wLjFWa6FrI8zswh8eeCrkQ7Ed97BqUEYmnNUbEBv9v6EEBlka/EQ00aXI0rUAc5TO/CfzQ/CJGjm5WDXE9DtZwZvjpdXqi+8zVlT+F91+eRgbngEYdI5TVsfCFgI5CgkC5A3ovA96xKFWcvbEA6G3YeNXB80zx2xAWi7jP5a50RfACTgYDlneHh4sDaMEW6tz0y65C9namYDD3RpCoaOZZpYDDIgnvX4vQFP/ZzDG2m9UQhEP4R2BAkH6BvG+5jVrh5BLZnmE+WxNU2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GeepVj26tSsdTAiuOnlE6bq69CA/xkYW/d6HAbvvz6vpOkGotFrf9KjRnIXGJhLg X-Forefront-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)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 22:31:43.2275 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1defadf-842c-4cdf-5068-08dcc167de28 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: AMS0EPF0000019B.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA6PR02MB10756 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 22:31:49 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/203571 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 --- PATCHv2: Change LICENSE to MIT and add EXCLUDE_FROM_WORLD to the test recipes .../bbclasses/systemd-and-sysvinit.bb | 17 +++ .../recipes-test/bbclasses/systemd-only.bb | 12 ++ meta/lib/oeqa/selftest/cases/bbclasses.py | 106 ++++++++++++++++++ 3 files changed, 135 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..f9fc59a494 --- /dev/null +++ b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb @@ -0,0 +1,17 @@ +LICENSE = "MIT" + +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" + +EXCLUDE_FROM_WORLD = "1" 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..590a27b9cb --- /dev/null +++ b/meta-selftest/recipes-test/bbclasses/systemd-only.bb @@ -0,0 +1,12 @@ +LICENSE = "MIT" + +inherit allarch systemd + +do_install() { + install -d ${D}${systemd_system_unitdir} + touch ${D}${systemd_system_unitdir}/${BPN}.service +} + +SYSTEMD_SERVICE:${PN} = "${BPN}.service" + +EXCLUDE_FROM_WORLD = "1" 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}")