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