From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id oKVcK1fxu2F0NgEAgWs5BA (envelope-from ) for ; Fri, 17 Dec 2021 03:09:27 +0100 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id EGgaJ1fxu2G8WQAA1q6Kng (envelope-from ) for ; Fri, 17 Dec 2021 02:09:27 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id 4A8FE35772 for ; Fri, 17 Dec 2021 03:09:27 +0100 (CET) Received: from localhost ([::1]:59880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1my2gY-0001M8-FU for larch@yhetil.org; Thu, 16 Dec 2021 21:09:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1my2dN-0004Q5-MJ for guix-patches@gnu.org; Thu, 16 Dec 2021 21:06:09 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:54063) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1my2dN-00081h-As for guix-patches@gnu.org; Thu, 16 Dec 2021 21:06:09 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1my2dN-0005DS-5W for guix-patches@gnu.org; Thu, 16 Dec 2021 21:06:09 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v5 29/45] gnu: Add node-sqlite3. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 17 Dec 2021 02:06:09 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51838 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51838@debbugs.gnu.org Cc: Timothy Sample , Pierre Langlois , Jelle Licht , Philip McGrath , Liliana Marie Prikler Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.163970676219916 (code B ref 51838); Fri, 17 Dec 2021 02:06:09 +0000 Received: (at 51838) by debbugs.gnu.org; 17 Dec 2021 02:06:02 +0000 Received: from localhost ([127.0.0.1]:37356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1my2dF-0005Ax-9K for submit@debbugs.gnu.org; Thu, 16 Dec 2021 21:06:01 -0500 Received: from mail-qk1-f175.google.com ([209.85.222.175]:42785) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1my2d5-00059n-55 for 51838@debbugs.gnu.org; Thu, 16 Dec 2021 21:05:51 -0500 Received: by mail-qk1-f175.google.com with SMTP id g28so767163qkk.9 for <51838@debbugs.gnu.org>; Thu, 16 Dec 2021 18:05:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=44FB1zj54SjqaiOtmegrvdn0Y4TBIILYWcHMvoWsBoA=; b=i/c2/gAYlkXXlbZoxfSx2YNZzfzr39SDS7IsO77m54xZClRP/R649bzLrAcrfVbspV dX0t+cWN5cARI/Lo/+7X6D7PS1zY4oAI1XopB46hZuEerlGtDgIP4yvUZxa2RA0x25eg U+gBcJopvVv4XwWMgt7ABct7qBzermBRB1+ofjGNesLTI2o1Iet+PIhOejNNywHsNn9+ pne5wjpFL60G6Z1Yp6j3Ckn+OOl7+s0RAooiQJgzVAITJhXt9aPaHjvz2fgpAdtFKnJX MH1XoAYwwvdr4UewCmpnEH+CBgrm1cqC7HrwEnY710FU6H7ph8vlTxxtjS/pj52eww1v OcgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=44FB1zj54SjqaiOtmegrvdn0Y4TBIILYWcHMvoWsBoA=; b=kmVC7e9uUszNJwWXvH7jLoTm+MJfPXj/fqbBAtqvdhVwSL6eORJfGx4TFnFxsqpu9z OzO6S+L567AwzRcW5gnXFmmh1jV2WukQCdPqFaB/trsMM2iGF/FphZZUKJtC/Wqc8srk 9UfbSIzIyC8zoVObPsOR0o34DtGm3K/NSV/Q4F2qaIVV9vdZFG3KOhmA8xd0Tnfcc5W9 N6YCWAuUdnOaq1hvZ4NzpENUF4m9KSkwvP/y/mJj4yBZQciZrx+p4QoIaZC4OYp3X4h9 RbhSkFnHXSvgKFOsvv+NVu1VMoTi3x0lRTU7EthD4PRc6LYkuH1jqz11RDOw5zRJnspB CtPQ== X-Gm-Message-State: AOAM530iIZzevqRdmoALCXTMgkEfOw2njbKUyrjRppQJ64gWRRSbcJHc oamj/ckstmXATsaCIUdOB1ZLI4L6OktzrG/QnE4= X-Google-Smtp-Source: ABdhPJx0ynEnqEI8DX9byp69rT1yhqb359TT6y9hiAexyDa/5aFOckxjLzBZ0U+iO6pLpOGnx+3AHw== X-Received: by 2002:a05:620a:94c:: with SMTP id w12mr573658qkw.190.1639706745403; Thu, 16 Dec 2021 18:05:45 -0800 (PST) Received: from localhost (c-73-125-89-242.hsd1.fl.comcast.net. [73.125.89.242]) by smtp.gmail.com with ESMTPSA id p10sm6017909qtw.97.2021.12.16.18.05.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Dec 2021 18:05:45 -0800 (PST) From: Philip McGrath Date: Thu, 16 Dec 2021 21:03:09 -0500 Message-Id: <20211217020325.520821-30-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211217020325.520821-1-philip@philipmcgrath.com> References: <20211213060107.129223-1-philip@philipmcgrath.com> <20211217020325.520821-1-philip@philipmcgrath.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639706967; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=44FB1zj54SjqaiOtmegrvdn0Y4TBIILYWcHMvoWsBoA=; b=ZALaFMX3TTN7s+70BQ/eVe3ddiiHXw+2T7tzDVWyYAmSOdA6ea8ZL0+FHZHmylcAqqvcWX KsnkiesWGcYCa8ZtamXykTrHZ4pfJJxLHdN1rXx2C8YPuXcSHiNllyCWd5siyFkMc6UKCu zpP2DtuHlSam5oFS2BgiE3XxJybnQre0LyW+7RwW+/tQ2+wvTEY8x1XQjFshxj2tFoQowN upzsx9GUWYFH7IhB7/iVnDq34L852rkjDSA6ZRnwWvWX+mGAEQIKC0JnSligzKzX0MWOaz xRCFaz28rk6M2inyl3UnvZGZqLeD4krwekrITuadnJSD8fhQ76Y1mY+LDc0/Xg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639706967; a=rsa-sha256; cv=none; b=SgAo7ofnKtFnng8pEWOnp46/7EFcahscbXkvWglG7/29uff3CKfCV07x+1ZHbyw9Bi12xO wuh35rgDMcoh1tEKT+TA1bsHI/QtikapbWoW5Qhabl+t485IdNAdbZa6rL9MD4oI16AeqC hI71EI3WAggaxdpchZ6y3HZ2YreeGFSTdrXvj+B1lwdD6F4MgzV/KVaWl6BtJsz5bX9gFI ykN1lrMxOyWaNm2p5Khlytd5HULPfcRnLxw7EAfXv3SsLHakrpw9/Lb5h91je1pfBMfuoY JyITuls5hNGAmu/TTPW99vz7SD/NwLZFCRIFA93kkhEEal1RXBzlAzdE0Pa7jQ== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b="i/c2/gAY"; dmarc=none; spf=pass (aspmx2.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -0.49 Authentication-Results: aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b="i/c2/gAY"; dmarc=none; spf=pass (aspmx2.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 4A8FE35772 X-Spam-Score: -0.49 X-Migadu-Scanner: scn0.migadu.com X-TUID: HCwCd6hWUrS7 * gnu/packages/node-xyz.scm (node-sqlite3): New variable. --- gnu/packages/node-xyz.scm | 130 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm index beebac7a40..f5297c869b 100644 --- a/gnu/packages/node-xyz.scm +++ b/gnu/packages/node-xyz.scm @@ -650,3 +650,133 @@ (define-public node-addon-api @code{libuv} (included in a project via @code{#include }) are not ABI-stable across Node.js major versions.") (license license:expat))) + +(define-public node-sqlite3 + (package + (name "node-sqlite3") + (version "5.0.2") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/mapbox/node-sqlite3") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0sbbzzli282nxyfha10zx0k5m8hdp0sf3ipl59khjb7wm449j86h")) + (snippet + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + ;; unbundle sqlite + (for-each delete-file-recursively + (find-files "deps" + (lambda (pth stat) + (gzip-file? pth))))))))) + (inputs + (list node-addon-api python sqlite)) + (build-system node-build-system) + (arguments + `(#:tests? + #f ; FIXME: tests depend on node-mocha + #:modules + ((guix build node-build-system) + (guix build json) + (srfi srfi-1) + (ice-9 match) + (guix build utils)) + #:absent-dependencies + `(;; Normally, this is "built" using @mapbox/node-pre-gyp, + ;; which publishes or downloads pre-built binaries + ;; or falls back to building from source. + ;; Here, we patch out all of that and just build directly. + ;; It would be better to patch a version of @mapbox/node-pre-gyp + ;; that always builds from source, as Debian does, + ;; but there are a number of dependencies that need + ;; to be packaged or removed. + "@mapbox/node-pre-gyp" + "node-pre-gyp" ;; deprecated name still used in some places + "aws-sdk" + "@mapbox/cloudfriend" + ;; Confusingly, this is only a dependency because of + ;; @mapbox/node-pre-gyp: with that removed, + ;; npm will use its own copy: + "node-gyp" + ;; These we'd like, we just don't have them yet: + "eslint" + "mocha") + #:phases + (modify-phases %standard-phases + (add-before 'configure 'npm-config-sqlite + ;; We need this step even if we do replace @mapbox/node-pre-gyp + ;; because the package expects to build its bundled sqlite + (lambda* (#:key inputs #:allow-other-keys) + (setenv "npm_config_sqlite" (assoc-ref inputs "sqlite")))) + (add-after 'install 'patch-binding-path + ;; We replace a file that dynamic searches for the addon using + ;; node-pre-gyp (which we don't have) with a version that + ;; simply uses the path to the addon we built directly. + ;; The exact path is supposed to depend on things like the + ;; architecture and napi_build_version, so, to avoid having + ;; hard-code the details accurately, we do this after the addon + ;; has been built so we can just find where it ended up. + (lambda* (#:key outputs #:allow-other-keys) + (with-directory-excursion + (string-append (assoc-ref outputs "out") + "/lib/node_modules/sqlite3/lib") + (match (find-files "binding" "\\.node$") + ((rel-path) + (with-atomic-file-replacement "sqlite3-binding.js" + (lambda (in out) + (format out "var binding = require('./~a');\n" rel-path) + (display "module.exports = exports = binding;\n" out)))))))) + (add-after 'patch-dependencies 'avoid-node-pre-gyp + (lambda args + ;; We need to patch .npmignore before the 'repack phase + ;; so that the built addon is installed with in the package. + ;; (Upstream assumes node-pre-gyp will download a pre-built + ;; version when this package is installed.) + (substitute* ".npmignore" + (("lib/binding") + "#lib/binding # <- patched for Guix")) + ;; We need to remove the install script from "package.json", + ;; as it would try to use node-pre-gyp and would block the + ;; automatic building performed by `npm install`. + (with-atomic-file-replacement "package.json" + (lambda (in out) + (let* ((js (read-json in)) + (alist (match js + (('@ . alist) alist))) + (scripts-alist (match (assoc-ref alist "scripts") + (('@ . alist) alist))) + (scripts-alist + ;; install script would use node-pre-gyp + (assoc-remove! scripts-alist "install")) + (alist + (assoc-set! alist "scripts" (cons '@ scripts-alist))) + (binary-alist (match (assoc-ref alist "binary") + (('@ . alist) alist))) + (js (cons '@ alist))) + ;; When it builds from source, node-pre-gyp supplies + ;; module_name and module_path based on the entries under + ;; "binary" from "package.json", so this package's + ;; "binding.gyp" doesn't define them. Thus, we also need + ;; to supply them. The GYP_DEFINES environment variable + ;; turns out to be the easiest way to make sure they are + ;; propagated from npm to node-gyp to gyp. + (setenv "GYP_DEFINES" + (string-append + "module_name=" + (assoc-ref binary-alist "module_name") + " " + "module_path=" + (assoc-ref binary-alist "module_path"))) + (write-json js + out))))))))) + (home-page "https://github.com/mapbox/node-sqlite3") + (synopsis "Asynchronous, non-blocking SQLite3 bindings for Node.js") + (description + "The Node.js add-on @code{node-sqlite3} provides a set of a asynchronous, +non-blocking bindings for SQLite3, written in modern C++ and tested for memory +leaks.") + (license license:bsd-3))) -- 2.32.0