2017-03-13 13:38:29 +01:00
|
|
|
#include "command.hh"
|
|
|
|
#include "common-args.hh"
|
|
|
|
#include "shared.hh"
|
|
|
|
#include "store-api.hh"
|
|
|
|
|
|
|
|
using namespace nix;
|
|
|
|
|
2017-04-25 12:06:32 +02:00
|
|
|
struct CmdLog : InstallablesCommand
|
2017-03-13 13:38:29 +01:00
|
|
|
{
|
|
|
|
CmdLog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string name() override
|
|
|
|
{
|
|
|
|
return "log";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string description() override
|
|
|
|
{
|
|
|
|
return "show the build log of the specified packages or paths";
|
|
|
|
}
|
|
|
|
|
|
|
|
void run(ref<Store> store) override
|
|
|
|
{
|
|
|
|
auto subs = getDefaultSubstituters();
|
|
|
|
|
|
|
|
subs.push_front(store);
|
|
|
|
|
2017-04-25 11:20:37 +02:00
|
|
|
for (auto & inst : installables) {
|
2017-07-14 17:10:13 +02:00
|
|
|
for (auto & b : inst->toBuildable()) {
|
|
|
|
auto path = b.second.drvPath != "" ? b.second.drvPath : b.first;
|
2017-04-25 11:20:37 +02:00
|
|
|
bool found = false;
|
|
|
|
for (auto & sub : subs) {
|
|
|
|
auto log = sub->getBuildLog(path);
|
|
|
|
if (!log) continue;
|
|
|
|
std::cout << *log;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!found)
|
2017-07-30 13:27:57 +02:00
|
|
|
throw Error("build log of path '%s' is not available", path);
|
2017-03-13 13:38:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static RegisterCommand r1(make_ref<CmdLog>());
|