#2014 BuildSRPMFromSCMTask: Support auto-selecting a matching specfile name
Closed 3 years ago by tkopecek. Opened 4 years ago by sgallagh.
sgallagh/koji multi_spec  into  master

file modified
+22 -2
@@ -4813,8 +4813,28 @@ 

          if len(spec_files) == 0:

              raise koji.BuildError("No spec file found")

          elif len(spec_files) > 1:

-             raise koji.BuildError("Multiple spec files found: %s" % spec_files)

-         spec_file = spec_files[0]

+             # If there are multiple spec files, check whether one of them

+             # matches the SCM repo name

+             scm_spec_options = [

+                 "%s/%s.spec".format(

+                     sourcedir, os.path.basename(sourcedir)),

+ 

+                 "%s/SPECS/%s.spec".format(

+                     sourcedir, os.path.basename(sourcedir))

+             ]

+ 

+             for scm_spec in scm_spec_options:

+                 if scm_spec in specs:

+                     # We have a match, so use this one.

+                     spec_file = scm_spec

+                     break

+ 

+             if not spec_file:

+                 # We didn't find an exact match, so throw an error

+                 raise koji.BuildError(

+                     "Multiple spec files found: %s" % spec_files)

+         else:

+             spec_file = spec_files[0]

  

          # Run spec file sanity checks.  Any failures will throw a BuildError

          self.spec_sanity_checks(spec_file)

There are cases where having two files with the .spec suffix in the
same dist-git repository makes sense, such as maintaining a common
dist-git structure for different distributions where the package
name might be different.

This patch would allow the build-system to use the matching spec
file name for the current SCM checkout path if it exists.

Signed-off-by: Stephen Gallagher sgallagh@redhat.com

I think this should be rather closed as duplicate of https://pagure.io/koji/issue/1905

Pull-Request has been closed by tkopecek

3 years ago