From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iLOnOpZP2WGGTAAAgWs5BA (envelope-from ) for ; Sat, 08 Jan 2022 09:47:18 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id MO7+N5ZP2WHSLwEA9RJhRA (envelope-from ) for ; Sat, 08 Jan 2022 09:47:18 +0100 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 aspmx1.migadu.com (Postfix) with ESMTPS id 88A5534C0D for ; Sat, 8 Jan 2022 09:47:18 +0100 (CET) Received: from localhost ([::1]:43670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n67Nd-0005AU-MO for larch@yhetil.org; Sat, 08 Jan 2022 03:47:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n67LT-0002qd-3Z for guix-patches@gnu.org; Sat, 08 Jan 2022 03:45:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:53435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n67LS-0004Bq-RL for guix-patches@gnu.org; Sat, 08 Jan 2022 03:45:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n67LS-0000oG-QE for guix-patches@gnu.org; Sat, 08 Jan 2022 03:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v9 05/41] guix: node-build-system: Add 'delete-dependencies' helper function. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 08 Jan 2022 08:45:02 +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 , Philip McGrath , Pierre Langlois , Liliana Marie Prikler , Leo Famulari , Jelle Licht Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.16416314532855 (code B ref 51838); Sat, 08 Jan 2022 08:45:02 +0000 Received: (at 51838) by debbugs.gnu.org; 8 Jan 2022 08:44:13 +0000 Received: from localhost ([127.0.0.1]:46300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n67Ke-0000jz-Nv for submit@debbugs.gnu.org; Sat, 08 Jan 2022 03:44:13 -0500 Received: from mail-qk1-f170.google.com ([209.85.222.170]:42717) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n67Kd-0000jZ-NQ for 51838@debbugs.gnu.org; Sat, 08 Jan 2022 03:44:12 -0500 Received: by mail-qk1-f170.google.com with SMTP id r139so8482862qke.9 for <51838@debbugs.gnu.org>; Sat, 08 Jan 2022 00:44:11 -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=ARE2mqghqlOfXQHHbSUdT+VoRFw22yMwYCjopfV/jzw=; b=T4jJv4+TRzLen3isAzAfBecUvDphCnYXuC3nW6zuMmOyTef5FKOi1KUT1f9h5mdibh glEpsTtE9h10rwFFR33QUf3q1Xjte23006L4jvE05We7BRt2653SvA0zeH5aGoZGX3wm 5Zxat+euCv6kQE418300EL+9lL1biSeh0Thvu7p4p/eDaWl3I21yv96PR4y5gv1cfq2w eyJJbVONXHcJd7G47R7n76DhDFYT0t88qWYIVyQtLOO6jdIOoUGzy6mhwJO+/H8gVnBh eDeXilstjYcS/QO+do5TcTIQFs7LCz7N9Hub9IpMZnY38CpTEnF6CEhaM+eLtXxbIs4I /r7A== 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=ARE2mqghqlOfXQHHbSUdT+VoRFw22yMwYCjopfV/jzw=; b=BBdppF637kkMKyS7Mpl4tyyjGCDNByxUaK1XdZK++M2i3aiUhq9ZdOZtMYlZpn4AQK lUKYVFtyJnw11aMchJcOFrOLtCOr2J/Cvak9fgcJW2saT/Fm+uHjU7Srs8fOFicKLN0N 9vQpTYQnYpXGIQz2v0u4Pa4OEjkLrSM93Ro7VXfsQ2SgAbo1Kp72QHvZ8HSlhVKjP+K1 f0n3cdRMjNxRbg3FDPtUdAw35iPNGCokI/U0kCL7qmKPowJKuIsxjJ4pWu69LrJLAOda 4t2Snp2Luc5oBJc8tUaGc4KQvV4mNZw3U9NcC2nW8IF1NZEg0vnD+4y2Etpl96Usbznu d+lw== X-Gm-Message-State: AOAM530kQDnvvz/Q1E8WtBcZxheIrPsoeGwGjUtc4bzyAfWQ0ZFfdtAr NwsrZp4La0wHBFs9V/CgB6v5WUl7xigpmJqJ X-Google-Smtp-Source: ABdhPJxoypi/xpSimygJXUGN6Rx3DOMvS1ZToc0kX+LJN71/qzKJsbtqDXvYPUsWYX7Vu3klNJ6xeA== X-Received: by 2002:a37:5a43:: with SMTP id o64mr47097944qkb.375.1641631446188; Sat, 08 Jan 2022 00:44:06 -0800 (PST) Received: from localhost (c-73-125-89-242.hsd1.fl.comcast.net. [73.125.89.242]) by smtp.gmail.com with UTF8SMTPSA id w10sm700863qkp.121.2022.01.08.00.44.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 08 Jan 2022 00:44:06 -0800 (PST) From: Philip McGrath Date: Sat, 8 Jan 2022 03:41:53 -0500 Message-Id: <20220108084229.362642-6-philip@philipmcgrath.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220108084229.362642-1-philip@philipmcgrath.com> References: <64e08d3a1838ed8507f33fae895545372960522f.camel@gmail.com> <7b04af28bbd57c67093ce8f33a648efec89693bd.camel@gmail.com> <441bfeb0-eb6e-81f6-488b-cdf1b09a78ef@philipmcgrath.com> <20220108084229.362642-1-philip@philipmcgrath.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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=1641631638; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=ARE2mqghqlOfXQHHbSUdT+VoRFw22yMwYCjopfV/jzw=; b=bsJTsPtvWMGTqbgNQheCNWmAU0wJQGPUf2qzUvaIwUSGArAfwLvuH1/xzQwRPnfXnhMJaA 0u80HA6nFr5NgGHnnVVB/rKrYPdWgUHwLfHxiIfbAZSiMgpx2OyeyyloxXC5rbWgLyLPPf NvRsHPFL8qCZyyur5iIPdLGeIhepTGf1rBDHEQCRnahWjBcJWAk0zq7SSQVuixophG5XQC Jc+C5fcQdEQyaxbEKM4gz0zzKtjulN9uZnIPpD9kBRjEpF5Zt/z9eBhGg+lOI3QNUwux82 oQ0i8gFYnbeumSdLEvC8IiynrrNjLAhox0Cwykq2MvapGkPpJLyau6pdAoq1Jw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641631638; a=rsa-sha256; cv=none; b=Y41rYtE1xIRiQoNZz989RBXxacZA3qSh5AjgGNE7ViYkJhHq/nM9KqVsEXOB6zIluL+0/+ 2yMIen6bJq52pMBxGP9cDTGbOcXkACkxGW1pptVEseXWo/6prhGM8tcWcluzHKJkf1JY/Z H0/RHhahggx+dokzwFMWR2+BMLp/uNoArza3GoTVssL8f8t6ilnqm9g5psipUKaiE5+i6B FIg5EkD38e0EyDIXgMmsJ0F4kLUkSDovOEArneVUa5KI+qlpX7w/sCgMWmP1HbSf4vkR56 pv70oby7LGNHnmtiWUze7FxSCmvI7VmD92OyKgXUEEceB+v0FM3hdV0/ZuHPiQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=T4jJv4+T; dmarc=none; spf=pass (aspmx1.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.40 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=T4jJv4+T; dmarc=none; spf=pass (aspmx1.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: 88A5534C0D X-Spam-Score: 0.40 X-Migadu-Scanner: scn0.migadu.com X-TUID: Wd/YbvcJmUmx Many node packages currently skip the configure phase, because they lack both dependencies and a convenient way to build without all of them, e.g. for the purposes of bootstrapping. This patch adds a big hammer to flatten these nails. * guix/build/node-build-system.scm (delete-dependencies): New variable. Co-authored-by: Liliana Marie Prikler --- guix/build/node-build-system.scm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm index ee3442e9e4..e37a0f7b44 100644 --- a/guix/build/node-build-system.scm +++ b/guix/build/node-build-system.scm @@ -2,7 +2,7 @@ ;;; Copyright © 2015 David Thompson ;;; Copyright © 2016, 2020 Jelle Licht ;;; Copyright © 2019, 2021 Timothy Sample -;;; Copyright © 2021 Philip McGrath +;;; Copyright © 2021, 2022 Philip McGrath ;;; Copyright © 2021 Liliana Marie Prikler ;;; ;;; This file is part of GNU Guix. @@ -25,11 +25,13 @@ (define-module (guix build node-build-system) #:use-module (guix build utils) #:use-module (guix build json) #:use-module (ice-9 ftw) + #:use-module (ice-9 regex) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-71) #:export (%standard-phases with-atomic-json-file-replacement + delete-dependencies node-build)) (define (with-atomic-json-file-replacement file proc) @@ -187,6 +189,27 @@ (define resolve-dependencies (@))))) #t) +(define (delete-dependencies absent) + "Rewrite 'package.json' to allow the build to proceed without packages +listed in ABSENT, a list of strings naming npm packages. + +To prevent the deleted dependencies from being reintroduced, use this function +only after the 'patch-dependencies' phase." + (define delete-from-jsobject + (match-lambda + (('@ . alist) + (cons '@ (filter (match-lambda + ((k . _) + (not (member k absent)))) + alist))))) + + (with-atomic-json-file-replacement "package.json" + (lambda (pkg-meta) + (jsobject-update* + pkg-meta + `("devDependencies" ,delete-from-jsobject (@)) + `("dependencies" ,delete-from-jsobject (@)))))) + (define* (delete-lockfiles #:key inputs #:allow-other-keys) "Delete 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json', if they exist." -- 2.32.0