From f755403014e70d875541bcce5474d2cf410b5da1 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Tue, 12 Aug 2014 12:32:16 +0400 Subject: profiles: Add 'manifest-add'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/profiles.scm (manifest-add): New procedure. * tests/profiles.scm (guile-1.8.8): New variable. ("manifest-add"): New test. Signed-off-by: Ludovic Courtès --- guix/profiles.scm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'guix/profiles.scm') diff --git a/guix/profiles.scm b/guix/profiles.scm index 5e69e012f9..c7aec7909b 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -47,6 +47,7 @@ (define-module (guix profiles) manifest-pattern? manifest-remove + manifest-add manifest-installed? manifest-matching-entries @@ -196,6 +197,25 @@ (define (remove-entry pattern lst) (manifest-entries manifest) patterns))) +(define (manifest-add manifest entries) + "Add a list of manifest ENTRIES to MANIFEST and return new manifest. +Remove MANIFEST entries that have the same name and output as ENTRIES." + (define (same-entry? entry name output) + (match entry + (($ entry-name _ entry-output _ ...) + (and (equal? name entry-name) + (equal? output entry-output))))) + + (make-manifest + (append entries + (fold (lambda (entry result) + (match entry + (($ name _ out _ ...) + (filter (negate (cut same-entry? <> name out)) + result)))) + (manifest-entries manifest) + entries)))) + (define (manifest-installed? manifest pattern) "Return #t if MANIFEST has an entry matching PATTERN (a manifest-pattern), #f otherwise." -- cgit v1.2.3