Add git name option for source-rpm

Adds the ability to set a source git repo name for the package that will
be imported.
This commit is contained in:
Louis Abel 2024-06-09 21:40:53 -07:00
parent f2864a875a
commit 18f9f5c77c
Signed by: label
GPG Key ID: 3331F061D1D9990E
2 changed files with 14 additions and 5 deletions

View File

@ -32,6 +32,7 @@ import (
var ( var (
sourceRpm string sourceRpm string
sourceRpmGitName string
sshKeyLocation string sshKeyLocation string
sshUser string sshUser string
upstreamPrefix string upstreamPrefix string
@ -72,6 +73,7 @@ func mn(_ *cobra.Command, _ []string) {
Version: version, Version: version,
StorageAddr: storageAddr, StorageAddr: storageAddr,
Package: sourceRpm, Package: sourceRpm,
PackageGitName: sourceRpmGitName,
ModuleMode: moduleMode, ModuleMode: moduleMode,
TmpFsMode: tmpFsMode, TmpFsMode: tmpFsMode,
ModulePrefix: modulePrefix, ModulePrefix: modulePrefix,
@ -125,6 +127,7 @@ func main() {
root.Flags().StringVar(&storageAddr, "storage-addr", "", "Bucket to use as blob storage") root.Flags().StringVar(&storageAddr, "storage-addr", "", "Bucket to use as blob storage")
_ = root.MarkFlagRequired("storage-addr") _ = root.MarkFlagRequired("storage-addr")
root.Flags().StringVar(&sourceRpmGitName, "source-rpm-git-name", "", "Actual git repo name of package if name is different from source-rpm value")
root.Flags().StringVar(&sshKeyLocation, "ssh-key-location", "", "Location of the SSH key to use to authenticate against upstream") root.Flags().StringVar(&sshKeyLocation, "ssh-key-location", "", "Location of the SSH key to use to authenticate against upstream")
root.Flags().StringVar(&sshUser, "ssh-user", "git", "SSH User") root.Flags().StringVar(&sshUser, "ssh-user", "git", "SSH User")
root.Flags().StringVar(&gitCommitterName, "git-committer-name", "rockyautomation", "Name of committer") root.Flags().StringVar(&gitCommitterName, "git-committer-name", "rockyautomation", "Name of committer")

View File

@ -71,6 +71,7 @@ type ProcessDataRequest struct {
Version int Version int
StorageAddr string StorageAddr string
Package string Package string
PackageGitName string
// Optional // Optional
ModuleMode bool ModuleMode bool
@ -219,6 +220,11 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) {
return nil, fmt.Errorf("package cannot be empty") return nil, fmt.Errorf("package cannot be empty")
} }
// tells srpmproc what the source name actually is
if req.PackageGitName == "" {
req.PackageGitName = req.Package
}
var importer data.ImportMode var importer data.ImportMode
var blobStorage blob.Storage var blobStorage blob.Storage
@ -238,9 +244,9 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) {
sourceRpmLocation := "" sourceRpmLocation := ""
if req.ModuleMode { if req.ModuleMode {
sourceRpmLocation = fmt.Sprintf("%s/%s", req.ModulePrefix, req.Package) sourceRpmLocation = fmt.Sprintf("%s/%s", req.ModulePrefix, req.PackageGitName)
} else { } else {
sourceRpmLocation = fmt.Sprintf("%s/%s", req.RpmPrefix, req.Package) sourceRpmLocation = fmt.Sprintf("%s/%s", req.RpmPrefix, req.PackageGitName)
} }
importer = &modes.GitMode{} importer = &modes.GitMode{}