mirror of
https://github.com/rocky-linux/srpmproc.git
synced 2024-12-04 18:36:26 +00:00
Add option for fallback module stream
This commit is contained in:
parent
32af526744
commit
6fb0ea1997
@ -42,26 +42,27 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
sourceRpm string
|
||||
sshKeyLocation string
|
||||
sshUser string
|
||||
upstreamPrefix string
|
||||
version int
|
||||
storageAddr string
|
||||
gitCommitterName string
|
||||
gitCommitterEmail string
|
||||
modulePrefix string
|
||||
rpmPrefix string
|
||||
importBranchPrefix string
|
||||
branchPrefix string
|
||||
singleTag string
|
||||
noDupMode bool
|
||||
moduleMode bool
|
||||
tmpFsMode string
|
||||
noStorageDownload bool
|
||||
noStorageUpload bool
|
||||
manualCommits string
|
||||
upstreamPrefixHttps string
|
||||
sourceRpm string
|
||||
sshKeyLocation string
|
||||
sshUser string
|
||||
upstreamPrefix string
|
||||
version int
|
||||
storageAddr string
|
||||
gitCommitterName string
|
||||
gitCommitterEmail string
|
||||
modulePrefix string
|
||||
rpmPrefix string
|
||||
importBranchPrefix string
|
||||
branchPrefix string
|
||||
singleTag string
|
||||
noDupMode bool
|
||||
moduleMode bool
|
||||
tmpFsMode string
|
||||
noStorageDownload bool
|
||||
noStorageUpload bool
|
||||
manualCommits string
|
||||
upstreamPrefixHttps string
|
||||
moduleFallbackStream string
|
||||
)
|
||||
|
||||
var root = &cobra.Command{
|
||||
@ -145,28 +146,29 @@ func mn(_ *cobra.Command, _ []string) {
|
||||
}
|
||||
|
||||
internal.ProcessRPM(&data.ProcessData{
|
||||
Importer: importer,
|
||||
RpmLocation: sourceRpmLocation,
|
||||
UpstreamPrefix: upstreamPrefix,
|
||||
SshKeyLocation: sshKeyLocation,
|
||||
SshUser: sshUser,
|
||||
Version: version,
|
||||
BlobStorage: blobStorage,
|
||||
GitCommitterName: gitCommitterName,
|
||||
GitCommitterEmail: gitCommitterEmail,
|
||||
ModulePrefix: modulePrefix,
|
||||
ImportBranchPrefix: importBranchPrefix,
|
||||
BranchPrefix: branchPrefix,
|
||||
SingleTag: singleTag,
|
||||
Authenticator: authenticator,
|
||||
NoDupMode: noDupMode,
|
||||
ModuleMode: moduleMode,
|
||||
TmpFsMode: tmpFsMode,
|
||||
NoStorageDownload: noStorageDownload,
|
||||
NoStorageUpload: noStorageUpload,
|
||||
ManualCommits: manualCs,
|
||||
UpstreamPrefixHttps: upstreamPrefixHttps,
|
||||
FsCreator: fsCreator,
|
||||
Importer: importer,
|
||||
RpmLocation: sourceRpmLocation,
|
||||
UpstreamPrefix: upstreamPrefix,
|
||||
SshKeyLocation: sshKeyLocation,
|
||||
SshUser: sshUser,
|
||||
Version: version,
|
||||
BlobStorage: blobStorage,
|
||||
GitCommitterName: gitCommitterName,
|
||||
GitCommitterEmail: gitCommitterEmail,
|
||||
ModulePrefix: modulePrefix,
|
||||
ImportBranchPrefix: importBranchPrefix,
|
||||
BranchPrefix: branchPrefix,
|
||||
SingleTag: singleTag,
|
||||
Authenticator: authenticator,
|
||||
NoDupMode: noDupMode,
|
||||
ModuleMode: moduleMode,
|
||||
TmpFsMode: tmpFsMode,
|
||||
NoStorageDownload: noStorageDownload,
|
||||
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)
|
||||
|
@ -27,27 +27,28 @@ import (
|
||||
)
|
||||
|
||||
type ProcessData struct {
|
||||
RpmLocation string
|
||||
UpstreamPrefix string
|
||||
SshKeyLocation string
|
||||
SshUser string
|
||||
Version int
|
||||
GitCommitterName string
|
||||
GitCommitterEmail string
|
||||
Mode int
|
||||
ModulePrefix string
|
||||
ImportBranchPrefix string
|
||||
BranchPrefix string
|
||||
SingleTag string
|
||||
Authenticator *ssh.PublicKeys
|
||||
Importer ImportMode
|
||||
BlobStorage blob.Storage
|
||||
NoDupMode bool
|
||||
ModuleMode bool
|
||||
TmpFsMode string
|
||||
NoStorageDownload bool
|
||||
NoStorageUpload bool
|
||||
ManualCommits []string
|
||||
UpstreamPrefixHttps string
|
||||
FsCreator func(branch string) billy.Filesystem
|
||||
RpmLocation string
|
||||
UpstreamPrefix string
|
||||
SshKeyLocation string
|
||||
SshUser string
|
||||
Version int
|
||||
GitCommitterName string
|
||||
GitCommitterEmail string
|
||||
Mode int
|
||||
ModulePrefix string
|
||||
ImportBranchPrefix string
|
||||
BranchPrefix string
|
||||
SingleTag string
|
||||
Authenticator *ssh.PublicKeys
|
||||
Importer ImportMode
|
||||
BlobStorage blob.Storage
|
||||
NoDupMode bool
|
||||
ModuleMode bool
|
||||
TmpFsMode string
|
||||
NoStorageDownload bool
|
||||
NoStorageUpload bool
|
||||
ManualCommits []string
|
||||
UpstreamPrefixHttps string
|
||||
ModuleFallbackStream string
|
||||
FsCreator func(branch string) billy.Filesystem
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user