feat(package,daemon): show binary variant details; list installed files
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 10s

This commit is contained in:
faumaray committed 2026-12-04 08:54:15 +03:00
1 parent b8c362917f
commit 27d909fdad
10 files changed
+145 -1

No files matched your search

+55
View File
@@ -431,6 +431,61 @@ download_release_archive(std::string_view registry_url, std::string_view package
return dest_file;
}
Void::Result::Result<BinaryReleaseInfo, Void::Result::Error>
fetch_binary_detail(std::string_view registry_url, std::string_view package_name,
std::string_view version, std::string_view variant_id,
const RegistryAuth &auth) {
auto parsed_url = parse_registry_url(registry_url);
if (!parsed_url) {
return std::unexpected{parsed_url.error()};
}
std::map<std::string, std::string, std::less<>> headers;
if (!auth.bearer_token.empty()) {
headers["Authorization"] = "Bearer " + auth.bearer_token;
}
const std::string path = "/api/v1/packages/" + Void::Encoding::Url::encode(package_name) + "/" +
Void::Encoding::Url::encode(version) + "/binaries/" +
Void::Encoding::Url::encode(variant_id);
auto reply = send_http_request(*parsed_url, "GET", path, headers, {});
if (!reply) {
return std::unexpected{reply.error()};
}
if (reply->status != 200) {
return std::unexpected{
make_error(reply->status == 404 ? Void::System::SystemErrorCode::not_found
: reply->status == 401 || reply->status == 403
? Void::System::SystemErrorCode::permission_denied
: Void::System::SystemErrorCode::io_error,
std::format("registry GET {} failed with HTTP {}", path, reply->status))};
}
auto json = Void::Json::Strict::parse(reply->body);
if (!json) {
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
"invalid JSON returned by registry binary endpoint")};
}
const auto *object = std::get_if<JsonVal::Object>(&json->value);
if (!object) {
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
"registry binary response must be a JSON object")};
}
BinaryReleaseInfo info;
info.variant_id = get_str(*object, "variant_id");
info.sha256 = get_str(*object, "sha256");
info.size_bytes = static_cast<std::uint64_t>(get_i64(*object, "size_bytes", 0));
info.yanked = get_bool(*object, "yanked", false);
if (const auto sig = get_str(*object, "signature"); !sig.empty()) {
info.signature = sig;
}
if (const auto key = get_str(*object, "public_key"); !key.empty()) {
info.public_key = key;
}
if (info.variant_id.empty()) {
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
"registry binary response is missing variant_id")};
}
return info;
}
Void::Result::Result<std::string, Void::Result::Error>
publish_binary_variant(const BinaryPublishOptions &options) {
if (!Void::Semver::parse_strict(options.version)) {