* [bug#47282] [PATCH v2 01/13] build-system: Rewrite node build system.
2021-03-30 5:24 ` Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 02/13] gnu: Add libuv-for-node Timothy Sample
` (12 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Timothy Sample, Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* guix/build/node-build-system.scm: Rewrite it.
* guix/build-system/node.scm: Adjust accordingly.
* gnu/packages/node-xyz.scm (node-semver): Likewise.
Co-authored-by: Timothy Sample <samplet@ngyro.com>
---
gnu/packages/node-xyz.scm | 6 +-
guix/build-system/node.scm | 27 ++--
guix/build/node-build-system.scm | 207 +++++++++++++++----------------
3 files changed, 110 insertions(+), 130 deletions(-)
diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index b1d6d4ce59..60cc005ea4 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -261,7 +261,11 @@ function with browser support.")
"06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
(build-system node-build-system)
(arguments
- `(#:tests? #f)) ;; FIXME: Tests depend on node-tap
+ '(#:tests? #f ; FIXME: Tests depend on node-tap
+ #:phases
+ (modify-phases %standard-phases
+ ;; The only dependency to check for is tap, which we don't have.
+ (delete 'configure))))
(home-page "https://github.com/npm/node-semver")
(synopsis "Parses semantic versions strings")
(description
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index a8c5eed09b..4991ed53a5 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -17,7 +18,6 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix build-system node)
- #:use-module (guix store)
#:use-module (guix utils)
#:use-module (guix packages)
#:use-module (guix derivations)
@@ -25,22 +25,15 @@
#:use-module (guix build-system)
#:use-module (guix build-system gnu)
#:use-module (ice-9 match)
- #:export (npm-meta-uri
- %node-build-system-modules
+ #:export (%node-build-system-modules
node-build
node-build-system))
-(define (npm-meta-uri name)
- "Return a URI string for the metadata of node module NAME found in the npm
-registry."
- (string-append "https://registry.npmjs.org/" name))
-
(define %node-build-system-modules
;; Build-side modules imported by default.
`((guix build node-build-system)
(guix build json)
- (guix build union)
- ,@%gnu-build-system-modules)) ;; TODO: Might be not needed
+ ,@%gnu-build-system-modules))
(define (default-node)
"Return the default Node package."
@@ -76,7 +69,7 @@ registry."
(define* (node-build store name inputs
#:key
- (npm-flags ''())
+ (test-target "test")
(tests? #t)
(phases '(@ (guix build node-build-system)
%standard-phases))
@@ -86,8 +79,6 @@ registry."
(guile #f)
(imported-modules %node-build-system-modules)
(modules '((guix build node-build-system)
- (guix build json)
- (guix build union)
(guix build utils))))
"Build SOURCE using NODE and INPUTS."
(define builder
@@ -97,12 +88,10 @@ registry."
#:source ,(match (assoc-ref inputs "source")
(((? derivation? source))
(derivation->output-path source))
- ((source)
- source)
- (source
- source))
+ ((source) source)
+ (source source))
#:system ,system
- #:npm-flags ,npm-flags
+ #:test-target ,test-target
#:tests? ,tests?
#:phases ,phases
#:outputs %outputs
@@ -129,5 +118,5 @@ registry."
(define node-build-system
(build-system
(name 'node)
- (description "The standard Node build system")
+ (description "The Node build system")
(lower lower)))
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 7799f03595..a55cab237c 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 David Thompson <davet@gnu.org>
-;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2016, 2020 Jelle Licht <jlicht@fsfe.org>
+;;; Copyright © 2019, 2021 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -19,144 +20,130 @@
(define-module (guix build node-build-system)
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
- #:use-module (guix build json)
- #:use-module (guix build union)
#:use-module (guix build utils)
+ #:use-module (guix build json)
+ #:use-module (ice-9 ftw)
#:use-module (ice-9 match)
- #:use-module (ice-9 popen)
- #:use-module (ice-9 regex)
#:use-module (srfi srfi-1)
- #:use-module (srfi srfi-26)
#:export (%standard-phases
node-build))
;; Commentary:
;;
-;; Builder-side code of the standard Node/npm package build procedure.
+;; Builder-side code of the standard Node/NPM package install procedure.
;;
;; Code:
-(define* (read-package-data #:key (filename "package.json"))
- (call-with-input-file filename
- (lambda (port)
- (read-json port))))
+(define (set-home . _)
+ (with-directory-excursion ".."
+ (let loop ((i 0))
+ (let ((dir (string-append "npm-home-" (number->string i))))
+ (if (directory-exists? dir)
+ (loop (1+ i))
+ (begin
+ (mkdir dir)
+ (setenv "HOME" (string-append (getcwd) "/" dir))
+ (format #t "set HOME to ~s~%" (getenv "HOME")))))))
+ #t)
-(define* (build #:key inputs #:allow-other-keys)
- (define (build-from-package-json? package-file)
- (let* ((package-data (read-package-data #:filename package-file))
- (scripts (assoc-ref package-data "scripts")))
- (assoc-ref scripts "build")))
- "Build a new node module using the appropriate build system."
- ;; XXX: Develop a more robust heuristic, allow override
- (cond ((file-exists? "gulpfile.js")
- (invoke "gulp"))
- ((file-exists? "gruntfile.js")
- (invoke "grunt"))
- ((file-exists? "Makefile")
- (invoke "make"))
- ((and (file-exists? "package.json")
- (build-from-package-json? "package.json"))
- (invoke "npm" "run" "build")))
+(define (module-name module)
+ (let* ((package.json (string-append module "/package.json"))
+ (package-meta (call-with-input-file package.json read-json)))
+ (assoc-ref package-meta "name")))
+
+(define (index-modules input-paths)
+ (define (list-modules directory)
+ (append-map (lambda (x)
+ (if (string-prefix? "@" x)
+ (list-modules (string-append directory "/" x))
+ (list (string-append directory "/" x))))
+ (filter (lambda (x)
+ (not (member x '("." ".."))))
+ (or (scandir directory) '()))))
+ (let ((index (make-hash-table (* 2 (length input-paths)))))
+ (for-each (lambda (dir)
+ (let ((nm (string-append dir "/lib/node_modules")))
+ (for-each (lambda (module)
+ (hash-set! index (module-name module) module))
+ (list-modules nm))))
+ input-paths)
+ index))
+
+(define* (patch-dependencies #:key inputs #:allow-other-keys)
+
+ (define index (index-modules (map cdr inputs)))
+
+ (define (resolve-dependencies package-meta meta-key)
+ (fold (lambda (key+value acc)
+ (match key+value
+ ('@ acc)
+ ((key . value) (acons key (hash-ref index key value) acc))))
+ '()
+ (or (assoc-ref package-meta meta-key) '())))
+
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (let ((package-meta (read-json in)))
+ (assoc-set! package-meta "dependencies"
+ (append
+ '(@)
+ (resolve-dependencies package-meta "dependencies")
+ (resolve-dependencies package-meta "peerDependencies")))
+ (assoc-set! package-meta "devDependencies"
+ (append
+ '(@)
+ (resolve-dependencies package-meta "devDependencies")))
+ (write-json package-meta out))))
#t)
-(define* (link-npm-dependencies #:key inputs #:allow-other-keys)
- (define (inputs->node-inputs inputs)
- "Filter the directory part from INPUTS."
- (filter (lambda (input)
- (match input
- ((name . _) (node-package? name))))
- inputs))
- (define (inputs->directories inputs)
- "Extract the directory part from INPUTS."
- (match inputs
- (((names . directories) ...)
- directories)))
- (define (make-node-path root)
- (string-append root "/lib/node_modules/"))
-
- (let ((input-node-directories (inputs->directories
- (inputs->node-inputs inputs))))
- (union-build "node_modules"
- (map make-node-path input-node-directories))
+(define* (configure #:key outputs inputs #:allow-other-keys)
+ (let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+ (invoke npm "--offline" "--ignore-scripts" "install")
#t))
-(define configure link-npm-dependencies)
+(define* (build #:key inputs #:allow-other-keys)
+ (let ((package-meta (call-with-input-file "package.json" read-json)))
+ (if (and=> (assoc-ref package-meta "scripts")
+ (lambda (scripts)
+ (assoc-ref scripts "build")))
+ (let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+ (invoke npm "run" "build"))
+ (format #t "there is no build script to run~%"))
+ #t))
-(define* (check #:key tests? #:allow-other-keys)
+(define* (check #:key tests? inputs #:allow-other-keys)
"Run 'npm test' if TESTS?"
(if tests?
- ;; Should only be enabled once we know that there are tests
- (invoke "npm" "test"))
+ (let ((npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+ (invoke npm "test"))
+ (format #t "test suite not run~%"))
#t)
-(define (node-package? name)
- "Check if NAME correspond to the name of an Node package."
- (string-prefix? "node-" name))
+(define* (repack #:key inputs #:allow-other-keys)
+ (invoke "tar" "-czf" "../package.tgz" ".")
+ #t)
(define* (install #:key outputs inputs #:allow-other-keys)
- "Install the node module to the output store item. The module itself is
-installed in a subdirectory of @file{node_modules} and its runtime dependencies
-as defined by @file{package.json} are symlinked into a @file{node_modules}
-subdirectory of the module's directory. Additionally, binaries are installed in
-the @file{bin} directory."
- (let* ((out (assoc-ref outputs "out"))
- (target (string-append out "/lib"))
- (binaries (string-append out "/bin"))
- (data (read-package-data))
- (modulename (assoc-ref data "name"))
- (binary-configuration (match (assoc-ref data "bin")
- (('@ configuration ...) configuration)
- ((? string? configuration) configuration)
- (#f #f)))
- (dependencies (match (assoc-ref data "dependencies")
- (('@ deps ...) deps)
- (#f #f))))
- (mkdir-p target)
- (copy-recursively "." (string-append target "/node_modules/" modulename))
- ;; Remove references to dependencies
- (delete-file-recursively
- (string-append target "/node_modules/" modulename "/node_modules"))
- (cond
- ((string? binary-configuration)
- (begin
- (mkdir-p binaries)
- (symlink (string-append target "/node_modules/" modulename "/"
- binary-configuration)
- (string-append binaries "/" modulename))))
- ((list? binary-configuration)
- (for-each
- (lambda (conf)
- (match conf
- ((key . value)
- (begin
- (mkdir-p (dirname (string-append binaries "/" key)))
- (symlink (string-append target "/node_modules/" modulename "/"
- value)
- (string-append binaries "/" key))))))
- binary-configuration)))
- (when dependencies
- (mkdir-p
- (string-append target "/node_modules/" modulename "/node_modules"))
- (for-each
- (lambda (dependency)
- (let ((dependency (car dependency)))
- (symlink
- (string-append (assoc-ref inputs (string-append "node-" dependency))
- "/lib/node_modules/" dependency)
- (string-append target "/node_modules/" modulename
- "/node_modules/" dependency))))
- dependencies))
+ "Install the node module to the output store item."
+ (let ((out (assoc-ref outputs "out"))
+ (npm (string-append (assoc-ref inputs "node") "/bin/npm")))
+ (invoke npm "--prefix" out
+ "--global"
+ "--offline"
+ "--loglevel" "info"
+ "--production"
+ "install" "../package.tgz")
#t))
-
(define %standard-phases
(modify-phases gnu:%standard-phases
+ (add-after 'unpack 'set-home set-home)
+ (add-before 'configure 'patch-dependencies patch-dependencies)
(replace 'configure configure)
(replace 'build build)
- (replace 'install install)
- (delete 'check)
- (add-after 'install 'check check)
- (delete 'strip)))
+ (replace 'check check)
+ (add-before 'install 'repack repack)
+ (replace 'install install)))
(define* (node-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 02/13] gnu: Add libuv-for-node
2021-03-30 5:24 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 01/13] build-system: Rewrite node build system Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 03/13] gnu: node: Use license prefix Timothy Sample
` (11 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/libevent.scm (libuv-for-node): New variable.
---
gnu/packages/libevent.scm | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/gnu/packages/libevent.scm b/gnu/packages/libevent.scm
index 7109d9a88d..0e683570d3 100644
--- a/gnu/packages/libevent.scm
+++ b/gnu/packages/libevent.scm
@@ -134,6 +134,22 @@ resolution, asynchronous file system operations, and threading primitives.")
;; details. Documentation is CC-BY 4.0 as of 1.12.0; see 'LICENSE-docs'.
(license (list expat cc-by4.0))))
+(define-public libuv-for-node
+ ;; When upgrading Node, also upgrade this. Get the version from
+ ;; https://github.com/nodejs/node/blob/master/deps/uv/include/uv/version.h
+ (package
+ (inherit libuv)
+ (name "libuv")
+ (version "1.40.0")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "https://dist.libuv.org/dist/v" version
+ "/libuv-v" version ".tar.gz"))
+ (sha256
+ (base32
+ "1551k3ab27vbg9517l9b4iqbramwxdkwgpf53knas05cbfwhvab1"))))
+ (properties '((hidden? . #t)))))
+
(define-public perl-anyevent
(package
(name "perl-anyevent")
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 03/13] gnu: node: Use license prefix.
2021-03-30 5:24 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 01/13] build-system: Rewrite node build system Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 02/13] gnu: Add libuv-for-node Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 04/13] gnu: Add node-bootstrap Timothy Sample
` (10 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/node.scm (node)[license]: Use prefix for license.
---
gnu/packages/node.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index a0df3d2cad..82a2ca7ce0 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -26,7 +26,7 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages node)
- #:use-module ((guix licenses) #:select (expat))
+ #:use-module ((guix licenses) #:prefix license:)
#:use-module ((guix build utils) #:select (alist-replace))
#:use-module (guix packages)
#:use-module (guix derivations)
@@ -207,7 +207,7 @@ 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.")
(home-page "https://nodejs.org/")
- (license expat)
+ (license license:expat)
(properties '((max-silent-time . 7200) ;2h, needed on ARM
(timeout . 21600))))) ;6h
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 04/13] gnu: Add node-bootstrap.
2021-03-30 5:24 ` Timothy Sample
` (2 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 03/13] gnu: node: Use license prefix Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 05/13] gnu: Add node-semver-bootstrap Timothy Sample
` (9 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/node (node-bootstrap): Add hidden alias for node.
---
gnu/packages/node.scm | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 82a2ca7ce0..73d022d87f 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -211,6 +211,11 @@ devices.")
(properties '((max-silent-time . 7200) ;2h, needed on ARM
(timeout . 21600))))) ;6h
+;; This should be the latest version of node that still builds without
+;; depending on llhttp.
+(define-public node-bootstrap
+ (hidden-package node))
+
(define-public libnode
(package/inherit node
(name "libnode")
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 05/13] gnu: Add node-semver-bootstrap.
2021-03-30 5:24 ` Timothy Sample
` (3 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 04/13] gnu: Add node-bootstrap Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 06/13] gnu: Add node-ms-bootstrap Timothy Sample
` (8 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/node.scm (node-semver-bootstrap): New variable.
---
gnu/packages/node.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 73d022d87f..773cef3716 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -41,6 +41,7 @@
#:use-module (gnu packages icu4c)
#:use-module (gnu packages libevent)
#:use-module (gnu packages linux)
+ #:use-module (gnu packages node-xyz)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
@@ -216,6 +217,35 @@ devices.")
(define-public node-bootstrap
(hidden-package node))
+;; Duplicate of node-semver
+(define-public node-semver-bootstrap
+ (package
+ (name "node-semver")
+ (version "7.2.1")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/npm/node-semver")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "06biknqb05r9xsmcflm3ygh50pjvdk84x6r79w43kmck4fn3qn5p"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:node ,node-bootstrap
+ #:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure))))
+ (home-page "https://github.com/npm/node-semver")
+ (properties '((hidden? . #t)))
+ (synopsis "Parses semantic versions strings")
+ (description
+ "@code{node-semver} is a JavaScript implementation of the
+@uref{https://semver.org/, SemVer.org} specification.")
+ (license license:isc)))
+
(define-public libnode
(package/inherit node
(name "libnode")
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 06/13] gnu: Add node-ms-bootstrap.
2021-03-30 5:24 ` Timothy Sample
` (4 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 05/13] gnu: Add node-semver-bootstrap Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 07/13] gnu: Add node-binary-search-bootstrap Timothy Sample
` (7 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/node.scm (node-ms-bootstrap): New variable.
---
gnu/packages/node.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 773cef3716..1d17502df7 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -31,8 +31,10 @@
#:use-module (guix packages)
#:use-module (guix derivations)
#:use-module (guix download)
+ #:use-module (guix git-download)
#:use-module (guix utils)
#:use-module (guix build-system gnu)
+ #:use-module (guix build-system node)
#:use-module (gnu packages)
#:use-module (gnu packages adns)
#:use-module (gnu packages base)
@@ -246,6 +248,34 @@ devices.")
@uref{https://semver.org/, SemVer.org} specification.")
(license license:isc)))
+(define-public node-ms-bootstrap
+ (package
+ (name "node-ms")
+ (version "2.1.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/vercel/ms.git")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1pjxzbi4j8pinlsc7yxvfrh0b47kb2dc4lfc2rjq4wx5bdwl33fj"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:node ,node-bootstrap
+ #:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure))))
+ (home-page "https://github.com/zeit/ms#readme")
+ (properties '((hidden? . #t)))
+ (synopsis "Tiny millisecond conversion utility")
+ (description "Use this package to easily convert various time
+formats to milliseconds.")
+ (license license:expat)))
+
(define-public libnode
(package/inherit node
(name "libnode")
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 07/13] gnu: Add node-binary-search-bootstrap.
2021-03-30 5:24 ` Timothy Sample
` (5 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 06/13] gnu: Add node-ms-bootstrap Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 08/13] gnu: Add node-debug-bootstrap Timothy Sample
` (6 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/node.scm (node-binary-search-bootstrap): New variable.
---
gnu/packages/node.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 1d17502df7..21d6052c06 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -276,6 +276,33 @@ devices.")
formats to milliseconds.")
(license license:expat)))
+(define-public node-binary-search-bootstrap
+ (package
+ (name "node-binary-search")
+ (version "1.3.6")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/darkskyapp/binary-search.git")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1xr2msdc143cd3xwgq7n3rhzy7j8wrnaidxl0r6l6b6g3mpbpjig"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:node ,node-bootstrap
+ #:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure))))
+ (home-page "https://github.com/darkskyapp/binary-search#readme")
+ (properties '((hidden? . #t)))
+ (synopsis "Tiny binary search function with comparators")
+ (description "This package is a binary search function for Node.js.")
+ (license license:cc0)))
+
(define-public libnode
(package/inherit node
(name "libnode")
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 08/13] gnu: Add node-debug-bootstrap.
2021-03-30 5:24 ` Timothy Sample
` (6 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 07/13] gnu: Add node-binary-search-bootstrap Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 09/13] gnu: Add node-llparse-builder-bootstrap Timothy Sample
` (5 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/node.scm (node-debug-bootstrap): New variable.
---
gnu/packages/node.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 21d6052c06..6c4c02265d 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -303,6 +303,36 @@ formats to milliseconds.")
(description "This package is a binary search function for Node.js.")
(license license:cc0)))
+(define-public node-debug-bootstrap
+ (package
+ (name "node-debug")
+ (version "4.3.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/visionmedia/debug.git")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "08g52r1d4yqcsfdfb7n5if33d4cghaq75gx5n9hj6m6fd8jfp2pi"))))
+ (build-system node-build-system)
+ (arguments
+ `(#:node ,node-bootstrap
+ #:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure))))
+ (inputs `(("node-ms" ,node-ms-bootstrap)))
+ (home-page "https://github.com/visionmedia/debug#readme")
+ (properties '((hidden? . #t)))
+ (synopsis "Small debugging utility")
+ (description "This package contains a tiny JavaScript debugging
+utility modelled after Node.js core's debugging technique. It works in
+Node.js and web browsers.")
+ (license license:expat)))
+
(define-public libnode
(package/inherit node
(name "libnode")
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 09/13] gnu: Add node-llparse-builder-bootstrap.
2021-03-30 5:24 ` Timothy Sample
` (7 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 08/13] gnu: Add node-debug-bootstrap Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 10/13] gnu: Add node-llparse-frontend-bootstrap Timothy Sample
` (4 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/node.scm (node-llparse-builder-bootstrap): New variable.
---
gnu/packages/node.scm | 65 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 6c4c02265d..570d4521ac 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -333,6 +333,71 @@ utility modelled after Node.js core's debugging technique. It works in
Node.js and web browsers.")
(license license:expat)))
+(define-public node-llparse-builder-bootstrap
+ (package
+ (name "node-llparse-builder")
+ (version "1.5.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/indutny/llparse-builder.git")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0r82iiwqsb73k2fxw7842rjjiixllxpyc6yl9cq4ma6ybkf6xmzm"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ ;; FIXME: Unneeded runtime dependency.
+ ;; https://github.com/indutny/llparse-builder/pull/2
+ (substitute* "package.json"
+ (("\"@types/debug.*,") ""))
+ ;; Fix imports for esbuild.
+ ;; https://github.com/evanw/esbuild/issues/477
+ (substitute* '("src/node/invoke.ts"
+ "src/node/base.ts"
+ "src/node/consume.ts"
+ "src/node/match.ts"
+ "src/node/error.ts"
+ "src/node/pause.ts"
+ "src/edge.ts"
+ "src/utils.ts"
+ "src/loop-checker/index.ts"
+ "src/loop-checker/lattice.ts"
+ "src/code/field.ts"
+ "src/span-allocator.ts")
+ (("\\* as assert") "assert")
+ (("\\* as debugAPI") "debugAPI"))
+ #t))))
+ (build-system node-build-system)
+ (arguments
+ `(#:node ,node-bootstrap
+ #:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (replace 'build
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((esbuild (string-append (assoc-ref inputs "esbuild")
+ "/bin/esbuild")))
+ (invoke esbuild
+ "--platform=node"
+ "--outfile=lib/builder.js"
+ "--bundle"
+ "src/builder.ts")))))))
+ (inputs
+ `(("node-binary-search" ,node-binary-search-bootstrap)
+ ("node-debug" ,node-debug-bootstrap)))
+ (native-inputs
+ `(("esbuild" ,esbuild)))
+ (home-page "https://github.com/indutny/llparse-builder#readme")
+ (properties '((hidden? . #t)))
+ (synopsis "Graph builder for consumption by llparse")
+ (description "This package builds graphs for consumption by llparse.")
+ (license license:expat)))
+
(define-public libnode
(package/inherit node
(name "libnode")
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 10/13] gnu: Add node-llparse-frontend-bootstrap.
2021-03-30 5:24 ` Timothy Sample
` (8 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 09/13] gnu: Add node-llparse-builder-bootstrap Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 11/13] gnu: Add node-llparse-bootstrap Timothy Sample
` (3 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/node.scm (node-llparse-frontend-bootstrap): New variable.
---
gnu/packages/node.scm | 56 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 570d4521ac..16c3decdd4 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -398,6 +398,62 @@ Node.js and web browsers.")
(description "This package builds graphs for consumption by llparse.")
(license license:expat)))
+(define-public node-llparse-frontend-bootstrap
+ (package
+ (name "node-llparse-frontend")
+ (version "3.0.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/indutny/llparse-frontend.git")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1rm9g4ifyip30svm5cgnf0gx7d45jgh4mpf2hkd092xhngmfvicc"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ ;; Fix imports for esbuild.
+ ;; https://github.com/evanw/esbuild/issues/477
+ (substitute* '("src/frontend.ts"
+ "src/code/field-value.ts"
+ "src/container/index.ts"
+ "src/container/wrap.ts"
+ "src/node/sequence.ts"
+ "src/node/single.ts"
+ "src/node/table-lookup.ts"
+ "src/trie/index.ts")
+ (("\\* as assert") "assert")
+ (("\\* as debugAPI") "debugAPI"))
+ #t))))
+ (build-system node-build-system)
+ (arguments
+ `(#:node ,node-bootstrap
+ #:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (replace 'build
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((esbuild (string-append (assoc-ref inputs "esbuild")
+ "/bin/esbuild")))
+ (invoke esbuild
+ "--platform=node"
+ "--outfile=lib/frontend.js"
+ "--bundle"
+ "src/frontend.ts")))))))
+ (inputs
+ `(("node-debug" ,node-debug-bootstrap)
+ ("node-llparse-builder" ,node-llparse-builder-bootstrap)))
+ (native-inputs
+ `(("esbuild" ,esbuild)))
+ (home-page "https://github.com/indutny/llparse-frontend#readme")
+ (properties '((hidden? . #t)))
+ (synopsis "Frontend for the llparse compiler")
+ (description "This package is a frontend for the llparse compiler.")
+ (license license:expat)))
+
(define-public libnode
(package/inherit node
(name "libnode")
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 11/13] gnu: Add node-llparse-bootstrap.
2021-03-30 5:24 ` Timothy Sample
` (9 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 10/13] gnu: Add node-llparse-frontend-bootstrap Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 5:27 ` [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap Timothy Sample
` (2 subsequent siblings)
13 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/node.scm (node-llparse-bootstrap): New variable.
---
gnu/packages/node.scm | 56 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 16c3decdd4..5336012e43 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -454,6 +454,62 @@ Node.js and web browsers.")
(description "This package is a frontend for the llparse compiler.")
(license license:expat)))
+(define-public node-llparse-bootstrap
+ (package
+ (name "node-llparse")
+ (version "7.1.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/indutny/llparse.git")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "10da273iy2if88hp79cwms6c8qpsl1fkgzll6gmqyx5yxv5mkyp6"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ ;; Fix imports for esbuild.
+ ;; https://github.com/evanw/esbuild/issues/477
+ (substitute* '("src/compiler/index.ts"
+ "src/implementation/c/node/base.ts"
+ "src/implementation/c/node/table-lookup.ts"
+ "src/implementation/c/compilation.ts"
+ "src/implementation/c/helpers/match-sequence.ts"
+ "src/implementation/c/code/mul-add.ts")
+ (("\\* as assert") "assert")
+ (("\\* as debugAPI") "debugAPI"))
+ #t))))
+ (build-system node-build-system)
+ (arguments
+ `(#:node ,node-bootstrap
+ #:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure)
+ (replace 'build
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((esbuild (string-append (assoc-ref inputs "esbuild")
+ "/bin/esbuild")))
+ (invoke esbuild
+ "--platform=node"
+ "--outfile=lib/api.js"
+ "--bundle"
+ "src/api.ts")))))))
+ (inputs
+ `(("node-debug" ,node-debug-bootstrap)
+ ("node-llparse-frontend" ,node-llparse-frontend-bootstrap)))
+ (native-inputs
+ `(("esbuild" ,esbuild)))
+ (home-page "https://github.com/nodejs/llparse#readme")
+ (properties '((hidden? . #t)))
+ (synopsis "Compile incremental parsers to C code")
+ (description "This package offers an API for compiling an incremental
+parser definition into a C output.")
+ (license license:expat)))
+
(define-public libnode
(package/inherit node
(name "libnode")
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap.
2021-03-30 5:24 ` Timothy Sample
` (10 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 11/13] gnu: Add node-llparse-bootstrap Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 6:59 ` Efraim Flashner
2021-03-30 5:27 ` [bug#47282] [PATCH v2 13/13] gnu: Add node-lts Timothy Sample
2021-04-02 16:18 ` bug#47282: [PATCH 00/13] node going forward Jelle Licht
13 siblings, 1 reply; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/node.scm (llhttp-bootstrap): New variable.
---
gnu/local.mk | 1 +
gnu/packages/node.scm | 70 ++++++++++++
.../llhttp-bootstrap-CVE-2020-8287.patch | 100 ++++++++++++++++++
3 files changed, 171 insertions(+)
create mode 100644 gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index 52a021c2a3..5959a563d1 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1366,6 +1366,7 @@ dist_patch_DATA = \
%D%/packages/patches/linux-pam-no-setfsuid.patch \
%D%/packages/patches/lirc-localstatedir.patch \
%D%/packages/patches/lirc-reproducible-build.patch \
+ %D%/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch \
%D%/packages/patches/llvm-3.5-fix-clang-build-with-gcc5.patch \
%D%/packages/patches/llvm-9-fix-bitcast-miscompilation.patch \
%D%/packages/patches/llvm-9-fix-lpad-miscompilation.patch \
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 5336012e43..45e5f8feca 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -510,6 +510,76 @@ Node.js and web browsers.")
parser definition into a C output.")
(license license:expat)))
+(define-public llhttp-bootstrap
+ (package
+ (name "llhttp")
+ (version "2.1.3")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nodejs/llhttp.git")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0pqj7kyyzr1zs4h9yzn5rdxnxspm3wqgsv00765dd42fszlmrmk8"))
+ (patches (search-patches "llhttp-bootstrap-CVE-2020-8287.patch"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ ;; Fix imports for esbuild.
+ ;; https://github.com/evanw/esbuild/issues/477
+ (substitute* "src/llhttp/http.ts"
+ (("\\* as assert") "assert"))
+ (substitute* "Makefile"
+ (("npx ts-node bin/generate.ts")
+ "node bin/generate.js"))
+ #t))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:tests? #f ; no tests
+ #:make-flags (list "CLANG=gcc"
+ (string-append "DESTDIR=" (assoc-ref %outputs "out"))
+ "PREFIX=")
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'configure
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((esbuild (string-append (assoc-ref inputs "esbuild")
+ "/bin/esbuild")))
+ (invoke esbuild
+ "--platform=node"
+ "--outfile=bin/generate.js"
+ "--bundle" "bin/generate.ts"))))
+ (add-before 'install 'create-install-directories
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (for-each (lambda (dir)
+ (mkdir-p (string-append out dir)))
+ (list "/lib" "/include" "/src"))
+ #t)))
+ (add-after 'install 'install-src
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (src-dir (string-append out "/src")))
+ (install-file "build/c/llhttp.c" src-dir)
+ (install-file "src/native/api.c" src-dir)
+ (install-file "src/native/http.c" src-dir)
+ #t))))))
+ (native-inputs
+ `(("esbuild" ,esbuild)
+ ("node" ,node-bootstrap)
+ ("node-semver" ,node-semver-bootstrap)
+ ("node-llparse-bootstrap" ,node-llparse-bootstrap)))
+ (home-page "https://github.com/nodejs/llhttp")
+ (properties '((hidden? . #t)))
+ (synopsis "Parser for HTTP messages")
+ (description "This is a rewrite of
+@url{https://github.com/nodejs/http-parser, http-parser} using
+@url{https://github.com/nodejs/llparse, llparse} to generate the C
+source files.")
+ (license license:expat)))
+
(define-public libnode
(package/inherit node
(name "libnode")
diff --git a/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch b/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
new file mode 100644
index 0000000000..215c920e53
--- /dev/null
+++ b/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
@@ -0,0 +1,100 @@
+This patch comes from upstream. It corresponds to a patch applied to
+the generated C source code for llhttp included in Node.js 14.16.0
+(see commit 641f786bb1a1f6eb1ff8750782ed939780f2b31a). That commit
+fixes CVE-2020-8287. With this patch, the output of our
+llhttp-bootstrap package matches the files included in Node.js 14.16.0
+exactly.
+
+commit e9b36ea64709c35ca66094d5cf3787f444029601
+Author: Fedor Indutny <fedor@indutny.com>
+Date: Sat Oct 10 19:56:01 2020 -0700
+
+ http: unset `F_CHUNKED` on new `Transfer-Encoding`
+
+ Duplicate `Transfer-Encoding` header should be a treated as a single,
+ but with original header values concatenated with a comma separator. In
+ the light of this, even if the past `Transfer-Encoding` ended with
+ `chunked`, we should be not let the `F_CHUNKED` to leak into the next
+ header, because mere presence of another header indicates that `chunked`
+ is not the last transfer-encoding token.
+
+diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts
+index f4f1a6e..0a0c365 100644
+--- a/src/llhttp/http.ts
++++ b/src/llhttp/http.ts
+@@ -460,11 +460,19 @@ export class HTTP {
+ .match([ ' ', '\t' ], n('header_value_discard_ws'))
+ .otherwise(checkContentLengthEmptiness);
+
++ // Multiple `Transfer-Encoding` headers should be treated as one, but with
++ // values separate by a comma.
++ //
++ // See: https://tools.ietf.org/html/rfc7230#section-3.2.2
++ const toTransferEncoding = this.unsetFlag(
++ FLAGS.CHUNKED,
++ 'header_value_te_chunked');
++
+ n('header_value_start')
+ .otherwise(this.load('header_state', {
+ [HEADER_STATE.UPGRADE]: this.setFlag(FLAGS.UPGRADE, fallback),
+ [HEADER_STATE.TRANSFER_ENCODING]: this.setFlag(
+- FLAGS.TRANSFER_ENCODING, 'header_value_te_chunked'),
++ FLAGS.TRANSFER_ENCODING, toTransferEncoding),
+ [HEADER_STATE.CONTENT_LENGTH]: n('header_value_content_length_once'),
+ [HEADER_STATE.CONNECTION]: n('header_value_connection'),
+ }, 'header_value'));
+@@ -847,6 +855,11 @@ export class HTTP {
+ return span.start(span.end(this.node(next)));
+ }
+
++ private unsetFlag(flag: FLAGS, next: string | Node): Node {
++ const p = this.llparse;
++ return p.invoke(p.code.and('flags', ~flag), this.node(next));
++ }
++
+ private setFlag(flag: FLAGS, next: string | Node): Node {
+ const p = this.llparse;
+ return p.invoke(p.code.or('flags', flag), this.node(next));
+diff --git a/test/request/transfer-encoding.md b/test/request/transfer-encoding.md
+index a7d1681..b0891d6 100644
+--- a/test/request/transfer-encoding.md
++++ b/test/request/transfer-encoding.md
+@@ -353,6 +353,38 @@ off=106 headers complete method=3 v=1/1 flags=200 content_length=0
+ off=106 error code=15 reason="Request has invalid `Transfer-Encoding`"
+ ```
+
++## POST with `chunked` and duplicate transfer-encoding
++
++<!-- meta={"type": "request", "noScan": true} -->
++```http
++POST /post_identity_body_world?q=search#hey HTTP/1.1
++Accept: */*
++Transfer-Encoding: chunked
++Transfer-Encoding: deflate
++
++World
++```
++
++```log
++off=0 message begin
++off=5 len=38 span[url]="/post_identity_body_world?q=search#hey"
++off=44 url complete
++off=54 len=6 span[header_field]="Accept"
++off=61 header_field complete
++off=62 len=3 span[header_value]="*/*"
++off=67 header_value complete
++off=67 len=17 span[header_field]="Transfer-Encoding"
++off=85 header_field complete
++off=86 len=7 span[header_value]="chunked"
++off=95 header_value complete
++off=95 len=17 span[header_field]="Transfer-Encoding"
++off=113 header_field complete
++off=114 len=7 span[header_value]="deflate"
++off=123 header_value complete
++off=125 headers complete method=3 v=1/1 flags=200 content_length=0
++off=125 error code=15 reason="Request has invalid `Transfer-Encoding`"
++```
++
+ ## POST with `chunked` before other transfer-coding (lenient)
+
+ TODO(indutny): should we allow it even in lenient mode? (Consider disabling
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap.
2021-03-30 5:27 ` [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap Timothy Sample
@ 2021-03-30 6:59 ` Efraim Flashner
2021-04-02 13:17 ` Jelle Licht
0 siblings, 1 reply; 37+ messages in thread
From: Efraim Flashner @ 2021-03-30 6:59 UTC (permalink / raw)
To: Timothy Sample; +Cc: Jelle Licht, 47282
[-- Attachment #1: Type: text/plain, Size: 9902 bytes --]
On Tue, Mar 30, 2021 at 01:27:42AM -0400, Timothy Sample wrote:
> From: Jelle Licht <jlicht@fsfe.org>
>
> * gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/node.scm (llhttp-bootstrap): New variable.
> ---
> gnu/local.mk | 1 +
> gnu/packages/node.scm | 70 ++++++++++++
> .../llhttp-bootstrap-CVE-2020-8287.patch | 100 ++++++++++++++++++
> 3 files changed, 171 insertions(+)
> create mode 100644 gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
>
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 52a021c2a3..5959a563d1 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -1366,6 +1366,7 @@ dist_patch_DATA = \
> %D%/packages/patches/linux-pam-no-setfsuid.patch \
> %D%/packages/patches/lirc-localstatedir.patch \
> %D%/packages/patches/lirc-reproducible-build.patch \
> + %D%/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch \
> %D%/packages/patches/llvm-3.5-fix-clang-build-with-gcc5.patch \
> %D%/packages/patches/llvm-9-fix-bitcast-miscompilation.patch \
> %D%/packages/patches/llvm-9-fix-lpad-miscompilation.patch \
> diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
> index 5336012e43..45e5f8feca 100644
> --- a/gnu/packages/node.scm
> +++ b/gnu/packages/node.scm
> @@ -510,6 +510,76 @@ Node.js and web browsers.")
> parser definition into a C output.")
> (license license:expat)))
>
> +(define-public llhttp-bootstrap
> + (package
> + (name "llhttp")
> + (version "2.1.3")
> + (source (origin
> + (method git-fetch)
> + (uri (git-reference
> + (url "https://github.com/nodejs/llhttp.git")
> + (commit (string-append "v" version))))
> + (file-name (git-file-name name version))
> + (sha256
> + (base32
> + "0pqj7kyyzr1zs4h9yzn5rdxnxspm3wqgsv00765dd42fszlmrmk8"))
> + (patches (search-patches "llhttp-bootstrap-CVE-2020-8287.patch"))
> + (modules '((guix build utils)))
> + (snippet
> + '(begin
> + ;; Fix imports for esbuild.
> + ;; https://github.com/evanw/esbuild/issues/477
> + (substitute* "src/llhttp/http.ts"
> + (("\\* as assert") "assert"))
> + (substitute* "Makefile"
> + (("npx ts-node bin/generate.ts")
> + "node bin/generate.js"))
> + #t))))
> + (build-system gnu-build-system)
> + (arguments
> + `(#:tests? #f ; no tests
> + #:make-flags (list "CLANG=gcc"
This should probably be cc-for-target
> + (string-append "DESTDIR=" (assoc-ref %outputs "out"))
> + "PREFIX=")
And normally DESTDIR is empty and PREFIX is %out. Does it need to be
switched here?
> + #:phases
> + (modify-phases %standard-phases
> + (replace 'configure
> + (lambda* (#:key inputs #:allow-other-keys)
> + (let ((esbuild (string-append (assoc-ref inputs "esbuild")
> + "/bin/esbuild")))
> + (invoke esbuild
> + "--platform=node"
> + "--outfile=bin/generate.js"
> + "--bundle" "bin/generate.ts"))))
> + (add-before 'install 'create-install-directories
> + (lambda* (#:key outputs #:allow-other-keys)
> + (let ((out (assoc-ref outputs "out")))
> + (for-each (lambda (dir)
> + (mkdir-p (string-append out dir)))
> + (list "/lib" "/include" "/src"))
> + #t)))
> + (add-after 'install 'install-src
> + (lambda* (#:key outputs #:allow-other-keys)
> + (let* ((out (assoc-ref outputs "out"))
> + (src-dir (string-append out "/src")))
> + (install-file "build/c/llhttp.c" src-dir)
> + (install-file "src/native/api.c" src-dir)
> + (install-file "src/native/http.c" src-dir)
> + #t))))))
> + (native-inputs
> + `(("esbuild" ,esbuild)
> + ("node" ,node-bootstrap)
> + ("node-semver" ,node-semver-bootstrap)
> + ("node-llparse-bootstrap" ,node-llparse-bootstrap)))
> + (home-page "https://github.com/nodejs/llhttp")
> + (properties '((hidden? . #t)))
> + (synopsis "Parser for HTTP messages")
> + (description "This is a rewrite of
> +@url{https://github.com/nodejs/http-parser, http-parser} using
> +@url{https://github.com/nodejs/llparse, llparse} to generate the C
> +source files.")
> + (license license:expat)))
> +
> (define-public libnode
> (package/inherit node
> (name "libnode")
> diff --git a/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch b/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
> new file mode 100644
> index 0000000000..215c920e53
> --- /dev/null
> +++ b/gnu/packages/patches/llhttp-bootstrap-CVE-2020-8287.patch
> @@ -0,0 +1,100 @@
> +This patch comes from upstream. It corresponds to a patch applied to
> +the generated C source code for llhttp included in Node.js 14.16.0
> +(see commit 641f786bb1a1f6eb1ff8750782ed939780f2b31a). That commit
> +fixes CVE-2020-8287. With this patch, the output of our
> +llhttp-bootstrap package matches the files included in Node.js 14.16.0
> +exactly.
> +
> +commit e9b36ea64709c35ca66094d5cf3787f444029601
> +Author: Fedor Indutny <fedor@indutny.com>
> +Date: Sat Oct 10 19:56:01 2020 -0700
> +
> + http: unset `F_CHUNKED` on new `Transfer-Encoding`
> +
> + Duplicate `Transfer-Encoding` header should be a treated as a single,
> + but with original header values concatenated with a comma separator. In
> + the light of this, even if the past `Transfer-Encoding` ended with
> + `chunked`, we should be not let the `F_CHUNKED` to leak into the next
> + header, because mere presence of another header indicates that `chunked`
> + is not the last transfer-encoding token.
> +
> +diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts
> +index f4f1a6e..0a0c365 100644
> +--- a/src/llhttp/http.ts
> ++++ b/src/llhttp/http.ts
> +@@ -460,11 +460,19 @@ export class HTTP {
> + .match([ ' ', '\t' ], n('header_value_discard_ws'))
> + .otherwise(checkContentLengthEmptiness);
> +
> ++ // Multiple `Transfer-Encoding` headers should be treated as one, but with
> ++ // values separate by a comma.
> ++ //
> ++ // See: https://tools.ietf.org/html/rfc7230#section-3.2.2
> ++ const toTransferEncoding = this.unsetFlag(
> ++ FLAGS.CHUNKED,
> ++ 'header_value_te_chunked');
> ++
> + n('header_value_start')
> + .otherwise(this.load('header_state', {
> + [HEADER_STATE.UPGRADE]: this.setFlag(FLAGS.UPGRADE, fallback),
> + [HEADER_STATE.TRANSFER_ENCODING]: this.setFlag(
> +- FLAGS.TRANSFER_ENCODING, 'header_value_te_chunked'),
> ++ FLAGS.TRANSFER_ENCODING, toTransferEncoding),
> + [HEADER_STATE.CONTENT_LENGTH]: n('header_value_content_length_once'),
> + [HEADER_STATE.CONNECTION]: n('header_value_connection'),
> + }, 'header_value'));
> +@@ -847,6 +855,11 @@ export class HTTP {
> + return span.start(span.end(this.node(next)));
> + }
> +
> ++ private unsetFlag(flag: FLAGS, next: string | Node): Node {
> ++ const p = this.llparse;
> ++ return p.invoke(p.code.and('flags', ~flag), this.node(next));
> ++ }
> ++
> + private setFlag(flag: FLAGS, next: string | Node): Node {
> + const p = this.llparse;
> + return p.invoke(p.code.or('flags', flag), this.node(next));
> +diff --git a/test/request/transfer-encoding.md b/test/request/transfer-encoding.md
> +index a7d1681..b0891d6 100644
> +--- a/test/request/transfer-encoding.md
> ++++ b/test/request/transfer-encoding.md
> +@@ -353,6 +353,38 @@ off=106 headers complete method=3 v=1/1 flags=200 content_length=0
> + off=106 error code=15 reason="Request has invalid `Transfer-Encoding`"
> + ```
> +
> ++## POST with `chunked` and duplicate transfer-encoding
> ++
> ++<!-- meta={"type": "request", "noScan": true} -->
> ++```http
> ++POST /post_identity_body_world?q=search#hey HTTP/1.1
> ++Accept: */*
> ++Transfer-Encoding: chunked
> ++Transfer-Encoding: deflate
> ++
> ++World
> ++```
> ++
> ++```log
> ++off=0 message begin
> ++off=5 len=38 span[url]="/post_identity_body_world?q=search#hey"
> ++off=44 url complete
> ++off=54 len=6 span[header_field]="Accept"
> ++off=61 header_field complete
> ++off=62 len=3 span[header_value]="*/*"
> ++off=67 header_value complete
> ++off=67 len=17 span[header_field]="Transfer-Encoding"
> ++off=85 header_field complete
> ++off=86 len=7 span[header_value]="chunked"
> ++off=95 header_value complete
> ++off=95 len=17 span[header_field]="Transfer-Encoding"
> ++off=113 header_field complete
> ++off=114 len=7 span[header_value]="deflate"
> ++off=123 header_value complete
> ++off=125 headers complete method=3 v=1/1 flags=200 content_length=0
> ++off=125 error code=15 reason="Request has invalid `Transfer-Encoding`"
> ++```
> ++
> + ## POST with `chunked` before other transfer-coding (lenient)
> +
> + TODO(indutny): should we allow it even in lenient mode? (Consider disabling
> --
> 2.31.0
>
>
>
>
--
Efraim Flashner <efraim@flashner.co.il> אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap.
2021-03-30 6:59 ` Efraim Flashner
@ 2021-04-02 13:17 ` Jelle Licht
0 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-04-02 13:17 UTC (permalink / raw)
To: Efraim Flashner, Timothy Sample; +Cc: 47282
Efraim Flashner <efraim@flashner.co.il> writes:
> On Tue, Mar 30, 2021 at 01:27:42AM -0400, Timothy Sample wrote:
>> + (build-system gnu-build-system)
>> + (arguments
>> + `(#:tests? #f ; no tests
>> + #:make-flags (list "CLANG=gcc"
>
> This should probably be cc-for-target
Fixed in my local version, thanks.
>> + (string-append "DESTDIR=" (assoc-ref %outputs "out"))
>> + "PREFIX=")
>
> And normally DESTDIR is empty and PREFIX is %out. Does it need to be
> switched here?
It does.
- Jelle
^ permalink raw reply [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 13/13] gnu: Add node-lts.
2021-03-30 5:24 ` Timothy Sample
` (11 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 12/13] gnu: Add llhttp-bootstrap Timothy Sample
@ 2021-03-30 5:27 ` Timothy Sample
2021-03-30 7:04 ` Efraim Flashner
2021-04-02 16:18 ` bug#47282: [PATCH 00/13] node going forward Jelle Licht
13 siblings, 1 reply; 37+ messages in thread
From: Timothy Sample @ 2021-03-30 5:27 UTC (permalink / raw)
To: 47282; +Cc: Jelle Licht
From: Jelle Licht <jlicht@fsfe.org>
* gnu/packages/node.scm (node-lts): New variable.
* guix/build-system/node.scm (default-node): Use it.
---
gnu/packages/node.scm | 135 +++++++++++++++++++++++++++++++++++++
guix/build-system/node.scm | 2 +-
2 files changed, 136 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 45e5f8feca..249241f110 100644
--- a/gnu/packages/node.scm
+++ b/gnu/packages/node.scm
@@ -580,6 +580,141 @@ parser definition into a C output.")
source files.")
(license license:expat)))
+(define-public node-lts
+ (package
+ (inherit node)
+ (version "14.16.0")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "https://nodejs.org/dist/v" version
+ "/node-v" version ".tar.xz"))
+ (sha256
+ (base32
+ "19nz2mhmn6ikahxqyna1dn25pb5v3z9vsz9zb2flb6zp2yk4hxjf"))
+ (modules '((guix build utils)))
+ (snippet
+ `(begin
+ ;; Remove bundled software, where possible
+ (for-each delete-file-recursively
+ '("deps/cares"
+ "deps/icu-small"
+ "deps/nghttp2"
+ "deps/openssl"
+ "deps/zlib"))
+ (substitute* "Makefile"
+ ;; Remove references to bundled software.
+ (("deps/uv/uv.gyp") "")
+ (("deps/zlib/zlib.gyp") ""))
+ #t))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments node)
+ ((#:configure-flags configure-flags)
+ ''("--shared-cares"
+ "--shared-libuv"
+ "--shared-nghttp2"
+ "--shared-openssl"
+ "--shared-zlib"
+ "--shared-brotli"
+ "--with-intl=system-icu"))
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (replace 'configure
+ ;; Node's configure script is actually a python script, so we can't
+ ;; run it with bash.
+ (lambda* (#:key outputs (configure-flags '()) inputs
+ #:allow-other-keys)
+ (let* ((prefix (assoc-ref outputs "out"))
+ (flags (cons (string-append "--prefix=" prefix)
+ 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" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
+ (apply invoke
+ (string-append (assoc-ref inputs "python")
+ "/bin/python3")
+ "configure" flags))))
+ (replace 'patch-files
+ (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 "'" (which "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 "'" (which "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
+ '("test/parallel/test-cluster-master-error.js"
+ "test/parallel/test-cluster-master-kill.js"))
+
+ ;; These require a DNS resolver.
+ (for-each delete-file
+ '("test/parallel/test-dns.js"
+ "test/parallel/test-dns-lookupService-promises.js"))
+
+ ;; FIXME: This test fails randomly:
+ ;; https://github.com/nodejs/node/issues/31213
+ (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
+
+ ;; FIXME: These tests fail on armhf-linux:
+ ;; https://github.com/nodejs/node/issues/31970
+ ,@(if (string-prefix? "arm" (%current-system))
+ '((for-each delete-file
+ '("test/parallel/test-zlib.js"
+ "test/parallel/test-zlib-brotli.js"
+ "test/parallel/test-zlib-brotli-flush.js"
+ "test/parallel/test-zlib-brotli-from-brotli.js"
+ "test/parallel/test-zlib-brotli-from-string.js"
+ "test/parallel/test-zlib-convenience-methods.js"
+ "test/parallel/test-zlib-random-byte-pipes.js"
+ "test/parallel/test-zlib-write-after-flush.js")))
+ '())
+
+ ;; These tests have an expiry date: they depend on the validity of
+ ;; TLS certificates that are bundled with the source. We want this
+ ;; package to be reproducible forever, so remove those.
+ ;; TODO: Regenerate certs instead.
+ (for-each delete-file
+ '("test/parallel/test-tls-passphrase.js"
+ "test/parallel/test-tls-server-verify.js"))
+
+ ;; Replace pre-generated llhttp sources
+ (let ((llhttp (assoc-ref inputs "llhttp")))
+ (copy-file (string-append llhttp "/src/llhttp.c")
+ "deps/llhttp/src/llhttp.c")
+ (copy-file (string-append llhttp "/src/api.c")
+ "deps/llhttp/src/api.c")
+ (copy-file (string-append llhttp "/src/http.c")
+ "deps/llhttp/src/http.c")
+ (copy-file (string-append llhttp "/include/llhttp.h")
+ "deps/llhttp/include/llhttp.h"))
+ #t))))))
+ (inputs
+ `(("c-ares" ,c-ares)
+ ("icu4c" ,icu4c-67)
+ ("libuv" ,libuv-for-node)
+ ("llhttp" ,llhttp-bootstrap)
+ ("google-brotli" ,google-brotli)
+ ("nghttp2" ,nghttp2 "lib")
+ ("openssl" ,openssl)
+ ("zlib" ,zlib)))
+ (native-inputs
+ (alist-replace "python" (list python-3)
+ (package-native-inputs node)))))
+
(define-public libnode
(package/inherit node
(name "libnode")
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 4991ed53a5..98f63f87ef 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -39,7 +39,7 @@
"Return the default Node package."
;; Lazily resolve the binding to avoid a circular dependency.
(let ((node (resolve-interface '(gnu packages node))))
- (module-ref node 'node)))
+ (module-ref node 'node-lts)))
(define* (lower name
#:key source inputs native-inputs outputs system target
--
2.31.0
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 13/13] gnu: Add node-lts.
2021-03-30 5:27 ` [bug#47282] [PATCH v2 13/13] gnu: Add node-lts Timothy Sample
@ 2021-03-30 7:04 ` Efraim Flashner
2021-04-02 13:20 ` Jelle Licht
0 siblings, 1 reply; 37+ messages in thread
From: Efraim Flashner @ 2021-03-30 7:04 UTC (permalink / raw)
To: Timothy Sample; +Cc: Jelle Licht, 47282
[-- Attachment #1: Type: text/plain, Size: 8701 bytes --]
On Tue, Mar 30, 2021 at 01:27:43AM -0400, Timothy Sample wrote:
> From: Jelle Licht <jlicht@fsfe.org>
>
> * gnu/packages/node.scm (node-lts): New variable.
> * guix/build-system/node.scm (default-node): Use it.
> ---
> gnu/packages/node.scm | 135 +++++++++++++++++++++++++++++++++++++
> guix/build-system/node.scm | 2 +-
> 2 files changed, 136 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
> index 45e5f8feca..249241f110 100644
> --- a/gnu/packages/node.scm
> +++ b/gnu/packages/node.scm
> @@ -580,6 +580,141 @@ parser definition into a C output.")
> source files.")
> (license license:expat)))
>
> +(define-public node-lts
> + (package
> + (inherit node)
> + (version "14.16.0")
> + (source (origin
> + (method url-fetch)
> + (uri (string-append "https://nodejs.org/dist/v" version
> + "/node-v" version ".tar.xz"))
> + (sha256
> + (base32
> + "19nz2mhmn6ikahxqyna1dn25pb5v3z9vsz9zb2flb6zp2yk4hxjf"))
> + (modules '((guix build utils)))
> + (snippet
> + `(begin
> + ;; Remove bundled software, where possible
> + (for-each delete-file-recursively
> + '("deps/cares"
> + "deps/icu-small"
> + "deps/nghttp2"
> + "deps/openssl"
> + "deps/zlib"))
> + (substitute* "Makefile"
> + ;; Remove references to bundled software.
> + (("deps/uv/uv.gyp") "")
> + (("deps/zlib/zlib.gyp") ""))
> + #t))))
> + (arguments
> + (substitute-keyword-arguments (package-arguments node)
> + ((#:configure-flags configure-flags)
> + ''("--shared-cares"
> + "--shared-libuv"
> + "--shared-nghttp2"
> + "--shared-openssl"
> + "--shared-zlib"
> + "--shared-brotli"
> + "--with-intl=system-icu"))
> + ((#:phases phases)
> + `(modify-phases ,phases
> + (replace 'configure
> + ;; Node's configure script is actually a python script, so we can't
> + ;; run it with bash.
> + (lambda* (#:key outputs (configure-flags '()) inputs
> + #:allow-other-keys)
> + (let* ((prefix (assoc-ref outputs "out"))
> + (flags (cons (string-append "--prefix=" prefix)
> + 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" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
again cc-for-target
> + (apply invoke
> + (string-append (assoc-ref inputs "python")
> + "/bin/python3")
> + "configure" flags))))
> + (replace 'patch-files
> + (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 "'" (which "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 "'" (which "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
> + '("test/parallel/test-cluster-master-error.js"
> + "test/parallel/test-cluster-master-kill.js"))
> +
> + ;; These require a DNS resolver.
> + (for-each delete-file
> + '("test/parallel/test-dns.js"
> + "test/parallel/test-dns-lookupService-promises.js"))
> +
> + ;; FIXME: This test fails randomly:
> + ;; https://github.com/nodejs/node/issues/31213
> + (delete-file "test/parallel/test-net-listen-after-destroying-stdin.js")
> +
> + ;; FIXME: These tests fail on armhf-linux:
> + ;; https://github.com/nodejs/node/issues/31970
> + ,@(if (string-prefix? "arm" (%current-system))
This could probably be changed to ,@(when (target-arm32?)
> + '((for-each delete-file
> + '("test/parallel/test-zlib.js"
> + "test/parallel/test-zlib-brotli.js"
> + "test/parallel/test-zlib-brotli-flush.js"
> + "test/parallel/test-zlib-brotli-from-brotli.js"
> + "test/parallel/test-zlib-brotli-from-string.js"
> + "test/parallel/test-zlib-convenience-methods.js"
> + "test/parallel/test-zlib-random-byte-pipes.js"
> + "test/parallel/test-zlib-write-after-flush.js")))
> + '())
> +
> + ;; These tests have an expiry date: they depend on the validity of
> + ;; TLS certificates that are bundled with the source. We want this
> + ;; package to be reproducible forever, so remove those.
> + ;; TODO: Regenerate certs instead.
> + (for-each delete-file
> + '("test/parallel/test-tls-passphrase.js"
> + "test/parallel/test-tls-server-verify.js"))
> +
> + ;; Replace pre-generated llhttp sources
> + (let ((llhttp (assoc-ref inputs "llhttp")))
> + (copy-file (string-append llhttp "/src/llhttp.c")
> + "deps/llhttp/src/llhttp.c")
> + (copy-file (string-append llhttp "/src/api.c")
> + "deps/llhttp/src/api.c")
> + (copy-file (string-append llhttp "/src/http.c")
> + "deps/llhttp/src/http.c")
> + (copy-file (string-append llhttp "/include/llhttp.h")
> + "deps/llhttp/include/llhttp.h"))
> + #t))))))
> + (inputs
> + `(("c-ares" ,c-ares)
> + ("icu4c" ,icu4c-67)
> + ("libuv" ,libuv-for-node)
> + ("llhttp" ,llhttp-bootstrap)
> + ("google-brotli" ,google-brotli)
> + ("nghttp2" ,nghttp2 "lib")
> + ("openssl" ,openssl)
> + ("zlib" ,zlib)))
> + (native-inputs
> + (alist-replace "python" (list python-3)
> + (package-native-inputs node)))))
> +
> (define-public libnode
> (package/inherit node
> (name "libnode")
> diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
> index 4991ed53a5..98f63f87ef 100644
> --- a/guix/build-system/node.scm
> +++ b/guix/build-system/node.scm
> @@ -39,7 +39,7 @@
> "Return the default Node package."
> ;; Lazily resolve the binding to avoid a circular dependency.
> (let ((node (resolve-interface '(gnu packages node))))
> - (module-ref node 'node)))
> + (module-ref node 'node-lts)))
>
> (define* (lower name
> #:key source inputs native-inputs outputs system target
> --
> 2.31.0
>
>
>
>
--
Efraim Flashner <efraim@flashner.co.il> אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH v2 13/13] gnu: Add node-lts.
2021-03-30 7:04 ` Efraim Flashner
@ 2021-04-02 13:20 ` Jelle Licht
0 siblings, 0 replies; 37+ messages in thread
From: Jelle Licht @ 2021-04-02 13:20 UTC (permalink / raw)
To: Efraim Flashner, Timothy Sample; +Cc: 47282
Efraim Flashner <efraim@flashner.co.il> writes:
> On Tue, Mar 30, 2021 at 01:27:43AM -0400, Timothy Sample wrote:
>> + (arguments
>> + (substitute-keyword-arguments (package-arguments node)
>> + ((#:configure-flags configure-flags)
>> + ''("--shared-cares"
>> + "--shared-libuv"
>> + "--shared-nghttp2"
>> + "--shared-openssl"
>> + "--shared-zlib"
>> + "--shared-brotli"
>> + "--with-intl=system-icu"))
>> + ((#:phases phases)
>> + `(modify-phases ,phases
>> + (replace 'configure
>> + ;; Node's configure script is actually a python script, so we can't
>> + ;; run it with bash.
>> + (lambda* (#:key outputs (configure-flags '()) inputs
>> + #:allow-other-keys)
>> + (let* ((prefix (assoc-ref outputs "out"))
>> + (flags (cons (string-append "--prefix=" prefix)
>> + 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" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
>
> again cc-for-target
Ack.
>> [snip]
>> + ;; FIXME: These tests fail on armhf-linux:
>> + ;; https://github.com/nodejs/node/issues/31970
>> + ,@(if (string-prefix? "arm" (%current-system))
>
> This could probably be changed to ,@(when (target-arm32?)
I changed it to ,@(if (target-arm32?), as otherwise the #f-branch
spliced #unspecified into the list.
^ permalink raw reply [flat|nested] 37+ messages in thread
* bug#47282: [PATCH 00/13] node going forward
2021-03-30 5:24 ` Timothy Sample
` (12 preceding siblings ...)
2021-03-30 5:27 ` [bug#47282] [PATCH v2 13/13] gnu: Add node-lts Timothy Sample
@ 2021-04-02 16:18 ` Jelle Licht
2021-04-03 1:19 ` [bug#47282] " Timothy Sample
13 siblings, 1 reply; 37+ messages in thread
From: Jelle Licht @ 2021-04-02 16:18 UTC (permalink / raw)
To: Timothy Sample; +Cc: 47282-done
Timothy,
Timothy Sample <samplet@ngyro.com> writes:
> Hi Jelle,
>
> Jelle Licht <jlicht@fsfe.org> writes:
>
>> So, some people seem to be interested in this one; please review and test.
>
> Now that I’ve finally taken the time to dig into what you’ve done here –
> I must say it’s very impressive!
If you bang your head against a wall often enough, it will crack
eventually. Head or wall, either way works in this metaphor ;-).
> I’ve taken the presumptuous step of re-rolling the series. The reason
> is that all the “(delete 'build)” bits were bothering me. I decided to
> have the build system check the “package.json” file for a build script
> before trying to run it. Since that change required changing all the
> other patches, I thought it would be easier to just post the updated
> patches. Also, I’m hoping to spare you some trouble (since you’ve
> already gone to a lot!).
Makes sense, thanks! Please be presumptuous as often as you'd like.
>
> • Change the “Fix incorrect import semantics” comments to “Fix
> imports for esbuild”. To me, if TypeScript’s tsc likes the
> imports, they are correct TypeScript (despite the esbuild bug
> report).
"Something a native speaker of English can make sense of" != "Proper
English", and in that same vein I don't think a commmon mistake with
workaround in place is not a mistake.
I really don't care about what ends up in the codebase though, as long
as it is clear why we do what we do, which works out just fine with your
comment.
> The final result is still a little messy, but I don’t think we should
> hold this back any longer. It’s a significant step forward, and it puts
> us in better shape to improve things incrementally.
>
> WDYT? Let me know if I made anything worse! :) If the altered patches
> look good to you, I suggest you go ahead and push them.
I still adressed some of Efraim's remarks, and pushed it to master just
now.
There are quite some ways to go from here:
* Get the 'binary' importer upstreamable (I will continue with this)
* Properly support cross-compilation of Node and Node-packages
I had a super quick look at this, but it seems that in building node,
you build intermediate tools that run on the host. Perhaps some our
x-compilation gurus can weigh in.
* Make a Rome-based build system, once Rome does more than linting, to
help untangle the knot that is JavaScript-packaging
But for today (and the upcoming release), modern Node on guix \o/
Thanks folks!
- Jelle
^ permalink raw reply [flat|nested] 37+ messages in thread
* [bug#47282] [PATCH 00/13] node going forward
2021-04-02 16:18 ` bug#47282: [PATCH 00/13] node going forward Jelle Licht
@ 2021-04-03 1:19 ` Timothy Sample
0 siblings, 0 replies; 37+ messages in thread
From: Timothy Sample @ 2021-04-03 1:19 UTC (permalink / raw)
To: Jelle Licht; +Cc: 47282-done
Hi,
Jelle Licht <jlicht@fsfe.org> writes:
> Timothy Sample <samplet@ngyro.com> writes:
>
>> • Change the “Fix incorrect import semantics” comments to “Fix
>> imports for esbuild”. To me, if TypeScript’s tsc likes the
>> imports, they are correct TypeScript (despite the esbuild bug
>> report).
>
> "Something a native speaker of English can make sense of" != "Proper
> English", and in that same vein I don't think a commmon mistake with
> workaround in place is not a mistake.
>
> I really don't care about what ends up in the codebase though, as long
> as it is clear why we do what we do, which works out just fine with your
> comment.
Heh. You’re right: it’s not a big deal. Thanks for humouring me. :)
>> The final result is still a little messy, but I don’t think we should
>> hold this back any longer. It’s a significant step forward, and it puts
>> us in better shape to improve things incrementally.
>>
>> WDYT? Let me know if I made anything worse! :) If the altered patches
>> look good to you, I suggest you go ahead and push them.
>
> I still adressed some of Efraim's remarks, and pushed it to master just
> now.
Nice!!
> There are quite some ways to go from here:
>
> * Get the 'binary' importer upstreamable (I will continue with this)
>
> * Properly support cross-compilation of Node and Node-packages
>
> I had a super quick look at this, but it seems that in building node,
> you build intermediate tools that run on the host. Perhaps some our
> x-compilation gurus can weigh in.
>
> * Make a Rome-based build system, once Rome does more than linting, to
> help untangle the knot that is JavaScript-packaging
Sounds pretty exciting!
-- Tim
^ permalink raw reply [flat|nested] 37+ messages in thread