Skip to contentSkip to conversation

npm: Convert to list-based commands for NpmEnvironment.run()

PATCH In review Eric Meyers 2 participants 3 messages Jun 10

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 npm: Convert to list-based commands for NpmEnvironment.run()

This only affects those who have bypassed npm being disabled in bitbake (post commit 355cd226)

This recent upstream bitbake commit:
https://git.openembedded.org/bitbake/commit/?id=2ee0a002cd50eec1a0743c9ced9e07e529c79ddf

broke npm install commands within the npm bitbake class since NpmEnvironment.run() expects a list instead of a string. Update the remaining callers to pass list-based commands to avoid:

AttributeError: 'str' object has no attribute 'append'

---
 meta/classes-recipe/npm.bbclass      | 2 +-
 scripts/lib/recipetool/create_npm.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
meta/classes-recipe/npm.bbclass +1 -1
index 7bb791d543..b1183a7ae3 100644
@@ -300,7 +300,7 @@ python npm_do_compile() {
 
         # 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"))
+        cmd = ["npm", "install", tarball] + shlex.split(d.getVar("EXTRA_OENPM") or "")
         env.run(cmd, args=args)
 }
 
scripts/lib/recipetool/create_npm.py +2 -2
index 8c4cdd5234..4d316d9a55 100644
@@ -97,14 +97,14 @@ class NpmRecipeHandler(RecipeHandler):
         bb.utils.remove(os.path.join(srctree, "node_modules"), recurse=True)
 
         env = NpmEnvironment(d, configs=configs)
-        env.run("npm install", workdir=srctree)
+        env.run(["npm", "install"], workdir=srctree)
 
     def _generate_shrinkwrap(self, d, srctree, dev):
         """Check and generate the 'npm-shrinkwrap.json' file if needed"""
         configs = self._npm_global_configs(dev)
 
         env = NpmEnvironment(d, configs=configs)
-        env.run("npm shrinkwrap", workdir=srctree)
+        env.run(["npm", "shrinkwrap"], workdir=srctree)
 
         return os.path.join(srctree, "npm-shrinkwrap.json")
 
#1 lore raw
Quoted 2 lines · Eric Meyers via lists.openembedded.org

This only affects those who have bypassed npm being disabled in bitbake (post commit 355cd226)

I am curious if you plan to help fix/maintain the npm fetcher?

If nobody actually steps up and fixes it, I will remove it. I'm getting a bit tired of maintaining things I have no interest in with no help from the people who actually use it.

Cheers,

Richard

#2 lore raw
Quoted 7 lines · Richard Purdie
Quoted 2 lines · Eric Meyers via lists.openembedded.org

This only affects those who have bypassed npm being disabled in bitbake (post commit 355cd226)

I am curious if you plan to help fix/maintain the npm fetcher?

Quoted 8 lines

If nobody actually steps up and fixes it, I will remove it. I'm getting a bit tired of maintaining things I have no interest in with no help from the people who actually use it.

Cheers,

Richard

We are using a kas patch to temporarily bypass the disabling of the npm fetcher as a stopgap until we figure out a solution for how to pull in the node-related repos. There hasn't been necessarily a need lately due to the kas patch, but I'm personally in favor of removing it altogether as it would be a forcing function to come up with a better (probably more secure) solution.