Skip to content

Commit

Permalink
dnfjson: new fields in osbuild-depsolve-dnf results
Browse files Browse the repository at this point in the history
Support the new package metadata fields added in osbuild-depsolve-dnf in
osbuild/osbuild#1674
  • Loading branch information
achilleas-k committed Mar 20, 2024
1 parent 92497c7 commit 04d6cb6
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions pkg/dnfjson/dnfjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ func (s *Solver) makeSearchRequest(repos []rpmmd.RepoConfig, packages []string)
func (pkgs packageSpecs) toRPMMD(repos map[string]rpmmd.RepoConfig) []rpmmd.PackageSpec {
rpmDependencies := make([]rpmmd.PackageSpec, len(pkgs))
for i, dep := range pkgs {
repo, ok := repos[dep.RepoID]
if !ok {
repo, haveRepo := repos[dep.RepoID]
if repos != nil && !haveRepo {
panic("dependency repo ID not found in repositories")
}
dep := pkgs[i]
Expand All @@ -496,14 +496,29 @@ func (pkgs packageSpecs) toRPMMD(repos map[string]rpmmd.RepoConfig) []rpmmd.Pack
rpmDependencies[i].Arch = dep.Arch
rpmDependencies[i].RemoteLocation = dep.RemoteLocation
rpmDependencies[i].Checksum = dep.Checksum
if repo.CheckGPG != nil {
rpmDependencies[i].CheckGPG = *repo.CheckGPG
}
if repo.IgnoreSSL != nil {
rpmDependencies[i].IgnoreSSL = *repo.IgnoreSSL
}
if repo.RHSM {
rpmDependencies[i].Secrets = "org.osbuild.rhsm"
if haveRepo {
// NOTE: Temporary backwards compatibility!
// After the next osbuild release, change the spec file to depend
// on the updated osbuild-depsolve-dnf and remove t his block and
// the requirement to specify the repos argumnet to this method.
if repo.CheckGPG != nil {
rpmDependencies[i].CheckGPG = *repo.CheckGPG
}
if repo.IgnoreSSL != nil {
rpmDependencies[i].IgnoreSSL = *repo.IgnoreSSL
}
if repo.RHSM {
rpmDependencies[i].Secrets = "org.osbuild.rhsm"
}
} else {
// New stuff from osbuild-depsolve-dnf
rpmDependencies[i].CheckGPG = dep.GPGCheck
rpmDependencies[i].IgnoreSSL = !dep.SSLVerify
secrets := ""
if dep.SSLCACert != "" && dep.SSLClientCert != "" && dep.SSLClientKey != "" {
secrets = "org.osbuild.rhsm"
}
rpmDependencies[i].Secrets = secrets
}
}
return rpmDependencies
Expand Down Expand Up @@ -594,7 +609,11 @@ type PackageSpec struct {
Path string `json:"path,omitempty"`
RemoteLocation string `json:"remote_location,omitempty"`
Checksum string `json:"checksum,omitempty"`
Secrets string `json:"secrets,omitempty"`
SSLVerify bool `json:"sslverify"`
GPGCheck bool `json:"gpgcheck"`
SSLClientKey string `json:"sslclientkey"`
SSLClientCert string `json:"sslclientcert"`
SSLCACert string `json:"sslcacert"`
}

// dnf-json error structure
Expand Down

0 comments on commit 04d6cb6

Please sign in to comment.