diff options
author | Ludovic Courtès <ludo@gnu.org> | 2019-04-06 23:05:27 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2019-04-10 17:09:47 +0200 |
commit | c872b952c527cb42766654d12059d5ea5224ca6c (patch) | |
tree | 08e192c2830b958401567a86370f4336593d8e75 /guix | |
parent | bacf980c76c94e7bda86220ca4bf662d0e34a45a (diff) | |
download | gnu-guix-c872b952c527cb42766654d12059d5ea5224ca6c.tar gnu-guix-c872b952c527cb42766654d12059d5ea5224ca6c.tar.gz |
profiles: Add 'generation-profile'.
* guix/profiles.scm (%profile-generation-rx): New variable.
(generation-profile): New procedure.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/profiles.scm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/guix/profiles.scm b/guix/profiles.scm index 6564526aee..dfc9ba1ca0 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -118,6 +118,7 @@ profile-search-paths generation-number + generation-profile generation-numbers profile-generations relative-generation-spec->number @@ -1552,6 +1553,20 @@ already effective." (compose string->number (cut match:substring <> 1))) 0)) +(define %profile-generation-rx + ;; Regexp that matches profile generation. + (make-regexp "(.*)-([0-9]+)-link$")) + +(define (generation-profile file) + "If FILE is a profile generation GC root such as \"guix-profile-42-link\", +return its corresponding profile---e.g., \"guix-profile\". Otherwise return +#f." + (match (regexp-exec %profile-generation-rx file) + (#f #f) + (m (let ((profile (match:substring m 1))) + (and (file-exists? (string-append profile "/manifest")) + profile))))) + (define (generation-numbers profile) "Return the sorted list of generation numbers of PROFILE, or '(0) if no former profiles were found." |