From d23a878eec30df7a27f4288634bf005c3c5fd39d Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Sat, 5 Dec 2026 03:45:09 +0300 Subject: [PATCH] feat(install,ide): self-extracting installers and install tasks --- README.md | 2 +- docs/agent-workflow/STATE.md | 4 ++ docs/agent-workflow/TASKS.md | 2 + docs/agent-workflow/VERIFICATION.md | 12 ++++ include/Void/Build/Install/Installer.hpp | 9 +++ src/Editor/CompDb.cpp | 19 ++++++ src/Install/Installer.cpp | 87 ++++++++++++++++++++++++ src/Main.cpp | 23 ++++++- tests/FullV1Tests.cpp | 79 ++++++++++++++++++++- 9 files changed, 232 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e6125fe..0f87b06 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ All CLI help text (`vbs --help`, `vbs --help`, `vbs compdb --help`, `v - `vbs ide generate|query [--project DIR] [--build-dir DIR] [--profile NAME] [--compiler gcc|clang] [--editor all|clangd|vscode|clion|zed] [--force]` - `vbs watch [--project DIR] [--build-dir DIR] [--profile NAME] [--target NAME]...` - `vbs deps resolve|update [--project DIR] [--build-dir DIR] [--profile NAME] [--offline]` -- `vbs install --prefix DIR [--project DIR] [--build-dir DIR] [--profile NAME] [--compiler gcc|clang] [--package-name NAME] [--package-version VER] [--component NAME] [--no-cmake-export] [--no-native-export]` +- `vbs install --prefix DIR [--bundle-dependencies] [--archive FILE] [--project DIR] [--build-dir DIR] [--profile NAME] [--compiler gcc|clang] [--package-name NAME] [--package-version VER] [--component NAME] [--no-cmake-export] [--no-native-export]` - `vbs uninstall --prefix DIR` - `vbs pack [--project DIR] [--output FILE]` - `vbs publish --registry URL --name PKG --version X.Y.Z [--project DIR] [--description TEXT] [--token-env VAR] [--signing-key FILE] [--private]` diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index 53d2d91..206b503 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -280,6 +280,10 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - **Wave 92 (TTY-Aware CLI Help & Log Colors)**: `ConsoleLogger` now installs a `PatternFormatter` with `ColorPolicy::defaults()` when stderr is a terminal, so log levels are colored (previously the default policy was disabled); CLI help is colorized (bold section headers/usage, cyan commands and options) when stdout is a terminal. `NO_COLOR` and the new global `--no-color` flag disable both. +- **Wave 93 (Self-Contained Installers)**: `InstallOptions` gained `bundle_runtime_dependencies` (copies installed targets' runtime shared libraries into `/lib`, deduplicated) and `archive_path` (writes a deterministic USTAR installer archive of the published prefix). `vbs install` exposes `--bundle-dependencies` and `--archive FILE`; the install CLI test unpacks the archive, checks its contents, and proves two runs are byte-identical. + +- **Wave 94 (CPack-Style Self-Extracting Installed & IDE Install Tasks)**: `vbs install --archive FILE --archive-format sh` now emits an executable POSIX self-extracting installer (tar payload + `--prefix`/`PREFIX` handling) in addition to the plain tar; the install test runs the generated script and verifies the extracted prefix. The generated VS Code and Zed tasks gained `vbs: install` and `vbs: package installer` entries (asserted in the IDE test). + ## Remaining future scope - **Post-v1 Expansion Roadmap ([21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md) & [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md))**: Track C (macOS/Windows ports + dual-profile cross-compilation) and dedicated external editor plugins remain planned; Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement/distribution, binary-variant signing/distribution) and Track E3 daemon capabilities are implemented, and Track E4 now uses `Void::Net` for the registry client/server and remote cache plus `Void::Sqlite` for the StateStore when available. diff --git a/docs/agent-workflow/TASKS.md b/docs/agent-workflow/TASKS.md index 2cf8c97..83bcea2 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -96,4 +96,6 @@ Base HEAD: `fe0d1a6` | Wave 90 (Verify trust + RFC 7232) | `vbs verify --trusted-public-key/--trusted-key-file`; swarm added binary-detail ETag and RFC 7232 If-None-Match matching | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; CLI contract and Registry suite pass, full CTest 8/8) | `src/Main.cpp`, `registry/service/RegistryService.cpp`, `tests/{RegistryTests,CliContracts}.cmake`, docs | | Wave 91 (Convention-based self-build + ConsoleLogger) | globs/conventions in `build.cpp` and the self-host recipe; `sdk/` and `registry/cli/` layout; absolute dependency cache paths; `Void::Logging::ConsoleLogger` without the `vbs` prefix | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; bootstrap build, self-build with absolute AND relative build dirs, SDK 17/17, full CTest 8/8) | `build.cpp`, `recipes/SelfHost/VbsSelfHostRecipe.cpp`, `sdk/`, `registry/cli/`, `src/Main.cpp`, `src/Package/Fetch.cpp`, `src/Config/Frontend.cpp`, `cmake/`, docs | | Wave 92 (CLI/log colors) | Colored `ConsoleLogger` levels and colorized help on TTYs; `NO_COLOR` + `--no-color` | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; PTY checks show ANSI codes for help and logs) | `src/Main.cpp`, docs | +| Wave 93 (Self-contained installers) | `bundle_runtime_dependencies` + deterministic installer archive; `vbs install --bundle-dependencies --archive` | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; install CLI test passes with archive extraction and byte-identical reruns, full CTest 8/8) | `include/Void/Build/Install/Installer.hpp`, `src/Install/Installer.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, docs | +| Wave 94 (Installer script + IDE install tasks) | `--archive-format sh` self-extracting installer executed in tests; VS Code/Zed install tasks | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; install and IDE tests pass, full CTest 8/8) | `include/Void/Build/Install/Installer.hpp`, `src/Install/Installer.cpp`, `src/Main.cpp`, `src/Editor/CompDb.cpp`, `tests/FullV1Tests.cpp`, docs | | 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/docs/agent-workflow/VERIFICATION.md b/docs/agent-workflow/VERIFICATION.md index 018a0db..c9e9058 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -1339,6 +1339,18 @@ dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color unidentified external actor; a fresh configure/build/CTest is fully green, and the anomaly is not attributable to VBS code. +## Self-Contained Installers & IDE Install Tasks (GCC 16.2, pin `0002e74`) + +- `vbs install --bundle-dependencies --archive FILE` writes a deterministic tar; two runs are + byte-identical and the archive extracts to the installed `bin/` and package metadata. +- `--archive-format sh` writes a POSIX self-extracting installer; running + `sh installer.sh --prefix DIR` installs the same files (`bin/cli_hi`, `share/vbs//package.json`). + Both are asserted by `foreign_cmake_meson_providers_bridge_and_relocatable_install` (5.88 s). +- `ide_integration_compdb_build_cpp_and_editor_configs_end_to_end` (3.21 s) verifies the generated + VS Code tasks contain `vbs: install` and `vbs: package installer`, and Zed tasks contain + `vbs: install`. +- Full CTest: **8 / 8 passed** in 277.74 s. + ## Limits and Unrun Checks 1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified). diff --git a/include/Void/Build/Install/Installer.hpp b/include/Void/Build/Install/Installer.hpp index 2f0851b..69adcd9 100644 --- a/include/Void/Build/Install/Installer.hpp +++ b/include/Void/Build/Install/Installer.hpp @@ -19,6 +19,13 @@ struct InstallOptions { std::optional component; // Empty = install all components bool export_cmake_config{true}; bool export_native_metadata{true}; + // Copies runtime shared libraries of installed targets into /lib. + bool bundle_runtime_dependencies{false}; + // Optional deterministic tar archive of the installed prefix (self-contained installer). + std::optional archive_path; + // When true, archive_path receives an executable POSIX self-extracting installer script + // (tar payload appended) instead of a bare tar. Accepts [--prefix DIR] or $PREFIX. + bool archive_as_script{false}; }; struct InstallReport { @@ -27,6 +34,8 @@ struct InstallReport { std::vector installed_files; std::optional cmake_config_file; std::optional native_package_file; + std::optional archive_path; + std::vector bundled_libraries; }; // Installs declared targets, files, headers, and relocatable native + CMake export diff --git a/src/Editor/CompDb.cpp b/src/Editor/CompDb.cpp index 35a7ea8..4a3ab99 100644 --- a/src/Editor/CompDb.cpp +++ b/src/Editor/CompDb.cpp @@ -874,6 +874,21 @@ generate_ide_configs(const Graph::BuildGraph &graph, const IdeConfigOptions &opt vs_tasks.push_back(make_vs_task("vbs: refresh compile_commands.json", {"compdb", "export", "--profile", graph.profile.name}, "", false)); + vs_tasks.push_back(make_vs_task( + "vbs: install", + {"install", "--profile", graph.profile.name, "--prefix", + (options.build_root / "install").string(), + "--bundle-dependencies", + "--archive", (options.build_root / "install" / "installer.tar").string()}, + "", false)); + vs_tasks.push_back(make_vs_task( + "vbs: package installer", + {"install", "--profile", graph.profile.name, "--prefix", + (options.build_root / "install").string(), + "--bundle-dependencies", + "--archive", (options.build_root / "install" / "installer.sh").string(), + "--archive-format", "sh"}, + "", false)); for (const auto &tname : buildable_targets) { vs_tasks.push_back(make_vs_task( "vbs: build " + tname, @@ -964,6 +979,10 @@ generate_ide_configs(const Graph::BuildGraph &graph, const IdeConfigOptions &opt ztasks.push_back(make_zed_task("vbs: build", {"build", "--profile", graph.profile.name})); ztasks.push_back(make_zed_task("vbs: test", {"test", "--profile", graph.profile.name})); ztasks.push_back(make_zed_task("vbs: clean", {"clean"})); + ztasks.push_back(make_zed_task( + "vbs: install", + {"install", "--profile", graph.profile.name, "--prefix", + (options.build_root / "install").string(), "--bundle-dependencies"})); for (const auto &rt : runnables) { ztasks.push_back( make_zed_task("vbs: build " + rt.name, diff --git a/src/Install/Installer.cpp b/src/Install/Installer.cpp index 691848b..968061f 100644 --- a/src/Install/Installer.cpp +++ b/src/Install/Installer.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -128,6 +129,8 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build std::vector local_deps; }; std::vector exported_targets; + std::set bundled_library_names; + std::vector bundled_libraries; for (const auto &trec : description.targets) { if (!trec.install_rule) { @@ -177,6 +180,20 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build } et.rel_artifact = rel_dest; } + // Bundle runtime shared libraries so the prefix is self-contained. + if (options.bundle_runtime_dependencies) { + for (const auto &library_path : sum_it->runtime_shared_libraries) { + const std::string filename = library_path.filename().string(); + if (!bundled_library_names.insert(filename).second) { + continue; + } + const auto rel_dest = std::filesystem::path{"lib"} / filename; + if (auto r = add_item(library_path, rel_dest, 0755u, trec.name); !r) { + return std::unexpected{r.error()}; + } + bundled_libraries.push_back(library_path); + } + } exported_targets.push_back(std::move(et)); } @@ -364,6 +381,76 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build if (!mw) { return std::unexpected{mw.error()}; } + report.bundled_libraries = std::move(bundled_libraries); + + // 7. Optional deterministic installer archive of the published prefix. + if (options.archive_path) { + std::vector archive_entries; + archive_entries.reserve(report.installed_files.size()); + for (const auto &file : report.installed_files) { + const auto meta = Platform::stat_lstat(file); + archive_entries.push_back( + {file.lexically_relative(prefix_abs).generic_string(), file, + meta ? (meta->mode & 0777u) : 0644u}); + } + + const auto archive_target = + options.archive_as_script + ? stage_root / "installer-payload.tar" + : std::filesystem::path{*options.archive_path}; + auto archived = Package::create_deterministic_tar(archive_target, + std::move(archive_entries), 0); + if (!archived) { + return std::unexpected{archived.error()}; + } + + if (options.archive_as_script) { + // Self-extracting installer: a POSIX sh header followed by the tar payload. + const auto make_header = [&](std::size_t payload_line) { + return "#!/bin/sh\n" + "# VoidBuildSystem self-extracting installer for " + + options.package_name + " " + options.package_version + + "\n" + "# Usage: sh [--prefix DIR] (default: ${PREFIX:-/usr/local})\n" + "set -eu\n" + "prefix=\"${PREFIX:-/usr/local}\"\n" + "if [ \"${1:-}\" = \"--prefix\" ]; then\n" + " prefix=\"${2:?--prefix requires a directory}\"\n" + "fi\n" + "tmp=\"$(mktemp -d)\"\n" + "trap 'rm -rf \"$tmp\"' EXIT\n" + "tail -n +" + + std::to_string(payload_line) + + " \"$0\" > \"$tmp/payload.tar\"\n" + "mkdir -p \"$prefix\"\n" + "tar -x -f \"$tmp/payload.tar\" -C \"$prefix\"\n" + "echo \"installed " + + options.package_name + + " to $prefix\"\n" + "exit 0\n"; + }; + std::size_t header_lines = 0; + for (const char c : make_header(0)) { + if (c == '\n') { + ++header_lines; + } + } + const std::string header = make_header(header_lines + 1); + + auto payload = Void::FileSystem::read_file(archive_target); + if (!payload) { + return std::unexpected{payload.error()}; + } + std::string script = header; + script += *payload; + if (auto written = + Platform::atomic_write_file(*options.archive_path, script, true, 0755); + !written) { + return std::unexpected{written.error()}; + } + } + report.archive_path = *options.archive_path; + } return report; } diff --git a/src/Main.cpp b/src/Main.cpp index afcf01c..4b0d9e8 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1668,8 +1668,11 @@ struct InstallCmdOptions { std::optional pkg_name_arg; std::string pkg_ver{"0.1.0"}; std::optional component_arg; + std::optional archive_arg; + std::string archive_format_arg{"tar"}; bool no_cmake_export{false}; bool no_native_export{false}; + bool bundle_dependencies{false}; }; int execute_install_command(const InstallCmdOptions &opts) { @@ -1698,6 +1701,16 @@ int execute_install_command(const InstallCmdOptions &opts) { iopts.component = opts.component_arg; iopts.export_cmake_config = !opts.no_cmake_export; iopts.export_native_metadata = !opts.no_native_export; + iopts.bundle_runtime_dependencies = opts.bundle_dependencies; + if (opts.archive_format_arg != "tar" && opts.archive_format_arg != "sh") { + std::cerr << "vbs install: unsupported --archive-format '" + << opts.archive_format_arg << "' (expected tar or sh)\n"; + return 2; + } + if (opts.archive_arg && !opts.archive_arg->empty()) { + iopts.archive_path = std::filesystem::path{*opts.archive_arg}; + iopts.archive_as_script = opts.archive_format_arg == "sh"; + } std::error_code ec; if (opts.pkg_name_arg && !opts.pkg_name_arg->empty()) { @@ -2827,7 +2840,15 @@ int main(int argc, char **argv) { .flag("--no-cmake-export", "", "Disable CMake Config.cmake export", install_opts.no_cmake_export) .flag("--no-native-export", "", "Disable native VBS package metadata export", - install_opts.no_native_export); + install_opts.no_native_export) + .flag("--bundle-dependencies", "", + "Bundle runtime shared libraries of installed targets into /lib", + install_opts.bundle_dependencies) + .option("--archive", "", "Write a deterministic installer archive of the prefix", + install_opts.archive_arg) + .option_default("--archive-format", "", + "Installer archive format: tar (default) or sh (self-extracting)", + install_opts.archive_format_arg, "tar"); add_log_flags(install_cmd); auto &uninstall_cmd = diff --git a/tests/FullV1Tests.cpp b/tests/FullV1Tests.cpp index 033776a..ef209d5 100644 --- a/tests/FullV1Tests.cpp +++ b/tests/FullV1Tests.cpp @@ -846,15 +846,80 @@ void build(Void::Build::Project &p) { Platform::ProcessRequest inst_req; inst_req.executable = vbs_bin; - inst_req.arguments = {"install", "--project", cli_proj.string(), - "--build-dir", cli_build.string(), "--prefix", - cli_prefix.string(), "--package-name", "CliHiPkg"}; + const auto installer_archive = tmp / "cli_hi-installer.tar"; + inst_req.arguments = {"install", + "--project", + cli_proj.string(), + "--build-dir", + cli_build.string(), + "--prefix", + cli_prefix.string(), + "--package-name", + "CliHiPkg", + "--bundle-dependencies", + "--archive", + installer_archive.string()}; auto inst_cli = Platform::run_supervised(inst_req); Void::Testing::expect(inst_cli.has_value() && inst_cli->succeeded()); Void::Testing::expect(std::filesystem::exists(cli_prefix / "bin" / "cli_hi")); Void::Testing::expect( std::filesystem::exists(cli_prefix / "share" / "vbs" / "CliHiPkg" / "package.json")); + // The installer archive is a deterministic, self-contained snapshot of the prefix. + Void::Testing::expect(std::filesystem::exists(installer_archive)); + const auto unpacked = tmp / "cli_inst_unpacked"; + auto unpack = Package::extract_safe_tar(installer_archive, unpacked); + Void::Testing::expect(unpack.has_value()); + Void::Testing::expect(std::filesystem::exists(unpacked / "bin" / "cli_hi")); + Void::Testing::expect( + std::filesystem::exists(unpacked / "share" / "vbs" / "CliHiPkg" / "package.json")); + const auto archive_a = tmp / "cli_hi-installer-a.tar"; + const auto archive_b = tmp / "cli_hi-installer-b.tar"; + auto req_a = inst_req; + auto req_b = inst_req; + for (auto &arg : req_a.arguments) { + if (arg == installer_archive.string()) { + arg = archive_a.string(); + } + } + for (auto &arg : req_b.arguments) { + if (arg == installer_archive.string()) { + arg = archive_b.string(); + } + } + Void::Testing::expect(Platform::run_supervised(req_a).value_or(Platform::ProcessResult{}) + .succeeded()); + Void::Testing::expect(Platform::run_supervised(req_b).value_or(Platform::ProcessResult{}) + .succeeded()); + const auto bytes_a = Void::FileSystem::read_file(archive_a); + const auto bytes_b = Void::FileSystem::read_file(archive_b); + Void::Testing::expect(bytes_a.has_value() && bytes_b.has_value() && *bytes_a == *bytes_b); + + // CPack-style self-extracting installer script. + const auto script_archive = tmp / "cli_hi-installer.sh"; + auto script_req = inst_req; + for (auto &arg : script_req.arguments) { + if (arg == installer_archive.string()) { + arg = script_archive.string(); + } + } + script_req.arguments.push_back("--archive-format"); + script_req.arguments.push_back("sh"); + auto script_res = Platform::run_supervised(script_req); + Void::Testing::expect(script_res.has_value() && script_res->succeeded()); + Void::Testing::expect(std::filesystem::exists(script_archive)); + if (script_res && script_res->succeeded()) { + const auto script_prefix = tmp / "cli_script_prefix"; + Platform::ProcessRequest run_script; + run_script.executable = "/bin/sh"; + run_script.arguments = {script_archive.string(), "--prefix", script_prefix.string()}; + auto run_res = Platform::run_supervised(run_script); + Void::Testing::expect(run_res.has_value() && run_res->succeeded()); + Void::Testing::expect(std::filesystem::exists(script_prefix / "bin" / "cli_hi")); + Void::Testing::expect(std::filesystem::exists( + script_prefix / "share" / "vbs" / "CliHiPkg" / "package.json")); + } + Platform::ProcessRequest uninst_req; uninst_req.executable = vbs_bin; uninst_req.arguments = {"uninstall", "--prefix", cli_prefix.string()}; @@ -2231,6 +2296,14 @@ VOID_TEST(FullV1Tests, ide_integration_compdb_build_cpp_and_editor_configs_end_t Void::Testing::expect(parsed.has_value()); } } + // The generated IDE tasks include install/package entries. + if (auto tasks = Void::FileSystem::read_file(proj / ".vscode" / "tasks.json"); tasks) { + Void::Testing::expect(tasks->find("vbs: install") != std::string::npos); + Void::Testing::expect(tasks->find("vbs: package installer") != std::string::npos); + } + if (auto zed_tasks = Void::FileSystem::read_file(proj / ".zed" / "tasks.json"); zed_tasks) { + Void::Testing::expect(zed_tasks->find("vbs: install") != std::string::npos); + } // 3. Non-destructive overwrite preservation without `--force`, and overwrite with `--force`. write_file(proj / ".clangd", "# user-customized clangd\n");