From patchwork Thu Jul 15 07:33:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 31428 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A133627BC85; Thu, 15 Jul 2021 08:34:18 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2DB9027BC82 for ; Thu, 15 Jul 2021 08:34:18 +0100 (BST) Received: from localhost ([::1]:43416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3vsv-0007MV-33 for patchwork@mira.cbaines.net; Thu, 15 Jul 2021 03:34:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3vsg-0007Dx-W6 for guix-patches@gnu.org; Thu, 15 Jul 2021 03:34:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35122) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3vsg-0000xo-OT for guix-patches@gnu.org; Thu, 15 Jul 2021 03:34:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m3vsg-0006wW-Kh for guix-patches@gnu.org; Thu, 15 Jul 2021 03:34:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#39258] [PATCH v6 1/2] DRAFT packages: Add fields to packages cache. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 15 Jul 2021 07:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39258 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 39258@debbugs.gnu.org Cc: ludo@gnu.org, arunisaac@systemreboot.net, zimoun Received: via spool by 39258-submit@debbugs.gnu.org id=B39258.162633442626650 (code B ref 39258); Thu, 15 Jul 2021 07:34:02 +0000 Received: (at 39258) by debbugs.gnu.org; 15 Jul 2021 07:33:46 +0000 Received: from localhost ([127.0.0.1]:46665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3vsP-0006vg-OJ for submit@debbugs.gnu.org; Thu, 15 Jul 2021 03:33:46 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:40785) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3vsN-0006vF-8O for 39258@debbugs.gnu.org; Thu, 15 Jul 2021 03:33:43 -0400 Received: by mail-wr1-f47.google.com with SMTP id l7so6414785wrv.7 for <39258@debbugs.gnu.org>; Thu, 15 Jul 2021 00:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/ETrfqt6DlChIkn+STgAdUgzArDXN/30X5H0lAwQnU4=; b=O+jNMlbCW5xz2OPfbZh027qckUJO0bRN+XZ32So/mbYdG0s6PdYzVsQXYSx/sQR9Qh mpGbLlnrI9waYMP61gAZv3Nfe0zCKb6gpawnDLy6H/Vzk4aNY9hVB8CLFLzdtHBLqbuw g2VJsmEomG/kXmaYzEkGNCDSRm5avAUJ2tcQL3w7rS1GqZZDmpAU2vfdZEJ59zlTKWj1 7nwmIhYMMByto+lw4Z2r29b/7pcMqj9+lzLTnGHFBlAaziryjaLc2iO4qFD6NiHVOIvf a/Zo7UJc7vG7Ekl4XCDOLvoeg7+C+0rVWiHOjn1/4qYmsnzLen5kGS058sSBLWMdSve4 x9kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/ETrfqt6DlChIkn+STgAdUgzArDXN/30X5H0lAwQnU4=; b=sSY0c5555FOAkCoHZCvhqnFAH8eAsyMvWJJPU+THEbLq/atfLcFSuud1uUK/ERSUKq 3bH6g4qMlGOMOTM7D1XJHHIE/HSBeRbSQNGyEO+XFX5ll2Dn6RCEmzmb5RXTk7HkpV46 hsLWMDpYRLoCnhkFKa9yDZl6C/j5ros2RPU8/AEm2JO7JLu97G13FA/P+yxew/kqHlID aIRG5lTAdrGOLZLKqKDJpPhpMFQme9yUIgbXo7jV11Qe0vV4YH7BU3kDHqxKfdHzw/ZA N388nbtc5QM+qawalTy/PY5MmA3ht80yNwcB2B/2GdZpqgtn79UNzqACCxKpCyIwUadg jcBw== X-Gm-Message-State: AOAM530r+HpijDJM4qM+v+iPZ4KJ2RoX5oaoYCUigUqox3JLEyciUNwh JuUP1grLogYVzoz1/nOmPZvohYpZ5i4= X-Google-Smtp-Source: ABdhPJykfFrSsZdXN7lqBguFHEd4FzSOna+Nl1Sxim6YOYkeHn+rwYvDvQouieAOoLjp3hgkn3R19A== X-Received: by 2002:adf:a1c2:: with SMTP id v2mr3657932wrv.155.1626334417589; Thu, 15 Jul 2021 00:33:37 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.117]) by smtp.gmail.com with ESMTPSA id y3sm5376205wrh.16.2021.07.15.00.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 00:33:37 -0700 (PDT) From: zimoun Date: Thu, 15 Jul 2021 09:33:27 +0200 Message-Id: <20210715073328.212123-2-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715073328.212123-1-zimon.toutoune@gmail.com> References: <20210715073328.212123-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages.scm (generate-package-cache)[expand-cache]: Add synopsis and description. (load-package-cache, find-packages-by-names, find-packages-locations): Adapt accordingly. (fold-available-packages): Add synopsis, description, module and symbol when cache is authoritative. Replace 'fold-packages' by 'fold-module-public-variables*' when cache is not authoritative. --- gnu/packages.scm | 52 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/gnu/packages.scm b/gnu/packages.scm index ccfc83dd11..34c6d73b86 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2016, 2017 Alex Kost ;;; Copyright © 2016 Mathieu Lirzin +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -211,28 +212,45 @@ package module." (vhash-fold (lambda (name vector result) (match vector (#(name version module symbol outputs + synopsis description supported? deprecated? file line column) (proc name version result #:outputs outputs + #:synopsis synopsis + #:description description #:location (and file (location file line column)) + #:module module + #:symbol symbol #:supported? supported? #:deprecated? deprecated?)))) init cache) - (fold-packages (lambda (package result) - (proc (package-name package) - (package-version package) - result - #:outputs (package-outputs package) - #:location (package-location package) - #:supported? - (->bool (supported-package? package)) - #:deprecated? - (->bool - (package-superseded package)))) - init))) + (fold-module-public-variables* + (lambda (module symbol variable result) + (let ((package (false-if-exception + (variable-ref variable)))) + (if (package? package) + (proc (package-name package) + (package-version package) + result + #:outputs (package-outputs package) + #:synopsis (package-synopsis package) + #:description (package-description package) + #:location (package-location package) + #:module (module-name module) + #:symbol symbol + #:supported? + (->bool (supported-package? package)) + #:deprecated? + (->bool + (package-superseded package))) + result))) + init + (all-modules (%package-module-path) + #:warn + warn-about-load-error)))) (define* (fold-packages proc init #:optional @@ -268,6 +286,7 @@ package names. Return #f on failure." (fold (lambda (item vhash) (match item (#(name version module symbol outputs + synopsis description supported? deprecated? file line column) (vhash-cons name item vhash)))) @@ -316,7 +335,7 @@ decreasing version order." (if (and (cache-is-authoritative?) cache) (match (cache-lookup cache name) (#f #f) - ((#(_ versions modules symbols _ _ _ _ _ _) ...) + ((#(_ versions modules symbols _ _ _ _ _ _ _ _) ...) (fold (lambda (version* module symbol result) (if (or (not version) (version-prefix? version version*)) @@ -337,9 +356,8 @@ matching NAME and VERSION." (if (and cache (cache-is-authoritative?)) (match (cache-lookup cache name) (#f '()) - ((#(name versions modules symbols outputs - supported? deprecated? - files lines columns) ...) + ((#(_ versions _ _ _ _ _ _ _ + files lines columns) ...) (fold (lambda (version* file line column result) (if (and file (or (not version) @@ -393,6 +411,8 @@ reducing the memory footprint." ,(module-name module) ,symbol ,(package-outputs package) + ,(package-synopsis package) + ,(package-description package) ,(->bool (supported-package? package)) ,(->bool (package-superseded package)) ,@(let ((loc (package-location package))) From patchwork Thu Jul 15 07:33:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 31427 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 59B3827BC82; Thu, 15 Jul 2021 08:34:17 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6993427BC85 for ; Thu, 15 Jul 2021 08:34:16 +0100 (BST) Received: from localhost ([::1]:43314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3vst-0007Hs-FL for patchwork@mira.cbaines.net; Thu, 15 Jul 2021 03:34:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3vsh-0007Eh-I2 for guix-patches@gnu.org; Thu, 15 Jul 2021 03:34:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35123) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3vsh-0000yl-9u for guix-patches@gnu.org; Thu, 15 Jul 2021 03:34:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m3vsh-0006wf-35 for guix-patches@gnu.org; Thu, 15 Jul 2021 03:34:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#39258] [PATCH v6 2/2] DRAFT scripts: package: Use cache in 'find-packages-by-description'. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 15 Jul 2021 07:34:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39258 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 39258@debbugs.gnu.org Cc: ludo@gnu.org, arunisaac@systemreboot.net, zimoun Received: via spool by 39258-submit@debbugs.gnu.org id=B39258.162633442826660 (code B ref 39258); Thu, 15 Jul 2021 07:34:03 +0000 Received: (at 39258) by debbugs.gnu.org; 15 Jul 2021 07:33:48 +0000 Received: from localhost ([127.0.0.1]:46667 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3vsS-0006vu-6y for submit@debbugs.gnu.org; Thu, 15 Jul 2021 03:33:48 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]:43748) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3vsN-0006vI-M8 for 39258@debbugs.gnu.org; Thu, 15 Jul 2021 03:33:44 -0400 Received: by mail-wr1-f41.google.com with SMTP id a13so6388669wrf.10 for <39258@debbugs.gnu.org>; Thu, 15 Jul 2021 00:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q96Oqdu7AN+kHj5/yhfWJ5qZNWVSRHSqyOco2OpaOS0=; b=o4MUinOnfDyJOuYrV8XNTr2wgth12z0/2DOIUhFi5mM/z7+ksPWn4JvFZwAoGwDBU+ DPWbVFfw3F6jZWcbIotJv+ALbSZUijFG3iu7PEZPWes2gsBuSKTaHQxrgyp3kDpkMcgd 4+TY7zFWE6f2v8W8tbjwpe+NsokOK/7m893nc2DjrTZHreNK4KV4T9/Y8g+BspDeQO1E CwXAXi6uMyt//XGddKn3TUnwG9MHrN7xRj8EEetJyJd+IYHH8fEck8tdue/gVkmulBbk zDS1RThQP+m6VqKnTRPcTOCB95KmA8DfUh5gw5Y5qK725T+SYUiTm3BKoNL9h5gpnHSY kcdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q96Oqdu7AN+kHj5/yhfWJ5qZNWVSRHSqyOco2OpaOS0=; b=LL+NCX0Ppw0jbIWo+z8QNq/jbtYslKyxFk+AOmM7rAFmAEk9vMneEBiudxTcGSvUfl O9qgOON727gBO0mQoer4SJxYR9nxrCLdkC9x19QjZZGnC7KzaHx44E2ITUjWiNs9ngMA Y9eCS7kCqsSjdaw5UlUJc+LM4A7UA3oxHcEDtc7Fk5M/R5Jpm2ycoiPKlca4wT7Dkwr9 i15n6qdw095De2JzpOPOUB3JqKPSJCRoQiYYB0IN9EzQGtCrXCRPyDk5n3OocyX/Gijy gYy7sGFLfBkQ+qJDHvbKQ996lxckpv0iT9ZzkvZwxek5CHe5bXKGqph2eh0g/wFzl0ir DEAQ== X-Gm-Message-State: AOAM530hcQ6bZ8htDfI9VdGiRFMG+2w+PqO3Ythf7eVNfu4/D3BmSOUm V4JL5wvYb/pPUUH9UAa//wLSfYs/FSM= X-Google-Smtp-Source: ABdhPJzbzCalx+tl+6TfRqV6nVv1R4h5gUVcklKnl+8PyXB71NjMQJ3lZqReLZS3z/Tr7NthXBRzxQ== X-Received: by 2002:adf:ed07:: with SMTP id a7mr3822135wro.70.1626334418108; Thu, 15 Jul 2021 00:33:38 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.117]) by smtp.gmail.com with ESMTPSA id y3sm5376205wrh.16.2021.07.15.00.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 00:33:37 -0700 (PDT) From: zimoun Date: Thu, 15 Jul 2021 09:33:28 +0200 Message-Id: <20210715073328.212123-3-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715073328.212123-1-zimon.toutoune@gmail.com> References: <20210715073328.212123-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/scripts/package.scm (find-packages-by-description): Replace 'fold-packages' by 'fold-available-packages'. --- guix/scripts/package.scm | 46 +++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 694959d326..ff2aed6905 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -8,7 +8,7 @@ ;;; Copyright © 2016 Chris Marusich ;;; Copyright © 2019 Tobias Geerinckx-Rice ;;; Copyright © 2020 Ricardo Wurmus -;;; Copyright © 2020 Simon Tournier +;;; Copyright © 2020, 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -181,17 +181,39 @@ hooks\" run when building the profile." "Return a list of pairs: packages whose name, synopsis, description, or output matches at least one of REGEXPS sorted by relevance, and its non-zero relevance score." - (let ((matches (fold-packages (lambda (package result) - (if (package-superseded package) - result - (match (package-relevance package - regexps) - ((? zero?) - result) - (score - (cons (cons package score) - result))))) - '()))) + (define (read-package-from module symbol) + (module-ref (resolve-interface module) symbol)) + + (let ((matches (fold-available-packages + (lambda* (name version result + #:key outputs description synopsis location + module symbol + deprecated? + #:allow-other-keys) + (if deprecated? + result + (let* ((package + (package + (name name) + (version version) + (source #f) + (build-system #f) + (outputs outputs) + (synopsis synopsis) + (description description) + (home-page #f) + (license #f) + (location location)))) + (match (package-relevance package + regexps) + ((? zero?) + result) + (score + (cons (cons (read-package-from module symbol) + score) + result)))))) + '()))) + (sort matches (lambda (m1 m2) (match m1