From patchwork Sat May 25 19:16:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Vollmert X-Patchwork-Id: 14078 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 8A4561701C; Sat, 25 May 2019 20:18:08 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 1FA0716CC8 for ; Sat, 25 May 2019 20:18:08 +0100 (BST) Received: from localhost ([127.0.0.1]:45474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUcBD-000346-HD for patchwork@mira.cbaines.net; Sat, 25 May 2019 15:18:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUcBA-00033p-OP for guix-patches@gnu.org; Sat, 25 May 2019 15:18:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUcB9-0000St-M5 for guix-patches@gnu.org; Sat, 25 May 2019 15:18:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36120) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hUcB7-0000R0-Vx for guix-patches@gnu.org; Sat, 25 May 2019 15:18:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hUcB7-0008AU-PI for guix-patches@gnu.org; Sat, 25 May 2019 15:18:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#35905] [PATCH] find-package-by-name: reverse package load precedence Resent-From: Robert Vollmert Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 25 May 2019 19:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35905 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 35905@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.155881183331315 (code B ref -1); Sat, 25 May 2019 19:18:01 +0000 Received: (at submit) by debbugs.gnu.org; 25 May 2019 19:17:13 +0000 Received: from localhost ([127.0.0.1]:49660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hUcAK-000891-Nv for submit@debbugs.gnu.org; Sat, 25 May 2019 15:17:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52157) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hUcAH-00088n-Mt for submit@debbugs.gnu.org; Sat, 25 May 2019 15:17:10 -0400 Received: from lists.gnu.org ([209.51.188.17]:49273) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hUcAB-0007pq-QU for submit@debbugs.gnu.org; Sat, 25 May 2019 15:17:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUcA8-0002vB-SW for guix-patches@gnu.org; Sat, 25 May 2019 15:17:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUcA6-0007iB-Tl for guix-patches@gnu.org; Sat, 25 May 2019 15:17:00 -0400 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]:24264) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hUcA5-0007XG-42 for guix-patches@gnu.org; Sat, 25 May 2019 15:16:58 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id E1A364FF6D for ; Sat, 25 May 2019 21:16:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id xvNc7L_6V_Ae for ; Sat, 25 May 2019 21:16:35 +0200 (CEST) From: Robert Vollmert Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Message-Id: Date: Sat, 25 May 2019 21:16:34 +0200 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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 From e484a11fa652c6e9cb4484c6f700b91f134e7156 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sat, 25 May 2019 08:40:38 +0200 Subject: [PATCH] guix: find-package-by-name: list modules in path order A particular effect of this is that if there are ambiguous packages in a directory specified with `-L module_dir` and the distribution, the version from `module_dir` will be loaded, which is usually what would be expected. (E.g. for `guix build` or `guix package -i`.) * guix/discovery.scm (all-modules): Return modules in path order. * tests/guix-package.sh: Test local definitions take precedence. --- guix/discovery.scm | 4 ++-- tests/guix-package.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/guix/discovery.scm b/guix/discovery.scm index ef5ae73973..5bb494941b 100644 --- a/guix/discovery.scm +++ b/guix/discovery.scm @@ -145,8 +145,8 @@ Call (PROC MODULE RESULT) for each module that is found." "Return the list of package modules found in PATH, a list of directories to search. Entries in PATH can be directory names (strings) or (DIRECTORY . SUB-DIRECTORY) pairs, in which case modules are searched for beneath -SUB-DIRECTORY." - (fold-modules cons '() path #:warn warn)) +SUB-DIRECTORY. Modules are listed in the order they appear on the path." + (reverse (fold-modules cons '() path #:warn warn))) (define (fold-module-public-variables* proc init modules) "Call (PROC MODULE SYMBOL VARIABLE) for each variable exported by one of MODULES, diff --git a/tests/guix-package.sh b/tests/guix-package.sh index 767c3f8a66..79d6ec65e4 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -280,6 +280,20 @@ export GUIX_PACKAGE_PATH guix package -A emacs-foo-bar | grep 42 guix package -i emacs-foo-bar@42 -n +# Make sure GUIX_PACKAGE_PATH/'-L' takes precedence in case of duplicate packages. +cat > "$module_dir/bar.scm"<&1 | grep choosing.*bar.scm +( unset GUIX_PACKAGE_PATH; \ + guix package -i hello -n -L "$module_dir" 2>&1 | grep choosing.*bar.scm ) + # Make sure patches that live under $GUIX_PACKAGE_PATH are found. cat > "$module_dir/emacs.patch"<