From b4bb73a195bc64880c3c84ed0afaeef81b75f25e Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 2 Feb 2020 22:28:37 +0100 Subject: [PATCH] dnf-json: expose each RPM location and content hash In adition to the NEVRA, include the location and hash over the rpm file. This allows us to separately fetch and verify that refernces to RPMs are correct, as the NEVRA alone is not sufficient for fetching nor verifying. This is a prerequisite for using the rpm rather than the dnf stage in our osbuild pipelines. Signed-off-by: Tom Gundersen --- dnf-json | 5 ++++- internal/rpmmd/repository.go | 12 +++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dnf-json b/dnf-json index 80a4981ad..e0921ec44 100644 --- a/dnf-json +++ b/dnf-json @@ -3,6 +3,7 @@ import datetime import dnf import hashlib +import hawkey import json import shutil import sys @@ -124,7 +125,9 @@ elif command == "depsolve": "epoch": package.epoch, "version": package.version, "release": package.release, - "arch": package.arch + "arch": package.arch, + "remote_location": package.remote_location(), + "checksum": f"{hawkey.chksum_name(package.chksum[0])}:{package.chksum[1].hex()}", }) json.dump({ "checksums": repo_checksums(base), diff --git a/internal/rpmmd/repository.go b/internal/rpmmd/repository.go index 04f747666..1ee291c0c 100644 --- a/internal/rpmmd/repository.go +++ b/internal/rpmmd/repository.go @@ -62,11 +62,13 @@ func (pkg Package) ToPackageInfo() PackageInfo { } type PackageSpec struct { - Name string `json:"name"` - Epoch uint `json:"epoch"` - Version string `json:"version,omitempty"` - Release string `json:"release,omitempty"` - Arch string `json:"arch,omitempty"` + Name string `json:"name"` + Epoch uint `json:"epoch"` + Version string `json:"version,omitempty"` + Release string `json:"release,omitempty"` + Arch string `json:"arch,omitempty"` + RemoteLocation string `json:"remote_location,omitempty"` + Checksum string `json:"checksum,omitempty"` } type PackageSource struct {