From e63ec85809b0428446c723f6cc79ea444a6dfcb4 Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Sat, 5 Dec 2026 10:45:59 +0300 Subject: [PATCH] fix(install): stream DEB members; extend the VoidLibrary build branch --- contrib/voidlibrary-migration/build.cpp | 10 ++ .../voidlibrary-migration/build.profiles.cpp | 8 ++ docs/agent-workflow/STATE.md | 2 + docs/agent-workflow/TASKS.md | 1 + src/Install/Installer.cpp | 110 +++++++++++++++--- 5 files changed, 112 insertions(+), 19 deletions(-) create mode 100644 contrib/voidlibrary-migration/build.profiles.cpp diff --git a/contrib/voidlibrary-migration/build.cpp b/contrib/voidlibrary-migration/build.cpp index 78ce995..38c5f9a 100644 --- a/contrib/voidlibrary-migration/build.cpp +++ b/contrib/voidlibrary-migration/build.cpp @@ -33,6 +33,16 @@ void build(Void::Build::Project &project) { .link_option("-ldl", Void::Build::Visibility::Public); } + // Install/packaging rules: module archives, public headers and license metadata. + for (auto &[name, target] : libs.modules) { + if (target.record().kind == Void::Build::TargetKind::HeaderOnly) { + continue; + } + target.install("lib"); + } + project.install_directory("include", "include"); + project.install_file("README.md", "share/doc/VoidLibrary"); + // Smoke test exercising the native VoidLibrary closure through VBS. auto smoke = project.test("void_smoke"); smoke.cxx_standard(Void::Build::CxxStandard::Cxx26) diff --git a/contrib/voidlibrary-migration/build.profiles.cpp b/contrib/voidlibrary-migration/build.profiles.cpp new file mode 100644 index 0000000..1564dcc --- /dev/null +++ b/contrib/voidlibrary-migration/build.profiles.cpp @@ -0,0 +1,8 @@ +#include + +// VoidLibrary native profiles: debug (default) and release, plus an optimized +// "relwithdebinfo" variant useful for sanitizer and benchmark runs. +void profiles(Void::Build::Profiles &descriptions) { + descriptions = Void::Build::default_profiles(); + descriptions.add("relwithdebinfo", {"-O2", "-g"}); +} diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index 7c91741..cd7eaab 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -330,6 +330,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - **Wave 118 (VoidLibrary In-Repo Build Description)**: pushed branch `build-vbs` to Void/Library containing `build.cpp`, `build-support/vl/VoidLibraryModules.{hpp,cpp}` and `tests/vl/smoke.cpp` (all 57 modules, verified in the clone: 134 actions and a passing smoke test). [Void/Library#61](https://git.faumaray.com/Void/Library/issues/61) was updated with the branch, verification details and the remaining CI/install work; `contrib/voidlibrary-migration/` now mirrors the exact pushed files. +- **Wave 119 (VoidLibrary Install/Packaging Rules & Profiles)**: added install rules (module archives to `lib`, headers, documentation), a `build.profiles.cpp` (default profiles plus `relwithdebinfo`) to the `build-vbs` branch, and verified a full `vbs install` of VoidLibrary (320 files) plus a 185 MB DEB accepted by `dpkg-deb`. VoidLibrary has no LICENSE file, so [Void/Library#63](https://git.faumaray.com/Void/Library/issues/63) was filed. The DEB writer now streams members (a 16 MiB read limit was hit on the large payload). + ## Remaining future scope - **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order. diff --git a/docs/agent-workflow/TASKS.md b/docs/agent-workflow/TASKS.md index f031586..6e66b0d 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -121,4 +121,5 @@ Base HEAD: `fe0d1a6` | Wave 115 (Zed extension repo) | `vbs ide plugin --editor zed` emits extension.toml/tasks.json/README; published to `Void/VbsZed` | COMPLETE & VERIFIED (unit test passes; repo contents confirmed via the Gitea API) | `src/Editor/CompDb.cpp`, `tests/FullV1Tests.cpp`, [Void/VbsZed](https://git.faumaray.com/Void/VbsZed), docs | | Wave 116 (CLion extension repo) | `vbs ide plugin --editor clion` emits a JetBrains plugin skeleton; published to `Void/VbsCLion` | COMPLETE & VERIFIED (unit test passes; repo contents confirmed via the Gitea API; full CTest 8/8) | `src/Editor/CompDb.cpp`, `tests/FullV1Tests.cpp`, [Void/VbsCLion](https://git.faumaray.com/Void/VbsCLion), docs | | Wave 118 (VoidLibrary in-repo build description) | Branch `build-vbs` in Void/Library with build.cpp + module table + smoke test; #61 updated | PUSHED & VERIFIED IN CLONE (branch content confirmed via Gitea API) | [Void/Library branch build-vbs](https://git.faumaray.com/Void/Library/src/branch/build-vbs), `contrib/voidlibrary-migration/`, Void/Library#61 | +| Wave 119 (VoidLibrary install rules + profiles) | install rules, `build.profiles.cpp`, verified 320-file prefix and a dpkg-valid DEB; streaming DEB writer; LICENSE issue #63 | COMPLETE & VERIFIED IN CLONE | `contrib/voidlibrary-migration/`, [Void/Library build-vbs](https://git.faumaray.com/Void/Library/src/branch/build-vbs), `src/Install/Installer.cpp`, Void/Library#63 | | Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) | diff --git a/src/Install/Installer.cpp b/src/Install/Installer.cpp index 14882b2..467ba51 100644 --- a/src/Install/Installer.cpp +++ b/src/Install/Installer.cpp @@ -12,6 +12,8 @@ #include #include +#include +#include #include #include #include @@ -166,26 +168,78 @@ write_stored_zip(const std::filesystem::path &output, return Platform::atomic_write_file(output, zip, true); } -void append_ar_member(std::string &out, std::string_view name, std::string_view data) { +std::string ar_member_header(std::string_view name, std::uint64_t size) { std::string header; std::string padded_name{name}; padded_name.push_back('/'); header.reserve(60); header += padded_name; header.resize(16, ' '); - header += std::format("{:<12}", 0); // mtime - header += std::format("{:<6}", 0); // uid - header += std::format("{:<6}", 0); // gid - header += std::format("{:<8}", 100644); // mode - header += std::format("{:<10}", data.size()); // size + header += std::format("{:<12}", 0); // mtime + header += std::format("{:<6}", 0); // uid + header += std::format("{:<6}", 0); // gid + header += std::format("{:<8}", 100644); // mode + header += std::format("{:<10}", size); // size header += "`\n"; - out += header; + return header; +} + +void append_ar_member(std::string &out, std::string_view name, std::string_view data) { + out += ar_member_header(name, data.size()); out += data; if (data.size() % 2 != 0) { out.push_back('\n'); } } +void append_ar_member_to_stream(std::ostream &out, std::string_view name, + std::string_view data) { + out << ar_member_header(name, data.size()); + out.write(data.data(), static_cast(data.size())); + if (data.size() % 2 != 0) { + out.put('\n'); + } +} + +// Streams a file into an ar member so payloads of any size bypass read limits. +Void::Result::Result +append_ar_member_file(std::ostream &out, std::string_view name, + const std::filesystem::path &source) { + std::error_code ec; + const auto size = std::filesystem::file_size(source, ec); + if (ec) { + return std::unexpected{Void::System::make_system_error( + Void::System::map_errno_to_system_code(ec.value()), + std::format("cannot stat '{}': {}", source.string(), ec.message()), ec.value())}; + } + std::ifstream in{source, std::ios::binary}; + if (!in) { + return std::unexpected{Void::System::make_system_error( + Void::System::SystemErrorCode::io_error, + std::format("cannot open '{}'", source.string()))}; + } + out << ar_member_header(name, size); + std::array buffer{}; + std::uint64_t copied = 0; + while (in) { + in.read(buffer.data(), static_cast(buffer.size())); + const auto count = in.gcount(); + if (count > 0) { + out.write(buffer.data(), count); + copied += static_cast(count); + } + } + if (copied != size) { + return std::unexpected{Void::System::make_system_error( + Void::System::SystemErrorCode::io_error, + std::format("short read while archiving '{}'", source.string()))}; + } + if (size % 2 != 0) { + out.put('\n'); + } + return {}; +} + // ── Minimal native RPM writer (uncompressed newc cpio payload) ────────────────────────────── namespace rpm { @@ -480,20 +534,38 @@ write_deb_package(const std::filesystem::path &output, const InstallOptions &opt return std::unexpected{control.error()}; } - auto data_bytes = Void::FileSystem::read_file(data_tar); - if (!data_bytes) { - return std::unexpected{data_bytes.error()}; + // Stream the members: package payloads can exceed in-memory read limits. + const auto temp_deb = output.parent_path() / (output.filename().string() + ".tmp"); + std::ofstream deb{temp_deb, std::ios::binary | std::ios::trunc}; + if (!deb) { + return std::unexpected{Void::System::make_system_error( + Void::System::SystemErrorCode::io_error, + std::format("cannot create '{}'", temp_deb.string()))}; } - auto control_bytes = Void::FileSystem::read_file(control_tar); - if (!control_bytes) { - return std::unexpected{control_bytes.error()}; + deb << "!\n"; + append_ar_member_to_stream(deb, "debian-binary", "2.0\n"); + if (auto member = append_ar_member_file(deb, "control.tar", control_tar); !member) { + return std::unexpected{member.error()}; } - - std::string deb = "!\n"; - append_ar_member(deb, "debian-binary", "2.0\n"); - append_ar_member(deb, "control.tar", *control_bytes); - append_ar_member(deb, "data.tar", *data_bytes); - return Platform::atomic_write_file(output, deb, true); + if (auto member = append_ar_member_file(deb, "data.tar", data_tar); !member) { + return std::unexpected{member.error()}; + } + deb.flush(); + deb.close(); + if (!deb) { + return std::unexpected{Void::System::make_system_error( + Void::System::SystemErrorCode::io_error, + std::format("failed writing '{}'", temp_deb.string()))}; + } + std::error_code rename_ec; + std::filesystem::rename(temp_deb, output, rename_ec); + if (rename_ec) { + return std::unexpected{Void::System::make_system_error( + Void::System::map_errno_to_system_code(rename_ec.value()), + std::format("cannot publish '{}': {}", output.string(), rename_ec.message()), + rename_ec.value())}; + } + return {}; } // Canonical short message signed for installer archives (independent of archive size).