[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#51838] [PATCH v2 01/26] gnu: node: Avoid duplicating build phases.
From: |
Philip McGrath |
Subject: |
[bug#51838] [PATCH v2 01/26] gnu: node: Avoid duplicating build phases. |
Date: |
Fri, 19 Nov 2021 23:33:41 -0500 |
* gnu/packages/node.scm (node)[arguments]: Split 'patch-files phase
into 'patch-hardcoded-program-references and
'delete-problematic-tests. Adapt 'patch-hardcoded-program-references
and 'configure to work unmodified on node-lts, but don't try to
share 'delete-problematic-tests, because those details seem to change
too much between node versions.
(node, node-lts)[inputs]: Use bash-minimal rather than bash.
(node-lts)[arguments]: Inherit 'patch-hardcoded-program-references,
and 'configure phases from the bootstrap node.
Remove the 'patch-files phase, keeping its remaining
non-inherited work in a new 'replace-llhttp-sources phase.
---
gnu/packages/node.scm | 105 +++++++++++++-----------------------------
1 file changed, 32 insertions(+), 73 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index dccf871d2c..7ebbbc3060 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2020, 2021 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -105,14 +106,22 @@ (define-public node
#:test-target "test-ci-js"
#:phases
(modify-phases %standard-phases
- (add-before 'configure 'patch-files
+ (add-before 'configure 'patch-hardcoded-program-references
(lambda* (#:key inputs #:allow-other-keys)
+
;; Fix hardcoded /bin/sh references.
- (substitute* '("lib/child_process.js"
- "lib/internal/v8_prof_polyfill.js"
-
"test/parallel/test-child-process-spawnsync-shell.js"
- "test/parallel/test-stdio-closed.js"
- "test/sequential/test-child-process-emfile.js")
+ (substitute*
+ (let ((common
+ '("lib/child_process.js"
+ "lib/internal/v8_prof_polyfill.js"
+ "test/parallel/test-child-process-spawnsync-shell.js"
+ "test/parallel/test-stdio-closed.js"
+ "test/sequential/test-child-process-emfile.js"))
+ ;; not in bootstap node:
+ (sigxfsz "test/parallel/test-fs-write-sigxfsz.js"))
+ (if (file-exists? sigxfsz)
+ (cons sigxfsz common)
+ common))
(("'/bin/sh'")
(string-append "'" (assoc-ref inputs "bash") "/bin/sh'")))
@@ -122,7 +131,10 @@ (define-public node
"test/parallel/test-child-process-exec-env.js")
(("'/usr/bin/env'")
(string-append "'" (assoc-ref inputs "coreutils")
- "/bin/env'")))
+ "/bin/env'")))))
+ (add-after 'patch-hardcoded-program-references
+ 'delete-problematic-tests
+ (lambda* (#:key inputs #:allow-other-keys)
;; FIXME: These tests fail in the build container, but they don't
;; seem to be indicative of real problems in practice.
@@ -217,9 +229,13 @@ (define-public node
(setenv "CXX" ,(cxx-for-target))
(setenv "PKG_CONFIG" ,(pkg-config-for-target))
(apply invoke
- (string-append (assoc-ref (or native-inputs inputs)
- "python")
- "/bin/python")
+ (let ((python
+ (string-append (assoc-ref (or native-inputs
inputs)
+ "python")
+ "/bin/python")))
+ (if (file-exists? python)
+ python
+ (string-append python "3")))
"configure" flags))))
(add-after 'patch-shebangs 'patch-npm-shebang
(lambda* (#:key outputs #:allow-other-keys)
@@ -256,7 +272,7 @@ (define-public node
(variable "NODE_PATH")
(files '("lib/node_modules")))))
(inputs
- `(("bash" ,bash)
+ `(("bash" ,bash-minimal)
("coreutils" ,coreutils)
("c-ares" ,c-ares)
("http-parser" ,http-parser)
@@ -712,66 +728,8 @@ (define-public node-lts
libuv "/lib:"
zlib "/lib"
"'],"))))))
- (replace 'configure
- ;; Node's configure script is actually a python script, so we
can't
- ;; run it with bash.
- (lambda* (#:key outputs (configure-flags '()) native-inputs inputs
- #:allow-other-keys)
- (let* ((prefix (assoc-ref outputs "out"))
- (xflags ,(if (%current-target-system)
- `'("--cross-compiling"
- ,(string-append
- "--dest-cpu="
- (match (%current-target-system)
- ((? (cut string-prefix? "arm" <>))
- "arm")
- ((? (cut string-prefix? "aarch64" <>))
- "arm64")
- ((? (cut string-prefix? "i686" <>))
- "ia32")
- ((? (cut string-prefix? "x86_64" <>))
- "x64")
- ((? (cut string-prefix? "powerpc64"
<>))
- "ppc64")
- (_ "unsupported"))))
- ''()))
- (flags (cons
- (string-append "--prefix=" prefix)
- (append xflags configure-flags))))
- (format #t "build directory: ~s~%" (getcwd))
- (format #t "configure flags: ~s~%" flags)
- ;; Node's configure script expects the CC environment
variable to
- ;; be set.
- (setenv "CC_host" "gcc")
- (setenv "CXX_host" "g++")
- (setenv "CC" ,(cc-for-target))
- (setenv "CXX" ,(cxx-for-target))
- (setenv "PKG_CONFIG" ,(pkg-config-for-target))
- (apply invoke
- (string-append (assoc-ref (or native-inputs inputs)
- "python")
- "/bin/python3")
- "configure" flags))))
- (replace 'patch-files
+ (replace 'delete-problematic-tests
(lambda* (#:key inputs #:allow-other-keys)
- ;; Fix hardcoded /bin/sh references.
- (substitute* '("lib/child_process.js"
- "lib/internal/v8_prof_polyfill.js"
-
"test/parallel/test-child-process-spawnsync-shell.js"
- "test/parallel/test-fs-write-sigxfsz.js"
- "test/parallel/test-stdio-closed.js"
- "test/sequential/test-child-process-emfile.js")
- (("'/bin/sh'")
- (string-append "'" (assoc-ref inputs "bash") "/bin/sh'")))
-
- ;; Fix hardcoded /usr/bin/env references.
- (substitute*
'("test/parallel/test-child-process-default-options.js"
- "test/parallel/test-child-process-env.js"
- "test/parallel/test-child-process-exec-env.js")
- (("'/usr/bin/env'")
- (string-append "'" (assoc-ref inputs "coreutils")
- "/bin/env'")))
-
;; FIXME: These tests fail in the build container, but they
don't
;; seem to be indicative of real problems in practice.
(for-each delete-file
@@ -810,8 +768,9 @@ (define-public node-lts
;; TODO: Regenerate certs instead.
(for-each delete-file
'("test/parallel/test-tls-passphrase.js"
- "test/parallel/test-tls-server-verify.js"))
-
+ "test/parallel/test-tls-server-verify.js"))))
+ (add-after 'delete-problematic-tests 'replace-llhttp-sources
+ (lambda* (#:key inputs #:allow-other-keys)
;; Replace pre-generated llhttp sources
(let ((llhttp (assoc-ref inputs "llhttp")))
(copy-file (string-append llhttp "/src/llhttp.c")
@@ -838,7 +797,7 @@ (define-public node-lts
("python" ,python)
("util-linux" ,util-linux)))
(inputs
- `(("bash" ,bash)
+ `(("bash" ,bash-minimal)
("coreutils" ,coreutils)
("c-ares" ,c-ares-for-node)
("icu4c" ,icu4c-67)
--
2.32.0
- [bug#51838] [PATCH 00/11] guix: node-build-system: Support compiling add-ons with node-gyp., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 01/11] gnu: node: Avoid duplicating build phases., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 02/11] gnu: node: Update to 10.24.1 for bootstrapping., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 03/11] guix: node-build-system: Support compiling add-ons with node-gyp., Philip McGrath, 2021/11/14
- [bug#51838] [PATCH 03/11] guix: node-build-system: Support compiling add-ons with node-gyp., Liliana Marie Prikler, 2021/11/14
- [bug#51838] [PATCH 03/11] guix: node-build-system: Support compiling add-ons with node-gyp., Philip McGrath, 2021/11/19
- [bug#51838] [PATCH v2 01/26] gnu: node: Avoid duplicating build phases.,
Philip McGrath <=
- [bug#51838] [PATCH v2 06/26] gnu: node-semver-bootstrap: Use #:absent-dependencies., Philip McGrath, 2021/11/19
- [bug#51838] [PATCH v2 06/26] gnu: node-semver-bootstrap: Use #:absent-dependencies., Liliana Marie Prikler, 2021/11/20
- [bug#51838] [PATCH v2 03/26] gnu: node: Patch shebangs in node_modules., Philip McGrath, 2021/11/19
- [bug#51838] [PATCH v2 07/26] gnu: node-ms-bootstrap: Use #:absent-dependencies., Philip McGrath, 2021/11/19
- [bug#51838] [PATCH v2 05/26] guix: node-build-system: Add #:absent-dependencies argument., Philip McGrath, 2021/11/19
- [bug#51838] [PATCH v2 05/26] guix: node-build-system: Add #:absent-dependencies argument., Liliana Marie Prikler, 2021/11/20
- [bug#51838] [PATCH v2 05/26] guix: node-build-system: Add #:absent-dependencies argument., Philip McGrath, 2021/11/20
- [bug#51838] [PATCH v2 05/26] guix: node-build-system: Add #:absent-dependencies argument., Liliana Marie Prikler, 2021/11/20
- [bug#51838] [PATCH 00/11] guix: node-build-system: Support compiling add-ons with node-gyp., Timothy Sample, 2021/11/28
- [bug#51838] [PATCH v2 04/26] gnu: node: Add an npmrc file to set nodedir., Philip McGrath, 2021/11/19