feat(package): download and verify prebuilt binary variants
This commit is contained in:
1 parent
118c0dc860
commit
9b405ce772
9 files changed
+199
-3
No files matched your search
@@ -1,5 +1,6 @@
|
||||
#include <Void/Build/Package/Fetch.hpp>
|
||||
|
||||
#include <Void/Build/Package/RegistryClient.hpp>
|
||||
#include <Void/Build/Platform/FileOps.hpp>
|
||||
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||
#include <Void/Build/Provenance/Verification.hpp>
|
||||
@@ -172,6 +173,32 @@ select_compatible_signed_binary(const BinaryCompatibilityKey &key,
|
||||
return *selected;
|
||||
}
|
||||
|
||||
Void::Result::Result<BinaryVariantMeta, Void::Result::Error>
|
||||
materialize_binary_variant(const BinaryCompatibilityKey &key,
|
||||
const std::vector<BinaryVariantMeta> &available,
|
||||
const BinaryFetchOptions &options) {
|
||||
auto selected = select_compatible_signed_binary(key, available, options.trusted_public_keys);
|
||||
if (!selected) {
|
||||
return std::unexpected{selected.error()};
|
||||
}
|
||||
|
||||
const auto destination = options.cache_dir / "binaries" / selected->sha256;
|
||||
std::error_code ec;
|
||||
if (std::filesystem::is_regular_file(destination, ec)) {
|
||||
auto cached_digest = Util::sha256_file_hex(destination);
|
||||
if (cached_digest && *cached_digest == selected->sha256) {
|
||||
return *selected;
|
||||
}
|
||||
}
|
||||
std::filesystem::create_directories(destination.parent_path(), ec);
|
||||
auto downloaded =
|
||||
download_binary_artifact(selected->download_url, selected->sha256, destination);
|
||||
if (!downloaded) {
|
||||
return std::unexpected{downloaded.error()};
|
||||
}
|
||||
return *selected;
|
||||
}
|
||||
|
||||
Void::Result::Result<MaterializedSource, Void::Result::Error>
|
||||
materialize_dependency_source(const DependencyRecord &dep, const FetchOptions &options) {
|
||||
std::error_code ec;
|
||||
|
||||
Reference in new issue
Block a user