diff options
author | Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> | 2021-12-13 12:13:53 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-01-05 17:36:26 +0000 |
commit | 0fb31e3238eac64ff3313c13bd157a1f7ce65133 (patch) | |
tree | 68c9557df90b396810ececd6ab5b90514729b964 /bitbake | |
parent | 9676f72521191219f88d64d8da9f83d7b4fe605c (diff) | |
download | poky-0fb31e3238eac64ff3313c13bd157a1f7ce65133.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: 56f6e7b5f86f1dc630c50a67e9027c1798a56a34)
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 9f272ad7f76c1559e745e9af686d0a529f917659)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-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 | ||