nix-copy-closure: Use computeFSClosure() and LegacySSHStore
This commit is contained in:
parent
6f4682ad36
commit
4724903c78
1 changed files with 11 additions and 12 deletions
|
@ -7,13 +7,15 @@ int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
return handleExceptions(argv[0], [&]() {
|
return handleExceptions(argv[0], [&]() {
|
||||||
initNix();
|
initNix();
|
||||||
|
|
||||||
auto gzip = false;
|
auto gzip = false;
|
||||||
auto toMode = true;
|
auto toMode = true;
|
||||||
auto includeOutputs = false;
|
auto includeOutputs = false;
|
||||||
auto dryRun = false;
|
auto dryRun = false;
|
||||||
auto useSubstitutes = false;
|
auto useSubstitutes = false;
|
||||||
auto sshHost = string{};
|
std::string sshHost;
|
||||||
auto storePaths = PathSet{};
|
PathSet storePaths;
|
||||||
|
|
||||||
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||||
if (*arg == "--help")
|
if (*arg == "--help")
|
||||||
showManPage("nix-copy-closure");
|
showManPage("nix-copy-closure");
|
||||||
|
@ -41,20 +43,17 @@ int main(int argc, char ** argv)
|
||||||
storePaths.insert(*arg);
|
storePaths.insert(*arg);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (sshHost.empty())
|
if (sshHost.empty())
|
||||||
throw UsageError("no host name specified");
|
throw UsageError("no host name specified");
|
||||||
|
|
||||||
auto remoteUri = "ssh://" + sshHost + (gzip ? "?compress=true" : "");
|
auto remoteUri = "legacy-ssh://" + sshHost + (gzip ? "?compress=true" : "");
|
||||||
auto to = toMode ? openStore(remoteUri) : openStore();
|
auto to = toMode ? openStore(remoteUri) : openStore();
|
||||||
auto from = toMode ? openStore() : openStore(remoteUri);
|
auto from = toMode ? openStore() : openStore(remoteUri);
|
||||||
if (includeOutputs) {
|
|
||||||
auto newPaths = PathSet{};
|
PathSet closure;
|
||||||
for (const auto & p : storePaths) {
|
from->computeFSClosure(storePaths, closure, false, includeOutputs);
|
||||||
auto outputs = from->queryDerivationOutputs(p);
|
|
||||||
newPaths.insert(outputs.begin(), outputs.end());
|
copyPaths(from, to, Paths(closure.begin(), closure.end()), useSubstitutes);
|
||||||
}
|
|
||||||
storePaths.insert(newPaths.begin(), newPaths.end());
|
|
||||||
}
|
|
||||||
copyPaths(from, to, Paths(storePaths.begin(), storePaths.end()), useSubstitutes);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue