aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/node.scm
diff options
context:
space:
mode:
authorJelle Licht <jlicht@fsfe.org>2021-03-30 01:27:42 -0400
committerJelle Licht <jlicht@fsfe.org>2021-04-02 18:04:24 +0200
commit31c4d89073bdbe2b807ccf7b172df6db200f8d32 (patch)
tree13ce3e6568b9b5ac5da7980cf566dc65e0191878 /gnu/packages/node.scm
parent91b78f371e13fb0116055d5987f65641467044ad (diff)
downloadguix-31c4d89073bdbe2b807ccf7b172df6db200f8d32.tar
guix-31c4d89073bdbe2b807ccf7b172df6db200f8d32.tar.gz
gnu: Add llhttp-bootstrap.
* 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.
Diffstat (limited to 'gnu/packages/node.scm')
-rw-r--r--gnu/packages/node.scm70
1 files changed, 70 insertions, 0 deletions
diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
index 5336012e43..26025c5d7c 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 (string-append "CLANG=" ,(cc-for-target))
+ (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")