Compare commits
No commits in common. "ee1234c15cdcb427dbd4828e0add09d02cd606c9" and "799441dcf6d595efb0def686ca0815aef398627b" have entirely different histories.
ee1234c15c
...
799441dcf6
14
flake.lock
14
flake.lock
|
@ -48,11 +48,11 @@
|
||||||
"pre-commit-hooks": "pre-commit-hooks"
|
"pre-commit-hooks": "pre-commit-hooks"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1728163191,
|
"lastModified": 1725228396,
|
||||||
"narHash": "sha256-SW0IEBsPN1EysqzvfDT+8Kimtzy03O1BxQQm7ZB6fRY=",
|
"narHash": "sha256-QBXwqyPuHUKBiuyzHBxqH/MpjPY9DQiY2M81P2t6b/0=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "ed9b7f4f84fd60ad8618645cc1bae2d686ff0db6",
|
"rev": "02eb07cfd539c34c080cb1baf042e5e780c1fcc2",
|
||||||
"revCount": 16323,
|
"revCount": 16214,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.lix.systems/lix-project/lix"
|
"url": "https://git.lix.systems/lix-project/lix"
|
||||||
},
|
},
|
||||||
|
@ -126,11 +126,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1728193676,
|
"lastModified": 1725001927,
|
||||||
"narHash": "sha256-PbDWAIjKJdlVg+qQRhzdSor04bAPApDqIv2DofTyynk=",
|
"narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6",
|
"rev": "6e99f2a27d600612004fbd2c3282d614bfee6421",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "error.hh"
|
|
||||||
#include "state.hh"
|
#include "state.hh"
|
||||||
#include "hydra-build-result.hh"
|
#include "hydra-build-result.hh"
|
||||||
#include "finally.hh"
|
#include "finally.hh"
|
||||||
|
@ -186,7 +185,7 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
|
||||||
unlink(result.logFile.c_str());
|
unlink(result.logFile.c_str());
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
ignoreExceptionInDestructor();
|
ignoreException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,37 +7,8 @@
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
|
|
||||||
struct Extractor : NARParseVisitor
|
struct Extractor : ParseSink
|
||||||
{
|
{
|
||||||
class MyFileHandle : public FileHandle
|
|
||||||
{
|
|
||||||
NarMemberData & memberData;
|
|
||||||
uint64_t expectedSize;
|
|
||||||
std::unique_ptr<HashSink> hashSink;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MyFileHandle(NarMemberData & memberData, uint64_t size) : memberData(memberData), expectedSize(size)
|
|
||||||
{
|
|
||||||
hashSink = std::make_unique<HashSink>(HashType::SHA256);
|
|
||||||
}
|
|
||||||
|
|
||||||
void receiveContents(std::string_view data) override
|
|
||||||
{
|
|
||||||
*memberData.fileSize += data.size();
|
|
||||||
(*hashSink)(data);
|
|
||||||
if (memberData.contents) {
|
|
||||||
memberData.contents->append(data);
|
|
||||||
}
|
|
||||||
assert(memberData.fileSize <= expectedSize);
|
|
||||||
if (memberData.fileSize == expectedSize) {
|
|
||||||
auto [hash, len] = hashSink->finish();
|
|
||||||
assert(memberData.fileSize == len);
|
|
||||||
memberData.sha256 = hash;
|
|
||||||
hashSink.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unordered_set<Path> filesToKeep {
|
std::unordered_set<Path> filesToKeep {
|
||||||
"/nix-support/hydra-build-products",
|
"/nix-support/hydra-build-products",
|
||||||
"/nix-support/hydra-release-name",
|
"/nix-support/hydra-release-name",
|
||||||
|
@ -45,6 +16,7 @@ struct Extractor : NARParseVisitor
|
||||||
};
|
};
|
||||||
|
|
||||||
NarMemberDatas & members;
|
NarMemberDatas & members;
|
||||||
|
NarMemberData * curMember = nullptr;
|
||||||
Path prefix;
|
Path prefix;
|
||||||
|
|
||||||
Extractor(NarMemberDatas & members, Path prefix)
|
Extractor(NarMemberDatas & members, Path prefix)
|
||||||
|
@ -56,15 +28,41 @@ struct Extractor : NARParseVisitor
|
||||||
members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tDirectory });
|
members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tDirectory });
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<FileHandle> createRegularFile(const Path & path, uint64_t size, bool executable) override
|
void createRegularFile(const Path & path) override
|
||||||
{
|
{
|
||||||
auto memberData = &members.insert_or_assign(prefix + path, NarMemberData {
|
curMember = &members.insert_or_assign(prefix + path, NarMemberData {
|
||||||
.type = FSAccessor::Type::tRegular,
|
.type = FSAccessor::Type::tRegular,
|
||||||
.fileSize = 0,
|
.fileSize = 0,
|
||||||
.contents = filesToKeep.count(path) ? std::optional("") : std::nullopt,
|
.contents = filesToKeep.count(path) ? std::optional("") : std::nullopt,
|
||||||
}).first->second;
|
}).first->second;
|
||||||
|
}
|
||||||
|
|
||||||
return std::make_unique<MyFileHandle>(*memberData, size);
|
std::optional<uint64_t> expectedSize;
|
||||||
|
std::unique_ptr<HashSink> hashSink;
|
||||||
|
|
||||||
|
void preallocateContents(uint64_t size) override
|
||||||
|
{
|
||||||
|
expectedSize = size;
|
||||||
|
hashSink = std::make_unique<HashSink>(HashType::SHA256);
|
||||||
|
}
|
||||||
|
|
||||||
|
void receiveContents(std::string_view data) override
|
||||||
|
{
|
||||||
|
assert(expectedSize);
|
||||||
|
assert(curMember);
|
||||||
|
assert(hashSink);
|
||||||
|
*curMember->fileSize += data.size();
|
||||||
|
(*hashSink)(data);
|
||||||
|
if (curMember->contents) {
|
||||||
|
curMember->contents->append(data);
|
||||||
|
}
|
||||||
|
assert(curMember->fileSize <= expectedSize);
|
||||||
|
if (curMember->fileSize == expectedSize) {
|
||||||
|
auto [hash, len] = hashSink->finish();
|
||||||
|
assert(curMember->fileSize == len);
|
||||||
|
curMember->sha256 = hash;
|
||||||
|
hashSink.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void createSymlink(const Path & path, const std::string & target) override
|
void createSymlink(const Path & path, const std::string & target) override
|
||||||
|
|
Loading…
Reference in a new issue