feat(install): write UDIF/DMG-style containers
This commit is contained in:
1 parent
ac08887d8f
commit
1caeab70fa
7 files changed
+213
-4
No files matched your search
@@ -1091,6 +1091,52 @@ void build(Void::Build::Project &p) {
|
||||
Void::Testing::expect(wix_text->find("ComponentGroup Id=\"ProductComponents\"") !=
|
||||
std::string::npos);
|
||||
|
||||
// UDIF (DMG-style) container: tar payload followed by a 512-byte koly trailer.
|
||||
const auto dmg_archive = tmp / "cli_hi.dmg";
|
||||
auto dmg_req = inst_req;
|
||||
for (auto &arg : dmg_req.arguments) {
|
||||
if (arg == installer_archive.string()) {
|
||||
arg = dmg_archive.string();
|
||||
}
|
||||
}
|
||||
dmg_req.arguments.push_back("--archive-format");
|
||||
dmg_req.arguments.push_back("dmg");
|
||||
auto dmg_res = Platform::run_supervised(dmg_req);
|
||||
Void::Testing::expect(dmg_res.has_value() && dmg_res->succeeded());
|
||||
auto dmg_bytes = Void::FileSystem::read_file(dmg_archive);
|
||||
Void::Testing::require(dmg_bytes.has_value() && dmg_bytes->size() > 512);
|
||||
const auto dmg_length = dmg_bytes->size();
|
||||
const std::string koly = dmg_bytes->substr(dmg_length - 512);
|
||||
const auto read_be32 = [](std::string_view bytes, std::size_t offset) {
|
||||
std::uint32_t value = 0;
|
||||
for (std::size_t i = 0; i < 4; ++i) {
|
||||
value = (value << 8) | static_cast<unsigned char>(bytes[offset + i]);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
const auto read_be64 = [](std::string_view bytes, std::size_t offset) {
|
||||
std::uint64_t value = 0;
|
||||
for (std::size_t i = 0; i < 8; ++i) {
|
||||
value = (value << 8) | static_cast<unsigned char>(bytes[offset + i]);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
Void::Testing::expect(koly.starts_with("koly"));
|
||||
Void::Testing::expect_eq(read_be32(koly, 8), std::uint32_t{512});
|
||||
const std::uint64_t data_fork_length = read_be64(koly, 32);
|
||||
Void::Testing::expect_eq(data_fork_length, static_cast<std::uint64_t>(dmg_length - 512));
|
||||
Void::Testing::expect_eq(read_be32(koly, 80), std::uint32_t{2}); // CRC-32
|
||||
std::uint32_t crc = 0xFFFFFFFFu;
|
||||
for (const char ch : dmg_bytes->substr(0, data_fork_length)) {
|
||||
crc ^= static_cast<std::uint32_t>(static_cast<unsigned char>(ch));
|
||||
for (int bit = 0; bit < 8; ++bit) {
|
||||
crc = (crc >> 1) ^ (0xEDB88320u & (0u - (crc & 1u)));
|
||||
}
|
||||
}
|
||||
Void::Testing::expect_eq(read_be32(koly, 88), ~crc);
|
||||
Void::Testing::expect_eq(read_be64(koly, 492), (data_fork_length + 511) / 512);
|
||||
Void::Testing::expect(dmg_bytes->substr(257, 5) == "ustar"); // tar payload
|
||||
|
||||
// RPM package generator: lead + header magic + newc cpio payload.
|
||||
const auto rpm_archive = tmp / "cli_hi.rpm";
|
||||
auto rpm_req = inst_req;
|
||||
@@ -3051,6 +3097,26 @@ VOID_TEST(FullV1Tests, ide_integration_compdb_build_cpp_and_editor_configs_end_t
|
||||
const auto codemodel_file = get_string(*codemodel_entry, "jsonFile");
|
||||
Void::Testing::require(!codemodel_file.empty());
|
||||
|
||||
// The full reply set an IDE needs to load the project: cache, cmake files, toolchains.
|
||||
for (const auto &kind : {"cache-v2", "cmakeFiles-v1", "toolchains-v1"}) {
|
||||
const auto *entry = get_object(*reply, kind);
|
||||
Void::Testing::require(entry != nullptr);
|
||||
const auto file = get_string(*entry, "jsonFile");
|
||||
Void::Testing::require(!file.empty());
|
||||
const auto parsed = read_json(reply_dir / file);
|
||||
Void::Testing::require(parsed.has_value());
|
||||
const auto *object = std::get_if<JsonObject>(&parsed->value);
|
||||
Void::Testing::require(object != nullptr);
|
||||
Void::Testing::expect(!get_string(*object, "kind").empty());
|
||||
}
|
||||
const auto cache_file = get_string(*get_object(*reply, "cache-v2"), "jsonFile");
|
||||
const auto cache_json = read_json(reply_dir / cache_file);
|
||||
Void::Testing::require(cache_json.has_value());
|
||||
auto cache_text = Void::FileSystem::read_file(reply_dir / cache_file);
|
||||
Void::Testing::require(cache_text.has_value());
|
||||
Void::Testing::expect(cache_text->find("CMAKE_BUILD_TYPE") != std::string::npos);
|
||||
Void::Testing::expect(cache_text->find("CMAKE_CXX_COMPILER") != std::string::npos);
|
||||
|
||||
const auto codemodel_json = read_json(reply_dir / codemodel_file);
|
||||
Void::Testing::require(codemodel_json.has_value());
|
||||
const auto *codemodel_object = std::get_if<JsonObject>(&codemodel_json->value);
|
||||
|
||||
Reference in new issue
Block a user