From 450c358e2055488897349bf50951cce16ad9bc90 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 7 Feb 2005 13:40:40 +0000 Subject: * Maintain a database table (`derivers') that maps output paths to the derivation that produced them. * `nix-store -qd PATH' prints out the derivation that produced a path. --- src/nix-store/main.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/nix-store') diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc index d473475b821a..4b8d2cf3f75c 100644 --- a/src/nix-store/main.cc +++ b/src/nix-store/main.cc @@ -162,7 +162,7 @@ static void printPathSet(const PathSet & paths) static void opQuery(Strings opFlags, Strings opArgs) { enum { qOutputs, qRequisites, qReferences, qReferers, - qReferersClosure, qGraph } query = qOutputs; + qReferersClosure, qDeriver, qGraph } query = qOutputs; bool useOutput = false; bool includeOutputs = false; bool forceRealise = false; @@ -174,6 +174,7 @@ static void opQuery(Strings opFlags, Strings opArgs) else if (*i == "--references") query = qReferences; else if (*i == "--referers") query = qReferers; else if (*i == "--referers-closure") query = qReferersClosure; + else if (*i == "--deriver" || *i == "-d") query = qDeriver; else if (*i == "--graph") query = qGraph; else if (*i == "--use-output" || *i == "-u") useOutput = true; else if (*i == "--force-realise" || *i == "-f") forceRealise = true; @@ -214,6 +215,18 @@ static void opQuery(Strings opFlags, Strings opArgs) break; } + case qDeriver: + for (Strings::iterator i = opArgs.begin(); + i != opArgs.end(); i++) + { + *i = followSymlinks(*i); + Path deriver = queryDeriver(noTxn, *i); + cout << format("%1%\n") % + (deriver == "" ? "unknown-deriver" : deriver); + } + break; + + #if 0 case qGraph: { PathSet roots; @@ -288,7 +301,7 @@ static void opValidPath(Strings opFlags, Strings opArgs) createStoreTransaction(txn); for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); ++i) - registerValidPath(txn, *i, hashPath(htSHA256, *i), PathSet()); + registerValidPath(txn, *i, hashPath(htSHA256, *i), PathSet(), ""); txn.commit(); } -- cgit 1.4.1