Add option for fallback module stream

This commit is contained in:
Mustafa Gezen 2021-04-25 12:58:13 +02:00
parent 32af526744
commit 6fb0ea1997
3 changed files with 83 additions and 68 deletions

View File

@ -62,6 +62,7 @@ var (
noStorageUpload bool
manualCommits string
upstreamPrefixHttps string
moduleFallbackStream string
)
var root = &cobra.Command{
@ -166,6 +167,7 @@ func mn(_ *cobra.Command, _ []string) {
NoStorageUpload: noStorageUpload,
ManualCommits: manualCs,
UpstreamPrefixHttps: upstreamPrefixHttps,
ModuleFallbackStream: moduleFallbackStream,
FsCreator: fsCreator,
})
}
@ -196,6 +198,7 @@ func main() {
root.Flags().BoolVar(&noStorageUpload, "no-storage-upload", false, "If enabled, blobs are not uploaded to blob storage")
root.Flags().StringVar(&manualCommits, "manual-commits", "", "Comma separated branch and commit list for packages with broken release tags (Format: BRANCH:HASH)")
root.Flags().StringVar(&upstreamPrefixHttps, "upstream-prefix-https", "", "Web version of upstream prefix. Required if module-mode")
root.Flags().StringVar(&moduleFallbackStream, "module-fallback-stream", "", "Override fallback stream. Some module packages are published as collections and mostly use the same stream name, some of them deviate from the main stream")
if err := root.Execute(); err != nil {
log.Fatal(err)

View File

@ -49,5 +49,6 @@ type ProcessData struct {
NoStorageUpload bool
ManualCommits []string
UpstreamPrefixHttps string
ModuleFallbackStream string
FsCreator func(branch string) billy.Filesystem
}

View File

@ -263,34 +263,45 @@ func patchModuleYaml(pd *data.ProcessData, md *data.ModeData) {
log.Printf("\t- %s", name)
}
defaultBranch := md.PushBranch
if pd.ModuleFallbackStream != "" {
defaultBranch = fmt.Sprintf("%s%d-stream-%s", pd.BranchPrefix, pd.Version, pd.ModuleFallbackStream)
}
for name, rpm := range module.Data.Components.Rpms {
var tipHash string
var pushBranch string
split := strings.Split(rpm.Ref, "-")
// TODO: maybe point to correct release tag? but refer to latest for now,
// we're bootstrapping a new distro for latest RHEL8 anyways. So earlier
// versions are not that important
if strings.HasPrefix(rpm.Ref, "stream-rhel-rhel-") {
pushBranch = md.PushBranch
pushBranch = defaultBranch
} else if strings.HasPrefix(rpm.Ref, "stream-rhel-") {
repString := fmt.Sprintf("%s%ss-", pd.BranchPrefix, string(split[4][0]))
newString := fmt.Sprintf("%s%s-", pd.BranchPrefix, string(split[4][0]))
pushBranch = strings.Replace(md.PushBranch, repString, newString, 1)
} else if strings.HasPrefix(rpm.Ref, "stream-") && len(split) == 2 {
pushBranch = md.PushBranch
pushBranch = defaultBranch
} else if strings.HasPrefix(rpm.Ref, "stream-") && len(split) == 3 {
// example: ant
pushBranch = fmt.Sprintf("%s%d-stream-%s", pd.BranchPrefix, pd.Version, split[2])
} else if strings.HasPrefix(rpm.Ref, "stream-") {
pushBranch = fmt.Sprintf("%s%s-stream-%s", pd.BranchPrefix, string(split[3][0]), split[1])
} else if strings.HasPrefix(rpm.Ref, "rhel-") {
pushBranch = md.PushBranch
pushBranch = defaultBranch
} else {
log.Fatal("could not recognize modulemd ref")
}
rpm.Ref = pushBranch
tipHash = getTipStream(pd, name, pushBranch, md.PushBranch, 0)
if tipHash == "0000000000000000000000000000000000000000" {
pushBranch = defaultBranch
rpm.Ref = pushBranch
tipHash = getTipStream(pd, name, pushBranch, md.PushBranch, 0)
}
err = module.Marshal(md.Worktree.Filesystem, mdTxtPath)
if err != nil {