From patchwork Sat May 27 06:17:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: belouargamohamed@gmail.com X-Patchwork-Id: 24608 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 A26F8C7EE2C for ; Sat, 27 May 2023 12:07:20 +0000 (UTC) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mx.groups.io with SMTP id smtpd.web11.5983.1685168251152313113 for ; Fri, 26 May 2023 23:17:31 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@gmail.com header.s=20221208 header.b=ZYmCdWRV; spf=pass (domain: gmail.com, ip: 209.85.128.44, mailfrom: belouargamohamed@gmail.com) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-3f611ccd06eso10129165e9.0 for ; Fri, 26 May 2023 23:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685168249; x=1687760249; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8bUpakl76o27hJf6ZRoQnS9ltw01zvaQbrcJZKpx2eI=; b=ZYmCdWRVazNTzC5Dpa74hnaMq47nkaZnGvKAi3F8wDkDqmRj79vhxWpH+AR4UAwl3X 4KMAptvlGSPFP+Us7XiAURndsY/j21zyaAwiejdtL6W98k1heo6ti13tfWHkcJl2EfEx jrdOjT0UMO3NhydUx3oW6niJTLIXKmSSvV97CBiH5BO83slnbBC68RLrjDCDKP3riT5U t2wl26bikvvIqQFrOIutYGDzP5fBlfYO3B5Q5mFILYBTdc1cSq2b6pDTVmHmcAdTF6U5 ujrRtSmcB5ERVLccKWaaeZtn7kCsm+8942Se2MW1n/xbb0mJGXgEzNJiQWB76AlrCKkW JF6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685168249; x=1687760249; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8bUpakl76o27hJf6ZRoQnS9ltw01zvaQbrcJZKpx2eI=; b=X64v7S45vObaSxPb7tiibawpXlMODAi1fgYYv/i2UFt7B0znz6Y97IA8Uyr6AJR4x6 MkyQHE7NS7SeqkB878wfbrkJCuttfiDCECw37P8zhu7AvCmGBKdigf/4zw3NATX0mSPW Zj+85yXprQp43mfSg9csbqhsKuu55C+beHPQx8qZjOnz4ccTO+B/X9ToPU7J0GNVyl/+ 8RjNKGMw68RmqQZesdukgX0d0Z5U22eXZKT4njojziRu5NJBV2pQQjoL/X04fhCdfoij ULaS2BNximxaroXpXHhrZerpCdeHe9khwViuYytp2LyPpzgGDvJ2xukB/l73eUr+dJ0f Go9w== X-Gm-Message-State: AC+VfDx60OmiCS0EPx4O0FuLWCCN3jcZrTVtH2sts1+McJMAASrkuY/u QqpHlCadYkD5bc+ZcxtTW6ydHKjnU99MMFEp X-Google-Smtp-Source: ACHHUZ6pQPVXD6h5TcL+9A9V394xFDfIwSAL93YpqhXt8z3S61IR/cHxCtyfj6nVpHBycW2rN5TikQ== X-Received: by 2002:a1c:4b11:0:b0:3f1:70a2:ceb5 with SMTP id y17-20020a1c4b11000000b003f170a2ceb5mr2856573wma.13.1685168248776; Fri, 26 May 2023 23:17:28 -0700 (PDT) Received: from localhost.localdomain (2a02-842a-002e-7001-f2b0-7c97-e26b-fbea.rev.sfr.net. [2a02:842a:2e:7001:f2b0:7c97:e26b:fbea]) by smtp.gmail.com with ESMTPSA id e8-20020a5d65c8000000b0030649242b72sm7014623wrw.113.2023.05.26.23.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 23:17:28 -0700 (PDT) From: belouargamohamed@gmail.com X-Google-Original-From: m.belouarga@technologyandstrategy.com To: openembedded-core@lists.openembedded.org Cc: e.aubineau@technologyandstrategy.com, f.lahoudere@technologyandstrategy.com, BELOUARGA Mohamed Subject: [kirkstone][PATCH 1/5] recipetool: create: npm: Remove duplicate function to not have future conflicts Date: Sat, 27 May 2023 08:17:22 +0200 Message-Id: <20230527061726.937747-1-m.belouarga@technologyandstrategy.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 ; Sat, 27 May 2023 12:07:20 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/181798 From: BELOUARGA Mohamed Npm packages do not have yocto friendly names. fore instance we can have names like "@example/npmPackage" npm fetcher has a function that convert these names to yocto friendly names. But in recipe tool we have an other function (duplicate). Signed-off-by: BELOUARGA Mohamed --- scripts/lib/recipetool/create_npm.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py index 3394a89970..e667a4d19b 100644 --- a/scripts/lib/recipetool/create_npm.py +++ b/scripts/lib/recipetool/create_npm.py @@ -13,6 +13,7 @@ import sys import tempfile import bb from bb.fetch2.npm import NpmEnvironment +from bb.fetch2.npm import npm_package from bb.fetch2.npmsw import foreach_dependencies from recipetool.create import RecipeHandler from recipetool.create import get_license_md5sums @@ -30,15 +31,6 @@ def tinfoil_init(instance): class NpmRecipeHandler(RecipeHandler): """Class to handle the npm recipe creation""" - @staticmethod - def _npm_name(name): - """Generate a Yocto friendly npm name""" - name = re.sub("/", "-", name) - name = name.lower() - name = re.sub(r"[^\-a-z0-9]", "", name) - name = name.strip("-") - return name - @staticmethod def _get_registry(lines): """Get the registry value from the 'npm://registry' url""" @@ -143,7 +135,7 @@ class NpmRecipeHandler(RecipeHandler): # Handle the dependencies def _handle_dependency(name, params, deptree): - suffix = "-".join([self._npm_name(dep) for dep in deptree]) + suffix = "-".join([npm_package(dep) for dep in deptree]) destdirs = [os.path.join("node_modules", dep) for dep in deptree] destdir = os.path.join(*destdirs) packages["${PN}-" + suffix] = destdir @@ -173,7 +165,7 @@ class NpmRecipeHandler(RecipeHandler): if "name" not in data or "version" not in data: return False - extravalues["PN"] = self._npm_name(data["name"]) + extravalues["PN"] = npm_package(data["name"]) extravalues["PV"] = data["version"] if "description" in data: From patchwork Sat May 27 06:17:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: belouargamohamed@gmail.com X-Patchwork-Id: 24607 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 A7B57C7EE31 for ; Sat, 27 May 2023 12:07:20 +0000 (UTC) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mx.groups.io with SMTP id smtpd.web11.5984.1685168252191732587 for ; Fri, 26 May 2023 23:17:32 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@gmail.com header.s=20221208 header.b=h7xsYDtK; spf=pass (domain: gmail.com, ip: 209.85.128.52, mailfrom: belouargamohamed@gmail.com) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-3f60e536250so17262475e9.1 for ; Fri, 26 May 2023 23:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685168250; x=1687760250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g2Pg2bBoqEJWl2vqD3mDnFoMzH6DPiC4LqbtV9o3gxY=; b=h7xsYDtKS5XRcbQ37mJww9HFIH+6S1UrzCa63t7Sc/Hd48WmAbh3zxPk29BtX3IttJ BRsXMZXIgUzxncWiWtq2rNUa4D3KS9ZnGjMCQNVYcVofQQSEpbRg89SWyRowKwjfD/Hu lNRRS8FVKb9+IwniHJ3zrcJAyx8LgD96lBwgcON5nysIqmmBc+zlRrvpQ5PRBAQ9OsuP XUXoh079WkEf3op2flx9MdpWBRuZJP2qclvg3vnLtZChICiw9KbscQx+1xKVVdJBE6ar N/OQTwNm6pVxmIB3+oocXq5qBWnByoOZgoWhl6ltSoBlHwhkNBegvilJkOL3BS6P/4Bt fVqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685168250; x=1687760250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g2Pg2bBoqEJWl2vqD3mDnFoMzH6DPiC4LqbtV9o3gxY=; b=VjtUW7uzsEupaKL6K9VBKAsWjTbKC8sZEIDyFtQehF5E9UnU4DWMQOJnaT9fzrVyEH 8L0bghRcfgd4HDzaKqIPB8QyqWsReFDlFwqGwa6lv8lZN4mdttHLZ+iTlXPie2En/osV e+bMfuZOIUN30q7GRzsEZcUfy9Dnwi0lYLiyXax4qhTiEpWdAbIbiGqZ7NvLIU3fXHGd eTCHeeMYOLLagzd2L7dfI0cSzlIJVj/VbP2KVzTSqhxE3Dsv1SUnq9gpCXmAPOdLrJQG 7M0UIBLQ1m313TlLfjdSBdXt/YJsQ0tZV37MdX6HjggI0qD6y37XDjrpuiGsIFod5afl 0tzw== X-Gm-Message-State: AC+VfDz204CXoQKbve4PRhpBQXkfhPx6lVGXuZ8wUK2cLm6jaBqLWctP lHyX+swXBd1AU6TQIP3BVNeX/AyhbW3NYCtN X-Google-Smtp-Source: ACHHUZ7vb3dwO7uioLB6pLZHf3Uj7PdIa+gNfGhqhtLgRElOjvU7IiR6y5cyzOf7KNFzUGhJbRN91w== X-Received: by 2002:a5d:4806:0:b0:30a:c5dc:6c47 with SMTP id l6-20020a5d4806000000b0030ac5dc6c47mr918367wrq.34.1685168250293; Fri, 26 May 2023 23:17:30 -0700 (PDT) Received: from localhost.localdomain (2a02-842a-002e-7001-f2b0-7c97-e26b-fbea.rev.sfr.net. [2a02:842a:2e:7001:f2b0:7c97:e26b:fbea]) by smtp.gmail.com with ESMTPSA id e8-20020a5d65c8000000b0030649242b72sm7014623wrw.113.2023.05.26.23.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 23:17:29 -0700 (PDT) From: belouargamohamed@gmail.com X-Google-Original-From: m.belouarga@technologyandstrategy.com To: openembedded-core@lists.openembedded.org Cc: e.aubineau@technologyandstrategy.com, f.lahoudere@technologyandstrategy.com, BELOUARGA Mohamed Subject: [kirkstone][PATCH 2/5] classes: npm: Handle peer dependencies for npm packages Date: Sat, 27 May 2023 08:17:23 +0200 Message-Id: <20230527061726.937747-2-m.belouarga@technologyandstrategy.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230527061726.937747-1-m.belouarga@technologyandstrategy.com> References: <20230527061726.937747-1-m.belouarga@technologyandstrategy.com> MIME-Version: 1.0 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 ; Sat, 27 May 2023 12:07:20 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/181799 From: BELOUARGA Mohamed NPM changed its manner to handle peer dependencies over its versions: - Before NPM 3: NPM installs automatically peer dependencies - Between NPM 3 and 7: NPM shows a warning about peer dependencies - After NPM 3: NPM reworked its manner how to handle peer dependencies The shrinkwrap doesn't have the parameters of the peer dependencies, so we cannot fetch them. in the same time peer dependencies are not direct dependencies, they should be installed as run time dependencies. Signed-off-by: BELOUARGA Mohamed --- meta/classes/npm.bbclass | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/meta/classes/npm.bbclass b/meta/classes/npm.bbclass index 8379c7b988..abc4c6f92b 100644 --- a/meta/classes/npm.bbclass +++ b/meta/classes/npm.bbclass @@ -108,6 +108,7 @@ python npm_do_configure() { import tempfile from bb.fetch2.npm import NpmEnvironment from bb.fetch2.npm import npm_unpack + from bb.fetch2.npm import npm_package from bb.fetch2.npmsw import foreach_dependencies from bb.progress import OutOfProgressHandler from oe.npm_registry import NpmRegistry @@ -168,6 +169,7 @@ python npm_do_configure() { if has_shrinkwrap_file: cached_shrinkwrap = copy.deepcopy(orig_shrinkwrap) cached_shrinkwrap.pop("dependencies", None) + cached_shrinkwrap["packages"][""].pop("peerDependencies", None) # Manage the dependencies progress = OutOfProgressHandler(d, r"^(\d+)/(\d+)$") @@ -202,6 +204,19 @@ python npm_do_configure() { if has_shrinkwrap_file: foreach_dependencies(orig_shrinkwrap, _count_dependency, dev) foreach_dependencies(orig_shrinkwrap, _cache_dependency, dev) + + # Manage Peer Dependencies + if has_shrinkwrap_file: + packages = orig_shrinkwrap.get("packages", {}) + peer_deps = packages.get("", {}).get("peerDependencies", {}) + package_runtime_dependencies = d.getVar("RDEPENDS:%s" % d.getVar("PN")) + + for peer_dep in peer_deps: + peer_dep_yocto_name = npm_package(peer_dep) + if peer_dep_yocto_name not in package_runtime_dependencies: + bb.warn(peer_dep + " is a peer dependencie that is not in RDEPENDS variable. " + + "Please add this peer dependencie to the RDEPENDS variable as %s and generate its recipe with devtool" + % peer_dep_yocto_name) # Configure the main package with tempfile.TemporaryDirectory() as tmpdir: @@ -277,6 +292,9 @@ python npm_do_compile() { args.append(("target_arch", d.getVar("NPM_ARCH"))) args.append(("build-from-source", "true")) + # Don't install peer dependencies as they should be in RDEPENDS variable + args.append(("legacy-peer-deps", "true")) + # Pack and install the main package (tarball, _) = npm_pack(env, d.getVar("NPM_PACKAGE"), tmpdir) cmd = "npm install %s %s" % (shlex.quote(tarball), d.getVar("EXTRA_OENPM")) From patchwork Sat May 27 06:17:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: belouargamohamed@gmail.com X-Patchwork-Id: 24609 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 B547CC7EE2F for ; Sat, 27 May 2023 12:07:20 +0000 (UTC) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mx.groups.io with SMTP id smtpd.web11.5985.1685168253900791776 for ; Fri, 26 May 2023 23:17:34 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@gmail.com header.s=20221208 header.b=M/8Xu0oq; spf=pass (domain: gmail.com, ip: 209.85.221.48, mailfrom: belouargamohamed@gmail.com) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-30957dd7640so845266f8f.3 for ; Fri, 26 May 2023 23:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685168252; x=1687760252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2irKUYwyYh1dcWlnjohfgaLhlT8ND93pcpRz1tlDtpw=; b=M/8Xu0oqe759Fz8f1+sLxhtgKwLXGFq1DvlLCMGTsi0OW4gsPuY/6qdR0kx7LVzwmY eFcuKMl9D6hCDUorT+TdWJdElG4XpcmEuvrobixc5mI+NMKioQr4LRYbwapXbLcX1ACb wIBmnwZb3CuvRDwThXVUdm4HMcJl2C9wR52kkQz3TTdgYNQ9uTonu9jKxcTWPNugOHYq VkWOmbji8vrbgwnY1P2r/LY1i0L23dJM6ZYXF1W4AEttGilCBqutTxTTYwS/mC1TIkMj RriFZWeFWZzvXz8APUU6fmYHU6o9DGqMU4OEZAfup+lNe9LWDgK44ez3Zh8y2hRPxw6w cftQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685168252; x=1687760252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2irKUYwyYh1dcWlnjohfgaLhlT8ND93pcpRz1tlDtpw=; b=KKa7POwqC58pC3mnwHnAuwocMVvbEZCVoaEtoYpEwk8jnXDIS+mE8t8021cKJjRDzg Wew9aLQHygU1dmhk+wlL6Vd7ocPVHMznVWnexQ8Y4drhLqIdT4jYCL8c75j3CBLyi5Y+ n4InPhtBMScXU94FxmGsnqfb7CoFO5t+MAXbHMkTuWOvbC7dfEvuyc1yksM/NOVP69aT Cqe+LORjjwJyTWLtrVlSy3g781WEF+x6BjqTRUJq5Q4nipna0ZyCRhS1tipPEGeDr59b 9lMxTSGSyB6Qovzp6xSXmiJxD84s49cTyv7BxW4CwGMuePFF46JP8pkAsVsI3lYkmOzQ 50ew== X-Gm-Message-State: AC+VfDw2HXyVbgkQJvdo9A0VyX2/WyXw+tOCxJsSybJitHre7w45nQa/ UnjvNh0KZvZHqHVYHK6vmctfNEPedLr4nXkx X-Google-Smtp-Source: ACHHUZ5jd+H+T6auJyGPpK/a99EXJW1fGUOh76C6GLH16XOsgQqUprFgxPILGKSIa0SH/k29SQkrUQ== X-Received: by 2002:adf:e4cf:0:b0:306:475d:92ff with SMTP id v15-20020adfe4cf000000b00306475d92ffmr2347398wrm.3.1685168251717; Fri, 26 May 2023 23:17:31 -0700 (PDT) Received: from localhost.localdomain (2a02-842a-002e-7001-f2b0-7c97-e26b-fbea.rev.sfr.net. [2a02:842a:2e:7001:f2b0:7c97:e26b:fbea]) by smtp.gmail.com with ESMTPSA id e8-20020a5d65c8000000b0030649242b72sm7014623wrw.113.2023.05.26.23.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 23:17:31 -0700 (PDT) From: belouargamohamed@gmail.com X-Google-Original-From: m.belouarga@technologyandstrategy.com To: openembedded-core@lists.openembedded.org Cc: e.aubineau@technologyandstrategy.com, f.lahoudere@technologyandstrategy.com, BELOUARGA Mohamed Subject: [kirkstone][PATCH 3/5] recipetool: create: npm: Add support for the new format of the shrinkwrap file Date: Sat, 27 May 2023 08:17:24 +0200 Message-Id: <20230527061726.937747-3-m.belouarga@technologyandstrategy.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230527061726.937747-1-m.belouarga@technologyandstrategy.com> References: <20230527061726.937747-1-m.belouarga@technologyandstrategy.com> MIME-Version: 1.0 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 ; Sat, 27 May 2023 12:07:20 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/181800 From: BELOUARGA Mohamed The shrinkwrap file changed its format, but npm does not version this file. So we can use it properly. The actual changes make the script check if the npm package has dependencies in the actual shrinkwrap format. Signed-off-by: BELOUARGA Mohamed --- scripts/lib/recipetool/create_npm.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py index e667a4d19b..25e7ddb472 100644 --- a/scripts/lib/recipetool/create_npm.py +++ b/scripts/lib/recipetool/create_npm.py @@ -134,11 +134,10 @@ class NpmRecipeHandler(RecipeHandler): licfiles.append(os.path.relpath(readme, srctree)) # Handle the dependencies - def _handle_dependency(name, params, deptree): + def _handle_dependency(name, params, destdir): + deptree = destdir.split('node_modules/') suffix = "-".join([npm_package(dep) for dep in deptree]) - destdirs = [os.path.join("node_modules", dep) for dep in deptree] - destdir = os.path.join(*destdirs) - packages["${PN}-" + suffix] = destdir + packages["${PN}" + suffix] = destdir _licfiles_append_fallback_readme_files(destdir) with open(shrinkwrap_file, "r") as f: @@ -234,7 +233,7 @@ class NpmRecipeHandler(RecipeHandler): value = origvalue.replace("version=" + data["version"], "version=${PV}") value = value.replace("version=latest", "version=${PV}") values = [line.strip() for line in value.strip('\n').splitlines()] - if "dependencies" in shrinkwrap: + if "dependencies" in shrinkwrap.get("packages", {}).get("", {}): values.append(url_recipe) return values, None, 4, False From patchwork Sat May 27 06:17:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: belouargamohamed@gmail.com X-Patchwork-Id: 24610 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 B7723C7EE32 for ; Sat, 27 May 2023 12:07:20 +0000 (UTC) Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mx.groups.io with SMTP id smtpd.web11.5986.1685168254951227736 for ; Fri, 26 May 2023 23:17:35 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@gmail.com header.s=20221208 header.b=nhjd6xBK; spf=pass (domain: gmail.com, ip: 209.85.221.43, mailfrom: belouargamohamed@gmail.com) Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3093eb8cd1fso906210f8f.1 for ; Fri, 26 May 2023 23:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685168253; x=1687760253; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i8/dDsCJrSYL8PrYUOdwWzwHq/4ZBZ2SonINWnKkMkw=; b=nhjd6xBKUdPV99h/Ub/FCpovZK6aywdhtC6uf7ldQTRiSY8EI9SygpGJTSnymXkhK2 o5760jNk/1NgNlZbuW28zO9AXxNfJZGQUJ/4G7ReEwiIzkz21CQi5OtKFEX3IcCOpiCa 4pM3V9TMuR5Ca2Yz2l3zN+BKElNb32mUz7361x9ROk2zh+xlZ1Rprg28/4JDQ3H5jxro J230LL6PsgJDbjcyLzSB3jYVPeHVBJDkeyP03m82bQDHD1Az2rwsdxOH59c6aOE+8Fz8 SJ2M3FOCdYk1enEDVFeq6ogwEr2VXlnqIKYdvS++49JtHL8ZEEAbSvPjqT6EE5pptItK +mMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685168253; x=1687760253; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i8/dDsCJrSYL8PrYUOdwWzwHq/4ZBZ2SonINWnKkMkw=; b=bI5Aw/OBl+1Xu3XHvtjFSZpYg3E9MhuTSxo8Y84dGG6YdP8Hm+QtRdqtkGDA8lBJaD Ms0+o5P/tT7JGD9aQTckBjVFj04UPA8QQV6ZrjQAWUy+MIz0pW/y1uSR+vkStWsshjOB TPSThGQoVQ9bSryLZ7oVTqr2NuijSJeLpZw9yaAbf0ffMzwwonAc35GxVaJXWOrGR5Wa 3fZtv9tRWwHMitqlOA4iO2oOrxQOHLSlMzZVbOoUzoc4VCBLlIqNcYRq3kFPepfbAsbe 2BdTztugyVWwLyPyYepbQOFPDGov22M5Mw3vl9NiLCFwTK78wmYeAjh990RSHngeGPWq mM0A== X-Gm-Message-State: AC+VfDwGF9VbELx96KrLQHgdLAJfJzkUEGaYqKFmrs3y5ro6oN1orkfQ +sgRnvcy8KVhBFA4x6KvlUPBwUDsKYBM8pKW X-Google-Smtp-Source: ACHHUZ6vd7LBdH/3+GIWUoVJMPsxro7VHJ9/g2YPSSf6GxU5qI/SHywo1lAfrcdWHA94XEUR6Dkm4g== X-Received: by 2002:a5d:5685:0:b0:309:4b55:419d with SMTP id f5-20020a5d5685000000b003094b55419dmr3302731wrv.8.1685168252993; Fri, 26 May 2023 23:17:32 -0700 (PDT) Received: from localhost.localdomain (2a02-842a-002e-7001-f2b0-7c97-e26b-fbea.rev.sfr.net. [2a02:842a:2e:7001:f2b0:7c97:e26b:fbea]) by smtp.gmail.com with ESMTPSA id e8-20020a5d65c8000000b0030649242b72sm7014623wrw.113.2023.05.26.23.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 23:17:32 -0700 (PDT) From: belouargamohamed@gmail.com X-Google-Original-From: m.belouarga@technologyandstrategy.com To: openembedded-core@lists.openembedded.org Cc: e.aubineau@technologyandstrategy.com, f.lahoudere@technologyandstrategy.com, BELOUARGA Mohamed Subject: [kirkstone][PATCH 4/5] recipetool: create: npm: Add support to handle peer dependencies Date: Sat, 27 May 2023 08:17:25 +0200 Message-Id: <20230527061726.937747-4-m.belouarga@technologyandstrategy.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230527061726.937747-1-m.belouarga@technologyandstrategy.com> References: <20230527061726.937747-1-m.belouarga@technologyandstrategy.com> MIME-Version: 1.0 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 ; Sat, 27 May 2023 12:07:20 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/181801 From: BELOUARGA Mohamed NPM changed its manner to handle peer dependencies over its versions: - Before NPM 3: NPM installs automatically peer dependencies - Between NPM 3 and 7: NPM shows a warning about peer dependencies - After NPM 3: NPM reworked its manner how to handle peer dependencies The shrinkwrap doesn't have the parameters of the peer dependencies, so we cannot fetch them. in the same time peer dependencies are not direct dependencies, they should be installed as run time dependencies. Signed-off-by: BELOUARGA Mohamed --- scripts/lib/recipetool/create_npm.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py index 25e7ddb472..113a89f6a6 100644 --- a/scripts/lib/recipetool/create_npm.py +++ b/scripts/lib/recipetool/create_npm.py @@ -146,6 +146,23 @@ class NpmRecipeHandler(RecipeHandler): foreach_dependencies(shrinkwrap, _handle_dependency, dev) return licfiles, packages + + # Handle the peer dependencies + def _handle_peer_dependency(self, shrinkwrap_file): + """Check if package has peer dependencies and show warning if it is the case""" + with open(shrinkwrap_file, "r") as f: + shrinkwrap = json.load(f) + + packages = shrinkwrap.get("packages", {}) + peer_deps = packages.get("", {}).get("peerDependencies", {}) + + for peer_dep in peer_deps: + peer_dep_yocto_name = npm_package(peer_dep) + bb.warn(peer_dep + " is a peer dependencie of the actual package. " + + "Please add this peer dependencie to the RDEPENDS variable as %s and generate its recipe with devtool" + % peer_dep_yocto_name) + + def process(self, srctree, classes, lines_before, lines_after, handled, extravalues): """Handle the npm recipe creation""" @@ -283,6 +300,9 @@ class NpmRecipeHandler(RecipeHandler): classes.append("npm") handled.append("buildsystem") + # Check if package has peer dependencies and inform the user + self._handle_peer_dependency(shrinkwrap_file) + return True def register_recipe_handlers(handlers): From patchwork Sat May 27 06:17:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: belouargamohamed@gmail.com X-Patchwork-Id: 24611 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 A0301C77B7C for ; Sat, 27 May 2023 12:07:20 +0000 (UTC) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mx.groups.io with SMTP id smtpd.web10.5762.1685168256242174105 for ; Fri, 26 May 2023 23:17:36 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@gmail.com header.s=20221208 header.b=dvbzHu2e; spf=pass (domain: gmail.com, ip: 209.85.221.44, mailfrom: belouargamohamed@gmail.com) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-30ab87a1897so848548f8f.1 for ; Fri, 26 May 2023 23:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685168254; x=1687760254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ykaw+olWTZ0e8jh7zgVVzcbFHBjvbKsIgcOS3GLFZk0=; b=dvbzHu2ema4IXS4PW2mArLxls3Vt43jbGYIEH1XojqSRZiwVfa3r3/cv6gqi7IsvGh iTgMfd6vX1Fpsqnn97DfvkTKAEIO2Si7DDaKTuMuI1D8C+QwL5cX4WPXtWnZom4rpj6w gpInIoAm1K0hnZbkRLPaMgFc+0eCL2dKJ3Cea72GqVSJNdWSxvJhlD96BtHium8I1jor rteCflGJDoy2bi0ry+2tswtmPTgGuCWBSiW38FiUMYlGQrkCEd0spLEf6ZqgsR/hLVJI 11kzqfFWgQKALbg5fJP2u25V2HtaJ5pGQSHh953uo2SHUQgjj45i4kLEFN4Cj6a6hDxE F2Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685168254; x=1687760254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ykaw+olWTZ0e8jh7zgVVzcbFHBjvbKsIgcOS3GLFZk0=; b=YPt3t4nDBfFL1JFcJAcg44P+QUuBBzZGYfII0PMPV81Ek5ZX+9ggxGPgiZwYjjGK89 2TDXM83zreJURrSMViBEbMb7E4OgDZL/bPvrOBj5hqzwM0iolc1zrwneUacWCK2G8X37 8iCB+b2MQFt8wZBMsFm8tSWQvSP+5TJDKzC8lxLxaQ4wbQ5EUeZ51d9QF1GFoWmlsP98 kAWK1VQ7MbTohOzgw4hqnehrynHJhUtXC1r68YG7yEM5O0HkHFdnPrEanK1meKv3GQXc wQ+Wx0L0mjNTD+X6rMHd8pbMgrXWHqw6Gcb/KZY/of3oM+k+mFCM6VeInXYye4KFS/7S 4dlw== X-Gm-Message-State: AC+VfDw68LaZryhhNcWUpqVCYWXou8R6OLyqCvhWMpqW2Rg1/5L8LzU7 dduL7DXr00Lg25odyhUvTj4fH3QIIsrT/P+0 X-Google-Smtp-Source: ACHHUZ43V7OB3cVafx4X8DLGs/nodOMnMf2w6gQSw7vbqn0vyVPpuht0kgTKpu9J27Ca73ZITMaDWw== X-Received: by 2002:adf:fd8d:0:b0:30a:dff0:7bac with SMTP id d13-20020adffd8d000000b0030adff07bacmr1659521wrr.30.1685168254348; Fri, 26 May 2023 23:17:34 -0700 (PDT) Received: from localhost.localdomain (2a02-842a-002e-7001-f2b0-7c97-e26b-fbea.rev.sfr.net. [2a02:842a:2e:7001:f2b0:7c97:e26b:fbea]) by smtp.gmail.com with ESMTPSA id e8-20020a5d65c8000000b0030649242b72sm7014623wrw.113.2023.05.26.23.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 23:17:34 -0700 (PDT) From: belouargamohamed@gmail.com X-Google-Original-From: m.belouarga@technologyandstrategy.com To: openembedded-core@lists.openembedded.org Cc: e.aubineau@technologyandstrategy.com, f.lahoudere@technologyandstrategy.com, BELOUARGA Mohamed Subject: [kirkstone][PATCH 5/5] classes: npm: Add support for the new format of the shrinkwrap file Date: Sat, 27 May 2023 08:17:26 +0200 Message-Id: <20230527061726.937747-5-m.belouarga@technologyandstrategy.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230527061726.937747-1-m.belouarga@technologyandstrategy.com> References: <20230527061726.937747-1-m.belouarga@technologyandstrategy.com> MIME-Version: 1.0 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 ; Sat, 27 May 2023 12:07:20 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/181802 From: BELOUARGA Mohamed 1 - Adapt do_configure to the new format of the shrinkwrap 2 - Remove useless function _npmsw_dependency_dict because the dictionnary is already given by npmsw:foreach_dependencies 3 - Rename arguments of callback functions Signed-off-by: BELOUARGA Mohamed --- meta/classes/npm.bbclass | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/meta/classes/npm.bbclass b/meta/classes/npm.bbclass index abc4c6f92b..6899a64909 100644 --- a/meta/classes/npm.bbclass +++ b/meta/classes/npm.bbclass @@ -129,22 +129,6 @@ python npm_do_configure() { sha512 = bb.utils.sha512_file(tarball) return "sha512-" + base64.b64encode(bytes.fromhex(sha512)).decode() - def _npmsw_dependency_dict(orig, deptree): - """ - Return the sub dictionary in the 'orig' dictionary corresponding to the - 'deptree' dependency tree. This function follows the shrinkwrap file - format. - """ - ptr = orig - for dep in deptree: - if "dependencies" not in ptr: - ptr["dependencies"] = {} - ptr = ptr["dependencies"] - if dep not in ptr: - ptr[dep] = {} - ptr = ptr[dep] - return ptr - # Manage the manifest file and shrinkwrap files orig_manifest_file = d.expand("${S}/package.json") orig_shrinkwrap_file = d.expand("${S}/npm-shrinkwrap.json") @@ -176,24 +160,25 @@ python npm_do_configure() { progress_total = 1 # also count the main package progress_done = 0 - def _count_dependency(name, params, deptree): + def _count_dependency(name, params, destsuffix): nonlocal progress_total progress_total += 1 - def _cache_dependency(name, params, deptree): - destsubdirs = [os.path.join("node_modules", dep) for dep in deptree] - destsuffix = os.path.join(*destsubdirs) + def _cache_dependency(name, params, destsuffix): with tempfile.TemporaryDirectory() as tmpdir: # Add the dependency to the npm cache destdir = os.path.join(d.getVar("S"), destsuffix) (tarball, pkg) = npm_pack(env, destdir, tmpdir) _npm_cache_add(tarball, pkg) # Add its signature to the cached shrinkwrap - dep = _npmsw_dependency_dict(cached_shrinkwrap, deptree) + dep = params dep["version"] = pkg['version'] dep["integrity"] = _npm_integrity(tarball) if params.get("dev", False): dep["dev"] = True + if "dependencies" not in cached_shrinkwrap: + cached_shrinkwrap["dependencies"] = {} + cached_shrinkwrap["dependencies"][name] = dep # Display progress nonlocal progress_done progress_done += 1