forked from lix-project/lix
* `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
This commit is contained in:
parent
c364d5d1e3
commit
ae6bf87273
|
@ -614,11 +614,6 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
|
||||||
if (!options.ignoreLiveness)
|
if (!options.ignoreLiveness)
|
||||||
addAdditionalRoots(state.roots);
|
addAdditionalRoots(state.roots);
|
||||||
|
|
||||||
if (options.action == GCOptions::gcReturnRoots) {
|
|
||||||
results.paths = state.roots;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read the temporary roots. This acquires read locks on all
|
/* Read the temporary roots. This acquires read locks on all
|
||||||
per-process temporary root files. So after this point no paths
|
per-process temporary root files. So after this point no paths
|
||||||
can be added to the set of temporary roots. */
|
can be added to the set of temporary roots. */
|
||||||
|
|
|
@ -22,10 +22,6 @@ struct GCOptions
|
||||||
{
|
{
|
||||||
/* Garbage collector operation:
|
/* Garbage collector operation:
|
||||||
|
|
||||||
- `gcReturnRoots': find and return the set of roots for the
|
|
||||||
garbage collector. These are the store paths symlinked to in
|
|
||||||
the `gcroots' directory.
|
|
||||||
|
|
||||||
- `gcReturnLive': return the set of paths reachable from
|
- `gcReturnLive': return the set of paths reachable from
|
||||||
(i.e. in the closure of) the roots.
|
(i.e. in the closure of) the roots.
|
||||||
|
|
||||||
|
@ -38,7 +34,6 @@ struct GCOptions
|
||||||
`pathsToDelete', insofar as they are not reachable.
|
`pathsToDelete', insofar as they are not reachable.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
gcReturnRoots,
|
|
||||||
gcReturnLive,
|
gcReturnLive,
|
||||||
gcReturnDead,
|
gcReturnDead,
|
||||||
gcDeleteDead,
|
gcDeleteDead,
|
||||||
|
|
|
@ -520,6 +520,7 @@ struct PrintFreed
|
||||||
|
|
||||||
static void opGC(Strings opFlags, Strings opArgs)
|
static void opGC(Strings opFlags, Strings opArgs)
|
||||||
{
|
{
|
||||||
|
bool printRoots = false;
|
||||||
GCOptions options;
|
GCOptions options;
|
||||||
options.action = GCOptions::gcDeleteDead;
|
options.action = GCOptions::gcDeleteDead;
|
||||||
|
|
||||||
|
@ -527,7 +528,7 @@ static void opGC(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
/* Do what? */
|
/* Do what? */
|
||||||
foreach (Strings::iterator, i, opFlags)
|
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-live") options.action = GCOptions::gcReturnLive;
|
||||||
else if (*i == "--print-dead") options.action = GCOptions::gcReturnDead;
|
else if (*i == "--print-dead") options.action = GCOptions::gcReturnDead;
|
||||||
else if (*i == "--delete") options.action = GCOptions::gcDeleteDead;
|
else if (*i == "--delete") options.action = GCOptions::gcDeleteDead;
|
||||||
|
@ -540,12 +541,20 @@ static void opGC(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
if (!opArgs.empty()) throw UsageError("no arguments expected");
|
if (!opArgs.empty()) throw UsageError("no arguments expected");
|
||||||
|
|
||||||
|
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);
|
PrintFreed freed(options.action == GCOptions::gcDeleteDead, results);
|
||||||
store->collectGarbage(options, results);
|
store->collectGarbage(options, results);
|
||||||
|
|
||||||
if (options.action != GCOptions::gcDeleteDead)
|
if (options.action != GCOptions::gcDeleteDead)
|
||||||
foreach (PathSet::iterator, i, results.paths)
|
foreach (PathSet::iterator, i, results.paths)
|
||||||
cout << *i << std::endl;
|
cout << *i << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue