2019-03-28 00:40:35 +02:00
|
|
|
#include "builtins.hh"
|
2019-09-11 14:10:46 +03:00
|
|
|
#include "tarfile.hh"
|
2019-03-28 00:40:35 +02:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
void builtinUnpackChannel(const BasicDerivation & drv)
|
|
|
|
{
|
2022-02-25 17:00:00 +02:00
|
|
|
auto getAttr = [&](const std::string & name) {
|
2019-03-28 00:40:35 +02:00
|
|
|
auto i = drv.env.find(name);
|
|
|
|
if (i == drv.env.end()) throw Error("attribute '%s' missing", name);
|
|
|
|
return i->second;
|
|
|
|
};
|
|
|
|
|
|
|
|
Path out = getAttr("out");
|
|
|
|
auto channelName = getAttr("channelName");
|
|
|
|
auto src = getAttr("src");
|
|
|
|
|
|
|
|
createDirs(out);
|
|
|
|
|
2019-09-11 16:25:43 +03:00
|
|
|
unpackTarfile(src, out);
|
2019-03-28 00:40:35 +02:00
|
|
|
|
|
|
|
auto entries = readDirectory(out);
|
|
|
|
if (entries.size() != 1)
|
|
|
|
throw Error("channel tarball '%s' contains more than one file", src);
|
2022-04-13 15:10:36 +03:00
|
|
|
renameFile((out + "/" + entries[0].name), (out + "/" + channelName));
|
2019-03-28 00:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|