2017-03-13 14:38:29 +02:00
|
|
|
#include "command.hh"
|
|
|
|
#include "common-args.hh"
|
|
|
|
#include "shared.hh"
|
|
|
|
#include "store-api.hh"
|
|
|
|
|
|
|
|
using namespace nix;
|
|
|
|
|
2017-04-25 13:06:32 +03:00
|
|
|
struct CmdLog : InstallablesCommand
|
2017-03-13 14:38:29 +02: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 12:20:37 +03:00
|
|
|
for (auto & inst : installables) {
|
2017-07-14 18:10:13 +03:00
|
|
|
for (auto & b : inst->toBuildable()) {
|
|
|
|
auto path = b.second.drvPath != "" ? b.second.drvPath : b.first;
|
2017-04-25 12:20:37 +03: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 14:27:57 +03:00
|
|
|
throw Error("build log of path '%s' is not available", path);
|
2017-03-13 14:38:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static RegisterCommand r1(make_ref<CmdLog>());
|