diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2009-11-23 17:23:12 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2009-11-23 17:23:12 +0000 |
commit | ae6bf87273b30258408dc292611f3f50015b843c (patch) | |
tree | 78c8140f4d93888ab927dd9db317dfd21981ebc5 /src/nix-store/nix-store.cc | |
parent | c364d5d1e36a9f790b0d610aae1d30d8732b58ce (diff) | |
download | guix-ae6bf87273b30258408dc292611f3f50015b843c.tar.gz |
* `nix-store --gc --print-roots': also print the path of the actual
root symlink, not just its target. E.g.: /nix/var/nix/profiles/system-99-link -> /nix/store/76kwf88657nq7wgk1hx3l1z5q91zb9wd-system
Diffstat (limited to 'src/nix-store/nix-store.cc')
-rw-r--r-- | src/nix-store/nix-store.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index 3740d0bf95..b951393092 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -520,6 +520,7 @@ struct PrintFreed static void opGC(Strings opFlags, Strings opArgs) { + bool printRoots = false; GCOptions options; options.action = GCOptions::gcDeleteDead; @@ -527,7 +528,7 @@ static void opGC(Strings opFlags, Strings opArgs) /* Do what? */ foreach (Strings::iterator, i, opFlags) - if (*i == "--print-roots") options.action = GCOptions::gcReturnRoots; + if (*i == "--print-roots") printRoots = true; else if (*i == "--print-live") options.action = GCOptions::gcReturnLive; else if (*i == "--print-dead") options.action = GCOptions::gcReturnDead; else if (*i == "--delete") options.action = GCOptions::gcDeleteDead; @@ -539,13 +540,21 @@ static void opGC(Strings opFlags, Strings opArgs) else throw UsageError(format("bad sub-operation `%1%' in GC") % *i); if (!opArgs.empty()) throw UsageError("no arguments expected"); - - PrintFreed freed(options.action == GCOptions::gcDeleteDead, results); - store->collectGarbage(options, results); - if (options.action != GCOptions::gcDeleteDead) - foreach (PathSet::iterator, i, results.paths) - cout << *i << std::endl; + if (printRoots) { + Roots roots = store->findRoots(); + foreach (Roots::iterator, i, roots) + cout << i->first << " -> " << i->second << std::endl; + } + + else { + PrintFreed freed(options.action == GCOptions::gcDeleteDead, results); + store->collectGarbage(options, results); + + if (options.action != GCOptions::gcDeleteDead) + foreach (PathSet::iterator, i, results.paths) + cout << *i << std::endl; + } } |