From 881feb96987dace75f983c16fec1013b70602d4f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 21 Feb 2007 17:57:59 +0000 Subject: [PATCH] * Flag `--print-invalid' in `nix-store --check-validity' to print out which paths specified on the command line are invalid (i.e., don't barf when encountering an invalid path, just print it). This is useful for build-remote.pl to figure out which paths need to be copied to a remote machine. (Currently we use rsync, but that's rather inefficient.) --- src/nix-store/nix-store.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index 61ae4cf4f..6399c0974 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -537,12 +537,23 @@ static void opRegisterValidity(Strings opFlags, Strings opArgs) static void opCheckValidity(Strings opFlags, Strings opArgs) { - if (!opFlags.empty()) throw UsageError("unknown flag"); + bool printInvalid = false; + + for (Strings::iterator i = opFlags.begin(); + i != opFlags.end(); ++i) + if (*i == "--print-invalid") printInvalid = true; + else throw UsageError(format("unknown flag `%1%'") % *i); for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); ++i) - if (!store->isValidPath(*i)) - throw Error(format("path `%1%' is not valid") % *i); + { + Path path = fixPath(*i); + if (!store->isValidPath(path)) + if (printInvalid) + cout << format("%1%\n") % path; + else + throw Error(format("path `%1%' is not valid") % path); + } }