diff options
| author | Eric Meyers <eric.meyers15310@gmail.com> | 2025-02-28 07:01:36 -0600 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-03-09 20:10:06 +0000 |
| commit | 57adda32c528fa30509eb55ca8423fa4ad6e4992 (patch) | |
| tree | ba8ca8b245f631f133e7b39a7a54005f3e596a18 /bitbake | |
| parent | 3480f4dbe9f9f285c75c1e874ddf994400c08c16 (diff) | |
| download | poky-57adda32c528fa30509eb55ca8423fa4ad6e4992.tar.gz | |
bitbake: fetch2/npm: Adding npmrc support for private registry authentication
(Bitbake rev: 5fa6137b6d98544766f3152b874e67d04fafb88f)
Signed-off-by: Eric Meyers <eric.meyers@arthrex.com>
Cc: Geoff Parker <geoffrey.parker@arthrex.com>
Cc: Chuck Wolber <chuckwolber@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
| -rw-r--r-- | bitbake/lib/bb/fetch2/npm.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py index c09f050448..e469d66768 100644 --- a/bitbake/lib/bb/fetch2/npm.py +++ b/bitbake/lib/bb/fetch2/npm.py | |||
| @@ -91,6 +91,12 @@ class NpmEnvironment(object): | |||
| 91 | self.d = d | 91 | self.d = d |
| 92 | 92 | ||
| 93 | self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1) | 93 | self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1) |
| 94 | |||
| 95 | hn = self._home_npmrc(d) | ||
| 96 | if hn is not None: | ||
| 97 | with open(hn, 'r') as hnf: | ||
| 98 | self.user_config.write(hnf.read()) | ||
| 99 | |||
| 94 | for key, value in configs: | 100 | for key, value in configs: |
| 95 | self.user_config.write("%s=%s\n" % (key, value)) | 101 | self.user_config.write("%s=%s\n" % (key, value)) |
| 96 | 102 | ||
| @@ -103,6 +109,15 @@ class NpmEnvironment(object): | |||
| 103 | if self.user_config: | 109 | if self.user_config: |
| 104 | self.user_config.close() | 110 | self.user_config.close() |
| 105 | 111 | ||
| 112 | def _home_npmrc(self, d): | ||
| 113 | """Function to return user's HOME .npmrc file (or None if it doesn't exist)""" | ||
| 114 | home_npmrc_file = os.path.join(os.environ.get("HOME"), ".npmrc") | ||
| 115 | if d.getVar("BB_USE_HOME_NPMRC") == "1" and os.path.exists(home_npmrc_file): | ||
| 116 | bb.warn(f"BB_USE_HOME_NPMRC flag set and valid .npmrc detected - "\ | ||
| 117 | f"npm fetcher will use {home_npmrc_file}") | ||
| 118 | return home_npmrc_file | ||
| 119 | return None | ||
| 120 | |||
| 106 | def run(self, cmd, args=None, configs=None, workdir=None): | 121 | def run(self, cmd, args=None, configs=None, workdir=None): |
| 107 | """Run npm command in a controlled environment""" | 122 | """Run npm command in a controlled environment""" |
| 108 | with tempfile.TemporaryDirectory() as tmpdir: | 123 | with tempfile.TemporaryDirectory() as tmpdir: |
