rpmmd: convert sources to repos
Add function to convert between a user source and a repo which can be passed to dnf-json. This is neccessary because user-defined sources have a slightly different format than dnf repos.
This commit is contained in:
parent
af73810a2d
commit
085ba6fec9
1 changed files with 19 additions and 0 deletions
|
|
@ -8,6 +8,8 @@ import (
|
|||
"os/exec"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/store"
|
||||
)
|
||||
|
||||
type RepoConfig struct {
|
||||
|
|
@ -159,3 +161,20 @@ func (packages PackageList) Search(name string) (int, int) {
|
|||
|
||||
return first, last - first
|
||||
}
|
||||
|
||||
func SourceToRepo(source store.SourceConfig) RepoConfig {
|
||||
var repo RepoConfig
|
||||
|
||||
repo.Name = source.Name
|
||||
repo.Id = source.Name
|
||||
|
||||
if source.Type == "yum-baseurl" {
|
||||
repo.BaseURL = source.URL
|
||||
} else if source.Type == "yum-metalink" {
|
||||
repo.Metalink = source.URL
|
||||
} else if source.Type == "yum-mirrorlist" {
|
||||
repo.MirrorList = source.URL
|
||||
}
|
||||
|
||||
return repo
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue