2022-01-17 18:45:21 +00:00
|
|
|
#include "command.hh"
|
|
|
|
#include "shared.hh"
|
|
|
|
#include "store-api.hh"
|
2022-03-09 15:27:48 +00:00
|
|
|
#include "store-cast.hh"
|
2022-03-08 18:20:39 +00:00
|
|
|
#include "log-store.hh"
|
2022-01-17 18:45:21 +00: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 15:27:48 +00:00
|
|
|
auto & srcLogStore = require<LogStore>(*srcStore);
|
2022-03-08 18:20:39 +00:00
|
|
|
|
2022-01-17 18:45:21 +00:00
|
|
|
auto dstStore = getDstStore();
|
2022-03-09 15:27:48 +00:00
|
|
|
auto & dstLogStore = require<LogStore>(*dstStore);
|
2022-01-17 18:45:21 +00:00
|
|
|
|
2022-12-15 21:09:32 +00:00
|
|
|
for (auto & drvPath : Installable::toDerivations(getEvalStore(), installables, true)) {
|
2022-03-08 18:20:39 +00:00
|
|
|
if (auto log = srcLogStore.getBuildLog(drvPath))
|
|
|
|
dstLogStore.addBuildLog(drvPath, *log);
|
2022-01-17 18:45:21 +00:00
|
|
|
else
|
2022-01-18 16:28:18 +00:00
|
|
|
throw Error("build log for '%s' is not available", srcStore->printStorePath(drvPath));
|
2022-01-17 18:45:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static auto rCmdCopyLog = registerCommand2<CmdCopyLog>({"store", "copy-log"});
|