From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Craven Subject: [PATCH 3/7] gnu: Add replace-input procedure. Date: Thu, 2 Feb 2017 00:35:27 +0100 Message-ID: <20170201233531.2640-3-david@craven.ch> References: <20170201233531.2640-1-david@craven.ch> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ4RN-0007lJ-5l for guix-devel@gnu.org; Wed, 01 Feb 2017 18:35:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZ4RJ-0005Le-TB for guix-devel@gnu.org; Wed, 01 Feb 2017 18:35:53 -0500 Received: from so254-10.mailgun.net ([198.61.254.10]:18736) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cZ4RJ-0005Kw-M5 for guix-devel@gnu.org; Wed, 01 Feb 2017 18:35:49 -0500 In-Reply-To: <20170201233531.2640-1-david@craven.ch> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org Cc: David Craven * gnu/packages.scm (replace-input): New procedure. --- gnu/packages.scm | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/gnu/packages.scm b/gnu/packages.scm index 0aa289d56..2535e10b1 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -53,7 +53,9 @@ find-newest-available-packages specification->package - specification->package+output)) + specification->package+output + + replace-input)) ;;; Commentary: ;;; @@ -356,3 +358,26 @@ version; if SPEC does not specify an output, return OUTPUT." (leave (_ "package `~a' lacks output `~a'~%") (package-full-name package) sub-drv)))))) + + +;;; +;;; Package utilities. +;;; + +(define (replace-input pkg name replacement) + "Returns a package with all inputs of NAME replaced with REPLACEMENT. Is +usefull for resolving circular dependencies." + (define replace + (match-lambda + ((tag input) + (if (string=? tag name) + (list name replacement) + (list tag (replace-input input name replacement)))))) + (package + (inherit pkg) + (inputs + (map replace (package-inputs pkg))) + (native-inputs + (map replace (package-native-inputs pkg))) + (propagated-inputs + (map replace (package-propagated-inputs pkg))))) -- 2.11.0