NPM Fetcher Private Registry Authentication Support:
v5 cover NPM Fetcher Private Registry Authentication Support:
Changes in this commit include:
- npm fetcher changes:
- Adding support to detect an .npmrc file within user's home directory if the BB_USE_HOME_NPMRC flag is set, then append the contents to the user_config.
- Added entry to bitbake documentation for BB_USE_HOME_NPMRC flag
- This is the fifth revision at adding npmrc support, with the first 4 revisions below:
- 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
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(+)
PATCH v5 1/2 fetch2/npm: Adding npmrc support for private registry authentication
--- 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: [PATCH v5 1/2] fetch2/npm: Adding npmrc support for private registry authentication
Quoted 38 lines · Eric Meyers
Signed-off-by Eric Meyers <[email protected]>Cc Geoff Parker <[email protected]>Cc Chuck Wolber <[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:
..Ch:W..
Signature · 3 lines
* Opinions expressed are my own. | --------------------------------|------ "Perfection must be reached by degrees she requires the slow hand of time." | -Voltaire*
PATCH v5 2/2 doc: bitbake-user-manual-ref-variables: document BB_USE_HOME_NPMRC
In reply to Eric Meyers--- .../bitbake-user-manual-ref-variables.rst | 6 ++++++ 1 file changed, 6 insertions(+)
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +6 -0
@@ -692,6 +692,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
Re: [PATCH v5 2/2] doc: bitbake-user-manual-ref-variables: document BB_USE_HOME_NPMRC
Quoted 25 lines · Eric Meyers
Signed-off-by Eric Meyers <[email protected]>Cc Geoff Parker <[email protected]>Cc Chuck Wolber <[email protected]>--- .../bitbake-user-manual-ref-variables.rst | 6 ++++++ 1 file changed, 6 insertions(+)doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +0
-0@@ -692,6 +692,12 @@ overview of their function and contents. Within an executing task, this variable holds the hash of the taskas
returned by the currently enabled signature generator.doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +2
-0+ :term:`BB_USE_HOME_NPMRC` + Controls whether or not BitBake uses the user's .npmrc file withintheir
+ 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
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst overview of their function and contents. · line 703
Quoted 5 lines
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +2
-0+ 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
..Ch:W..
Signature · 3 lines
* Opinions expressed are my own. | --------------------------------|------ "Perfection must be reached by degrees she requires the slow hand of time." | -Voltaire*
Re: [PATCH v5 2/2] doc: bitbake-user-manual-ref-variables: document BB_USE_HOME_NPMRC
Quoted 39 lines · Chuck Wolber
Quoted 29 lines · Eric Meyers
Signed-off-by Eric Meyers <[email protected]>Cc Geoff Parker <[email protected]>Cc Chuck Wolber <[email protected]>--- .../bitbake-user-manual-ref-variables.rst | 6 ++++++ 1 file changed, 6 insertions(+)diff --git
a/doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rstb/doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rstindex858de6347..00300d0d8100644doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +0
-0@@ -692,6 +692,12 @@ overview of their function and contents. Within an executing task, this variable holds the hash of the taskas
returned by the currently enabled signature generator.doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +2
-0+ :term:`BB_USE_HOME_NPMRC` + Controls whether or not BitBake uses the user's .npmrc file withintheir
+ home directory within the npm fetcher. This can be used for
authentication
+ of private NPM registries, among other uses. This is turned off by
defaultdoc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +2
-0+ 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, shellQuoted 3 lines
scripts
echo commands and shell script output appears on standard outSigned-off-by Chuck Wolber <[email protected]>
Quoted 2 lines
..Ch:W..
Apologies if this isn't the correct process (this is my first time submitting a patch), but what's needed to merge this patch into master-next, then master?
Thanks,
-Eric
Re: [PATCH v5 2/2] doc: bitbake-user-manual-ref-variables: document BB_USE_HOME_NPMRC
Quoted 6 lines · Eric Meyers
Apologies if this isn't the correct process (this is my first time submitting a patch), but what's needed to merge this patch into master-next, then master?
For now, probably nothing, but it never hurts to do what you did and ask. The
bitbake repo maintainers watch this list.
Your patches show up in patchwork here:
https://patchwork.yoctoproject.org/project/bitbake/list/
Just search for your name.
Also, have you reviewed the contribution docs?
https://docs.yoctoproject.org/dev/contributor-guide/submit-changes.html
..Ch:W..
Signature · 3 lines
* Opinions expressed are my own. | --------------------------------|------ "Perfection must be reached by degrees she requires the slow hand of time." | -Voltaire*
Re: [PATCH v5 2/2] doc: bitbake-user-manual-ref-variables: document BB_USE_HOME_NPMRC
Quoted 17 lines · Chuck Wolber
Quoted 6 lines · Eric Meyers
Apologies if this isn't the correct process (this is my first time submitting a patch), but what's needed to merge this patch into master-next, then master?
For now, probably nothing, but it never hurts to do what you did and ask. The
bitbake repo maintainers watch this list.Your patches show up in patchwork here:
https://patchwork.yoctoproject.org/project/bitbake/list/
Just search for your name.
Quoted 8 lines
Also, have you reviewed the contribution docs?
https://docs.yoctoproject.org/dev/contributor-guide/submit-changes.html
..Ch:W..
Yes, I have reviewed those, they are what helped me out with initially submitting the patch, I just wanted to poke this thread since the guidance was 2-3 days until it makes it into master-next.
Anyways, I see the commits have been applied now:
- https://github.com/openembedded/bitbake/commit/177395a4dee1b51380e61ffa8889588f81740bc0 -
https://github.com/openembedded/bitbake/commit/23f3f16cf211f9a9db8914eeb82ccf131ac21b22
Thanks a ton! I will submit another patch for backporting this to the scarthgap version of bitbake (2.8) in the coming days.
-Eric
Re: [bitbake-devel] [PATCH v5 2/2] doc: bitbake-user-manual-ref-variables: document BB_USE_HOME_NPMRC
Quoted 38 lines · Eric Meyers via lists.openembedded.org
Quoted 18 lines · Chuck Wolber
Quoted 6 lines · Eric Meyers
Apologies if this isn't the correct process (this is my first time submitting a patch), but what's needed to merge this patch into master-next, then master?
For now, probably nothing, but it never hurts to do what you did and ask. The
bitbake repo maintainers watch this list.Your patches show up in patchwork here:
https://patchwork.yoctoproject.org/project/bitbake/list/
Just search for your name.Quoted 8 lines
Also, have you reviewed the contribution docs?
https://docs.yoctoproject.org/dev/contributor-guide/submit-changes.html
..Ch:W..
Yes, I have reviewed those, they are what helped me out with initially submitting the patch, I just wanted to poke this thread since the guidance was 2-3 days until it makes it into master-next.
Anyways, I see the commits have been applied now:
Quoted 8 lines
-
https://github.com/openembedded/bitbake/commit/177395a4dee1b51380e61ffa8889588f81740bc0
-
https://github.com/openembedded/bitbake/commit/23f3f16cf211f9a9db8914eeb82ccf131ac21b22Thanks a ton! I will submit another patch for backporting this to the scarthgap version of bitbake (2.8) in the coming days.
They're in master-next, they haven't merged until they're in master.
If you're looking at 2.8, they'll need to be backported to 2.10 first as per the stable release policies. One of the policies related to not backporting new features, this one is a bit borderline in that regard.
Cheers,
Richard