Remove all the internal package that are now in the github.com/osbuild/images package and vendor it. A new function in internal/blueprint/ converts from an osbuild-composer blueprint to an images blueprint. This is necessary for keeping the blueprint implementation in both packages. In the future, the images package will change the blueprint (and most likely rename it) and it will only be part of the osbuild-composer internals and interface. The Convert() function will be responsible for converting the blueprint into the new configuration object.
39 lines
934 B
Go
39 lines
934 B
Go
package rpmmd
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type RPM struct {
|
|
Type string `json:"type"` // must be 'rpm'
|
|
Name string `json:"name"`
|
|
Version string `json:"version"`
|
|
Release string `json:"release"`
|
|
Epoch *string `json:"epoch,omitempty"`
|
|
Arch string `json:"arch"`
|
|
Sigmd5 string `json:"sigmd5"`
|
|
Signature *string `json:"signature"`
|
|
}
|
|
|
|
// NEVRA string for the package
|
|
func (r RPM) String() string {
|
|
epoch := ""
|
|
if r.Epoch != nil {
|
|
epoch = *r.Epoch + ":"
|
|
}
|
|
return fmt.Sprintf("%s-%s%s-%s.%s", r.Name, epoch, r.Version, r.Release, r.Arch)
|
|
}
|
|
|
|
// Deduplicate a list of RPMs based on NEVRA string
|
|
func DeduplicateRPMs(rpms []RPM) []RPM {
|
|
rpmMap := make(map[string]struct{}, len(rpms))
|
|
uniqueRPMs := make([]RPM, 0, len(rpms))
|
|
|
|
for _, rpm := range rpms {
|
|
if _, added := rpmMap[rpm.String()]; !added {
|
|
rpmMap[rpm.String()] = struct{}{}
|
|
uniqueRPMs = append(uniqueRPMs, rpm)
|
|
}
|
|
}
|
|
return uniqueRPMs
|
|
}
|