diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-02-21T17·57+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-02-21T17·57+0000 |
commit | 881feb96987dace75f983c16fec1013b70602d4f (patch) | |
tree | cc825dd8b26185f86ec446c69aa60e560f5a816d | |
parent | 65f195f4c7eec4f0880e7c3953aa5e78eeffbebf (diff) |
* 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.)
-rw-r--r-- | src/nix-store/nix-store.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index 61ae4cf4f925..6399c097468a 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); + } } |