[2.10][PATCH v1 0/2] NPM Fetcher Private Registry Authentication Support
This patch backports support for use of an .npmrc file within the NPM fetcher via the BB_USE_HOME_NPMRC variable (introduced on master with commit 5fa6137b6).
This commit does not introduce any regression due to "BB_USE_HOME_NPMRC" gating the use of this functionality - since no one was using the variable before, a majority of the code introduced in this patch will be bypassed when using the NPM fetcher. So while this technically is "new" functionality being backported, in order for it to be used, the user will need to "opt-in" via the use of the new bitbake variable (thus it should be safe to backport).
If this patch is accepted, I will also submit a patch to 2.8 in order to get this into scarthgap upstream.
Mailing List Discussions for Patch Submission on Master:
- v1: https://lists.openembedded.org/g/bitbake-devel/topic/110839321
- v2: https://lists.openembedded.org/g/bitbake-devel/topic/111289667
- v3: https://lists.openembedded.org/g/bitbake-devel/topic/111395041
- v4: https://lists.openembedded.org/g/bitbake-devel/topic/111424927
- v5 (accepted): https://lists.openembedded.org/g/bitbake-devel/topic/111433461
Eric Meyers (2):
fetch2/npm: Adding npmrc support for private registry authentication
doc: bitbake-user-manual-ref-variables: document BB_USE_HOME_NPMRC
.../bitbake-user-manual-ref-variables.rst | 6 ++++++ lib/bb/fetch2/npm.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+)
[bitbake][styhead][2.10][PATCH v1 1/2] fetch2/npm: Adding npmrc support for private registry authentication
From: Eric Meyers <[email protected]>
--- lib/bb/fetch2/npm.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
lib/bb/fetch2/npm.py +15 -0
@@ -91,6 +91,12 @@ class NpmEnvironment(object): self.d = d self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1) + + hn = self._home_npmrc(d) + if hn is not None: + with open(hn, 'r') as hnf: + self.user_config.write(hnf.read()) + for key, value in configs: self.user_config.write("%s=%s\n" % (key, value))
@@ -103,6 +109,15 @@ class NpmEnvironment(object): if self.user_config: self.user_config.close() + def _home_npmrc(self, d): + """Function to return user's HOME .npmrc file (or None if it doesn't exist)""" + home_npmrc_file = os.path.join(os.environ.get("HOME"), ".npmrc") + if d.getVar("BB_USE_HOME_NPMRC") == "1" and os.path.exists(home_npmrc_file): + bb.warn(f"BB_USE_HOME_NPMRC flag set and valid .npmrc detected - "\ + f"npm fetcher will use {home_npmrc_file}") + return home_npmrc_file + return None + def run(self, cmd, args=None, configs=None, workdir=None): """Run npm command in a controlled environment""" with tempfile.TemporaryDirectory() as tmpdir:
Re: [bitbake][styhead][2.10][PATCH v1 1/2] fetch2/npm: Adding npmrc support for private registry authentication
Quoted 39 lines · Eric Meyers
From: Eric Meyers <[email protected]>
Signed-off-by Eric Meyers <[email protected]>Cc Geoff Parker <[email protected]>--- lib/bb/fetch2/npm.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+)lib/bb/fetch2/npm.py +8
-0@@ -91,6 +91,12 @@ class NpmEnvironment(object): self.d = d self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1) + + hn = self._home_npmrc(d) + if hn is not None: + with open(hn, 'r') as hnf: + self.user_config.write(hnf.read()) + for key, value in configs: self.user_config.write("%s=%s\n" % (key, value))@@ -103,6 +109,15 @@ class NpmEnvironment(object): if self.user_config: self.user_config.close() + def _home_npmrc(self, d): + """Function to return user's HOME .npmrc file (or None if itdoesn't exist)"""
lib/bb/fetch2/npm.py +2
-0+ home_npmrc_file = os.path.join(os.environ.get("HOME"), ".npmrc") + if d.getVar("BB_USE_HOME_NPMRC") == "1" and
os.path.exists(home_npmrc_file):
+ bb.warn(f"BB_USE_HOME_NPMRC flag set and valid .npmrc
detected - "\
lib/bb/fetch2/npm.py class NpmEnvironment(object): · line 123
Quoted 7 lines
lib/bb/fetch2/npm.py +4
-0+ f"npm fetcher will use {home_npmrc_file}") + return home_npmrc_file + return None + def run(self, cmd, args=None, configs=None, workdir=None): """Run npm command in a controlled environment""" with tempfile.TemporaryDirectory() as tmpdir:
Just poking this patch submission since I haven't heard anything since initially submitting it a week ago/haven't seen anything merge yet.
I know @rpurdie said it was borderline new functionality on a previous thread and might not be accepted into styhead (2.10) and scarthgap (2.8), but just wanted to have closure if that's the case.
Would be really nice/make our lives easier if this could make it all the way into scarthgap, but understand if there is hesitation from the maintainers.
Thanks,
-Eric
Re: [bitbake-devel] [bitbake][styhead][2.10][PATCH v1 1/2] fetch2/npm: Adding npmrc support for private registry authentication
Quoted 49 lines · Eric Meyers via lists.openembedded.org
Quoted 32 lines · Eric Meyers
From: Eric Meyers <[email protected]>
Signed-off-by Eric Meyers <[email protected]>Cc Geoff Parker <[email protected]>--- lib/bb/fetch2/npm.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+)lib/bb/fetch2/npm.py +8
-0@@ -91,6 +91,12 @@ class NpmEnvironment(object): self.d = d self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1) + + hn = self._home_npmrc(d) + if hn is not None: + with open(hn, 'r') as hnf: + self.user_config.write(hnf.read()) + for key, value in configs: self.user_config.write("%s=%s\n" % (key, value))@@ -103,6 +109,15 @@ class NpmEnvironment(object): if self.user_config: self.user_config.close() + def _home_npmrc(self, d): + """Function to return user's HOME .npmrc file (or None if it doesn't exist)"""lib/bb/fetch2/npm.py class NpmEnvironment(object): · line 123
Quoted 10 lines
lib/bb/fetch2/npm.py +7
-0+ home_npmrc_file = os.path.join(os.environ.get("HOME"), ".npmrc") + if d.getVar("BB_USE_HOME_NPMRC") == "1" and os.path.exists(home_npmrc_file): + bb.warn(f"BB_USE_HOME_NPMRC flag set and valid .npmrc detected - "\ + f"npm fetcher will use {home_npmrc_file}") + return home_npmrc_file + return None + def run(self, cmd, args=None, configs=None, workdir=None): """Run npm command in a controlled environment""" with tempfile.TemporaryDirectory() as tmpdir:Just poking this patch submission since I haven't heard anything since initially submitting it a week ago/haven't seen anything merge yet.
Quoted 1 line
I know @rpurdie said it was borderline new functionality on a previous thread and might not be accepted into styhead (2.10) and scarthgap (2.8), but just wanted to have closure if that's the case.
This does cross the line of adding new functionality, so I'm not inclined to take it unless Richard (as bitbake maintainer) feels that an exception should be made.
In any event though, this was only accepted into master a week ago. I typically let patches "age" a bit there to see if problems crop up before backporting.
Steve
Quoted 13 lines
Would be really nice/make our lives easier if this could make it all the way into scarthgap, but understand if there is hesitation from the maintainers.
Thanks,
-Eric-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#17449): https://lists.openembedded.org/g/bitbake-devel/message/17449
Mute This Topic: https://lists.openembedded.org/mt/111638710/3620601
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
[bitbake][styhead][2.10][PATCH v1 2/2] doc: bitbake-user-manual-ref-variables: document BB_USE_HOME_NPMRC
In reply to Eric MeyersFrom: Eric Meyers <[email protected]>
--- .../bitbake-user-manual-ref-variables.rst | 6 ++++++ 1 file changed, 6 insertions(+)
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +6 -0
@@ -699,6 +699,12 @@ overview of their function and contents. Within an executing task, this variable holds the hash of the task as returned by the currently enabled signature generator. + :term:`BB_USE_HOME_NPMRC` + Controls whether or not BitBake uses the user's .npmrc file within their + home directory within the npm fetcher. This can be used for authentication + of private NPM registries, among other uses. This is turned off by default + and requires the user to explicitly set it to "1" to enable. + :term:`BB_VERBOSE_LOGS` Controls how verbose BitBake is during builds. If set, shell scripts echo commands and shell script output appears on standard out