From patchwork Wed Feb 9 13:24:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 37138 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 D302327BBEA; Wed, 9 Feb 2022 13:39:48 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 7803027BBE9 for ; Wed, 9 Feb 2022 13:39:48 +0000 (GMT) Received: from localhost ([::1]:51336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHnCD-0005Gt-Rz for patchwork@mira.cbaines.net; Wed, 09 Feb 2022 08:39:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHmy9-0004dd-T4 for guix-patches@gnu.org; Wed, 09 Feb 2022 08:25:13 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:56277) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHmxx-0004E3-Ot for guix-patches@gnu.org; Wed, 09 Feb 2022 08:25:11 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHmxx-00076E-Ly; Wed, 09 Feb 2022 08:25:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53818] [PATCH v3 1/7] upstream: Sort list of updaters. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: maximedevos@telenet.be, guix-patches@gnu.org Resent-Date: Wed, 09 Feb 2022 13:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53818 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53818@debbugs.gnu.org Cc: Maxime Devos X-Debbugs-Original-Xcc: Maxime Devos Received: via spool by 53818-submit@debbugs.gnu.org id=B53818.164441305127186 (code B ref 53818); Wed, 09 Feb 2022 13:25:01 +0000 Received: (at 53818) by debbugs.gnu.org; 9 Feb 2022 13:24:11 +0000 Received: from localhost ([127.0.0.1]:50168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHmx8-00074P-MV for submit@debbugs.gnu.org; Wed, 09 Feb 2022 08:24:10 -0500 Received: from h178-251-242-94.cust.a3fiber.se ([178.251.242.94]:44826 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHmx7-000749-Oe for 53818@debbugs.gnu.org; Wed, 09 Feb 2022 08:24:10 -0500 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yoctocell.xyz; s=mail; t=1644413044; bh=uePA9eU3rVfA9D2Eoe6XklIGhmYCp8Bpq3h/n9/hOOk=; h=From:To:Subject:In-Reply-To:References:Date; b=piFvX2WkUE1M1DgHLzOs8GXc/OEfIFmX9GG+w2aXe2yxqy+styolguiqbm2M2ZoS7 aEvWJeobXGepvFnKylduL7f+/LD4viEXKx48RlhGaKYBmaBf9jFEdrk7Th2NuBM/5+ OhcRzI3qAbJdlcyJZXukv63b/O19QJZMoIIkfPQE= In-Reply-To: References: Message-Id: <0f119f2aaf1f3d492bdf733136c310a9f1a6d85d.1644412701.git.public@yoctocell.xyz> Date: Wed, 09 Feb 2022 14:24:03 +0100 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 The order determines which updater gets used first when running ‘guix refresh’ on a package. We want the most generic updaters to be last since they usually don’t provide as much or accurate information as language-specific updaters. * guix/upstream.scm (sort-updaters): New procedure. (%updaters): Use it. --- guix/upstream.scm | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/guix/upstream.scm b/guix/upstream.scm index 6666803a92..d5faf9d3ee 100644 --- a/guix/upstream.scm +++ b/guix/upstream.scm @@ -250,14 +250,31 @@ (define (importer-modules) %load-path) #:warn warn-about-load-error))) +(define (sort-updaters updaters) + "Sort UPDATERS by putting the more generic ones last." + (define (genericity updater) + (cond + ((equal? 'repology (upstream-updater-name updater)) + 2) + ((string-prefix? "generic-" + (symbol->string (upstream-updater-name updater))) + 1) + (else 0))) + + (define (less a b) + (<= (genericity a) (genericity b))) + + (stable-sort updaters less)) + (define %updaters ;; The list of publically-known updaters. - (delay (fold-module-public-variables (lambda (obj result) - (if (upstream-updater? obj) - (cons obj result) - result)) - '() - (importer-modules)))) + (delay (sort-updaters + (fold-module-public-variables (lambda (obj result) + (if (upstream-updater? obj) + (cons obj result) + result)) + '() + (importer-modules))))) ;; Tests need to mock this variable so mark it as "non-declarative". (set! %updaters %updaters)