From 18f9f5c77c9e92299226bf0a107d3e53ff01ebdf Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Sun, 9 Jun 2024 21:40:53 -0700 Subject: [PATCH] Add git name option for source-rpm Adds the ability to set a source git repo name for the package that will be imported. --- cmd/srpmproc/main.go | 3 +++ pkg/srpmproc/process.go | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cmd/srpmproc/main.go b/cmd/srpmproc/main.go index 11e154f..f72151b 100644 --- a/cmd/srpmproc/main.go +++ b/cmd/srpmproc/main.go @@ -32,6 +32,7 @@ import ( var ( sourceRpm string + sourceRpmGitName string sshKeyLocation string sshUser string upstreamPrefix string @@ -72,6 +73,7 @@ func mn(_ *cobra.Command, _ []string) { Version: version, StorageAddr: storageAddr, Package: sourceRpm, + PackageGitName: sourceRpmGitName, ModuleMode: moduleMode, TmpFsMode: tmpFsMode, ModulePrefix: modulePrefix, @@ -125,6 +127,7 @@ func main() { root.Flags().StringVar(&storageAddr, "storage-addr", "", "Bucket to use as blob storage") _ = 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(&sshUser, "ssh-user", "git", "SSH User") root.Flags().StringVar(&gitCommitterName, "git-committer-name", "rockyautomation", "Name of committer") diff --git a/pkg/srpmproc/process.go b/pkg/srpmproc/process.go index 04afc01..0075f35 100644 --- a/pkg/srpmproc/process.go +++ b/pkg/srpmproc/process.go @@ -68,9 +68,10 @@ const ( type ProcessDataRequest struct { // Required - Version int - StorageAddr string - Package string + Version int + StorageAddr string + Package string + PackageGitName string // Optional ModuleMode bool @@ -219,6 +220,11 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) { 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 blobStorage blob.Storage @@ -238,9 +244,9 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) { sourceRpmLocation := "" if req.ModuleMode { - sourceRpmLocation = fmt.Sprintf("%s/%s", req.ModulePrefix, req.Package) + sourceRpmLocation = fmt.Sprintf("%s/%s", req.ModulePrefix, req.PackageGitName) } else { - sourceRpmLocation = fmt.Sprintf("%s/%s", req.RpmPrefix, req.Package) + sourceRpmLocation = fmt.Sprintf("%s/%s", req.RpmPrefix, req.PackageGitName) } importer = &modes.GitMode{}