From patchwork Fri May 6 06:59:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 7676 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 7FDB8C433F5 for ; Fri, 6 May 2022 07:00:45 +0000 (UTC) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.85]) by mx.groups.io with SMTP id smtpd.web10.6635.1651820433030208227 for ; Fri, 06 May 2022 00:00:35 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@weidmueller.onmicrosoft.com header.s=selector1-weidmueller-onmicrosoft-com header.b=3+etzVam; spf=pass (domain: weidmueller.com, ip: 40.107.13.85, mailfrom: stefan.herbrechtsmeier-oss@weidmueller.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A30EGAsxvvO8WR7XZiA3oExITRgXtXU3EqXpHbugMIHC0RHK8+ecJt13inzrF0F/dfNucu7vp33WFBPMtmR617rdac9NHGcD3g5v83O2Vhx6cGpD3YiWtNyE99c7gNppIls5AW68DNDfgxO9OzSGTXDZ19lHFeTyOdEm1XeR+pKRsYcs17pMnQPUumxPZP6Q24I8b4WmFr8576rKGDt/uHsVtJMZ01z02wjgwHuiU1F/l91OHdj9sb26EHJzdPUIolx0Go9ONptAiAy6xdiJM7+n4+HA2PofY5b4pipVD0wBIi1y4QXXxVen4pfdIybycZ2DH1I4PXJpJS5uKGhijQ== 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=x+NFZNwtWOfnjC+pHXYrx6vBEhJy4UZOPYqvRKAz9PQ=; b=f/gkoW1yMhv8bZjSoeF4DTaP4WcmlsTPnfAuq/3mgFVoDb/731pjC+R1A2dzzumeVweM0S3njvRMrUcsl/SM2MtEvLPt22iG12QI3vGsJSEjkc7VMtOH5s3aWrHkBC4Kmayp+nTLRzszddqYppAMfsBuflxrTTTMfb19MhivU29VSCRsyRjyU8k8759/VWxRG6dqfH82piIzBDnHPwdbZeJcdETnrapxbE8NF+/QipNGYR0laqsaXbGrgLHWr0ni9AhdrPgWOFqnN+MABnZGLwebO4iJwYi0oK/qBpH1NZPPqkU+DGOa/+cc2WUt4LaC8TBtgs4PkNFwYWtgfaDklQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x+NFZNwtWOfnjC+pHXYrx6vBEhJy4UZOPYqvRKAz9PQ=; b=3+etzVamRjnI1IAM6+n1R3+bnSN7STOxCGmkYvW/pjR8tK26z3njpQ1z3XPe2ESQYXl8uoTUWeHSI5JCA5s9kae+f+m5BfFhkLibBTKRzWbzS+TxgRdR6ms3u3dHz7lriDu3IXqfVWrPoXo/ezUeWoA6Mpr4PQX3NF9lvuYpVj8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by HE1PR0801MB1881.eurprd08.prod.outlook.com (2603:10a6:3:55::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.12; Fri, 6 May 2022 07:00:27 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23%8]) with mapi id 15.20.5206.027; Fri, 6 May 2022 07:00:27 +0000 From: Stefan Herbrechtsmeier To: openembedded-core@lists.openembedded.org CC: Lukas Funke , Stefan Herbrechtsmeier Subject: [PATCH 1/5] recipetool-create: add ensure_native_cmd function Date: Fri, 6 May 2022 08:59:13 +0200 Message-ID: <20220506065917.1375-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: AS9PR06CA0090.eurprd06.prod.outlook.com (2603:10a6:20b:464::7) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 91c557b7-ce75-4000-6c4d-08da2f2e19bc X-MS-TrafficTypeDiagnostic: HE1PR0801MB1881: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: BJ9P/AS6plO3Ob60jKVQP8jBDBTO6IyNQ/N3rB7MoISUzEr2YT0T0xs74JrwDObGCGPkMKE90fWdMsL6dQ0pAHG7GitpuOZ+S4lV1MjD6dqf7i64DuyINqk1JmBz3b8j3hy9Ft/YbX1DPPhAuygAMeU3ajZiDzr+EJe5RBClC++lUdkF3fc1WnHFSxS+JsHEmBG3mDPkRblT2T81tKRK2pv5G0ZwJjEbGpyBzIQEMNJ7S7IvTbX7JHee2oxDkTpq2hLSiebner2dtwiZjdYfOjbtGtQJ8olkkoUSda1DBoJH394mgiuSqWJpCRaTOamSF02eP0rpktGeRMXmChK/kC8HvExVZMnMm2RQItEtYWAvsChwkfsD7nXnMxpaxvG9ONLZxnptkxLQZ5KyIw8ZBmXIF+MpGv/WamDr74DAe+bUmELVL0efYt4hJj47iJkgw7Dz+jZKdJHu67k68Im+s7ewNWn8K7sYOPTBu3ehWbeRMBP24DH/1SlvtyMkTwM9a0Lwa4QSfxYApIxKH2Mar+MHBCirb8FpDQp8MRJI4TjNXF1lDqKPtVurH6eeG6ckAcNIY0j3xiersDnF3wmXMixdhrBlgR1PAxhmaCN8wTX9gnn7l0yUTnRKuK2jAtCahiSruFKhpt7i4wSBNljkA49aE6ibNgRFu+SC6jPZu+pOYDQEFwy7pJIo8GJ1x0ykX0LDifQbQSg22nnGZxiQ0g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6969.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6506007)(6486002)(5660300002)(316002)(38100700002)(38350700002)(2906002)(6666004)(8936002)(508600001)(52116002)(36756003)(1076003)(2616005)(86362001)(6512007)(186003)(26005)(54906003)(6916009)(4326008)(66556008)(66476007)(66946007)(8676002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: te62/m8kb4dy82sJpJDV15zWLdmW0zil3LpkkFwBWA2Mh3yINb3ZbtjNfrxdloCuqUnHVHj81zQ6hITF3j9cAtgxlLur+5eHct0yQkZoI4wrYBVEhOzKWspq/WahdoffWmYloplBTPn4QqaCsfqhoX5zsbqVrVQbexpenb8KKPU8AEoTRg/zQkYMrBa0X7lJ2mWocP+fO5wV0lBvbLKI+DMCbd1zhnGKZ+fTJtT/YRYVvYCBVyQ4sFUvRgDsMYcN6d4bO1sQ7jnw91pUlApOHk3PXb6wFBcHOWXriEhkmRR1KUiq0BnROXsq6sSZRFyfZcReAhvX1rw8PbUtLF7ZjXkemom9kTaAJ/ZkpQ93yHJSP0n0bAvXxBEBMKW4VzkFdbOG/R+AqRUfSFqEwRMzqZ4ZuYtVzc3J8ZHkh+TQi7HgRp4d1bWXOIfUSTxUkfklEflYQ81AFOb32mSPQEQnUTVL1AhdoX6kSZzoyIedhx1zq1c0WKCCijhZFZK9Xk/sW+xtJCQ6kKsKsjvfDBGu2gKRIlhhcceWdrcCHP9MdopmcAV5lze2BQPqse5cJ9gD7EC1AevfAPrLc3zdUuK+hOvmmmIodKICze5UFs1X3TOpv2CCYKgTZ7pMGIJt+S4dlMU3DUeEFpOTAfIakevC6309pnRG8GgrfhNcXphQhoXZfMNO9n9YbihR8Gqa+EPAqjW0ec3WTUG08wLf9YTB8oLkGNvojviMN/wMIkK3oEWZ1gEp7SNL0IlH0tgUhfFJX53Jw8Z7BJrNH1IHMBSAjuIUZo1/ZE+VmhfxyIvTAZP3ohYTfHkLdsHYG1WlEGWdFVxWYOAzJ83r7meov4pYIVMZLYc6lYes0k0mMhMenWRTGFW/4o6xeNVd5hd/3T2zWXhYMlAMNGmfcxiDTjEJIuQ3iwVw/SG8hLUWxg7Rxoz9jgzJhbTP+WaPOpzF26zVBvjCckv8WzdMtmMgf8BMgUYB9zh6kUiojI8+Yh5fE5U5ffY5KxQuDj/VbcYH8PcUYBV46j35XcC+OtiWUBcQZWmcv33YibfActSCC1p08LMhEDoEotIx9zmdvGRs2Wp4hbVJnTLfIpJshuL8Qb8Za/B/9GIJguuNUaZyNi2rSkuwu/6Py4TtQdiNHCt2eNiu9UZK298gghCZ+sKdFbBrxkivtL8g5k82bv+7uZovf1WY9Oli9VoBhhik+BVfTPggLbGJ5l538gr22lcBT93yMi2O0bzqWfdjELaYTq4BIv8pakQHHAZipXeXDlxoR62E+ZT3yO+33tC3jNIpZ6xrk9MhAGYXAxNwKzXTfSZN0Nju5ZIlNDMm9o9xFSSnoTEWlog8d1jg0abLiS58gtoNVGzwwZilUn2W70QEQ+Q7pH0lDRIqvRtLixFdjwf8y0LMLgYM8woL8tD9pASETIYwhXDiAo/rBLwKORg+HYlgPzFLKm3UvX7JuNQdHEP+cYkdWlF2L05xgAgIPvY4K/y0NRcOfmXu+YVHg5nfKeZnb2aY4ixQD3hFd1uJKB7l2Jt3uSHzFmaQrFLc/j0Disx3MLKEz3p4py+G477wvbeB55jf4RbW4d09/hFwohe4U2nKus0Wn/XKBo7Ws14dJiFu9h+JqAea261ZSc2QDixIuQGjHzvA7SCLJwWadyDh7BzSkXI+sGpC4BUe399VMOJP3WePs4SyW1ciuZls5khSZBKY+BcxqY4RjJbT1nSjeDCArqCSa522jcQv9sT0Uzlzw/Bfhs7x+fK04fpaWTk31/Y= X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91c557b7-ce75-4000-6c4d-08da2f2e19bc X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 07:00:27.4532 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tTrdx8CEOUdD+Z5a2upEVKAryPa/0MZbCY5jZybAI7Vfoe582NaRJujGIZlMhoGvmr24t82V5P8YV6i+bfoQQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1881 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 ; Fri, 06 May 2022 07:00:45 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/165323 From: Lukas Funke Signed-off-by: Lukas Funke Signed-off-by: Stefan Herbrechtsmeier --- scripts/lib/recipetool/create.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 824ac6350d..efcb82173e 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py @@ -1375,6 +1375,29 @@ def convert_rpm_xml(xmlfile): values[varname] = child[0].text return values +def ensure_native_cmd(tinfoil, cmd): + """Check if the command is available in the recipes""" + if not tinfoil.recipes_parsed: + tinfoil.parse_recipes() + + try: + d = tinfoil.parse_recipe("%s-native" % cmd) + except bb.providers.NoProvider: + bb.error("Nothing provides '%s-native' which is required for the build" % cmd) + bb.note("You will likely need to add a layer that provides %s" % cmd) + sys.exit(14) + + bindir = d.getVar("STAGING_BINDIR_NATIVE") + cmdpath = os.path.join(bindir, cmd) + + if not os.path.exists(cmdpath): + tinfoil.build_targets("%s-native" % cmd, "addto_recipe_sysroot") + + if not os.path.exists(cmdpath): + bb.error("Failed to add '%s' to sysroot" % cmd) + sys.exit(14) + + return bindir def register_commands(subparsers): parser_create = subparsers.add_parser('create', From patchwork Fri May 6 06:59:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 7678 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 85FA2C433EF for ; Fri, 6 May 2022 07:00:45 +0000 (UTC) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.85]) by mx.groups.io with SMTP id smtpd.web10.6635.1651820433030208227 for ; Fri, 06 May 2022 00:00:38 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@weidmueller.onmicrosoft.com header.s=selector1-weidmueller-onmicrosoft-com header.b=Xm7Guyuv; spf=pass (domain: weidmueller.com, ip: 40.107.13.85, mailfrom: stefan.herbrechtsmeier-oss@weidmueller.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dHPjVJ6UzHrSpiexU4jHqxvMNA6OVUWUegLZxEZBwGxm2eyH23Bi8FPmriAZB+OZYLLI/62nzbdHOIWwJnqVnLF3WDITP0KlOo8zSF4BS2D3YRVZVHahpitgCWNTI6fEI82pO2Bbx4nZv/SpaL74KQIinjFKt3CZ7Y1fJEeshPMv+tYC/chV4FlGEIjP25bt6xoG7qEL3KNof/GHbtm6OeHz9RpHqKi6sL1DU0aWh/9ARFa7Ej4t2GntNRC7ovlD1Gn8GmpkBxjNt2uQLWpjNKYQbb/wfdUWF/86Vw9QiZTUWDPRrDWdNqGM4TQNvohR4z4cigNRsJNeILPJEaCV5w== 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=HC3ZLjBPIV5KIL2FRpmeFO2X5K5zq8AZeRuBTIZieYo=; b=kedHnuJ+CV10RjUbv/KUXTznvLnwFlLMlNu7CkldIba1RaQ1Unw6AUVAHlXOvVFx5nAIYcLPfAMAj8fQCAQjsDh4UPhsHbGv6rpj729CynFMpfC6+32w4aXE1athVej7d/qvvSXgGwuk6ntzmSF04qQVhArhcKdgaF4cGyPdr1QXSpmI6lo3gO7ai+7iLSu1s5qPkNHIKvE9d4oeXEUkqzf8i0wq6pFKCU4EKOiMbNS1yCbbG1lAw/62+Gt+MvPYX0EKHVuOq31dIoGkQf/ANDWkY9nCZxFycWfvm5bR2wztu95Y+B4uAGvtEKqurxRBhLOrqjFh2SgVmeJ3QzuAkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HC3ZLjBPIV5KIL2FRpmeFO2X5K5zq8AZeRuBTIZieYo=; b=Xm7GuyuvV0sWSADGotmr7Ph5TY1V57SmVGNGy7heVLMa1bnFeRRqlhEf10P3fJP5e1I5JkALAzQTtg+9Q+ZUgkGfmLuRFpdKk8t2BtfztrLcGNara4Vnb3hwWIT+OmoAWjzYnfycLYbfv/UFQ/fNYJNNrFqjXABJSEdTr0Y7/XA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by HE1PR0801MB1881.eurprd08.prod.outlook.com (2603:10a6:3:55::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.12; Fri, 6 May 2022 07:00:28 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23%8]) with mapi id 15.20.5206.027; Fri, 6 May 2022 07:00:28 +0000 From: Stefan Herbrechtsmeier To: openembedded-core@lists.openembedded.org CC: Lukas Funke , Stefan Herbrechtsmeier Subject: [PATCH 2/5] create_npm: reuse ensure_native_cmd from create.py Date: Fri, 6 May 2022 08:59:14 +0200 Message-ID: <20220506065917.1375-2-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220506065917.1375-1-stefan.herbrechtsmeier-oss@weidmueller.com> References: <20220506065917.1375-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-ClientProxiedBy: AS9PR06CA0090.eurprd06.prod.outlook.com (2603:10a6:20b:464::7) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbe4d33b-f045-4ea5-01b5-08da2f2e1a17 X-MS-TrafficTypeDiagnostic: HE1PR0801MB1881: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: bdpnYZWReW0S9ftoczwXmsY7TqtQxLz9DJdLhu2296Iy1CJFc8a0asPG0c6KU3FTeGAUIiMM8uuo65WxPpN8uVIX/ZNyZtgPXkaUKnLVds510ZTvwDiZBK4tb5DtYWg0ivmzhMc2qhoRKXrPw6uZ0z66NJO5ky7ispzXma6FhSJEU/2SnoMnAvnMhAR1gzeEPBaMNjtHpuXv3tb8qn9mcKOWIiQ/OPVlLtFefSjR9iRccOweHsCx/1zP/rapECrMIquBrGsGBi7IjRq7EiPxqxdUSlFB6kkcCvyuQHUA7PjzK2S709QfidDcMTS0wfvL4AD4vQzP1AOchMwqVGkvtW1SFfuDtK4TJ9IQL8d17lVVYL9Jb8qHA1qqhNedfr7vZMnUIIjfu8dTe74PXU51F17QSeyDTp3mRUHthCWP09BdZ6QOOiJx9PXVBQM4XiyGFBxoJ/z9hCCej3bALbsIKrCGQyQDT4iDLo6YHsRBKXTRQOo7vTi5j/liwnym4wfKi3hgtp2q2F90yK4XGGvb3n7mtBtkOc4yrcf1JEZ6faJnYgrOKZZ5EiUZEpnw7zgyQ8HAT7b2ETu3WHLkvZX5+SOOLWrv2YD0e1en19FDaEaO1DLo715kUQJPDUDheAaRj4k3o4Tax6pL4EFnbsqGO5JhMtqmB5lWCXqB1fExUJjqhxWxKegnk6MD5gfMuO5isIgPmBfTRTaRq7oCykSiig== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6969.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6506007)(6486002)(5660300002)(316002)(38100700002)(38350700002)(2906002)(6666004)(83380400001)(8936002)(508600001)(52116002)(36756003)(1076003)(2616005)(86362001)(6512007)(186003)(26005)(54906003)(6916009)(4326008)(66556008)(66476007)(66946007)(8676002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7l2ePb+Rgg37gRBi+Htw19rU9cwXD5NGfT7vCjii62NaIoOdQ32PmvrWqImaa0fK9gWHYR0zyAvjIEywHOLueqUVrGpeAjSVwPGOcKQqF6JHF5eGAyWQcbgYqmrpliooaCKckGnLTFmAyIVQOdi0rEhuzWiGtYV0BtQrp5a84SP6KvS5gdPA4Nhgp6p1G/UXjfXxcffjMZzcDVtfj6/njbOl1EE/cKN6tW9BPgySps48CQ/StS1WpWa14CDYgAyLlnR/cq/IBdncBaD2odga/GsZmqaBVGCtKQ/aPaKgB7tT35jM4b5cBzr1W4UqU93pP1NS+83D+WnJVdCxRDspEXqKYZ/xj0tWgtSGB/JAnkx6qC9iBAQGtQNUwcPYN0A1SXAT86+gJASeWVUFPeq4BJFvpRCMpWuRdVyer0qiDwNTEUeOrIiSgMdzr2mJj8SI7an9+q/MnGv4SMlF8/WfSJFYRqriFAhSlJJSwutW223qXuM2m2oAAo8KNb+ryNtZwwkSNm2o/yp/Zx9LdMqQtYhdNksVWB2Vm7dLXnGpBo6veVnVSPaXDUmOPzqQ0LUDPa161N35Yo2IFF4eHbsdLQvT4urj2OTcJkObQ3u3Z2O/S/G+wipdehT5GLLICGNrk3HAskoK5rmG9yvezWs/2HMgtedWmiSZdprSqlPaOYxS5SivoqTR47960l+NYoMxocCQTitbRlFiUBKbyKycJYSp/KNJf91Nkj5KcWAIudPq/6Nl/GoAbKPLz0V66VB8RG2SLUQwmwvmSLKEwi24oCqf7fr+JPmqLSyI9xHBuxrsdnfBwyVa63hK4qRBUkWRwSGaapaGh6XagKJOoGu2L4+kHiBWWTmGo4QJrcoLXjS96Zg/pig2uYLUlaYXS6hYcDKg4sWk4U1eidN5FazOBklFakdOfNWMMI9tCge6FuMB4uM42b2onYs4GKS+aY020H5y+ft068CWzuTV2UWJesL3kpsdhuEssW0TBuA4wqm+XJlCjGMhz87TTO3JVHIeNfu8nT/6LKJUwAUwcBAagiIqCasZVeL3D+k0wU9YM1jhH0uLliflBsp50eXraL6/n7iiMfnxGDY9YdfV1YnGiwDzFUNfD8fmmHzgmy1AlfXC2ZlUkC6V+2PCH+aImbq5OdGsVriyJAnKhaIJ1QulRjno5Mbh9/ZVZxA8i1J33RIqo2lN9fFnGx+AvkY5LZqIgA3NgwaFCF/8iSkj6t02cJ0CCBD0bALpN/61Q/AIVrgKGd0rjpFlXUUWzjf9fst4NWWEmTzL+mCfu0jg+dw1w5RWGi7E1BbdQX8wtB3gwwA16guCXKK14eBwuyzlG1g7MgnnugM+9Xaq1bXiEr31XUVUx8pkyg4+rCXZ5iec8EvRWuwTjr+1mPQij7zuL9FTuWOBboaweTHCy2HiuJ/SJfxnfzS7OLILG6GFE0wBuW/+o7QKBAkKc0dyL3qsYzwqDscpemu8oBo5S955RSdxB9N7UWpnDNCJrU5IXzxaADuTQkvWntpGhltRx12TbcbY4ZYYZGhDzhDWSBP9Q1mvj0t+J5YdxeEx9+4cGd/rJDqVr/CWZeXcWRhOnnttaBJEDOpDZP9SRKDjTdhmzPdPX55sWuL2CiV0qAdJoIdXrVbBgOYvvH6pW9jFWR977yrvRqDh12BYnEhF9IcbWIZFiaB77XWv3YPFYh6760ASlaAbrxGWTjQTI5apm+pDucq+7v0IxTupOIc4tnKuHN1Ql+JD2gYN63CHtFnINweBiZU= X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbe4d33b-f045-4ea5-01b5-08da2f2e1a17 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 07:00:28.0937 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tX83FoN3/stw0WymjPaP3T0QcR2BIGqG3UzwsWOkIhL+E0a+vkwinTgevwckrvgjm1SkXvvFS2H73XF0BBlqsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1881 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 ; Fri, 06 May 2022 07:00:45 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/165325 From: Lukas Funke Signed-off-by: Lukas Funke Signed-off-by: Stefan Herbrechtsmeier --- scripts/lib/recipetool/create_npm.py | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py index 3394a89970..3aed59252c 100644 --- a/scripts/lib/recipetool/create_npm.py +++ b/scripts/lib/recipetool/create_npm.py @@ -18,6 +18,7 @@ from recipetool.create import RecipeHandler from recipetool.create import get_license_md5sums from recipetool.create import guess_license from recipetool.create import split_pkg_licenses +from recipetool.create import ensure_native_cmd logger = logging.getLogger('recipetool') TINFOIL = None @@ -54,31 +55,6 @@ class NpmRecipeHandler(RecipeHandler): return registry - @staticmethod - def _ensure_npm(): - """Check if the 'npm' command is available in the recipes""" - if not TINFOIL.recipes_parsed: - TINFOIL.parse_recipes() - - try: - d = TINFOIL.parse_recipe("nodejs-native") - except bb.providers.NoProvider: - bb.error("Nothing provides 'nodejs-native' which is required for the build") - bb.note("You will likely need to add a layer that provides nodejs") - sys.exit(14) - - bindir = d.getVar("STAGING_BINDIR_NATIVE") - npmpath = os.path.join(bindir, "npm") - - if not os.path.exists(npmpath): - TINFOIL.build_targets("nodejs-native", "addto_recipe_sysroot") - - if not os.path.exists(npmpath): - bb.error("Failed to add 'npm' to sysroot") - sys.exit(14) - - return bindir - @staticmethod def _npm_global_configs(dev): """Get the npm global configuration""" @@ -190,7 +166,7 @@ class NpmRecipeHandler(RecipeHandler): # npm version is high enough to ensure an efficient dependency tree # resolution and avoid issue with the shrinkwrap file format. # Moreover the native npm is mandatory for the build. - bindir = self._ensure_npm() + bindir = ensure_native_cmd(TINFOIL, "npm") d = bb.data.createCopy(TINFOIL.config_data) d.prependVar("PATH", bindir + ":") From patchwork Fri May 6 06:59:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 7680 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 8785FC4332F for ; Fri, 6 May 2022 07:00:45 +0000 (UTC) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.85]) by mx.groups.io with SMTP id smtpd.web10.6635.1651820433030208227 for ; Fri, 06 May 2022 00:00:36 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@weidmueller.onmicrosoft.com header.s=selector1-weidmueller-onmicrosoft-com header.b=M+Yqcn9W; spf=pass (domain: weidmueller.com, ip: 40.107.13.85, mailfrom: stefan.herbrechtsmeier-oss@weidmueller.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aQbSZxmC8J6Yei83GG86kvN1/Vr3DoV6Q0ET5qOKpIsVQ3K1xQZJg67Uepfe2pJPBgT4Rel50Xnx/nPZLw9Z5f12NXzhwpAxwcG7dua83cHZ+10FqIvcQMT/DSMcTXnECbC755SE5bFhpysWDpTz97PPY7RdyJEjA0yYsRP/mRK7rGT6fEoyjTh+iJ105sAr50pYYH39n/j9w75nqBztXUA4IGGL3/6msO8h3eeedXFFPEJee+XDFWWfYhngXXxdg/Wkd91Ww5b0uU5RJMZm0bpGALGSOIje1aVv4Yj6CdlH9LBeLG1FqNsHXA9K0xnD4Qo1RrNpaf2RxbGdgMBRHA== 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=tRj4VY9att/NO2nFDk4Dh6yiv8xluf+xjJUTqe9bAO4=; b=EsRsUKET7AyORCKt5EkuFWfQDwA/DKxnNXhb4BQDYctzRjW/XPn6FrZh8x8MatrnHyERpJnxf4XD1BwqqWW0MdILS+vxkbFfnGN4ihSW3pT+vMRMMHC5znDVCQoxEH5+1btIr880u1d3hEX7GsK+5086S6Y7HL8Gsr6lZXg/RvAHt5j3k2F2u+GFs9VxBLTzu/om6Y8/u2JH3yt465NMmfaV92GB8BKIjYrTjQ6+BQS9gzMkW86I6fUHNmDJSE7Qjyw3ddmiC8WBuTLCGLP58XIcVdKan1B64OrNgzRyxWivxK/SIRNgWwIrzXZdyxpzTfpiUfGypQTtpLY2o6fnFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tRj4VY9att/NO2nFDk4Dh6yiv8xluf+xjJUTqe9bAO4=; b=M+Yqcn9WwE0BkRBHnxL6VjLfEqPUu5F1Dc//d9EbnVraFNDYEoLpugiTrePolfJyym32dn9cBeRGplyWeB3l3wzY2T/C79Fi83pXz45hrlVPPU5DYtXLS4XSo3WpzTKz6FXcttxCJ3MZW1JEpxzOA4WsbUaf4n4HBRldHX0ei8M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by HE1PR0801MB1881.eurprd08.prod.outlook.com (2603:10a6:3:55::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.12; Fri, 6 May 2022 07:00:29 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23%8]) with mapi id 15.20.5206.027; Fri, 6 May 2022 07:00:28 +0000 From: Stefan Herbrechtsmeier To: openembedded-core@lists.openembedded.org CC: Lukas Funke , Stefan Herbrechtsmeier Subject: [PATCH 3/5] poky-meta: add go vendor class for offline builds Date: Fri, 6 May 2022 08:59:15 +0200 Message-ID: <20220506065917.1375-3-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220506065917.1375-1-stefan.herbrechtsmeier-oss@weidmueller.com> References: <20220506065917.1375-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-ClientProxiedBy: AS9PR06CA0090.eurprd06.prod.outlook.com (2603:10a6:20b:464::7) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 034dd016-d75e-4559-e705-08da2f2e1a60 X-MS-TrafficTypeDiagnostic: HE1PR0801MB1881: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: i1BpxRWlqvQLyxHSpkXmlowCrGHYze0VfF+n4ySaXnvptq7vQWP7jIoWXme/yXmk6rUVayRaLLL5Ehib38eakEcM7Hpbh6M+raYYd4ylao2CHBbnTVfBU8Z3HaUpCzt28PkxaW9hbVHf3QHCvvQgl2ZkFDWz1Wkws54J+k/vZKiUZPJmPS0wQCy1aMpLrWDDfowrE6cIzPBCVIHGPGLMch19S3pRtW+T6xnFHuMepHTM295poc15vKLVAmiFCq3qjPwzFhAMn+HtkID5rcItmGeLXjuzoNpvR4YKMzqySSehUPoj2d4tz1f7MO+JouIPGI/jKWLzWJXaXPNlkApWP2NhpAI+071IcIZ1UM5slq0JGMGhQqp6BivWjataXIlhFuRzGPHD4dQmpK7YtpFXCsk3RlE6V8wxbcq1KowTwDgUX5PzCY/zO5FcOvyBGz8aTw0SnsaO3Zzkpk21otMbJvJMNdEZY+fDeu1JFSf20w12INt47ZvLPan1BCFg8xXfTVXP7fTMnEo4pefR8i33OK41Ov8mKQAvKQ86L/XKuwJIoNnPnVIlUZzTF7eEk5hjqdQ7hkSo1tX1GP9uxCtH6bz8eiguJ6seREAbEVbvBGG9Dkdiyh++VwWEuKDvH1/UBsyB6w6FFrlHkoAAyX2an2yelChi1EIOF86BhBh9+kZWr/c8HHdALL91qBs4ziEPUspTZatpMs/TRHn5j1Lhkg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6969.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6506007)(6486002)(5660300002)(316002)(38100700002)(38350700002)(2906002)(6666004)(83380400001)(8936002)(508600001)(52116002)(36756003)(1076003)(2616005)(86362001)(6512007)(186003)(26005)(19627235002)(54906003)(6916009)(4326008)(66556008)(66476007)(66946007)(8676002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UhaKjACTo11klOIH8DZpqEwiKiY0xaf49qfDY3oiJmQuA3uhYP2HME+QYym2olBZxSoYPZe2DKhpwfHHeHC0zCP2tefm/tE6w0fgTJxb31Lhqp0Xz5Iet5KhoM6t+WHQXcfmhN9MCR2lXJ8lETiBJSNVTW7fsVzth7hGQO4spKhbOTyN1bWz2cSpWU741pPVWimVh8c90a/F2NLJjlmApf6C258EeqN+MVfuuYmDcZHWwblELl/InlSoJnE0mAe0v+JPZF6OsdPZMFNSMXeExjsgD2a7F75yDevHN1jg31DTJS3fp3ePAh+gFBaTGCoTwPOX+bd8O+ESFaBBpeoGhSMgg0DqieMsezkVOHIXYFxh8MY8fXfYIL0iJTN9UFLhBQrPFUGEk3N6UJLA42gI48iOkDr4OV0wtxKWi7pe0IKPy5V9OQHvE7DDeLoCySnN3jEOfBxgGjI66f67O1VQsdB4RS2YrLC78RbYfh77Cui33uRV7B10OE9A/Ml60E9gAQdyUk6VoPkAfkcn6K2czNgu2DAV38VKmOQrMayLM6DAVBSfGK/2vwtjiuE2HHicHIpnJCxUMfxs/x0A4FjvdxgLeEdFzTpzb7B0vbHL1OwZeNNqgoU//mKn0yTkdEpBPu2jmyomQcpPRabpnkd84wmN7UQV5NnIUiX0frCzzCA5xLHoRVAa/+nYM4rU1nVTRgO2mVzNxqm8ZsP1CrY9o2ZYCuvIneentJJUBK14WtONpF7wHDNu1GisOwHWEyzVluwKy4ULnSVZ9HyPNIG+UwApiWY3643uYrMf6C1w8f+KkrkkknSULwRna5yUt5IfjKd1leJUAe9/CzFB07Gk5kN3rc5c2+gGXtz0X/sPC4kIVN3mTbzEjHcRUPIuzhV2C97yH7X/qbHYuPm5TddJf+yjd6JgTTP6slDRsNfe/+cBZ5dx2uLG90dc9FUJlTOq0kNbjUaG2Ezer7LZVSt3HRyILzAVHeTzPVptA+iKQLjBIo/H6gDg33kb1AwtV0DxazT43/A0VxkWqCl9A4MPU4OV8s7/18eNaV4laeIiiv43hnpGsIxIppeInp8rfgmvxgROc7GFg5eegjfceO5WZs9bqVlN5kn36ESIY7MfqMlQldF4N1XD01mhrGO1BEiE+y4uyo/IGF/mQXuUzWFRKxxzE4/eOipyziYPjCcZiFn+Nh5z//To/9fbQrVTEcC282zg/NRGA8HKgxEys37XU3nTSUeAxnc+Iil5Ldw7QAYbEIKIvx+lAhDREBysBCp75IfzmlyF4yHQYfkguULvSsbOrDz2Z1s99Q1J2Kmk8riKA66k52h/XxdURyQ5grDTEWwRbA8je62xFliHmVcwIGKlTKJuTsfzspiXQn+DRNParr30C3Aiq3ZXkE86Jl4sQv15JceI2+v4658T3oDCXncfF/8cV7uXwkn0DwBVSRAh0Ogv9z8DFcHLDhcGH3gPX5lJ1zFOu5lXcSsC/8/ZQhPWDaPg+Lfv8gBp8laSGXGvrG+adYWJbfAfzeTx1t8A/VxICsdvnKuv2Ck1/nAQZqP6Vmulfh/RBokoHIsqw6VpvJc7jtXBZtQhUMdH89dJi8GotdaZ7zNqCkIVrtN49XHaIr6VMcbSUEgZSRjT7ZrrShewpEY44sjnyyduvl2hM6j4ui2w9OxiJw9bTT6WKaJ/Ve+nFaltVWPgXH5E7zvcPLe9nmaxS4H/AF3bISHhz2LBrXFYIFSDDMz7giHikU6DmhJFN5dtbVW6gYK12bQ= X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 034dd016-d75e-4559-e705-08da2f2e1a60 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 07:00:28.5311 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mRvAWf5i0PzyLc6i2OVLbEFfkRJfuWnjjTfMfhE199gYQw43L0HeaupTlYd4MJSUQPq+5FjDh9UVWK59fA+p9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1881 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 ; Fri, 06 May 2022 07:00:45 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/165324 From: Lukas Funke Signed-off-by: Lukas Funke Signed-off-by: Stefan Herbrechtsmeier --- meta/classes/go-vendor.bbclass | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 meta/classes/go-vendor.bbclass diff --git a/meta/classes/go-vendor.bbclass b/meta/classes/go-vendor.bbclass new file mode 100644 index 0000000000..a1a740a1fc --- /dev/null +++ b/meta/classes/go-vendor.bbclass @@ -0,0 +1,68 @@ +# Copyright 2022 (C) Weidmueller GmbH & Co KG +# Author: Lukas Funke +# +# Handle Go vendor support for offline builds +# +# When importing Go modules, Go downloads the imported module using +# a network (proxy) connection ahead of the compile stage. This contradicts +# the yocto build concept of fetching every source ahead of build-time +# and supporting offline builds. +# +# To support offline builds, we use Go 'vendoring': module dependencies are +# downloaded during the fetch-phase and unpacked into the modules 'vendor' +# folder. Additinally a manifest file is generated for the 'vendor' folder +# + +inherit go-mod + +def go_src_uri(repo, path=None, subdir=None, vcs='git', destsuffix_prefix = 'git/src/import/vendor.fetch'): + module_path = repo if not path else path + src_uri = "{}://{};name={};destsuffix={}/{}".format(vcs, repo, \ + module_path.replace('/', '.'), \ + destsuffix_prefix, module_path) + + src_uri += ";subdir={}".format(subdir) if subdir else "" + src_uri += ";nobranch=1;protocol=https" if vcs == "git" else "" + + return src_uri + +def go_generate_vendor_manifest(d): + + vendor_dir = os.path.join(os.path.basename(d.getVar('S')), + 'src', d.getVar('GO_IMPORT'), "vendor") + dst = os.path.join(vendor_dir, "modules.txt") + + go_modules = d.getVarFlags("GO_MODULE_PATH") + with open(dst, "w") as manifest: + for go_module in go_modules: + module_path = d.getVarFlag("GO_MODULE_PATH", go_module) + module_version = d.getVarFlag("GO_MODULE_VERSION", go_module) + if module_path and module_version: + manifest.write("# %s %s\n" % (module_path, module_version)) + manifest.write("## explicit\n") + exclude = set(['vendor']) + for subdir, dirs, files in os.walk(os.path.join(vendor_dir, module_path), topdown=True): + dirs[:] = [d for d in dirs if d not in exclude] + for file in files: + if file.endswith(".go"): + manifest.write(subdir[len(vendor_dir)+1:] + "\n") + break + +python go_do_unpack:append() { + src_uri = (d.getVar('SRC_URI') or "").split() + if len(src_uri) == 0: + return + + try: + fetcher = bb.fetch2.Fetch(src_uri, d) + src_folder = os.path.join(os.path.basename(d.getVar('S')), + 'src', d.getVar('GO_IMPORT')) + vendor_src = os.path.join(src_folder, "vendor") + vendor_dst = os.path.join(d.getVar('S'), "src", "import", "vendor.fetch") + + os.symlink(os.path.relpath(vendor_dst, src_folder), vendor_src) + go_generate_vendor_manifest(d) + + except bb.fetch2.BBFetchException as e: + raise bb.build.FuncFailed(e) +} From patchwork Fri May 6 06:59:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 7677 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 8CFB4C433FE for ; Fri, 6 May 2022 07:00:45 +0000 (UTC) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.85]) by mx.groups.io with SMTP id smtpd.web10.6635.1651820433030208227 for ; Fri, 06 May 2022 00:00:39 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@weidmueller.onmicrosoft.com header.s=selector1-weidmueller-onmicrosoft-com header.b=fgY94SIB; spf=pass (domain: weidmueller.com, ip: 40.107.13.85, mailfrom: stefan.herbrechtsmeier-oss@weidmueller.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X2Idl+HXWxuNQnzziSrEKcyNpdFgvkLybRsCKBWy/QX5axzG5F9DdA6dk8e5HclwX2XWHZ6tXu95ZSb0oEnRRBi2g6upCMpYL0GFc4g+oAzc2P9Phrt8PXRB2GfuB5MreDvAT+z+X9xlPWqnvCloq4L2S8K6+gr2/ghGgCrKhPJTdl0fdBAajT/miVXP7szp3CqMGNm83TyxnQUeLJxyEnNBKbYYwBnlBRRasSfMfwEBL6ai2dLxL01UwinMSZ2ganLWfLJojPi8LTzNFiapLhfNguQpiaGaIgRnEBYFfB8HFoP3m3mxA/2SikqKp39ril4jfk4qL0J0DDe3lLaMPA== 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=/SGsAeiPKSnFJR/i2ZKDGpBpJ7i4DMmFZJGt5+EuINI=; b=VtmR4f5mdwKXCDYnGgTGGgBrokkchunPoCysdAESgfLYZKKiqZjrFRNnNCRYDo8+MnUBXrHJ6/9YNRY36PAfzJw98SzoaYz23rx6qUYqD9uPqutbjfah3JXk1n1FY0ATbOtqlNbqVJ3j0v6qYVEvesntWEBCvmt8+A3E/RtQIPuprrvYooIfvUFnVQIl3lsgmBlW8VXzshRJh4uJK+FP+fvph9UjvUANJeV5nJhBmqsQcM9G9jRTmRg64uDDru5JU5MkpKwhCxIAYy1FR/wJhCrxI4CRPu7eVaQw8UXSxK+Ie0zcfAuXa1vbQSMb4TPnneeyhETmCJAYOwujBZj0JA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/SGsAeiPKSnFJR/i2ZKDGpBpJ7i4DMmFZJGt5+EuINI=; b=fgY94SIBJTkIuotPUsvcqB7k0dpsmlM0Ca0kR8k/EmuHVG/gEn6M/QtSBDXBW/R8KYi5VbzGghJTqcHASXqqx+k2OALDIyFBG/+Qb5j7brdGocCjhD38aE92ja2dhMMg6vK5JdQYhghoFfRW1tBNOztzWC7IcplF4vqKt6X/k/U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by HE1PR0801MB1881.eurprd08.prod.outlook.com (2603:10a6:3:55::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.12; Fri, 6 May 2022 07:00:29 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23%8]) with mapi id 15.20.5206.027; Fri, 6 May 2022 07:00:29 +0000 From: Stefan Herbrechtsmeier To: openembedded-core@lists.openembedded.org CC: Lukas Funke , Stefan Herbrechtsmeier Subject: [PATCH 4/5] recipetool: add go recipe generator Date: Fri, 6 May 2022 08:59:16 +0200 Message-ID: <20220506065917.1375-4-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220506065917.1375-1-stefan.herbrechtsmeier-oss@weidmueller.com> References: <20220506065917.1375-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-ClientProxiedBy: AS9PR06CA0090.eurprd06.prod.outlook.com (2603:10a6:20b:464::7) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8bad08ab-104e-45f3-a5c8-08da2f2e1aa3 X-MS-TrafficTypeDiagnostic: HE1PR0801MB1881: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: 383fGF5Mtwz3knxyrf2FIWoaXBOOBzylhINYmRBcJVOIFvqkBfY5M30h9cI+k45MLvHMDp7uMy+fkggJwHXK2tdF6eRJMVG/aGmln6MLHQg6IUa88u9GOMQU7xd8ccGt50dwJMIqpW2JB37nttD+86H71E3z2U69antD/llO5Bi3BNPSxs44FJoWyHMf0Bp0IVlqttRayeP1PPlBN3uGk3WSTZU0WS3EpiLU2PAs+tkCI2ml4eiLG0C8UjiMs7L3zTuGiyIlAtvNdJRoW+tHL+tetpyoRfkfYxSe6WSxI0wIVGJaTsmEdr+PrlxBdQCQworptvr3d9WK580C0yxHf2eX//wfOXM79hXPbS5HfvU2WbNC4sF9UR/w72D9s/xafs9g047R8hWlVZSQPeCzUSvs95gfm/JpFn6MrmFh5VVKnVsT2EC/fPyk9Q7QIw5W5eGi99z+5K2+l3F+Z4aHrhAxZ27BY7it1vXTQJGOKHFnoHRVSrWPRRzthWMMtpluvDZ8zdfwK7vNpw9zXwPIue798xqHxaK2Ndt8c/ZYPolXDx4fFdstECJgNojgrubZuS0Rge7c2NejiHuJccBAS/2EnzeswgnyrV5kQLAVKA9CF3c2wBVV0v4o2zhxygCspO13QJ5k6vTGs4Ghlu8ta8+GmpEEAkV7glBvIxUdu377xlO6eQAXNYBROR0ejvqAMoANLope0HwCTaUiKHgwPw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6969.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6506007)(6486002)(30864003)(5660300002)(316002)(38100700002)(38350700002)(2906002)(6666004)(83380400001)(8936002)(508600001)(52116002)(36756003)(1076003)(2616005)(86362001)(6512007)(186003)(26005)(54906003)(6916009)(4326008)(66556008)(66476007)(66946007)(8676002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r433aR1Rau3iMRm1T2Wa1G3rdZRQZOsqJ92ta6y5mwqEzpFeynlwFylsv5Br89i4ZhpCJgxXUpFXdQEK5+QE6gyv50390xH3c2czf6pHTWNS6Eh+xzcDZ7rkmw+Gz1ytpanEPUHt3pWO8otlGvarfdNy0ZSHDNsH1g2UPjeFrv+4jEIYvhLpQRtlDk02Wj27URghQv3bXY7+OYGNaqFMpGcfkm6FVP9ZtaNZ+XCmZdHl7Rk0GCwiYy48bMxeWhojzc01ztzV150vOLBYt8yoEA8saGO/n7qBbUCUMBd5IvWBKbA4g5ZZpUCxC9ZAovqvgHrTOpl4Xm/WzrCusBSiKTjbw5uozMwJEgKhEGGFx2H5I1iqfJssR3Zs+RK8ThstEegKvlFB5F6wv7Y/5Edwk4gp2xVuNyanV5on4llX1mdQVeRQ5/bdmRO4csMtJvg9ORMCxsuuNIvptZj/bZhUHL2UHvxo3J+mo2yEsHxzyWayP2acJDBYFam0OzL7yQ/HQXFSRbRkoKpDiiWbVTQnf1uhD4mFjRbspOztAE3+jtotxwLSeHhBUBq7a/glvWRauhRsnDZlA2grRsWvLBSOmBe+4mzacZ8TsZT+1uvxcdlZDupSq8Z/3MyQ1nSKEa4x6qc8hfq7yTkxMAq0TypgiMpviBxTS8a0YrCw7vzn4YtLCz4j5NAtrrUVM3H7I+M6VIlBOZEuZ24yq+BbBxinJOy8jpVGlT27WHG5KKdUG3QhI5ao/G3LBffLvjCmBBKQHK/bNlKdj8VWRiEjK1p+dyeeHhwVa2HyIHiYjFlwt4CCxXOg8Ri3zD90hCaNqc4kYYDpYu1ooCZeOzuODbfnOL1ypzIlICMBtZpOJBEeNImPXAU+wLaP5gcDhx2K5EpCE/leHlv2y4buRNxzPaHz1RADYejCY8mxX/z+lh6DX/GMBS715TtRXCVI0vPRww6CGFMeWXsURcW3pVkiariNQcNQnsuOcFp0NCFg1DmBcghF/N6xnr0If9rMpNN2foLFrYR0vJkb9chpqEK9ikYu7t06pv15PaScTyPOu3j626lxnuqZT4R3PWcczqHSXj5/WVkoA1sIXL8Vv7qhuDO/bf7dpAOEefQaExBVAA/B3+3vYhXBh+ab8dJ27tKRQ55p+jH8Ud4lRTChneqzS6T6xUo/VS3Nl0sbYtsvrVw+POe0AEuSv9kpyfkWYhoPrjsaEgorJCMDuK1n9FjfszphbTzDpBmGNrmthHKfw92J8JkuPhuG/+6J1ERGf3BXoukbGES7egxoZ0B3xXUDDvOVDmmLVa9quUq62qPONPHwq+FE4aye5JzzW+Y6VNrfAi2zGWkexh3w2Znf/M6VgARDU7EA/z8ugb9ddyp7h2y6f3gt2PyO5qCD4hoB8vtYAHIdM71ZYRDsPkRHjojrxt1N/RdEgivntrRCppOfzezbUqThLrGSl9FJISdzIEV7MN1z0KjNCKP480dL/EorMzCmI9jTSXPDzIScEsw3WbnRnnWBeykbl6+io9IsWC/B+Gaw2EYfyz/Ls8XCmDIXN68NOpJ3KcxZLgiwuedL9aJzhO2iz0YRKXX7no2BRtshnI+jrOB8SkuBRnapdo/kLyf0QhBSf9ysQIlS0IgwiQhrBvbLb9RZ1/evgITaXpYE3DAPzWZttRgyzP2z6cwfMKY/SgF+DAO3BJf+AyEHuDRWqeFAtEFd0AEtp8+I8r/Pd4otxwgR2SbnY74oaBi1R3tkkQ3B1N/Kve6K24ZqzjlNEJQ= X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8bad08ab-104e-45f3-a5c8-08da2f2e1aa3 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 07:00:29.0168 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nQfDHxvA1rsKM8wPjV5iei2/Gdop0lt+TpctwtY4b0u8cyYKhLsrTzGcGm6mBlzRkMAztreZGsz2eUH/8uuTpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1881 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 ; Fri, 06 May 2022 07:00:45 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/165326 From: Lukas Funke Signed-off-by: Lukas Funke Signed-off-by: Stefan Herbrechtsmeier --- scripts/lib/recipetool/create_go.py | 394 ++++++++++++++++++++++++++++ 1 file changed, 394 insertions(+) create mode 100644 scripts/lib/recipetool/create_go.py diff --git a/scripts/lib/recipetool/create_go.py b/scripts/lib/recipetool/create_go.py new file mode 100644 index 0000000000..4552e9b470 --- /dev/null +++ b/scripts/lib/recipetool/create_go.py @@ -0,0 +1,394 @@ +# Recipe creation tool - go support plugin +# +# Copyright (C) 2022 Weidmueller GmbH & Co KG +# Author: Lukas Funke +# +# Copyright (c) 2009 The Go Authors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause AND GPL-2.0-only +# +import bb.utils +from collections import namedtuple +from enum import Enum +from html.parser import HTMLParser +import json +import logging +import os +import re +import subprocess +import sys +import tempfile +import shutil +from urllib.error import URLError, HTTPError +import urllib.parse +import urllib.request + +from recipetool.create import RecipeHandler, handle_license_vars, ensure_native_cmd + +GoImport = namedtuple('GoImport', 'reporoot vcs repourl suffix') +logger = logging.getLogger('recipetool') + +tinfoil = None + +re_pseudo_semver = re.compile(r"v([0-9]+)\.([0-9]+).([0-9]+|\([0-9]+\+1\))-(pre\.[0-9]+\.)?([0-9]+\.)?(?P[0-9]+)-(?P[0-9Aa-zA-Z]+)") +re_semver = re.compile(r"^v(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$") + +def tinfoil_init(instance): + global tinfoil + tinfoil = instance + +class GoRecipeHandler(RecipeHandler): + + def _resolve_repository_static(self, modulepath): + _rootpath = None + _vcs = None + _repourl = None + _suffix = None + + host, _, path = modulepath.partition('/') + + class vcs(Enum): + pathprefix = "pathprefix" + regexp = "regexp" + vcs = "vcs" + repo = "repo" + check = "check" + schemelessRepo = "schemelessRepo" + + # GitHub + vcsGitHub = {} + vcsGitHub[vcs.pathprefix] = "github.com" + vcsGitHub[vcs.regexp] = re.compile(r'^(?Pgithub\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/(?P[A-Za-z0-9_.\-]+))*$') + vcsGitHub[vcs.vcs] = "git" + vcsGitHub[vcs.repo] = "https://\g" + + # Bitbucket + vcsBitbucket = {} + vcsBitbucket[vcs.pathprefix] = "bitbucket.org" + vcsBitbucket[vcs.regexp] = re.compile(r'^(?Pbitbucket\.org/(?P[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/(?P[A-Za-z0-9_.\-]+))*$') + vcsBitbucket[vcs.vcs] = "git" + vcsBitbucket[vcs.repo] = "https://\g" + + # IBM DevOps Services (JazzHub) + vcsIBMDevOps = {} + vcsIBMDevOps[vcs.pathprefix] = "hub.jazz.net/git" + vcsIBMDevOps[vcs.regexp] = re.compile(r'^(?Phub\.jazz\.net/git/[a-z0-9]+/[A-Za-z0-9_.\-]+)(/(?P[A-Za-z0-9_.\-]+))*$') + vcsIBMDevOps[vcs.vcs] = "git" + vcsIBMDevOps[vcs.repo] = "https://\g" + + # Git at Apache + vcsApacheGit = {} + vcsApacheGit[vcs.pathprefix] = "git.apache.org" + vcsApacheGit[vcs.regexp] = re.compile(r'^(?Pgit\.apache\.org/[a-z0-9_.\-]+\.git)(/(?P[A-Za-z0-9_.\-]+))*$') + vcsApacheGit[vcs.vcs] = "git" + vcsApacheGit[vcs.repo] = "https://\g" + + # Git at OpenStack + vcsOpenStackGit = {} + vcsOpenStackGit[vcs.pathprefix] = "git.openstack.org" + vcsOpenStackGit[vcs.regexp] = re.compile(r'^(?Pgit\.openstack\.org/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(\.git)?(/(?P[A-Za-z0-9_.\-]+))*$') + vcsOpenStackGit[vcs.vcs] = "git" + vcsOpenStackGit[vcs.repo] = "https://\g" + + # chiselapp.com for fossil + vcsChiselapp = {} + vcsChiselapp[vcs.pathprefix] = "chiselapp.com" + vcsChiselapp[vcs.regexp] = re.compile(r'^(?Pchiselapp\.com/user/[A-Za-z0-9]+/repository/[A-Za-z0-9_.\-]+)$') + vcsChiselapp[vcs.vcs] = "fossil" + vcsChiselapp[vcs.repo] = "https://\g" + + # General syntax for any server. + # Must be last. + vcsGeneralServer = {} + vcsGeneralServer[vcs.regexp] = re.compile("(?P(?P([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\-]+)+?)\.(?Pbzr|fossil|git|hg|svn))(/~?(?P[A-Za-z0-9_.\-]+))*$") + vcsGeneralServer[vcs.schemelessRepo] = True + + vcsPaths = [vcsGitHub, vcsBitbucket, vcsIBMDevOps, vcsApacheGit, vcsOpenStackGit, vcsChiselapp, vcsGeneralServer] + + if modulepath.startswith("example.net") or modulepath == "rsc.io": + logger.warning("Suspicious module path %s" % modulepath) + return None + if modulepath.startswith("http:") or modulepath.startswith("https:"): + logger.warning("Import path should not start with %s %s" % ("http", "https")) + return None + + for srv in vcsPaths: + m = srv[vcs.regexp].match(modulepath) + if vcs.pathprefix in srv: + if host == srv[vcs.pathprefix]: + _rootpath = m.group('root') + _vcs = srv[vcs.vcs] + _repourl = m.expand(srv[vcs.repo]) + _suffix = m.group('suffix') + break + elif m and srv[vcs.schemelessRepo]: + _rootpath = m.group('root') + _vcs = m[vcs.vcs] + _repourl = m[vcs.repo] + _suffix = m.group('suffix') + break + + return GoImport(_rootpath, _vcs, _repourl, _suffix) + + def _resolve_repository_dynamic(self, modulepath): + + url = urllib.parse.urlparse("https://" + modulepath) + + class GoImportHTMLParser(HTMLParser): + + def __init__(self): + super().__init__() + self.__srv = [] + + def handle_starttag(self, tag, attrs): + if tag == 'meta' and list(filter(lambda a: (a[0] == 'name' and a[1] == 'go-import'), attrs)): + content = list(filter(lambda a: (a[0] == 'content'), attrs)) + if content: + self.__srv = content[0][1].split() + + @property + def rootpath(self): + return self.__srv[0] + + @property + def vcs(self): + return self.__srv[1] + + @property + def repourl(self): + return self.__srv[2] + + req = urllib.request.Request(url.geturl() + "?go-get=1") + + try: + resp = urllib.request.urlopen(req) + except URLError as url_err: + logger.error("Error while fetching redirect page: %s", str(url_err)) + return None + except HTTPError as http_err: + logger.error("Error while fetching redirect page: %s", str(http_err)) + return None + + parser = GoImportHTMLParser() + parser.feed(resp.read().decode('utf-8')) + parser.close() + + return GoImport(parser.rootpath, parser.vcs, parser.repourl, None) + + def _resolve_repository(self, modulepath): + """ + Resolves src uri from go module-path + """ + repodata = self._resolve_repository_static(modulepath) + if not repodata.repourl: + repodata = self._resolve_repository_dynamic(modulepath) + + if repodata: + logger.info("Resolved download path for import '%s' => %s", modulepath, repodata.repourl) + + return repodata + + def _resolve_pseudo_semver(self, d, repo, module_version): + hash = None + + def vcs_fetch_all(): + tmpdir = tempfile.mkdtemp() + clone_cmd = "%s clone --bare %s %s" % ('git', repo, tmpdir) + bb.process.run(clone_cmd) + log_cmd = "git log --all --pretty='%H %d' --decorate=short" + output, errors = bb.process.run(log_cmd, shell=True, stderr=subprocess.PIPE, cwd=tmpdir) + bb.utils.prunedir(tmpdir) + return output.strip().split('\n') + + def vcs_fetch_remote(search=""): + ls_remote_cmd = "git ls-remote --tags {} {}".format(repo, search) + output, errors = bb.process.run(ls_remote_cmd) + return output.strip().split('\n') + + m_pseudo_semver = re_pseudo_semver.match(module_version) + if m_pseudo_semver: + remote_refs = vcs_fetch_all() + short_commit = m_pseudo_semver.group('sha1_abbrev') + for l in remote_refs: + r = l.split(maxsplit=1) + sha1 = r[0] if len(r) else None + if not sha1: + logger.error("Ups: could not resolve abbref commit for %s" % short_commit) + + elif sha1.startswith(short_commit): + hash = sha1 + break + else: + m_semver = re_semver.match(module_version) + if m_semver: + + def get_sha1_remote(re, groupId): + for l in remote_refs: + r = l.split(maxsplit=1) + sha1 = r[0] if len(r) else None + ref = r[1] if len(r) == 2 else None + if ref: + m = re.match(ref) + if m and semver_tag in m.group(groupId).split(','): + return sha1 + return None + + re_tags_remote = re.compile(r"refs/tags/(?P[0-9A-Za-z-_\.]+)") + re_tags_all = re.compile(r"\((HEAD -> (.*), )?tag: *((?:([0-9A-Za-z-_\.]+),? *)+)\)") + semver_tag = "v" + m_semver.group('major') + "."\ + +m_semver.group('minor') + "."\ + +m_semver.group('patch') \ + +(("-" + m_semver.group('prerelease')) if m_semver.group('prerelease') else "") + remote_refs = vcs_fetch_remote(semver_tag) + # probe tag using 'ls-remote', which is faster than fetching complete history + sha1 = get_sha1_remote(re_tags_remote, 'tag') + if sha1: + hash = sha1 + else: + # backup: fetch complete history + remote_refs = vcs_fetch_all() + hash = get_sha1_remote(re_tags_all, 3) + return hash + + def _handle_dependencies(self, d, srctree, go_mod): + runenv = dict(os.environ, PATH=d.getVar('PATH')) + src_uris = [] + src_revs = [] + for require in go_mod['Require']: + module_path = require['Path'] + module_version = require['Version'] + + repodata = self._resolve_repository(module_path) + commit_id = self._resolve_pseudo_semver(d, repodata.repourl, module_version) + url = urllib.parse.urlparse(repodata.repourl) + repo_url = url.netloc + url.path + inline_fcn = "${@go_src_uri(" + inline_fcn += "'{}'".format(repo_url) + if repo_url != module_path: + inline_fcn += ",path='{}'".format(module_path) + if repodata.suffix and not re.match("v[0-9]+", repodata.suffix): + inline_fcn += ",subdir='{}'".format(repodata.suffix) + if repodata.vcs != 'git': + inline_fcn += ",vcs='{}'".format(repodata.vcs) + inline_fcn += ")}" + + src_uris.append(inline_fcn) + flat_module_path = module_path.replace('/', '.') + src_rev = "# %s@%s => %s\n" % (module_path, module_version, commit_id) + src_rev += "SRCREV_%s = \"%s\"\n" % (flat_module_path, commit_id) + src_rev += "GO_MODULE_PATH[%s] = \"%s\"\n" % (flat_module_path, module_path) + src_rev += "GO_MODULE_VERSION[%s] = \"%s\"" % (flat_module_path, module_version) + src_revs.append(src_rev) + + return src_uris, src_revs + + def _go_mod_patch(self, patchfile, go_import, srctree, localfilesdir, extravalues, d): + runenv = dict(os.environ, PATH=d.getVar('PATH')) + # first remove go.mod and go.sum, otherwise 'go mod init' will fail + bb.utils.remove(os.path.join(srctree, "go.mod")) + bb.utils.remove(os.path.join(srctree, "go.sum")) + bb.process.run("go mod init %s" % go_import, stderr=subprocess.STDOUT, env=runenv, shell=True, cwd=srctree) + bb.process.run("go mod tidy", stderr=subprocess.STDOUT, env=runenv, shell=True, cwd=srctree) + output, _ = bb.process.run("go mod edit -json", stderr=subprocess.STDOUT, env=runenv, shell=True, cwd=srctree) + bb.process.run("git diff go.mod > %s" % (patchfile), stderr=subprocess.STDOUT, env=runenv, shell=True, cwd=srctree) + bb.process.run("git checkout HEAD go.mod go.sum;", stderr=subprocess.STDOUT, env=runenv, shell=True, cwd=srctree) + go_mod = json.loads(output) + tmpfile = os.path.join(localfilesdir, patchfile) + shutil.move(os.path.join(srctree, patchfile), tmpfile) + extravalues.setdefault('extrafiles', {}) + extravalues['extrafiles'][patchfile] = tmpfile + + return go_mod + + def process(self, srctree, classes, lines_before, lines_after, handled, extravalues): + + if 'buildsystem' in handled: + return False + + files = RecipeHandler.checkfiles(srctree, ['go.mod']) + if not files: + return False + + go_bindir = ensure_native_cmd(tinfoil, "go") + + d = bb.data.createCopy(tinfoil.config_data) + d.prependVar('PATH', '%s:' % go_bindir) + handled.append('buildsystem') + classes.append("go-vendor") + + runenv = dict(os.environ, PATH=d.getVar('PATH')) + output, _ = bb.process.run("go mod edit -json", stderr=subprocess.STDOUT, env=runenv, shell=True, cwd=srctree) + go_mod = json.loads(output) + + go_import = go_mod['Module']['Path'] + go_version_match = re.match("([0-9]+).([0-9]+)", go_mod['Go']) + go_version_major = int(go_version_match.group(1)) + go_version_minor = int(go_version_match.group(2)) + src_uris = [] + if go_version_major == 1 and go_version_minor < 17: + logger.warning("go.mod files generated by Go < 1.17 might have incomplete indirect dependencies.") + patchfile = "go.mod.patch" + localfilesdir = tempfile.mkdtemp(prefix='recipetool-go-') + go_mod = self._go_mod_patch(patchfile, go_import, srctree, localfilesdir, extravalues, d) + src_uris.append("file://%s;patchdir=src/${GO_IMPORT}" % (patchfile)) + + if not os.path.exists(os.path.join(srctree, "vendor")): + dep_src_uris, src_revs = self._handle_dependencies(d, srctree, go_mod) + src_uris.extend(dep_src_uris) + lines_after.append("#TODO: Subdirectories are heuristically derived from " \ + "the import path and might be incorrect.") + for src_rev in src_revs: + lines_after.append(src_rev) + + self._rewrite_src_uri(src_uris, lines_before) + + handle_license_vars(srctree, lines_before, handled, extravalues, d) + self._rewrite_lic_uri(lines_before) + + lines_before.append("GO_IMPORT = \"{}\"".format(go_import)) + lines_before.append("SRCREV_FORMAT = \"${PN}\"") + + def _update_lines_before(self, updated, newlines, lines_before): + if updated: + del lines_before[:] + for line in newlines: + # Hack to avoid newlines that edit_metadata inserts + if line.endswith('\n'): + line = line[:-1] + lines_before.append(line) + return updated + + def _rewrite_lic_uri(self, lines_before): + + def varfunc(varname, origvalue, op, newlines): + if varname == 'LIC_FILES_CHKSUM': + new_licenses = [] + licenses = origvalue.split() + + for license in licenses: + uri, chksum = license.split(';', 1) + url = urllib.parse.urlparse(uri) + new_uri = os.path.join(url.scheme + "://", "src", "${GO_IMPORT}", url.netloc + url.path) + ";" + chksum + new_licenses.append(new_uri) + + return new_licenses, None, -1, True + return origvalue, None, 0, True + + updated, newlines = bb.utils.edit_metadata(lines_before, ['LIC_FILES_CHKSUM'], varfunc) + return self._update_lines_before(updated, newlines, lines_before) + + def _rewrite_src_uri(self, src_uris_deps, lines_before): + + def varfunc(varname, origvalue, op, newlines): + if varname == 'SRC_URI': + src_uri = [] + src_uri.append("git://${GO_IMPORT};nobranch=1;name=${PN};protocol=https") + src_uri.extend(src_uris_deps) + return src_uri, None, -1, True + return origvalue, None, 0, True + + updated, newlines = bb.utils.edit_metadata(lines_before, ['SRC_URI'], varfunc) + return self._update_lines_before(updated, newlines, lines_before) + +def register_recipe_handlers(handlers): + handlers.append((GoRecipeHandler(), 60)) From patchwork Fri May 6 06:59:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 7679 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 9A751C43217 for ; Fri, 6 May 2022 07:00:45 +0000 (UTC) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.85]) by mx.groups.io with SMTP id smtpd.web10.6635.1651820433030208227 for ; Fri, 06 May 2022 00:00:41 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@weidmueller.onmicrosoft.com header.s=selector1-weidmueller-onmicrosoft-com header.b=0weI3UqQ; spf=pass (domain: weidmueller.com, ip: 40.107.13.85, mailfrom: stefan.herbrechtsmeier-oss@weidmueller.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GlB8k/8zQy1u/eYeJZGveaThAv+Ouqh3OQC0hYSb/Qx3CMWLniMymHXR6Zmz/jwvTae33pYMD9K35lM/C7YwF8gL7VleM5922TLk1RMbzs2vELVzhjE200IBL/kO/askwGA9QFm4VInJw2ZDWTBMUzXNltgaTgNK43MnbAczX6YY+PaYyYvaleHqI8P/Z2MAmPkY6huQww6MLlXaxxgY2D0RQKww27UD5Gb6ILM21C0EfmTVbfVuzVAPVoU3ApOAaq69KJyuv3W8Dal7cLK7Ha3ZqGI2Ch1Q+Bwsu2O7MRLxILI4tkU+X2TTU264sCwOAwx21udNruB3XMneDGM8KA== 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=9oReOzIFbb2SrtTQLty6IQSDlnCgks50kfsksRJL4gU=; b=eNBdDiIMwNb0DG3h49BK584a7QkpwLbUByWevEaYcQ3bKK1DuX9vncjwn49WSNZB3HrTW9tfykJSbsWQHTCPosCgoW0+vABOLZkm8LJkehaWI+xOVtXrI5VPAcw6QxFodqUJSk2RyAS+vLOe3d0DH0eH2xGMyHvoowjd6lTyn/PmwZhKQRIk3QQgscr1jnjxT+QGwTsI5OfC0szE19+adcNp86BKxXX2OrgsaqmTCyMYaVYwxpDIUWrXre/sQKuM1KNsoJ0bE4MlpuFdFKgyz44BIE0JvFAKfevuMXhxyyEEMKrG5EVptzPpQPcS/ThMwlrODG9+dlAfyK364RXVow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9oReOzIFbb2SrtTQLty6IQSDlnCgks50kfsksRJL4gU=; b=0weI3UqQ30h6Irh9UirR8AuyGOoY/lNOO9ssfrHQJj8UwUg8Ju0/O3U2p9jKLpe05bVWVGQ1Ptc4eIpbDf4Mr9SgXYES0KqyWpQJqzCj9y1dEbp3eVddukFw6nbyVg+0sPXyPUHZ9h8nIhF4VQAST4iiYEomCFG3U6Po7NrQzxQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by HE1PR0801MB1881.eurprd08.prod.outlook.com (2603:10a6:3:55::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.12; Fri, 6 May 2022 07:00:30 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f938:78d7:da4b:8d23%8]) with mapi id 15.20.5206.027; Fri, 6 May 2022 07:00:30 +0000 From: Stefan Herbrechtsmeier To: openembedded-core@lists.openembedded.org CC: Lukas Funke , Stefan Herbrechtsmeier Subject: [PATCH 5/5] oe-selftest: add go recipe create selftest Date: Fri, 6 May 2022 08:59:17 +0200 Message-ID: <20220506065917.1375-5-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220506065917.1375-1-stefan.herbrechtsmeier-oss@weidmueller.com> References: <20220506065917.1375-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-ClientProxiedBy: AS9PR06CA0090.eurprd06.prod.outlook.com (2603:10a6:20b:464::7) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 83acbd2b-bed3-4275-235d-08da2f2e1af0 X-MS-TrafficTypeDiagnostic: HE1PR0801MB1881: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: fQkj/cZvgqP2Yde9AiXmBgrSgEM9bLiIXmOBUOTcKVAy8mSX1fJkCrzG+Yq0q5+xu+3rbnXaPg3h+Ctz4LhB1fLkI2O7OqX+hvAIWi3jmC01OD27dY5Ka0iVv1AtSvNJcmXf62M0o31JTy1E8YEPTfESODe2kFKAS8kAOYN5ryPt0METnmyWOjaUQNcfqVc3zjtn1gQZnAkOktQcWQFIz2A7AoKkKmmZFoSyecMeZs+1TQogiyMjoJZU2UWhs7OQRNtvrMSHEObwRbTlrIPVKNAx0RVzJweH//yGBbsfX9gkbQ1mqH04kGnHHMVZCzraqZP7G56J/Q+ZVdnOzyVkuXcEF9LBaMv6wOpZvhGqTotAETriZrGFIrepGZkcLLWjc57s3bU8PT8q7meaWZ8mQl6izyGbjceLkP3xK7fK3f6S3JqDfBH1N+BXDZxUvwRqWwZjFqYzsjNIeAzr7m/M4unIcFriiWb14uZJiAQ94gUjNGS8xQrRKWXUTKviqwdwhPZ27+EOPA8t6aoAVvsLDUYXzvYiuNGlBx7tydTQYSM7c4DxTSGkuA7aCR6AovBtg7ShPCck6tZqYocWsDvXlWOG2BPsDxJRltD7D6QxffwFQRz8Ntm3XZU4ErnLB0ujqmIvvRaypJfpWOmvSSm7z3BG9VokcUyB2z19Q+r00kUwpqAAuEuN8o+3xu17pihGFR5t4ZEoiSIbmD+eHVKoVwZFZ9vigPy2OweN+89DhvLEMwkwrAzYdvVi0UURz/v7gKIT2PmDyvoITACHDOYwT9uvCJTZpuMu2vfDD6KiseQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6969.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6506007)(6486002)(5660300002)(316002)(38100700002)(38350700002)(2906002)(6666004)(83380400001)(8936002)(508600001)(52116002)(36756003)(1076003)(2616005)(86362001)(6512007)(186003)(26005)(54906003)(6916009)(4326008)(66556008)(66476007)(66946007)(8676002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VvEFQBdNxNzOIcvrSLpHPLbg7zrwuAFO0Y9vtHwMUwCJrCOXePQGWZS1Q7tYp5nZbncs9yNEMj6EkBRazY+725nErxbGJ/0WjMIjhCSgjRLc5dREi0BrgUgLVHuh8ERKRbdnMZpxirSku6iriwio3pUMPDpa0lTS5tjuhXf4Tw7YtxLLIca5tqZrXbuP1dh3LdrGXzVoRPvu46Cg9TKhn3y8++FUJWZ1zsh5J3RNvXdzLaKlohEKbqlsZKbREd4PYK79IX2/Fb5/ZxyGHRIJUeFedvBSJauefVQqXWG25gFG8t6nYjcDvRGQxKm/H3sri1nWkS9lpI0G9z/ISdLapfoBXfFz0Zya2Bw9depA3+WUDhfKN8j8dyxpHfhOeBJ2HjHAMm7CrFPMTcN8pTG+v0PaajIq8rNRxuUINHLba8wPWgIJKcuh4FwT+BBQnA3wQvxVuU+8LgHbEs0lFnI277Kgd8GpKFAjktxyHhzcZIYqDdbAlhxeG2h5JPQzwGJuzP5UEDOHc8LF/nwCT43C0R8W7mEUBqU/sZBLQZ2oaX+lSpOYH9pYQSWK77hWKTwLP72JagoGoMCoPWbcqEuLXi99+HHH8Jod2AhSzUFL5lTInBJIxyUcvFOOeN3BAXBu1K95zI+aNonwa8uByhO/OExjTycOzEAjxY6C0nQXZq9g+VKmPcl/f9T5M0KrJDd4jwdhQZ5UE94WV5BnuU3UFVAPz3+O1IqtzMD5FxbpVPAshdMGM9DmAonLk8BwtzOzB5Zfofq8TRErje2OuudPa7gD2JZZh9PyldjBL85O4yBunrBVsQa0e0pJKVIcWlOkWFxlYP4d+7q3xYQx2nPzE8Vq2d25D7ZlZSyU56zHtSXpqCpw8JUKd96d9W/kP33CFQ2tpekSAdNb55F11FoqzedaOrpBpZofti5FICaNVREhA0IPliC5PoWjEfQdokNeEtlqPks2U5RXuSdSQ99H9YUi3ABta1NgBbfL++ygFZx21ja/62CJUYRqiCdJjQFZL1SqduvUmVsVqLLAegMT6psNy+lURbw3FfLEVUjYqpnR1tBTXvDdBCrJslOt/xnYqeZ1VVwBkwizkjydGCVssIv0EngDYcMnvY1KB0K8NIJHinJIL89BRZ5V4OOzjXgQ9F6fJ5uCbZ2peA/T2O80UACJUc4w0rcX/L+f/QVQTI+btochyk7JbGHN/IX1SC1XDCxed1Oerc+kz/3SRtuwErtX454ckEaOMw0x3Fcl6NJT8e9yiFk6uIfFYZnwmxUhI/G3RwPLZAoaWdeVzTOPsAL1q+gIy4NLdUljI9sCQ81tNX/2/1YCMvLOwz2Wge2Vlp62HglugE2Ox1QYLh2NwFwe8+zKsWqnIg2sHmZSa0RYlVGnE5Nwjg/1wV44ZpyC1MXlzG9qUkK6qVKvLQXPiJfDlWdqZXUNcj/hIQCty8estVd7IxfN7eIGEG/txNPjkFjADzXRmoHeBlVIk/Kc7QjmS1YL0zRo3qiWM3xOS8nePkkjDZ0o3BWA5Zd4HtbTcRk+XSQWZQ816rTPVErqZ8D8zKWqylTHAVx71mR/TdA8/T4oRoUdcrL3OL+rCRfBctnUzMkZVui1n3AhgWtS1huFYhOXX9kBHX+XlSyz10JVArNTTlp249eqxI80N7sfbt71ZRRRLM2Div0BrJ1cFCsvaKOJPiX8NDe/VYkTvdii/bCfONTAossPeaGlxkgB/VcFqHOk9dK+CD5YMx67CGgDgmEpRzOa84+Bn/qU7+k= X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83acbd2b-bed3-4275-235d-08da2f2e1af0 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 07:00:29.4386 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9mBq5/Uu4QojfYhbnANzDQ4LuEe0LhkQBVRAGGoeKJtDHH32APvMWu3pzKI9FR9ty+TxT7E/AGG6Ouvh+fcGXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1881 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 ; Fri, 06 May 2022 07:00:45 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/165327 From: Lukas Funke Signed-off-by: Lukas Funke Signed-off-by: Stefan Herbrechtsmeier --- meta/lib/oeqa/selftest/cases/recipetool.py | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py index 510dae6bad..bb36e7b6d5 100644 --- a/meta/lib/oeqa/selftest/cases/recipetool.py +++ b/meta/lib/oeqa/selftest/cases/recipetool.py @@ -530,6 +530,94 @@ class RecipetoolTests(RecipetoolBase): libpath = os.path.join(get_bb_var('COREBASE'), 'scripts', 'lib', 'recipetool') sys.path.insert(0, libpath) + def test_recipetool_create_go(self): + # Basic test to check go recipe generation + def urifiy(url, version, path = None, subdir = None): + path = ",path='%s'" % path if path else '' + subdir = ",subdir='%s'" % subdir if subdir else '' + return "${@go_src_uri('%s','%s'%s%s)}" % (url, path, subdir) + + temprecipe = os.path.join(self.tempdir, 'recipe') + os.makedirs(temprecipe) + recipefile = os.path.join(temprecipe, 'edgex-go_git.bb') + srcuri = 'https://github.com/edgexfoundry/edgex-go.git' + srcrev = "v2.2.0-dev.54" + result = runCmd('recipetool create -o %s %s -S %s' % (temprecipe, srcuri, srcrev)) + self.assertTrue(os.path.isfile(recipefile)) + checkvars = {} + src_uri = ['git://${GO_IMPORT};nobranch=1;name=${BPN}'] + checkvars['LIC_FILES_CHKSUM'] = set(['file://src/${GO_IMPORT}/LICENSE;md5=71a6955f3cd81a809549da266346dc59']) + checkvars['GO_IMPORT'] = "github.com/edgexfoundry/edgex-go" + inherits = ['go-vendor'] + dependencies = \ + [ + ('bitbucket.org/bertimus9/systemstat'), + ('github.com/edgexfoundry/go-mod-bootstrap','github.com/edgexfoundry/go-mod-bootstrap/v2'), + ('github.com/edgexfoundry/go-mod-core-contracts''github.com/edgexfoundry/go-mod-core-contracts/v2'), + ('github.com/edgexfoundry/go-mod-messaging','github.com/edgexfoundry/go-mod-messaging/v2'), + ('github.com/edgexfoundry/go-mod-registry','github.com/edgexfoundry/go-mod-registry/v2'), + ('github.com/edgexfoundry/go-mod-secrets','github.com/edgexfoundry/go-mod-secrets/v2'), + ('github.com/fxamacker/cbor','github.com/fxamacker/cbor/v2'), + ('github.com/golang-jwt/jwt','github.com/golang-jwt/jwt/v4'), + ('github.com/gomodule/redigo'), + ('github.com/google/uuid'), + ('github.com/gorilla/mux'), + ('github.com/lib/pq'), + ('github.com/pelletier/go-toml'), + ('github.com/spiffe/go-spiffe','github.com/spiffe/go-spiffe/v2'), + ('github.com/stretchr/testify'), + ('go.googlesource.com/crypto','golang.org/x/crypto'), + ('gopkg.in/eapache/queue.v1'), + ('gopkg.in/yaml.v3'), + ('github.com/armon/go-metrics'), + ('github.com/cenkalti/backoff'), + ('github.com/davecgh/go-spew'), + ('github.com/eclipse/paho.mqtt.golang'), + ('github.com/edgexfoundry/go-mod-configuration','github.com/edgexfoundry/go-mod-configuration/v2'), + ('github.com/fatih/color'), + ('github.com/go-kit/log'), + ('github.com/go-logfmt/logfmt'), + ('github.com/go-playground/locales'), + ('github.com/go-playground/universal-translator'), + ('github.com/go-playground/validator','github.com/go-playground/validator/v10'), + ('github.com/go-redis/redis','github.com/go-redis/redis/v7'), + ('github.com/golang/protobuf'), + ('github.com/gorilla/websocket'), + ('github.com/hashicorp/consul','api'), + ('github.com/hashicorp/errwrap'), + ('github.com/hashicorp/go-cleanhttp'), + ('github.com/hashicorp/go-hclog'), + ('github.com/hashicorp/go-immutable-radix'), + ('github.com/hashicorp/go-multierror'), + ('github.com/hashicorp/go-rootcerts'), + ('github.com/hashicorp/golang-lru'), + ('github.com/hashicorp/serf'), + ('github.com/leodido/go-urn'), + ('github.com/mattn/go-colorable'), + ('github.com/mattn/go-isatty'), + ('github.com/mitchellh/consulstructure'), + ('github.com/mitchellh/copystructure'), + ('github.com/mitchellh/go-homedir'), + ('github.com/mitchellh/mapstructure'), + ('github.com/mitchellh/reflectwalk'), + ('github.com/pebbe/zmq4'), + ('github.com/pmezard/go-difflib'), + ('github.com/stretchr/objx'), + ('github.com/x448/float16'), + ('github.com/zeebo/errs'), + ('go.googlesource.com/net','golang.org/x/net'), + ('go.googlesource.com/sys','golang.org/x/sys'), + ('go.googlesource.com/text','golang.org/x/text'), + ('github.com/googleapis/go-genproto','google.golang.org/genproto'), + ('github.com/grpc/grpc-go','google.golang.org/grpc'), + ('go.googlesource.com/protobuf','google.golang.org/protobuf'), + ('gopkg.in/square/go-jose.v2'), + ] + src_uri = {urifiy(*d) for d in dependencies} + checkvars['SRC_URI'] = set(src_uri) + self.maxDiff = None + self._test_recipe_contents(recipefile, checkvars, inherits) + def _copy_file_with_cleanup(self, srcfile, basedstdir, *paths): dstdir = basedstdir self.assertTrue(os.path.exists(dstdir))