Merge pull request #2579 from catern/dumpdb

nix-store: make --dump-db take a list of paths to dump
This commit is contained in:
Eelco Dolstra 2019-02-14 13:08:02 +01:00 committed by GitHub
commit d8fe447139
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View file

@ -1282,6 +1282,7 @@ ktorrent-2.2.1/NEWS
<cmdsynopsis> <cmdsynopsis>
<command>nix-store</command> <command>nix-store</command>
<arg choice='plain'><option>--dump-db</option></arg> <arg choice='plain'><option>--dump-db</option></arg>
<arg rep='repeat'><replaceable>paths</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
</refsection> </refsection>
@ -1292,6 +1293,13 @@ Nix database to standard output. It can be loaded into an empty Nix
store using <option>--load-db</option>. This is useful for making store using <option>--load-db</option>. This is useful for making
backups and when migrating to different database schemas.</para> backups and when migrating to different database schemas.</para>
<para>By default, <option>--dump-db</option> will dump the entire Nix
database. When one or more store paths is passed, only the subset of
the Nix database for those store paths is dumped. As with
<option>--export</option>, the user is responsible for passing all the
store paths for a closure. See <option>--export</option> for an
example.</para>
</refsection> </refsection>
</refsection> </refsection>

View file

@ -485,11 +485,16 @@ static void opReadLog(Strings opFlags, Strings opArgs)
static void opDumpDB(Strings opFlags, Strings opArgs) static void opDumpDB(Strings opFlags, Strings opArgs)
{ {
if (!opFlags.empty()) throw UsageError("unknown flag"); if (!opFlags.empty()) throw UsageError("unknown flag");
if (!opArgs.empty()) if (!opArgs.empty()) {
throw UsageError("no arguments expected"); for (auto & i : opArgs)
PathSet validPaths = store->queryAllValidPaths(); i = store->followLinksToStorePath(i);
for (auto & i : validPaths) for (auto & i : opArgs)
cout << store->makeValidityRegistration({i}, true, true); cout << store->makeValidityRegistration({i}, true, true);
} else {
PathSet validPaths = store->queryAllValidPaths();
for (auto & i : validPaths)
cout << store->makeValidityRegistration({i}, true, true);
}
} }