2022-01-17 20:45:21 +02:00
|
|
|
#include "command.hh"
|
|
|
|
#include "shared.hh"
|
|
|
|
#include "store-api.hh"
|
2022-03-09 17:27:48 +02:00
|
|
|
#include "store-cast.hh"
|
2022-03-08 20:20:39 +02:00
|
|
|
#include "log-store.hh"
|
2022-01-17 20:45:21 +02:00
|
|
|
#include "sync.hh"
|
|
|
|
#include "thread-pool.hh"
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
|
|
|
|
using namespace nix;
|
|
|
|
|
|
|
|
struct CmdCopyLog : virtual CopyCommand, virtual InstallablesCommand
|
|
|
|
{
|
|
|
|
std::string description() override
|
|
|
|
{
|
|
|
|
return "copy build logs between Nix stores";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string doc() override
|
|
|
|
{
|
|
|
|
return
|
|
|
|
#include "store-copy-log.md"
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
Category category() override { return catUtility; }
|
|
|
|
|
|
|
|
void run(ref<Store> srcStore) override
|
|
|
|
{
|
2022-03-09 17:27:48 +02:00
|
|
|
auto & srcLogStore = require<LogStore>(*srcStore);
|
2022-03-08 20:20:39 +02:00
|
|
|
|
2022-01-17 20:45:21 +02:00
|
|
|
auto dstStore = getDstStore();
|
2022-03-09 17:27:48 +02:00
|
|
|
auto & dstLogStore = require<LogStore>(*dstStore);
|
2022-01-17 20:45:21 +02:00
|
|
|
|
2022-01-18 18:28:18 +02:00
|
|
|
StorePathSet drvPaths;
|
|
|
|
|
|
|
|
for (auto & i : installables)
|
|
|
|
for (auto & drvPath : i->toDrvPaths(getEvalStore()))
|
|
|
|
drvPaths.insert(drvPath);
|
|
|
|
|
|
|
|
for (auto & drvPath : drvPaths) {
|
2022-03-08 20:20:39 +02:00
|
|
|
if (auto log = srcLogStore.getBuildLog(drvPath))
|
|
|
|
dstLogStore.addBuildLog(drvPath, *log);
|
2022-01-17 20:45:21 +02:00
|
|
|
else
|
2022-01-18 18:28:18 +02:00
|
|
|
throw Error("build log for '%s' is not available", srcStore->printStorePath(drvPath));
|
2022-01-17 20:45:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static auto rCmdCopyLog = registerCommand2<CmdCopyLog>({"store", "copy-log"});
|