package/nodejs: fixup qemu dependencies
PATCH 1/4 package/nodejs: fixup qemu dependencies
Commit 1facb09b94bf806b301868539185c0ff9ddffee2 ("package/nodejs:
build host-nodejs only if we're installing modules with NPM") forgot to account for the dependency on Qemu. Now that nodejs no longer depends on host-nodejs, but needs host-qemu, we need to make sure that nodejs selects the relevant BR2_PACKAGE_HOST_QEMU options.
So this patch:
- Drops the dependency of BR2_PACKAGE_NODEJS_ARCH_SUPPORTS on BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET, which was incorrect: we don't care about running Qemu on the target. We care about host-qemu supporting the emulation of the target architecture, which is what BR2_PACKAGE_HOST_QEMU_ARCH_SUPPORTS is for.
- Adds the dependency to the relevant BR2_PACKAGE_HOST_QEMU options to BR2_PACKAGE_NODEJS, so that host-qemu is built with the appropriate features needed to build the target nodejs.
- Removes the qemu related dependencies from host-nodejs, which does not need Qemu at all.
Without this change the build of nodejs without npm enabled is broken as the host-qemu that gets built does not have all the features that are needed. There are no autobuild failures at this point, however.
--- package/nodejs/Config.in | 4 +++- package/nodejs/Config.in.host | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-)
package/nodejs/Config.in +3 -1
@@ -6,7 +6,7 @@ config BR2_PACKAGE_NODEJS_ARCH_SUPPORTS default y if BR2_aarch64 || BR2_i386 || BR2_x86_64 # libuv depends on BR2_TOOLCHAIN_HAS_SYNC_4 - depends on BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET + depends on BR2_PACKAGE_HOST_QEMU_USER_ARCH_SUPPORTS comment "nodejs needs a toolchain w/ C++, dynamic library, NPTL, gcc >= 7, wchar, host gcc >= 8" depends on BR2_USE_MMU
@@ -31,6 +31,8 @@ config BR2_PACKAGE_NODEJS select BR2_PACKAGE_HOST_PYTHON3 select BR2_PACKAGE_HOST_PYTHON3_BZIP2 select BR2_PACKAGE_HOST_PYTHON3_SSL + select BR2_PACKAGE_HOST_QEMU + select BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE select BR2_PACKAGE_C_ARES select BR2_PACKAGE_LIBUV select BR2_PACKAGE_ZLIB
package/nodejs/Config.in.host +0 -4
@@ -1,12 +1,9 @@ config BR2_PACKAGE_HOST_NODEJS bool "host nodejs" - depends on BR2_PACKAGE_HOST_QEMU_USER_ARCH_SUPPORTS depends on BR2_HOST_GCC_AT_LEAST_8 select BR2_PACKAGE_HOST_PYTHON3 select BR2_PACKAGE_HOST_PYTHON3_BZIP2 select BR2_PACKAGE_HOST_PYTHON3_SSL - select BR2_PACKAGE_HOST_QEMU - select BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE help Event-driven I/O server-side JavaScript environment based on V8.
@@ -14,5 +11,4 @@ config BR2_PACKAGE_HOST_NODEJS http://nodejs.org/ comment "host nodejs needs a host gcc >= 8" - depends on BR2_PACKAGE_HOST_QEMU_USER_ARCH_SUPPORTS depends on !BR2_HOST_GCC_AT_LEAST_8
Signature · 6 lines
2.37.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/4 package/nodejs: bump to v16.17.1
This is currently the latest version in the v16.x branch.
Patch 0001-add-qemu-wrapper-support.patch needs some minor adaptations to resolve conflicts with other unrelated upstream changes. The other patches are simply refreshed.
The license file is updates due to:
- Reformatting changes
- Addition of the mention of some files being under GPLv3, but it's only the autoconf machinery: aclocal.m4 and config.guess, so it's not relevant to add in our LICENSE variable.
- Addition of the mention of another file being under the MIT license (install-sh), and MIT is already listed, and this file is anyway only part of the autoconf machinery.
--- .../0001-add-qemu-wrapper-support.patch | 28 +++++++++---------- ...heck-if-uclibc-has-backtrace-support.patch | 6 ++-- ...lude-obj-name-in-shared-intermediate.patch | 4 +-- package/nodejs/nodejs.hash | 6 ++-- package/nodejs/nodejs.mk | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-)
package/nodejs/0001-add-qemu-wrapper-support.patch +14 -14
@@ -1,4 +1,4 @@ -From c6103ceab64b73c1a25ece3315ea8f52507c2bfe Mon Sep 17 00:00:00 2001 +From 1f6c55d7318e7075169004b4314708f4766ec193 Mon Sep 17 00:00:00 2001 From: Adam Duskett <[email protected]> Date: Mon, 27 Sep 2021 12:55:09 -0700 Subject: [PATCH] add qemu-wrapper support
@@ -22,10 +22,10 @@ Signed-off-by: Adam Duskett <[email protected]> 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/node.gyp b/node.gyp -index 74e9f9cc2e..c3eaab6c92 100644 +index 97cdbb531d..db5cf51ce6 100644 --- a/node.gyp +++ b/node.gyp -@@ -295,7 +295,7 @@ +@@ -319,7 +319,7 @@ 'action_name': 'run_mkcodecache', 'process_outputs_as_sources': 1, 'inputs': [
@@ -34,17 +34,17 @@ index 74e9f9cc2e..c3eaab6c92 100644 ], 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_code_cache.cc', -@@ -320,7 +320,7 @@ - 'action_name': 'node_mksnapshot', - 'process_outputs_as_sources': 1, - 'inputs': [ -- '<(node_mksnapshot_exec)', -+ @MAYBE_WRAPPER@ '<(node_mksnapshot_exec)', - ], - 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc', +@@ -346,7 +346,7 @@ + 'action_name': 'node_mksnapshot', + 'process_outputs_as_sources': 1, + 'inputs': [ +- '<(node_mksnapshot_exec)', ++ @MAYBE_WRAPPER@ '<(node_mksnapshot_exec)', + '<(node_snapshot_main)', + ], + 'outputs': [ diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp -index 39b96803c7..9321982ea4 100644 +index 73099a03e4..88ca91efb4 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -68,7 +68,7 @@
@@ -83,7 +83,7 @@ index 39b96803c7..9321982ea4 100644 ], 'outputs': [ '<(INTERMEDIATE_DIR)/snapshot.cc', -@@ -1503,7 +1503,7 @@ +@@ -1505,7 +1505,7 @@ { 'action_name': 'run_gen-regexp-special-case_action', 'inputs': [
package/nodejs/0002-check-if-uclibc-has-backtrace-support.patch +3 -3
@@ -1,4 +1,4 @@ -From 7c69553d7275bbcaa88fada8ccd0d2d9f787e1ad Mon Sep 17 00:00:00 2001 +From f1a15cea9a47d0a9b0ae78fb22fef3a268e355ad Mon Sep 17 00:00:00 2001 From: Martin Bark <[email protected]> Date: Sat, 4 Mar 2017 20:41:40 +0000 Subject: [PATCH] check if uclibc has backtrace support
@@ -9,7 +9,7 @@ Signed-off-by: Martin Bark <[email protected]> 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/v8/src/base/debug/stack_trace_posix.cc b/deps/v8/src/base/debug/stack_trace_posix.cc -index 87c0a73..d2c182a 100644 +index 270f1ca4e0..5227e88671 100644 --- a/deps/v8/src/base/debug/stack_trace_posix.cc +++ b/deps/v8/src/base/debug/stack_trace_posix.cc @@ -25,7 +25,7 @@
@@ -22,5 +22,5 @@ index 87c0a73..d2c182a 100644 #endif -- -2.7.4 +2.37.3
package/nodejs/0003-include-obj-name-in-shared-intermediate.patch +2 -2
@@ -1,4 +1,4 @@ -From e6e691d093de440e0f408d48971e2b7332a07d58 Mon Sep 17 00:00:00 2001 +From af47d317e5ae12978c1cdc40627008ada144f98b Mon Sep 17 00:00:00 2001 From: Min RK <[email protected]> Date: Fri, 19 Feb 2021 11:57:04 +0100 Subject: [PATCH] include obj name in shared intermediate
@@ -12,7 +12,7 @@ Signed-off-by: Thomas Petazzoni <[email protected]> 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/gyp/pylib/gyp/generator/ninja.py b/tools/gyp/pylib/gyp/generator/ninja.py -index d173bf2299..efaeee53ef 100644 +index 3db3771ac9..2e0a021703 100644 --- a/tools/gyp/pylib/gyp/generator/ninja.py +++ b/tools/gyp/pylib/gyp/generator/ninja.py @@ -42,7 +42,7 @@ generator_default_variables = {
package/nodejs/nodejs.hash +3 -3
@@ -1,5 +1,5 @@ -# From https://nodejs.org/dist/v16.16.0/SHASUMS256.txt -sha256 145151eff3b2aa5ebe73384009c52271a83740ae687a93c98c628cd7d52736eb node-v16.16.0.tar.xz +# From https://nodejs.org/dist/v16.17.1/SHASUMS256.txt +sha256 6721feb4152d56d2c6b358ce397abd5a7f1daf09ee2e25c5021b9b4d3f86a330 node-v16.17.1.tar.xz # Hash for license file -sha256 6211cc77f9ceaf365db12faf050775b3a1e6da7a1eff3577ba006c4918103c33 LICENSE +sha256 69090e865afa7c62715b97f0712632d2923bd7a5faba91f94e4e75a2f9219d5e LICENSE
package/nodejs/nodejs.mk +1 -1
@@ -4,7 +4,7 @@ # ################################################################################ -NODEJS_VERSION = 16.16.0 +NODEJS_VERSION = 16.17.1 NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.xz NODEJS_SITE = http://nodejs.org/dist/v$(NODEJS_VERSION) NODEJS_DEPENDENCIES = \
Signature · 6 lines
2.37.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Yann E. MORIN
AppliedRe: [Buildroot] [PATCH 2/4] package/nodejs: bump to v16.17.1
Thomas, All,
On 2022-09-25 19:19 +0200, Thomas Petazzoni via buildroot spake thusly:
Quoted 14 lines
This is currently the latest version in the v16.x branch.
Patch 0001-add-qemu-wrapper-support.patch needs some minor adaptations to resolve conflicts with other unrelated upstream changes. The other patches are simply refreshed.
The license file is updates due to:
- Reformatting changes
- Addition of the mention of some files being under GPLv3, but it's only the autoconf machinery: aclocal.m4 and config.guess, so it's not relevant to add in our LICENSE variable.
Quoted 5 lines
- Addition of the mention of another file being under the MIT license (install-sh), and MIT is already listed, and this file is anyway only part of the autoconf machinery.
Signed-off-by Thomas Petazzoni <[email protected]>
Applied to master, thanks.
Regards,
Yann E. MORIN.
Quoted 146 lines
--- .../0001-add-qemu-wrapper-support.patch | 28 +++++++++---------- ...heck-if-uclibc-has-backtrace-support.patch | 6 ++-- ...lude-obj-name-in-shared-intermediate.patch | 4 +-- package/nodejs/nodejs.hash | 6 ++-- package/nodejs/nodejs.mk | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-)package/nodejs/0001-add-qemu-wrapper-support.patch +14
-14@@ -1,4 +1,4 @@ -From c6103ceab64b73c1a25ece3315ea8f52507c2bfe Mon Sep 17 00:00:00 2001 +From 1f6c55d7318e7075169004b4314708f4766ec193 Mon Sep 17 00:00:00 2001 From: Adam Duskett <[email protected]> Date: Mon, 27 Sep 2021 12:55:09 -0700 Subject: [PATCH] add qemu-wrapper support@@ -22,10 +22,10 @@ Signed-off-by: Adam Duskett <[email protected]> 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/node.gyp b/node.gyp -index 74e9f9cc2e..c3eaab6c92 100644 +index 97cdbb531d..db5cf51ce6 100644 --- a/node.gyp +++ b/node.gyp -@@ -295,7 +295,7 @@ +@@ -319,7 +319,7 @@ 'action_name': 'run_mkcodecache', 'process_outputs_as_sources': 1, 'inputs': [@@ -34,17 +34,17 @@ index 74e9f9cc2e..c3eaab6c92 100644 ], 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_code_cache.cc', -@@ -320,7 +320,7 @@ - 'action_name': 'node_mksnapshot', - 'process_outputs_as_sources': 1, - 'inputs': [ -- '<(node_mksnapshot_exec)', -+ @MAYBE_WRAPPER@ '<(node_mksnapshot_exec)', - ], - 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc', +@@ -346,7 +346,7 @@ + 'action_name': 'node_mksnapshot', + 'process_outputs_as_sources': 1, + 'inputs': [ +- '<(node_mksnapshot_exec)', ++ @MAYBE_WRAPPER@ '<(node_mksnapshot_exec)', + '<(node_snapshot_main)', + ], + 'outputs': [ diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp -index 39b96803c7..9321982ea4 100644 +index 73099a03e4..88ca91efb4 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -68,7 +68,7 @@@@ -83,7 +83,7 @@ index 39b96803c7..9321982ea4 100644 ], 'outputs': [ '<(INTERMEDIATE_DIR)/snapshot.cc', -@@ -1503,7 +1503,7 @@ +@@ -1505,7 +1505,7 @@ { 'action_name': 'run_gen-regexp-special-case_action', 'inputs': [package/nodejs/0002-check-if-uclibc-has-backtrace-support.patch +3
-3@@ -1,4 +1,4 @@ -From 7c69553d7275bbcaa88fada8ccd0d2d9f787e1ad Mon Sep 17 00:00:00 2001 +From f1a15cea9a47d0a9b0ae78fb22fef3a268e355ad Mon Sep 17 00:00:00 2001 From: Martin Bark <[email protected]> Date: Sat, 4 Mar 2017 20:41:40 +0000 Subject: [PATCH] check if uclibc has backtrace support@@ -9,7 +9,7 @@ Signed-off-by: Martin Bark <[email protected]> 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/v8/src/base/debug/stack_trace_posix.cc b/deps/v8/src/base/debug/stack_trace_posix.cc -index 87c0a73..d2c182a 100644 +index 270f1ca4e0..5227e88671 100644 --- a/deps/v8/src/base/debug/stack_trace_posix.cc +++ b/deps/v8/src/base/debug/stack_trace_posix.cc @@ -25,7 +25,7 @@@@ -22,5 +22,5 @@ index 87c0a73..d2c182a 100644 #endif -- -2.7.4 +2.37.3package/nodejs/0003-include-obj-name-in-shared-intermediate.patch +2
-2@@ -1,4 +1,4 @@ -From e6e691d093de440e0f408d48971e2b7332a07d58 Mon Sep 17 00:00:00 2001 +From af47d317e5ae12978c1cdc40627008ada144f98b Mon Sep 17 00:00:00 2001 From: Min RK <[email protected]> Date: Fri, 19 Feb 2021 11:57:04 +0100 Subject: [PATCH] include obj name in shared intermediate@@ -12,7 +12,7 @@ Signed-off-by: Thomas Petazzoni <[email protected]> 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/gyp/pylib/gyp/generator/ninja.py b/tools/gyp/pylib/gyp/generator/ninja.py -index d173bf2299..efaeee53ef 100644 +index 3db3771ac9..2e0a021703 100644 --- a/tools/gyp/pylib/gyp/generator/ninja.py +++ b/tools/gyp/pylib/gyp/generator/ninja.py @@ -42,7 +42,7 @@ generator_default_variables = {package/nodejs/nodejs.hash +3
-3@@ -1,5 +1,5 @@ -# From https://nodejs.org/dist/v16.16.0/SHASUMS256.txt -sha256 145151eff3b2aa5ebe73384009c52271a83740ae687a93c98c628cd7d52736eb node-v16.16.0.tar.xz +# From https://nodejs.org/dist/v16.17.1/SHASUMS256.txt +sha256 6721feb4152d56d2c6b358ce397abd5a7f1daf09ee2e25c5021b9b4d3f86a330 node-v16.17.1.tar.xz # Hash for license file -sha256 6211cc77f9ceaf365db12faf050775b3a1e6da7a1eff3577ba006c4918103c33 LICENSE +sha256 69090e865afa7c62715b97f0712632d2923bd7a5faba91f94e4e75a2f9219d5e LICENSEpackage/nodejs/nodejs.mk +1
-1@@ -4,7 +4,7 @@ # ################################################################################ -NODEJS_VERSION = 16.16.0 +NODEJS_VERSION = 16.17.1 NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.xz NODEJS_SITE = http://nodejs.org/dist/v$(NODEJS_VERSION) NODEJS_DEPENDENCIES = \Signature · 6 lines
2.37.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/4] package/nodejs: bump to v16.17.1
In reply to Thomas Petazzoni via buildrootQuoted 15 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:
This is currently the latest version in the v16.x branch. Patch 0001-add-qemu-wrapper-support.patch needs some minor adaptations to resolve conflicts with other unrelated upstream changes. The other patches are simply refreshed.
The license file is updates due to:
- Reformatting changes
- Addition of the mention of some files being under GPLv3, but it's only the autoconf machinery: aclocal.m4 and config.guess, so it's not relevant to add in our LICENSE variable.
Quoted 5 lines
- Addition of the mention of another file being under the MIT license (install-sh), and MIT is already listed, and this file is anyway only part of the autoconf machinery.
Signed-off-by Thomas Petazzoni <[email protected]>
Committed to 2022.08.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/4] package/nodejs: bump to v16.17.1
Quoted 16 lines
Quoted 15 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
"Peter" == Peter Korsgaard <[email protected]> writes:
"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:
This is currently the latest version in the v16.x branch. Patch 0001-add-qemu-wrapper-support.patch needs some minor adaptations to resolve conflicts with other unrelated upstream changes. The other patches are simply refreshed.
The license file is updates due to:
- Reformatting changes
- Addition of the mention of some files being under GPLv3, but it's only the autoconf machinery: aclocal.m4 and config.guess, so it's not relevant to add in our LICENSE variable.
Quoted 7 lines
Quoted 5 lines
- Addition of the mention of another file being under the MIT license (install-sh), and MIT is already listed, and this file is anyway only part of the autoconf machinery.
Signed-off-by Thomas Petazzoni <[email protected]>Committed to 2022.08.x, thanks.
I forgot to mention that this should have been marked as a security bump given the security fixes it contains:
https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V16.md#16.17.1
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/4] package/nodejs: bump to v16.17.1
Peter, All,
On 2022-10-12 10:26 +0200, Peter Korsgaard spake thusly:
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
"Peter" == Peter Korsgaard <[email protected]> writes:
"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:This is currently the latest version in the v16.x branch.
Committed to 2022.08.x, thanks.
I forgot to mention that this should have been marked as a security bump given the security fixes it contains:
Hrm... Aren't all nodejs version bumps security fixes? ;-]
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 3/4 package/nodejs: add patch to adjust default NodeJS search path
In reply to Thomas PetazzoniBy default, NodeJS searches global modules in /usr/lib/node, but NPM installs them in /usr/lib/node_modules/. Therefore by default, if one installs modules with BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL, they are not accessible by NodeJS, unless by passing a NODE_PATH=/usr/lib/node_modules/ variable. Since this is not obvious, and it's nicer when things work out of the box, we simply patch NodeJS to look for modules at the right place.
See
https://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package
for some discussions on this topic.
---
I am not 100% sure this is the correct approach, and I would definitely like to get the feedback from some NodeJS people.
--- ...ules-cjs-loader.js-adjust-default-pa.patch | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 package/nodejs/0004-lib-internal-modules-cjs-loader.js-adjust-default-pa.patch
package/nodejs/0004-lib-internal-modules-cjs-loader.js-adjust-default-pa.patch new file +35 -0
@@ -0,0 +1,35 @@ +From 4ed7de24fe18bb75b6e38922eb33141e2cec43dd Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni <[email protected]> +Date: Sun, 25 Sep 2022 11:10:06 +0200 +Subject: [PATCH] lib/internal/modules/cjs/loader.js: adjust default path to + search modules + +NPM installs modules in /usr/lib/node_modules/, but by default NodeJS +searches for them in /usr/lib/node/. We could also set the NODE_PATH +environment variable, but it is more convienient to have NodeJS +configured by default to find modules where they are installed. + +This issue is discussed at +https://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package. + +Signed-off-by: Thomas Petazzoni <[email protected]> +--- + lib/internal/modules/cjs/loader.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js +index f1971c40a4..52fcd56125 100644 +--- a/lib/internal/modules/cjs/loader.js ++++ b/lib/internal/modules/cjs/loader.js +@@ -1261,7 +1261,7 @@ Module._initPaths = function() { + path.resolve(process.execPath, '..') : + path.resolve(process.execPath, '..', '..'); + +- const paths = [path.resolve(prefixDir, 'lib', 'node')]; ++ const paths = [path.resolve(prefixDir, 'lib', 'node_modules')]; + + if (homeDir) { + ArrayPrototypeUnshift(paths, path.resolve(homeDir, '.node_libraries')); +-- +2.37.3 +
Signature · 6 lines
2.37.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/4] package/nodejs: add patch to adjust default NodeJS search path
On 2022-09-25 19:19 +0200, Thomas Petazzoni spake thusly:
Quoted 46 lines
By default, NodeJS searches global modules in
/usr/lib/node, but NPM installs them in/usr/lib/node_modules/. Therefore by default, if one installs modules withBR2_PACKAGE_NODEJS_MODULES_ADDITIONAL, they are not accessible by NodeJS, unless by passing a NODE_PATH=/usr/lib/node_modules/ variable. Since this is not obvious, and it's nicer when things work out of the box, we simply patch NodeJS to look for modules at the right place.See
https://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package
for some discussions on this topic.Signed-off-by Thomas Petazzoni <[email protected]>---
I am not 100% sure this is the correct approach, and I would definitely like to get the feedback from some NodeJS people.--- ...ules-cjs-loader.js-adjust-default-pa.patch | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 package/nodejs/0004-lib-internal-modules-cjs-loader.js-adjust-default-pa.patchpackage/nodejs/0004-lib-internal-modules-cjs-loader.js-adjust-default-pa.patch new file +19
-0@@ -0,0 +1,35 @@ +From 4ed7de24fe18bb75b6e38922eb33141e2cec43dd Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni <[email protected]> +Date: Sun, 25 Sep 2022 11:10:06 +0200 +Subject: [PATCH] lib/internal/modules/cjs/loader.js: adjust default path to + search modules + +NPM installs modules in /usr/lib/node_modules/, but by default NodeJS +searches for them in /usr/lib/node/. We could also set the NODE_PATH +environment variable, but it is more convienient to have NodeJS +configured by default to find modules where they are installed. + +This issue is discussed at +https://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package. + +Signed-off-by: Thomas Petazzoni <[email protected]> +--- + lib/internal/modules/cjs/loader.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) +
package/nodejs/0004-lib-internal-modules-cjs-loader.js-adjust-default-pa.patch line 29
Quoted 10 lines
package/nodejs/0004-lib-internal-modules-cjs-loader.js-adjust-default-pa.patch new file +10
-0+diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js +index f1971c40a4..52fcd56125 100644 +--- a/lib/internal/modules/cjs/loader.js ++++ b/lib/internal/modules/cjs/loader.js +@@ -1261,7 +1261,7 @@ Module._initPaths = function() { + path.resolve(process.execPath, '..') : + path.resolve(process.execPath, '..', '..'); + +- const paths = [path.resolve(prefixDir, 'lib', 'node')]; ++ const paths = [path.resolve(prefixDir, 'lib', 'node_modules')];
It looks like this is an array, so maybe we could keep the original path, and add the npm installation path:
const paths = [path.resolve(prefixDir, 'lib', 'node'),
path.resolve(prefixDir, 'lib', 'node_modules'),];
This, in case some ot-of-tree packages simply copy files into the original .../node/ directory.
Alternatively, we could symlink node_modules to node.
Regards,
Yann E. MORIN.
Quoted 12 lines
package/nodejs/0004-lib-internal-modules-cjs-loader.js-adjust-default-pa.patch new file +5
-0+ if (homeDir) { + ArrayPrototypeUnshift(paths, path.resolve(homeDir, '.node_libraries')); +-- +2.37.3 +Signature · 6 lines
2.37.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/4] package/nodejs: add patch to adjust default NodeJS search path
Quoted 8 lines · On Sun, 25 Sep 2022 20:15:57 +0200 "Yann E. MORIN" <[email protected]>…
It looks like this is an array, so maybe we could keep the original path, and add the npm installation path:
const paths = [
path.resolve(prefixDir, 'lib', 'node'),
path.resolve(prefixDir, 'lib', 'node_modules'),];This, in case some ot-of-tree packages simply copy files into the original .../node/ directory.
Good point, I've sent a v2 which does exactly this.
Quoted 1 line
Alternatively, we could symlink
node_modulesto node.
I did consider the symlink solution as well, but I worried (perhaps wrongly, or too conservatively) that it could get removed. Or it would have to be the other way around: node -> node_modules, as npm installs in node_modules and I would be worried of npm being unhappy with installing inside a path that contains a symlink.
Overall, I found patching the search path to be safer, but if the symlink solution is preferred, I can definitely implement it.
Best regards,
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 4/4 support/testing/tests: add NodeJS tests
In reply to Thomas PetazzoniThis commit adds two new test cases:
- TestNodeJSBasic which builds a target configuration with just NodeJS enabled, and which runs a very simple NodeJS script on the target.
- TestNodeJSModule, which builds a target configuration with NodeJS enabled + the installation of one extra module, which means npm on the host (from host-nodejs) is used, and which runs a very simple NodeJS script on the target that uses this extra module.
Having both tests separately allows to validate that both nodejs-only and nodejs+host-nodejs configurations behave correctly, at least in minimal scenarios.
--- DEVELOPERS | 3 ++ .../tests/package/sample_nodejs_basic.js | 3 ++ .../tests/package/sample_nodejs_module.js | 7 +++ support/testing/tests/package/test_nodejs.py | 52 +++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 support/testing/tests/package/sample_nodejs_basic.js create mode 100644 support/testing/tests/package/sample_nodejs_module.js create mode 100644 support/testing/tests/package/test_nodejs.py
DEVELOPERS +3 -0
@@ -2927,11 +2927,14 @@ F: package/weston/ F: support/testing/tests/boot/test_grub.py F: support/testing/tests/boot/test_grub/ F: support/testing/tests/boot/test_syslinux.py +F: support/testing/tests/package/sample_nodejs_basic.js +F: support/testing/tests/package/sample_nodejs_module.js F: support/testing/tests/package/sample_python_augeas.py F: support/testing/tests/package/sample_python_flask.py F: support/testing/tests/package/sample_python_flask_expects_json.py F: support/testing/tests/package/sample_python_git.py F: support/testing/tests/package/sample_python_unittest_xml_reporting.py +F: support/testing/tests/package/test_nodejs.py F: support/testing/tests/package/test_python_augeas.py F: support/testing/tests/package/test_python_flask.py F: support/testing/tests/package/test_python_flask_expects_json.py
support/testing/tests/package/sample_nodejs_basic.js new file +3 -0
@@ -0,0 +1,3 @@ +var assert = require('assert'); +assert.strictEqual(1, 1); +console.log("Hello World");
support/testing/tests/package/sample_nodejs_module.js new file +7 -0
@@ -0,0 +1,7 @@ +var assert = require('assert'); +var lodash = require('lodash'); +result = lodash.chunk(['a', 'b', 'c', 'd'], 2); +expected = [ [ 'a', 'b' ], [ 'c', 'd' ] ]; +assert.deepStrictEqual(result, expected) + +
support/testing/tests/package/test_nodejs.py new file +52 -0
52 lines not on this page · raw message
Signature · 6 lines
2.37.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Yann E. MORIN
AppliedTomas, All,
On 2022-09-25 19:19 +0200, Thomas Petazzoni spake thusly:
Quoted 18 lines
Commit
1facb09b94bf806b301868539185c0ff9ddffee2("package/nodejs:
build host-nodejs only if we're installing modules with NPM") forgot to account for the dependency on Qemu. Now that nodejs no longer depends on host-nodejs, but needs host-qemu, we need to make sure that nodejs selects the relevantBR2_PACKAGE_HOST_QEMUoptions.So this patch:
- Drops the dependency of
BR2_PACKAGE_NODEJS_ARCH_SUPPORTSonBR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET, which was incorrect: we don't care about running Qemu on the target. We care about host-qemu supporting the emulation of the target architecture, which is whatBR2_PACKAGE_HOST_QEMU_ARCH_SUPPORTSis for.- Adds the dependency to the relevant
BR2_PACKAGE_HOST_QEMUoptions toBR2_PACKAGE_NODEJS, so that host-qemu is built with the appropriate features needed to build the target nodejs.
Quoted 8 lines
- Removes the qemu related dependencies from host-nodejs, which does not need Qemu at all.
Without this change the build of nodejs without npm enabled is broken as the host-qemu that gets built does not have all the features that are needed. There are no autobuild failures at this point, however.
Signed-off-by Thomas Petazzoni <[email protected]>
Applied to master, thanks.
Regards,
Yann E. MORIN.
Quoted 57 lines
--- package/nodejs/Config.in | 4 +++- package/nodejs/Config.in.host | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-)package/nodejs/Config.in +3
-1@@ -6,7 +6,7 @@ config BR2_PACKAGE_NODEJS_ARCH_SUPPORTS default y if BR2_aarch64 || BR2_i386 || BR2_x86_64 # libuv depends on BR2_TOOLCHAIN_HAS_SYNC_4 - depends on BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET + depends on BR2_PACKAGE_HOST_QEMU_USER_ARCH_SUPPORTS comment "nodejs needs a toolchain w/ C++, dynamic library, NPTL, gcc >= 7, wchar, host gcc >= 8" depends on BR2_USE_MMU@@ -31,6 +31,8 @@ config BR2_PACKAGE_NODEJS select BR2_PACKAGE_HOST_PYTHON3 select BR2_PACKAGE_HOST_PYTHON3_BZIP2 select BR2_PACKAGE_HOST_PYTHON3_SSL + select BR2_PACKAGE_HOST_QEMU + select BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE select BR2_PACKAGE_C_ARES select BR2_PACKAGE_LIBUV select BR2_PACKAGE_ZLIBpackage/nodejs/Config.in.host +0
-4@@ -1,12 +1,9 @@ config BR2_PACKAGE_HOST_NODEJS bool "host nodejs" - depends on BR2_PACKAGE_HOST_QEMU_USER_ARCH_SUPPORTS depends on BR2_HOST_GCC_AT_LEAST_8 select BR2_PACKAGE_HOST_PYTHON3 select BR2_PACKAGE_HOST_PYTHON3_BZIP2 select BR2_PACKAGE_HOST_PYTHON3_SSL - select BR2_PACKAGE_HOST_QEMU - select BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE help Event-driven I/O server-side JavaScript environment based on V8.@@ -14,5 +11,4 @@ config BR2_PACKAGE_HOST_NODEJS http://nodejs.org/ comment "host nodejs needs a host gcc >= 8" - depends on BR2_PACKAGE_HOST_QEMU_USER_ARCH_SUPPORTS depends on !BR2_HOST_GCC_AT_LEAST_8Signature · 6 lines
2.37.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 20 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
Commit
1facb09b94bf806b301868539185c0ff9ddffee2("package/nodejs:
build host-nodejs only if we're installing modules with NPM") forgot to account for the dependency on Qemu. Now that nodejs no longer depends on host-nodejs, but needs host-qemu, we need to make sure that nodejs selects the relevantBR2_PACKAGE_HOST_QEMUoptions.So this patch:
- Drops the dependency of
BR2_PACKAGE_NODEJS_ARCH_SUPPORTSonBR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET, which was incorrect: we don't care about running Qemu on the target. We care about host-qemu supporting the emulation of the target architecture, which is whatBR2_PACKAGE_HOST_QEMU_ARCH_SUPPORTSis for.- Adds the dependency to the relevant
BR2_PACKAGE_HOST_QEMUoptions toBR2_PACKAGE_NODEJS, so that host-qemu is built with the appropriate features needed to build the target nodejs.
Quoted 8 lines
- Removes the qemu related dependencies from host-nodejs, which does not need Qemu at all.
Without this change the build of nodejs without npm enabled is broken as the host-qemu that gets built does not have all the features that are needed. There are no autobuild failures at this point, however.
Signed-off-by Thomas Petazzoni <[email protected]>
Committed to 2022.08.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot