gnu: node: Avoid duplicating build phases.
* 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. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
This commit is contained in:
		
							parent
							
								
									ba744faeb1
								
							
						
					
					
						commit
						2d6d881eb3
					
				
					 1 changed files with 35 additions and 72 deletions
				
			
		| 
						 | 
					@ -10,6 +10,7 @@
 | 
				
			||||||
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
 | 
					;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
 | 
				
			||||||
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 | 
					;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 | 
				
			||||||
;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
 | 
					;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
 | 
				
			||||||
 | 
					;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
 | 
				
			||||||
;;;
 | 
					;;;
 | 
				
			||||||
;;; This file is part of GNU Guix.
 | 
					;;; This file is part of GNU Guix.
 | 
				
			||||||
;;;
 | 
					;;;
 | 
				
			||||||
| 
						 | 
					@ -106,14 +107,22 @@
 | 
				
			||||||
       #:test-target "test-ci-js"
 | 
					       #:test-target "test-ci-js"
 | 
				
			||||||
       #:phases
 | 
					       #:phases
 | 
				
			||||||
       (modify-phases %standard-phases
 | 
					       (modify-phases %standard-phases
 | 
				
			||||||
         (add-before 'configure 'patch-files
 | 
					         (add-before 'configure 'patch-hardcoded-program-references
 | 
				
			||||||
           (lambda* (#:key inputs #:allow-other-keys)
 | 
					           (lambda* (#:key inputs #:allow-other-keys)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
             ;; Fix hardcoded /bin/sh references.
 | 
					             ;; Fix hardcoded /bin/sh references.
 | 
				
			||||||
             (substitute* '("lib/child_process.js"
 | 
					             (substitute*
 | 
				
			||||||
 | 
					                 (let ((common
 | 
				
			||||||
 | 
					                        '("lib/child_process.js"
 | 
				
			||||||
                          "lib/internal/v8_prof_polyfill.js"
 | 
					                          "lib/internal/v8_prof_polyfill.js"
 | 
				
			||||||
                          "test/parallel/test-child-process-spawnsync-shell.js"
 | 
					                          "test/parallel/test-child-process-spawnsync-shell.js"
 | 
				
			||||||
                          "test/parallel/test-stdio-closed.js"
 | 
					                          "test/parallel/test-stdio-closed.js"
 | 
				
			||||||
                            "test/sequential/test-child-process-emfile.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'")
 | 
					               (("'/bin/sh'")
 | 
				
			||||||
                (string-append "'" (assoc-ref inputs "bash") "/bin/sh'")))
 | 
					                (string-append "'" (assoc-ref inputs "bash") "/bin/sh'")))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -123,7 +132,10 @@
 | 
				
			||||||
                            "test/parallel/test-child-process-exec-env.js")
 | 
					                            "test/parallel/test-child-process-exec-env.js")
 | 
				
			||||||
               (("'/usr/bin/env'")
 | 
					               (("'/usr/bin/env'")
 | 
				
			||||||
                (string-append "'" (assoc-ref inputs "coreutils")
 | 
					                (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
 | 
					             ;; FIXME: These tests fail in the build container, but they don't
 | 
				
			||||||
             ;; seem to be indicative of real problems in practice.
 | 
					             ;; seem to be indicative of real problems in practice.
 | 
				
			||||||
| 
						 | 
					@ -218,9 +230,16 @@
 | 
				
			||||||
               (setenv "CXX" ,(cxx-for-target))
 | 
					               (setenv "CXX" ,(cxx-for-target))
 | 
				
			||||||
               (setenv "PKG_CONFIG" ,(pkg-config-for-target))
 | 
					               (setenv "PKG_CONFIG" ,(pkg-config-for-target))
 | 
				
			||||||
               (apply invoke
 | 
					               (apply invoke
 | 
				
			||||||
                      (search-input-file (or native-inputs inputs)
 | 
					                      (let ((inpts (or native-inputs inputs)))
 | 
				
			||||||
                                         "/bin/python")
 | 
					                        (with-exception-handler
 | 
				
			||||||
                      "configure" flags))))
 | 
					                            (lambda (e)
 | 
				
			||||||
 | 
					                              (if (search-error? e)
 | 
				
			||||||
 | 
					                                  (search-input-file inpts "/bin/python3")
 | 
				
			||||||
 | 
					                                  (raise-exception e)))
 | 
				
			||||||
 | 
					                          (lambda ()
 | 
				
			||||||
 | 
					                            (search-input-file inpts "/bin/python"))))
 | 
				
			||||||
 | 
					                      "configure"
 | 
				
			||||||
 | 
					                      flags))))
 | 
				
			||||||
         (add-after 'patch-shebangs 'patch-npm-shebang
 | 
					         (add-after 'patch-shebangs 'patch-npm-shebang
 | 
				
			||||||
           (lambda* (#:key outputs #:allow-other-keys)
 | 
					           (lambda* (#:key outputs #:allow-other-keys)
 | 
				
			||||||
             (let* ((bindir (string-append (assoc-ref outputs "out")
 | 
					             (let* ((bindir (string-append (assoc-ref outputs "out")
 | 
				
			||||||
| 
						 | 
					@ -256,7 +275,7 @@
 | 
				
			||||||
            (variable "NODE_PATH")
 | 
					            (variable "NODE_PATH")
 | 
				
			||||||
            (files '("lib/node_modules")))))
 | 
					            (files '("lib/node_modules")))))
 | 
				
			||||||
    (inputs
 | 
					    (inputs
 | 
				
			||||||
     (list bash
 | 
					     (list bash-minimal
 | 
				
			||||||
           coreutils
 | 
					           coreutils
 | 
				
			||||||
           c-ares
 | 
					           c-ares
 | 
				
			||||||
           http-parser
 | 
					           http-parser
 | 
				
			||||||
| 
						 | 
					@ -705,65 +724,8 @@ source files.")
 | 
				
			||||||
                                   libuv "/lib:"
 | 
					                                   libuv "/lib:"
 | 
				
			||||||
                                   zlib "/lib"
 | 
					                                   zlib "/lib"
 | 
				
			||||||
                                   "'],"))))))
 | 
					                                   "'],"))))))
 | 
				
			||||||
           (replace 'configure
 | 
					           (replace 'delete-problematic-tests
 | 
				
			||||||
             ;; 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
 | 
					 | 
				
			||||||
                        (search-input-file (or native-inputs inputs)
 | 
					 | 
				
			||||||
                                           "/bin/python3")
 | 
					 | 
				
			||||||
                        "configure" flags))))
 | 
					 | 
				
			||||||
           (replace 'patch-files
 | 
					 | 
				
			||||||
             (lambda* (#:key inputs #:allow-other-keys)
 | 
					             (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
 | 
					               ;; FIXME: These tests fail in the build container, but they don't
 | 
				
			||||||
               ;; seem to be indicative of real problems in practice.
 | 
					               ;; seem to be indicative of real problems in practice.
 | 
				
			||||||
               (for-each delete-file
 | 
					               (for-each delete-file
 | 
				
			||||||
| 
						 | 
					@ -802,8 +764,9 @@ source files.")
 | 
				
			||||||
               ;; TODO: Regenerate certs instead.
 | 
					               ;; TODO: Regenerate certs instead.
 | 
				
			||||||
               (for-each delete-file
 | 
					               (for-each delete-file
 | 
				
			||||||
                         '("test/parallel/test-tls-passphrase.js"
 | 
					                         '("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
 | 
					               ;; Replace pre-generated llhttp sources
 | 
				
			||||||
               (let ((llhttp (assoc-ref inputs "llhttp")))
 | 
					               (let ((llhttp (assoc-ref inputs "llhttp")))
 | 
				
			||||||
                 (copy-file (string-append llhttp "/src/llhttp.c")
 | 
					                 (copy-file (string-append llhttp "/src/llhttp.c")
 | 
				
			||||||
| 
						 | 
					@ -830,7 +793,7 @@ source files.")
 | 
				
			||||||
           python
 | 
					           python
 | 
				
			||||||
           util-linux))
 | 
					           util-linux))
 | 
				
			||||||
    (inputs
 | 
					    (inputs
 | 
				
			||||||
     (list bash
 | 
					     (list bash-minimal
 | 
				
			||||||
           coreutils
 | 
					           coreutils
 | 
				
			||||||
           c-ares-for-node
 | 
					           c-ares-for-node
 | 
				
			||||||
           icu4c-67
 | 
					           icu4c-67
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue