Control: retitle -1 nodejs: cannot bootstrap nodejs

Hi Jérémy,

On Fri, 2023-10-20 at 02:25 +0200, Jérémy Lal wrote:
> https://salsa.debian.org/js-team/nodejs/-/blob/master-
> 18.x/debian/README.source

Thanks for your suggestion. I actually did follow those instructions to
attempt to build nodejs 18.13.0+dfsg1-1.

For nodejs 16.15.1+dfsg-1 following those instructions bootstraps the package
just fine, I think because the "externalized builtin" JS files are present in
the packaging.

I have attached the three patches to debian/ to get _something_ bootstrap for
18x but it still fails with the error "Cannot load externalized builtin" when
trying to launch bootstrapped node.

I build the package using debuild --no-lintian in a chroot. In the build
system I have no ability to build arch:all packages, just architecture
dependant packages.

Thanks!

> Le ven. 20 oct. 2023 à 01:27, Christopher Obbard
> <chris.obb...@collabora.com> a écrit :
> > Source: nodejs
> > Version: 18.13.0+dfsg1-1
> > Severity: important
> > X-Debbugs-Cc: chris.obb...@collabora.com
> > 
> > Dear Maintainer,
> > 
> > Bootstrapping nodejs version 18 FTBFS for me. There seems to be a couple
> > of different issues when bootstrapping:
> > 
> > 1) The created node binary fails with an error about the externalized
> > builtins not being found. This renders the binary useless. This also
> > causes an error in the bootstrap process, override_dh_auto_build-arch
> > fails with:
> > 
> >     Cannot load externalized builtin: "internal/deps/cjs-module-
> > lexer/lexer:/usr/share/nodejs/cjs-module-lexer/lexer.js".
> >      1: 0x7f06454026cc node::Abort() [/mnt/_build/nodejs-
> > 18.13.0+dfsg1/out/Release/libnode.so.108]
> >      2: 0x7f06453e1f1d  [/mnt/_build/nodejs-
> > 18.13.0+dfsg1/out/Release/libnode.so.108]
> >      3: 0x7f06453e2069 node::builtins::BuiltinLoader::BuiltinLoader()
> > [/mnt/_build/nodejs-18.13.0+dfsg1/out/Release/libnode.so.108]
> >      4: 0x7f064531db83  [/mnt/_build/nodejs-
> > 18.13.0+dfsg1/out/Release/libnode.so.108]
> >      5: 0x7f064782947e  [/lib64/ld-linux-x86-64.so.2]
> >      6: 0x7f0647829568  [/lib64/ld-linux-x86-64.so.2]
> >      7: 0x7f06478432ca  [/lib64/ld-linux-x86-64.so.2]
> >     Aborted (core dumped)
> > 
> > 
> > 2) dh_install fails with:
> > 
> >     dh_install: warning: Cannot find (any matches for)
> > "./<@(node_builtin_shareable_builtins)" (tried in ., debian/tmp)
> >     dh_install: warning: nodejs missing files:
> > ./<@(node_builtin_shareable_builtins)
> >     dh_install: error: missing files, aborting
> > 
> > 
> > I have a couple of patches which works around these issues and can create
> > a bootstrapped nodejs (I can share my patches if that is useful); but the
> > created binary is useless due to the "Cannot load externalized builtin"
> > error.
> > 
> > Thanks!
> > 
> > -- System Information:
> > Debian Release: trixie/sid
> >   APT prefers unstable
> >   APT policy: (500, 'unstable'), (1, 'experimental')
> > Architecture: amd64 (x86_64)
> > 
> > Kernel: Linux 6.5.0-2-amd64 (SMP w/16 CPU threads; PREEMPT)
> > Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8),
> > LANGUAGE=en_GB:en
> > Shell: /bin/sh linked to /usr/bin/dash
> > Init: systemd (via /run/systemd/system)
> > LSM: AppArmor: enabled
> > 

Thanks!

Chris
From 8175c5f66df782c672df5b5a2a8d31eed915021b Mon Sep 17 00:00:00 2001
From: Christopher Obbard <chris.obb...@collabora.com>
Date: Thu, 19 Oct 2023 14:38:26 +0100
Subject: [PATCH 1/9] Set build profiles to bootstrap nodejs

Signed-off-by: Christopher Obbard <chris.obb...@collabora.com>
---
 debian/control | 74 +++++++++++++++++++++++++-------------------------
 debian/rules   |  2 ++
 2 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/debian/control b/debian/control
index d1966836..4f12726c 100644
--- a/debian/control
+++ b/debian/control
@@ -6,13 +6,13 @@ Uploaders: Jérémy Lal <kapo...@melix.org>,
  Jonas Smedegaard <d...@jones.dk>
 Build-Depends:
  gcc-11, g++-11,
- sse2-support [i386] <!nocheck>,
- armv6k-support [armel] <!nocheck>, vfpv2-support [armel] <!nocheck>,
+# sse2-support [i386] <!nocheck>,
+# armv6k-support [armel] <!nocheck>, vfpv2-support [armel] <!nocheck>,
  debhelper-compat (= 13),
  dh-buildinfo,
  bash-completion,
  ca-certificates,
- curl <!nocheck>,
+# curl <!nocheck>,
  gyp (>= 0.1~svn1773),
  jq,
  libbrotli-dev,
@@ -29,21 +29,21 @@ Build-Depends:
  libssl-dev:native,
  libuv1-dev (>= 1.43.0~),
  libuv1-dev:native,
- node-acorn (>= 6.2.1~) <!pkg.nodejs.nobuiltin>,
- node-cjs-module-lexer (>= 1.2.2~) <!pkg.nodejs.nobuiltin>,
- node-undici (>= 5.0.0~) <!pkg.nodejs.nobuiltin>,
- openssl (>= 1.1.1~) <!nocheck>,
+# node-acorn (>= 6.2.1~) <!pkg.nodejs.nobuiltin>,
+# node-cjs-module-lexer (>= 1.2.2~) <!pkg.nodejs.nobuiltin>,
+# node-undici (>= 5.0.0~) <!pkg.nodejs.nobuiltin>,
+# openssl (>= 1.1.1~) <!nocheck>,
  pkg-config,
- pkg-js-tools (>= 0.8.2~) <!nocheck>,
+# pkg-js-tools (>= 0.8.2~) <!nocheck>,
  python3:native,
  python3-distutils,
- procps <!nocheck>,
+# procps <!nocheck>,
  zlib1g-dev,
  zlib1g-dev:native,
 Build-Depends-Indep:
- node-js-yaml (>= 4.1.0+dfsg+~4.0.5-6) <!nodoc>,
- node-marked (>= 4~) <!nodoc>,
- node-highlight.js <!nodoc>,
+# node-js-yaml (>= 4.1.0+dfsg+~4.0.5-6) <!nodoc>,
+# node-marked (>= 4~) <!nodoc>,
+# node-highlight.js <!nodoc>,
 Standards-Version: 4.6.1.0
 Homepage: https://nodejs.org/
 Vcs-Browser: https://salsa.debian.org/js-team/nodejs/tree/master-16.x
@@ -114,9 +114,9 @@ Depends: ${shlibs:Depends},
  ${misc:Depends},
  sse2-support [i386],
  armv6k-support [armel], vfpv2-support [armel],
- node-acorn (>= 6.2.1~) <!pkg.nodejs.nobuiltin>,
- node-cjs-module-lexer (>= 1.2.2~) <!pkg.nodejs.nobuiltin>,
- node-undici (>= 5.0.0~) <!pkg.nodejs.nobuiltin>
+# node-acorn (>= 6.2.1~) <!pkg.nodejs.nobuiltin>,
+# node-cjs-module-lexer (>= 1.2.2~) <!pkg.nodejs.nobuiltin>,
+# node-undici (>= 5.0.0~) <!pkg.nodejs.nobuiltin>
 Breaks: node-modern-syslog (<< 1.1.4-2),
  libnode64 (<< 10.24.1~),
  libnode72 (<< 13)
@@ -137,25 +137,25 @@ Description: evented I/O for V8 javascript - runtime library
  .
  This package provides the dynamic library for Node.js.
 
-Package: nodejs-doc
-Section: doc
-Architecture: all
-Multi-Arch: foreign
-Recommends: nodejs
-Depends: ${misc:Depends}
-Replaces: nodejs (<< 6.11.2~dfsg-3)
-Conflicts: nodejs (<< 6.11.2~dfsg-3)
-Description: API documentation for Node.js, the javascript platform
- Node.js is a platform built on Chrome's JavaScript runtime for easily
- building fast, scalable network applications. Node.js uses an
- event-driven, non-blocking I/O model that makes it lightweight and
- efficient, perfect for data-intensive real-time applications that run
- across distributed devices.
- .
- Node.js is bundled with several useful libraries to handle server
- tasks:
- .
- System, Events, Standard I/O, Modules, Timers, Child Processes, POSIX,
- HTTP, Multipart Parsing, TCP, DNS, Assert, Path, URL, Query Strings.
- .
- This package contains API documentation for Node.js.
+#Package: nodejs-doc
+#Section: doc
+#Architecture: all
+#Multi-Arch: foreign
+#Recommends: nodejs
+#Depends: ${misc:Depends}
+#Replaces: nodejs (<< 6.11.2~dfsg-3)
+#Conflicts: nodejs (<< 6.11.2~dfsg-3)
+#Description: API documentation for Node.js, the javascript platform
+# Node.js is a platform built on Chrome's JavaScript runtime for easily
+# building fast, scalable network applications. Node.js uses an
+# event-driven, non-blocking I/O model that makes it lightweight and
+# efficient, perfect for data-intensive real-time applications that run
+# across distributed devices.
+# .
+# Node.js is bundled with several useful libraries to handle server
+# tasks:
+# .
+# System, Events, Standard I/O, Modules, Timers, Child Processes, POSIX,
+# HTTP, Multipart Parsing, TCP, DNS, Assert, Path, URL, Query Strings.
+# .
+# This package contains API documentation for Node.js.
diff --git a/debian/rules b/debian/rules
index 1c18c035..53c4bb97 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,6 +11,8 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
 builtins := /usr/share/nodejs/node
 
+DEB_BUILD_PROFILES += " nodoc nocheck pkg.nodejs.nobuiltin noautodbgsym"
+
 # source equivalent of nodejs -e 'console.log(process.versions.modules)'
 ABI = $(shell awk '/^#define NODE_MODULE_VERSION/ {print $$3}' src/node_version.h)
 
-- 
2.42.0

From bba9d77ef944e79edf6215b60ef9582da9145b00 Mon Sep 17 00:00:00 2001
From: Christopher Obbard <chris.obb...@collabora.com>
Date: Thu, 19 Oct 2023 19:40:52 +0100
Subject: [PATCH 3/9] HACK: bootstrap: Don't attempt to install
 bash-completions

If we try to call node during bootstrap, it fails with:

    Cannot load externalized builtin: "internal/deps/cjs-module-lexer/lexer:/usr/share/nodejs/cjs-module-lexer/lexer.js".
     1: 0x7f06454026cc node::Abort() [/mnt/_build/nodejs-18.13.0+dfsg1/out/Release/libnode.so.108]
     2: 0x7f06453e1f1d  [/mnt/_build/nodejs-18.13.0+dfsg1/out/Release/libnode.so.108]
     3: 0x7f06453e2069 node::builtins::BuiltinLoader::BuiltinLoader() [/mnt/_build/nodejs-18.13.0+dfsg1/out/Release/libnode.so.108]
     4: 0x7f064531db83  [/mnt/_build/nodejs-18.13.0+dfsg1/out/Release/libnode.so.108]
     5: 0x7f064782947e  [/lib64/ld-linux-x86-64.so.2]
     6: 0x7f0647829568  [/lib64/ld-linux-x86-64.so.2]
     7: 0x7f06478432ca  [/lib64/ld-linux-x86-64.so.2]
    Aborted (core dumped)

This happens when calling debian/rules target override_dh_auto_build-arch
which builds the bash-completions.

Workaround this issue by not calling node during bootstrap.

Signed-off-by: Christopher Obbard <chris.obb...@collabora.com>
---
 debian/nodejs.links | 1 -
 debian/rules        | 3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/debian/nodejs.links b/debian/nodejs.links
index f80ac770..ca645e16 100644
--- a/debian/nodejs.links
+++ b/debian/nodejs.links
@@ -2,4 +2,3 @@ usr/bin/node usr/bin/nodejs
 usr/share/man/man1/node.1 usr/share/man/man1/nodejs.1
 usr/share/nodejs usr/share/node_modules
 usr/lib/${DEB_HOST_MULTIARCH}/nodejs usr/lib/${DEB_HOST_MULTIARCH}/node_modules
-/usr/share/bash-completion/completions/nodejs /usr/share/bash-completion/completions/node
diff --git a/debian/rules b/debian/rules
index 53c4bb97..2a9724fa 100755
--- a/debian/rules
+++ b/debian/rules
@@ -235,7 +235,8 @@ endif
 
 override_dh_auto_build-arch:
 	dh_auto_build
-	./out/Release/node --completion-bash > ./debian/nodejs.bash-completion
+	# TODO don't call this if nodoc is present ...
+	#./out/Release/node --completion-bash > ./debian/nodejs.bash-completion
 
 override_dh_auto_build-indep:
 	mkdir -p node_modules
-- 
2.42.0

From 4a64765ffcb44205649616dedc547c0b491ae1db Mon Sep 17 00:00:00 2001
From: Christopher Obbard <chris.obb...@collabora.com>
Date: Thu, 19 Oct 2023 20:34:20 +0100
Subject: [PATCH 4/9] HACK: bootstrap: Don't attempt to install
 <@(node_builtin_shareable_builtins)

When bootstrapping, dh_install fails with:

    dh_install: warning: Cannot find (any matches for) "./<@(node_builtin_shareable_builtins)" (tried in ., debian/tmp)
    dh_install: warning: nodejs missing files: ./<@(node_builtin_shareable_builtins)
    dh_install: error: missing files, aborting

Don't attempt to install that file during bootstrap.

Signed-off-by: Christopher Obbard <chris.obb...@collabora.com>
---
 debian/rules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/rules b/debian/rules
index 2a9724fa..a26fa192 100755
--- a/debian/rules
+++ b/debian/rules
@@ -269,7 +269,7 @@ override_dh_install-arch:
 	cp debian/nodejs.install.in debian/nodejs.install
 ifneq ($(filter pkg.nodejs.nobuiltin,$(DEB_BUILD_PROFILES)),)
 	echo "./lib $(builtins)/" >> debian/nodejs.install
-	deps_files="$(shell $(PYTHON) -c "import ast; d = ast.literal_eval(open('node.gyp').read()); print(' '.join(d['variables']['deps_files']));")"; \
+	deps_files="$(shell $(PYTHON) -c "import ast; d = ast.literal_eval(open('node.gyp').read()); print(' '.join(d['variables']['deps_files'][:-1]));")"; \
 	for src in $$deps_files; do \
 		dst=`dirname $$src`; \
 		echo "./$$src $(builtins)/$$dst" >> debian/nodejs.install; \
-- 
2.42.0

Reply via email to