diff mbox series

[kirkstone,1/5] recipetool: create: npm: Remove duplicate function to not have future conflicts

Message ID 20230527062532.938477-1-m.belouarga@technologyandstrategy.com
State New, archived
Headers show
Series [kirkstone,1/5] recipetool: create: npm: Remove duplicate function to not have future conflicts | expand

Commit Message

belouargamohamed@gmail.com May 27, 2023, 6:25 a.m. UTC
From: BELOUARGA Mohamed <m.belouarga@technologyandstrategy.com>

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 <m.belouarga@technologyandstrategy.com>
---
 scripts/lib/recipetool/create_npm.py | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Steve Sakoman May 29, 2023, 3:13 p.m. UTC | #1
Are these same issues present in the master branch?  If so, this
series should be submitted for the master branch first, and I will
then backport to kirkstone (and mickledore).

Steve

On Fri, May 26, 2023 at 8:25 PM <belouargamohamed@gmail.com> wrote:
>
> From: BELOUARGA Mohamed <m.belouarga@technologyandstrategy.com>
>
> 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 <m.belouarga@technologyandstrategy.com>
> ---
>  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:
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#181791): https://lists.openembedded.org/g/openembedded-core/message/181791
> Mute This Topic: https://lists.openembedded.org/mt/99163838/3620601
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [steve@sakoman.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
belouargamohamed@gmail.com May 29, 2023, 8:16 p.m. UTC | #2
Yes, the same issues are present in master branch.

But this series of patches won't work on master, it needs some adaptation.

Because in kirkstone we have Nodejs 16.19.1 and in master we have Nodejs 18.16, and they generate shrinkwrap files that are slightly different.

For Mickledore, I didn't test yet but I think that it will work like in the master branch.

Note: these changes work only if my patch for bitbake is accepted: https://lists.openembedded.org/g/bitbake-devel/topic/kirkstone_patch_fetch2/99163598?p=,,,20,0,0,0::recentpostdate/sticky,,,20,2,0,99163598,previd%3D1685367798112436212,nextid%3D1683629533018906083&previd=1685367798112436212&nextid=1683629533018906083

Best regards,
BELOUARGA Mohamed
Steve Sakoman May 29, 2023, 10:59 p.m. UTC | #3
Forgot to reply all!

---------- Forwarded message ---------
From: Steve Sakoman <steve@sakoman.com>
Date: Mon, May 29, 2023 at 12:58 PM
Subject: Re: [OE-core] [kirkstone][PATCH 1/5] recipetool: create: npm:
Remove duplicate function to not have future conflicts
To: <belouargamohamed@gmail.com>


On Mon, May 29, 2023 at 10:16 AM <belouargamohamed@gmail.com> wrote:
>
> Yes, the same issues are present in master branch.
>
> But this series of patches won't work on master, it needs some adaptation.

In that case you will also need to submit a modified series for master
(which will hopefully cherry-pick to mickledore)

At that point I can take the kirkstone version of the patch.  The
reason is that we don't want to have issues fixed in a stable branch
that aren't also fixed in master.

Thanks!

Steve

> Because in kirkstone we have Nodejs 16.19.1 and in master we have Nodejs 18.16, and they generate shrinkwrap files that are slightly different.
>
> For Mickledore, I didn't test yet but I think that it will work like in the master branch.
>
>  Note: these changes work only if my patch for bitbake is accepted: https://lists.openembedded.org/g/bitbake-devel/topic/kirkstone_patch_fetch2/99163598?p=,,,20,0,0,0::recentpostdate/sticky,,,20,2,0,99163598,previd%3D1685367798112436212,nextid%3D1683629533018906083&previd=1685367798112436212&nextid=1683629533018906083
>
> Best regards,
> BELOUARGA Mohamed
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#181892): https://lists.openembedded.org/g/openembedded-core/message/181892
> Mute This Topic: https://lists.openembedded.org/mt/99163838/3620601
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [steve@sakoman.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
belouargamohamed@gmail.com May 31, 2023, 8:27 p.m. UTC | #4
Hello,

I fixed the problem on master branch.
*For master:*

In order that my changes work, Some patches on bitbake should be accepted:
https://lists.openembedded.org/g/bitbake-devel/message/14815?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cbelouarga%2C20%2C2%2C0%2C99163598
https://lists.openembedded.org/g/bitbake-devel/message/14819?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cbelouarga%2C20%2C2%2C0%2C99230772
https://lists.openembedded.org/g/bitbake-devel/message/14820?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cbelouarga%2C20%2C2%2C0%2C99248868
And:
https://lists.openembedded.org/g/openembedded-core/message/182022?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cbelouarga%2C20%2C2%2C0%2C99248914
And this series of patches:
https://lists.openembedded.org/g/openembedded-core/message/181961?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cbelouarga%2C20%2C2%2C0%2C99230551

*For kirkstone:*
In order that my changes work, Some patches on bitbake should be accepted:
https://lists.openembedded.org/g/bitbake-devel/message/14815?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cbelouarga%2C20%2C2%2C0%2C99163598
https://lists.openembedded.org/g/bitbake-devel/message/14819?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cbelouarga%2C20%2C2%2C0%2C99230772
https://lists.openembedded.org/g/bitbake-devel/message/14820?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cbelouarga%2C20%2C2%2C0%2C99248868

And this series of patches.

Thanks
diff mbox series

Patch

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: