support multi rpm modules correctly

This commit is contained in:
Mustafa Gezen 2021-01-01 16:20:39 +01:00
parent 654c4933df
commit fa52ff07e3
2 changed files with 124 additions and 45 deletions

View File

@ -290,24 +290,24 @@ func patchModuleYaml(pd *ProcessData, md *modeData) {
log.Fatalf("could not parse modulemd file: %v", err) log.Fatalf("could not parse modulemd file: %v", err)
} }
var tipHash string for name, rpm := range module.Data.Components.Rpms {
name := md.rpmFile.Name() var tipHash string
module.Data.Name = name if strings.HasPrefix(rpm.Ref, "stream-") {
ref := module.Data.Components.Rpms[name].Ref rpm.Ref = md.pushBranch
if strings.HasPrefix(ref, "stream-") { tipHash = getTipStream(pd, name, md.pushBranch)
module.Data.Components.Rpms[name].Ref = md.pushBranch } else {
tipHash = getTipStream(pd, name, md.pushBranch) log.Fatal("could not recognize modulemd file, no stream- ref?")
} else { }
log.Fatal("could not recognize modulemd file, no stream- ref?")
err = module.Marshal(md.worktree.Filesystem, mdTxtPath)
if err != nil {
log.Fatalf("could not marshal modulemd: %v", err)
}
rpm.Ref = tipHash
} }
err = module.Marshal(md.worktree.Filesystem, mdTxtPath) rootModule := fmt.Sprintf("%s.yaml", md.rpmFile.Name())
if err != nil {
log.Fatalf("could not marshal modulemd: %v", err)
}
module.Data.Components.Rpms[name].Ref = tipHash
rootModule := fmt.Sprintf("%s.yaml", name)
err = module.Marshal(md.worktree.Filesystem, rootModule) err = module.Marshal(md.worktree.Filesystem, rootModule)
if err != nil { if err != nil {
log.Fatalf("could not marshal root modulemd: %v", err) log.Fatalf("could not marshal root modulemd: %v", err)

View File

@ -6,43 +6,122 @@ import (
) )
type ModuleMd struct { type ModuleMd struct {
Document string `yaml:"document"` Document string `yaml:"document,omitempty"`
Version int `yaml:"version"` Version int `yaml:"version,omitempty"`
Data struct { Data struct {
Name string `yaml:"name"` Name string `yaml:"name,omitempty"`
Stream string `yaml:"stream"` Stream string `yaml:"stream,omitempty"`
Summary string `yaml:"summary"` Version int64 `yaml:"version,omitempty"`
Description string `yaml:"description"` StaticContext bool `yaml:"static_context,omitempty"`
License struct { Context string `yaml:"context,omitempty"`
Module []string `yaml:"module"` Arch string `yaml:"arch,omitempty"`
} `yaml:"license"` Summary string `yaml:"summary,omitempty"`
Description string `yaml:"description,omitempty"`
Servicelevels struct {
Rawhide struct {
Eol struct {
} `yaml:"eol,omitempty"`
} `yaml:"rawhide,omitempty"`
StableAPI struct {
Eol struct {
} `yaml:"eol,omitempty"`
} `yaml:"stable_api,omitempty"`
BugFixes struct {
Eol struct {
} `yaml:"eol,omitempty"`
} `yaml:"bug_fixes,omitempty"`
SecurityFixes struct {
Eol struct {
} `yaml:"eol,omitempty"`
} `yaml:"security_fixes,omitempty"`
} `yaml:"servicelevels,omitempty"`
License struct {
Module []string `yaml:"module,omitempty"`
Content []string `yaml:"content,omitempty"`
} `yaml:"license,omitempty"`
Xmd map[string]interface{} `yaml:"xmd,omitempty"`
Dependencies []struct { Dependencies []struct {
BuildRequires struct { Buildrequires struct {
Platform []string `yaml:"platform"` Platform []string `yaml:"platform,omitempty"`
} `yaml:"buildrequires"` Buildtools []string `yaml:"buildtools,omitempty"`
Compatible []string `yaml:"compatible,omitempty"`
Extras []interface{} `yaml:"extras,omitempty"`
Moreextras []string `yaml:"moreextras,omitempty"`
} `yaml:"buildrequires,omitempty,omitempty"`
Requires struct { Requires struct {
Platform []string `yaml:"platform"` Platform []string `yaml:"platform,omitempty"`
} `yaml:"requires"` Compatible []string `yaml:"compatible,omitempty"`
} `yaml:"dependencies"` Runtime []string `yaml:"runtime,omitempty"`
Extras []interface{} `yaml:"extras,omitempty"`
Moreextras []string `yaml:"moreextras,omitempty"`
} `yaml:"requires,omitempty,omitempty"`
} `yaml:"dependencies,omitempty"`
References struct { References struct {
Documentation string `yaml:"documentation"` Community string `yaml:"community,omitempty"`
Tracker string `yaml:"tracker"` Documentation string `yaml:"documentation,omitempty"`
} `yaml:"references"` Tracker string `yaml:"tracker,omitempty"`
} `yaml:"references,omitempty"`
Profiles struct { Profiles struct {
Common struct { Container struct {
Rpms []string `yaml:"rpms"` Rpms []string `yaml:"rpms,omitempty"`
} `yaml:"common"` } `yaml:"container,omitempty"`
} `yaml:"profiles"` Minimal struct {
Description string `yaml:"description,omitempty"`
Rpms []string `yaml:"rpms,omitempty"`
} `yaml:"minimal,omitempty"`
Buildroot struct {
Rpms []string `yaml:"rpms,omitempty"`
} `yaml:"buildroot,omitempty"`
SrpmBuildroot struct {
Rpms []string `yaml:"rpms,omitempty"`
} `yaml:"srpm-buildroot,omitempty"`
} `yaml:"profiles,omitempty"`
API struct { API struct {
Rpms []string `yaml:"rpms"` Rpms []string `yaml:"rpms,omitempty"`
} `yaml:"api"` } `yaml:"api,omitempty"`
Filter struct {
Rpms []string `yaml:"rpms,omitempty"`
} `yaml:"filter,omitempty"`
Buildopts struct {
Rpms struct {
Macros string `yaml:"macros,omitempty"`
Whitelist []string `yaml:"whitelist,omitempty"`
} `yaml:"rpms,omitempty"`
Arches []string `yaml:"arches,omitempty"`
} `yaml:"buildopts,omitempty"`
Components struct { Components struct {
Rpms map[string]*struct { Rpms map[string]*struct {
Rationale string `yaml:"rationale"` Name string `yaml:"name,omitempty"`
Ref string `yaml:"ref"` Rationale string `yaml:"rationale,omitempty"`
} `yaml:"rpms"` Repository string `yaml:"repository,omitempty"`
} `yaml:"components"` Cache string `yaml:"cache,omitempty"`
} `yaml:"data"` Ref string `yaml:"ref,omitempty"`
Buildonly bool `yaml:"buildonly,omitempty"`
Buildroot bool `yaml:"buildroot,omitempty"`
SrpmBuildroot bool `yaml:"srpm-buildroot,omitempty"`
Buildorder int `yaml:"buildorder,omitempty"`
Arches []string `yaml:"arches,omitempty"`
Multilib []string `yaml:"multilib,omitempty"`
} `yaml:"rpms,omitempty"`
Modules map[string]*struct {
Rationale string `yaml:"rationale,omitempty"`
Repository string `yaml:"repository,omitempty"`
Ref string `yaml:"ref,omitempty"`
Buildorder int `yaml:"buildorder,omitempty"`
} `yaml:"modules,omitempty"`
} `yaml:"components,omitempty"`
Artifacts struct {
Rpms []string `yaml:"rpms,omitempty"`
RpmMap map[string]map[string]*struct {
Name string `yaml:"name,omitempty"`
Epoch int `yaml:"epoch,omitempty"`
Version float64 `yaml:"version,omitempty"`
Release string `yaml:"release,omitempty"`
Arch string `yaml:"arch,omitempty"`
Nevra string `yaml:"nevra,omitempty"`
} `yaml:"rpm-map,omitempty"`
} `yaml:"artifacts,omitempty"`
} `yaml:"data,omitempty"`
} }
func Parse(input []byte) (*ModuleMd, error) { func Parse(input []byte) (*ModuleMd, error) {