unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 35176@debbugs.gnu.org
Subject: [bug#35176] [PATCH 3/5] profiles: Add 'generation-profile'.
Date: Sat,  6 Apr 2019 23:31:21 +0200	[thread overview]
Message-ID: <20190406213123.27164-3-ludo@gnu.org> (raw)
In-Reply-To: <20190406213123.27164-1-ludo@gnu.org>

* guix/profiles.scm (%profile-generation-rx): New variable.
(generation-profile): New procedure.
---
 guix/profiles.scm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

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."
-- 
2.21.0

  parent reply	other threads:[~2019-04-06 21:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-06 21:26 [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots' Ludovic Courtès
2019-04-06 21:31 ` [bug#35176] [PATCH 1/5] Add (guix store roots) Ludovic Courtès
2019-04-06 21:31   ` [bug#35176] [PATCH 2/5] guix gc: Add '--list-roots' Ludovic Courtès
2019-04-06 21:31   ` Ludovic Courtès [this message]
2019-04-06 21:31   ` [bug#35176] [PATCH 4/5] guix gc: Add '--delete-generations' Ludovic Courtès
2019-04-06 21:31   ` [bug#35176] [PATCH 5/5] scripts: GC hint suggests 'guix gc -d 1m' Ludovic Courtès
2019-04-09 19:01 ` [bug#35176] [PATCH 0/5] 'guix gc --delete-generations' and '--list-roots' Björn Höfling
2019-04-09 20:02   ` Ludovic Courtès
2019-04-09 20:58     ` Björn Höfling
2019-04-10 15:19       ` bug#35176: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190406213123.27164-3-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=35176@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).