diff options
author | Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> | 2021-12-13 12:13:53 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-12-14 22:47:04 +0000 |
commit | 31bc9cab25692fd0b07dbd994afd93802e93d6bf (patch) | |
tree | 12cebf1d180ddb3071298d62c2a2ef036e1952f5 | |
parent | bb42e4b35601a2fe94c93b4c35c6d59a3e439606 (diff) | |
download | poky-31bc9cab25692fd0b07dbd994afd93802e93d6bf.tar.gz |
bitbake: fetch: npm: Use temporary file for empty user config
Always use a temporary file for the user config 'NPM_CONFIG_USERCONFIG'
because npm otherwise failed if configs and npmrc aren't set:
double-loading config "/dev/null" as "global", previously loaded as "user"
(Bitbake rev: 9f272ad7f76c1559e745e9af686d0a529f917659)
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/fetch2/npm.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py index d9daec2092..b3a3a444ee 100644 --- a/bitbake/lib/bb/fetch2/npm.py +++ b/bitbake/lib/bb/fetch2/npm.py | |||
@@ -79,16 +79,12 @@ class NpmEnvironment(object): | |||
79 | Using a npm config file seems more reliable than using cli arguments. | 79 | Using a npm config file seems more reliable than using cli arguments. |
80 | This class allows to create a controlled environment for npm commands. | 80 | This class allows to create a controlled environment for npm commands. |
81 | """ | 81 | """ |
82 | def __init__(self, d, configs=None, npmrc=None): | 82 | def __init__(self, d, configs=[], npmrc=None): |
83 | self.d = d | 83 | self.d = d |
84 | 84 | ||
85 | if configs: | 85 | self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1) |
86 | self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1) | 86 | for key, value in configs: |
87 | self.user_config_name = self.user_config.name | 87 | self.user_config.write("%s=%s\n" % (key, value)) |
88 | for key, value in configs: | ||
89 | self.user_config.write("%s=%s\n" % (key, value)) | ||
90 | else: | ||
91 | self.user_config_name = "/dev/null" | ||
92 | 88 | ||
93 | if npmrc: | 89 | if npmrc: |
94 | self.global_config_name = npmrc | 90 | self.global_config_name = npmrc |
@@ -109,7 +105,7 @@ class NpmEnvironment(object): | |||
109 | workdir = tmpdir | 105 | workdir = tmpdir |
110 | 106 | ||
111 | def _run(cmd): | 107 | def _run(cmd): |
112 | cmd = "NPM_CONFIG_USERCONFIG=%s " % (self.user_config_name) + cmd | 108 | cmd = "NPM_CONFIG_USERCONFIG=%s " % (self.user_config.name) + cmd |
113 | cmd = "NPM_CONFIG_GLOBALCONFIG=%s " % (self.global_config_name) + cmd | 109 | cmd = "NPM_CONFIG_GLOBALCONFIG=%s " % (self.global_config_name) + cmd |
114 | return runfetchcmd(cmd, d, workdir=workdir) | 110 | return runfetchcmd(cmd, d, workdir=workdir) |
115 | 111 | ||