aboutsummaryrefslogtreecommitdiff
path: root/nix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-11-12 22:16:28 +0100
committerLudovic Courtès <ludo@gnu.org>2017-11-12 22:42:17 +0100
commitfb17a89912c2a3738dae716e30481c11e1c6f0ac (patch)
treeb524221259b1a5d6ca8f37d54b6bf633e43982fa /nix/scripts
parentb8f59cdc20e9d83ce63523ef917e95fcee07f134 (diff)
downloadguix-fb17a89912c2a3738dae716e30481c11e1c6f0ac.tar.gz
guix-fb17a89912c2a3738dae716e30481c11e1c6f0ac.zip
list-runtime-roots: Canonicalize store items.
Looking at 'addAdditionalRoots' in libstore/gc.cc, it looks like it should always have been this way. In practice it probably doesn't make much of a difference. * nix/scripts/list-runtime-roots.in (canonicalize-store-item): New procedure. <top level>: Use it.
2021-08-29Migrate to-rw-r--r--nix/scripts/list-runtime-roots.in16
1 files changed, 15 insertions, 1 deletions
diff --git a/nix/scripts/list-runtime-roots.in b/nix/scripts/list-runtime-roots.in
index 6f0e7f5b6a..001d25c577 100644
--- a/nix/scripts/list-runtime-roots.in
+++ b/nix/scripts/list-runtime-roots.in
@@ -26,6 +26,7 @@
(use-modules (ice-9 ftw)
(ice-9 regex)
(ice-9 rdelim)
+ (ice-9 match)
(srfi srfi-1)
(srfi srfi-26)
(rnrs io ports))
@@ -126,5 +127,18 @@ or the empty list."
(lambda (a b)
(< (string->number a) (string->number b))))))
+(define canonicalize-store-item
+ (let ((prefix (+ 1 (string-length %store-directory))))
+ (lambda (file)
+ "Return #f if FILE is not a store item; otherwise, return the store file
+name without any sub-directory components."
+ (and (string-prefix? %store-directory file)
+ (string-append %store-directory "/"
+ (let ((base (string-drop file prefix)))
+ (match (string-index base #\/)
+ (#f base)
+ (slash (string-take base slash)))))))))
+
(for-each (cut simple-format #t "~a~%" <>)
- (delete-duplicates (referenced-files)))
+ (delete-duplicates
+ (filter-map canonicalize-store-item (referenced-files))))