feat(daemon): pack the project into a confined source archive
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 18s

This commit is contained in:
faumaray committed 2026-12-04 02:32:52 +03:00
1 parent 3a3376c331
commit 69d1a8d274
8 files changed
+101 -2

No files matched your search

+29
View File
@@ -10,6 +10,7 @@
#include <Void/Build/Package/Lockfile.hpp>
#include <Void/Build/Package/Resolver.hpp>
#include <Void/Build/Package/Toml.hpp>
#include <Void/Build/Platform/FileOps.hpp>
#include <Void/Build/Platform/ProcessSupervisor.hpp>
#include <Void/Build/Provenance/TrustedKeys.hpp>
#include <Void/Build/Provider/Provider.hpp>
@@ -1744,6 +1745,34 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
if (*name == "ide_configs") {
return {ide_configs_project(options), false};
}
if (*name == "pack") {
std::string output_name{"package.tar"};
if (const auto entry = object->find("output"); entry != object->end()) {
const auto *value = std::get_if<std::string>(&entry->second.value);
if (value == nullptr || value->empty() || value->size() > 1024) {
return {error_response("output must be a bounded non-empty string"), false};
}
output_name = *value;
}
// Writes stay confined to the build root; absolute or escaping paths are rejected.
std::error_code ec;
const auto build_root = std::filesystem::weakly_canonical(options.build_root, ec);
const auto candidate = (build_root / output_name).lexically_normal();
if (ec || !Void::Build::Platform::path_is_within(build_root, candidate) ||
candidate == build_root) {
return {error_response("output must stay inside the build root"), false};
}
auto sha = Package::create_source_package(options.project_root, candidate, 0);
if (!sha) {
return {error_response(std::format("pack: {}", sha.error().format())), false};
}
JsonValue::Object packed;
packed.emplace("ok", JsonValue{true});
packed.emplace("op", JsonValue{std::string{"pack"}});
packed.emplace("archive", JsonValue{candidate.string()});
packed.emplace("sha256", JsonValue{*sha});
return {serialize_response(JsonValue{std::move(packed)}), false};
}
if (*name == "clean") {
bool all = false;
if (const auto entry = object->find("all"); entry != object->end()) {