mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-16 03:06:17 +02:00
1db7d1b840
`nix::readDirectory` is removed. `std::filesystem::directory_iterator` is used directly in places that used this util.
32 lines
862 B
C++
32 lines
862 B
C++
#include "builtins.hh"
|
|
#include "tarfile.hh"
|
|
|
|
namespace nix {
|
|
|
|
void builtinUnpackChannel(
|
|
const BasicDerivation & drv,
|
|
const std::map<std::string, Path> & outputs)
|
|
{
|
|
auto getAttr = [&](const std::string & name) {
|
|
auto i = drv.env.find(name);
|
|
if (i == drv.env.end()) throw Error("attribute '%s' missing", name);
|
|
return i->second;
|
|
};
|
|
|
|
auto out = outputs.at("out");
|
|
auto channelName = getAttr("channelName");
|
|
auto src = getAttr("src");
|
|
|
|
createDirs(out);
|
|
|
|
unpackTarfile(src, out);
|
|
|
|
auto entries = std::filesystem::directory_iterator{out};
|
|
auto file_count = std::distance(entries, std::filesystem::directory_iterator{});
|
|
|
|
if (file_count != 1)
|
|
throw Error("channel tarball '%s' contains more than one file", src);
|
|
renameFile(entries->path().string(), (out + "/" + channelName));
|
|
}
|
|
|
|
}
|