From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id aB8IEdTitmEeVgEAgWs5BA (envelope-from ) for ; Mon, 13 Dec 2021 07:06:12 +0100 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id YCnnDNTitmG0YwAAB5/wlQ (envelope-from ) for ; Mon, 13 Dec 2021 06:06:12 +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 EAD141F88B for ; Mon, 13 Dec 2021 07:06:11 +0100 (CET) Received: from localhost ([::1]:45130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mweTS-0004yX-En for larch@yhetil.org; Mon, 13 Dec 2021 01:06:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mweSR-0003el-DA for guix-patches@gnu.org; Mon, 13 Dec 2021 01:05:08 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:42273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mweSP-0007ZB-I5 for guix-patches@gnu.org; Mon, 13 Dec 2021 01:05:07 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mweSP-0002dc-BZ for guix-patches@gnu.org; Mon, 13 Dec 2021 01:05:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v4 29/45] gnu: Add node-sqlite3. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 13 Dec 2021 06:05:05 +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.16393754959996 (code B ref 51838); Mon, 13 Dec 2021 06:05:05 +0000 Received: (at 51838) by debbugs.gnu.org; 13 Dec 2021 06:04:55 +0000 Received: from localhost ([127.0.0.1]:53788 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mweRz-0002a3-VY for submit@debbugs.gnu.org; Mon, 13 Dec 2021 01:04:55 -0500 Received: from mail-ua1-f54.google.com ([209.85.222.54]:45627) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mweRj-0002Z7-QN for 51838@debbugs.gnu.org; Mon, 13 Dec 2021 01:04:24 -0500 Received: by mail-ua1-f54.google.com with SMTP id ay21so27252382uab.12 for <51838@debbugs.gnu.org>; Sun, 12 Dec 2021 22:04:23 -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=4QlSe+2vPMDGTufcnOYGxZK20Lpc6crlgOBa5eFV5z4=; b=ELcx9hEyutAB1wHbWzyzTxR9N1oBQIqzkyBt5/jIT9odoG9hzK2RnJl9QH9FmWw8hL xZ1EwtxUJKvKBRxG0nP5Hw4nuNRjduZKZHJBOoRn4DWoiymjErn488n919k05Z3xWLTu XKPgA0wWPNfOty4PbA07+N8m1WNgE93x+QbT5ePYBEN/LMiEwOlD9/5P3eALX4d6xhvd +9ZLeV1Q9U1zJXOuiHr3AevpuDc0FcvMGxL5MpoKKAh7i47pgo4kMwwGClEwxj9f7NlV kVu71OUsaPhpa/PkcvNpSwdNkJik8mwhlRkne0PNu7SQ3FA/SfnpWi3j6c5jSzHb4mN/ dQ2w== 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=4QlSe+2vPMDGTufcnOYGxZK20Lpc6crlgOBa5eFV5z4=; b=IuIMc1W9HtCaaoCAzV3B65wApxXwaQXDV3iuh4IyoBOZ21fjUFF9jJV+CbLQnfvs6P AR41au3BIVDIkMiab+t4DQC0NgwyiIxyeW2vE8ncUrcCxKB2pfYpCaEe5xctTb+gkPV3 dLLcUEfYCd5wrlnv87xVVUeTBiwt+rg8xq0NEvj/m6MU8mLcokEAKIOHvJq0qvwA4Fab VL+sFSMN6yaui3+K+uusUl7xnDlRmh7e7D9YV1FuD78OrQ4qgiYecFRf3KgOODIuWzBj 4QowHkKg8HMvoEr73OuT3+EWFm7y+tGD4nAyrNmItKuuMWtZ0tpdTamtRvG64sgWOAXu gYyA== X-Gm-Message-State: AOAM532ejvnG8Z2wGj6Ga9N1PDXpYPcTh6g4xzSp2uAEdq4KU3wPKixo Kx8/D79P9xFK8Deb2Bg8LLoHQhUiMiBGzz+7buQ= X-Google-Smtp-Source: ABdhPJy+Ts/lrPhHTOiu0Q1WSKYXB0wXlHQ7GCSIBoDsg/e1EEXiu/jza/gNYXJXkpN+8M4+CYssYw== X-Received: by 2002:a67:e44e:: with SMTP id n14mr25859999vsm.55.1639375458411; Sun, 12 Dec 2021 22:04:18 -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 e13sm3694595vkd.21.2021.12.12.22.04.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Dec 2021 22:04:18 -0800 (PST) From: Philip McGrath Date: Mon, 13 Dec 2021 01:00:51 -0500 Message-Id: <20211213060107.129223-30-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211213060107.129223-1-philip@philipmcgrath.com> References: <46a042bc08eb72a068b1e8c69bfe28cf2d4b2e53.camel@gmail.com> <20211208202838.752542-1-philip@philipmcgrath.com> <20211208202838.752542-5-philip@philipmcgrath.com> <877dc924h7.fsf@gmx.com> <5c62c3ce-dd50-5dcd-00ed-ff1524be4e0b@philipmcgrath.com> <20211213060107.129223-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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639375572; 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=4QlSe+2vPMDGTufcnOYGxZK20Lpc6crlgOBa5eFV5z4=; b=aFk9QX0nKCRqV2kYWFBPyKKkunj8PeFShGO1NkE4EvZ5Ycq/DqtN449cvKzJPTWDDSScEk hFE2E498MB0Mo7vqFd4xNVEwMTQvzC9fEoGt5PSuEKdxYIDTGnBhcXc6Wb0LUvqqXyjcHL vjIHlwgkrDlQ0o9wAkNO3sxP8XKtLFsESxahQ/wXRhPAau2nomGB81vXyuxZnemdMlHQXu T1QY3wI44NmC/LG6HZc4aGsaksQQnXmSkbtzO3KYWb5rxfxUMy4bAuDUTlKpvTzk3azD/F nqop5dOUUvHqp/bYqk7NuZMaWeSUmK9yN+6EPXwQR5Vn7fpoNOAFkP4DBcQLig== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639375572; a=rsa-sha256; cv=none; b=UnHRGWC6orp/EPIiBdMFtEbxrgfb02/jMWj+vqbaInsAo9znWEVhXFMP+FyqO/4pMLlHDr KmsSRfuzxDxNoUZ9hfAbdZAIi3cDWwcNO2EbyE80oMEr1ptGbO+31X9Ln1SoVgtRm+PgAZ sW1/y6aoHxGpQhoHCk0DWZzh6+m5nRpELyqzt3j/56OSEQxndEvfBZsop1w0Kv60W179WW drTwoGDF3tB/e8tqyKpPfOyZgoqP2ULum8FNUkymnQ+ynv5hqC757lTg276UzlvZkp1JVt VhLRNFc/+pxi2yNcfMgV85dgbMqHrzZa2LJ0CiOuCijJ+caoCPuzN0ku4gojLw== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=ELcx9hEy; 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: 1.03 Authentication-Results: aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=ELcx9hEy; 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: EAD141F88B X-Spam-Score: 1.03 X-Migadu-Scanner: scn1.migadu.com X-TUID: eIGWbSk+g/UR * gnu/packages/node-xyz.scm (node-sqlite3): New variable. --- gnu/packages/node-xyz.scm | 132 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm index c7bc660134..d1bb236186 100644 --- a/gnu/packages/node-xyz.scm +++ b/gnu/packages/node-xyz.scm @@ -655,3 +655,135 @@ (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 + `(("node-addon-api" ,node-addon-api) + ("python" ,python) + ("sqlite" ,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