#2257 BuildSRPMFromSCMTask: Support auto-selecting a matching specfile name
Merged 2 years ago by mikem. Opened 2 years ago by tkopecek.
tkopecek/koji issue1905  into  master

file modified
+20 -2
@@ -4959,8 +4959,26 @@ 

          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" % (sourcedir, os.path.basename(sourcedir)),

+                 "%s/SPECS/%s.spec" % (sourcedir, os.path.basename(sourcedir)),

+             )

+ 

+             spec_file = None

+             for scm_spec in scm_spec_options:

+                 if scm_spec in spec_files:

+                     # 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 but none is matching "

+                                       "SCM checkout dir name: %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)

@@ -1198,6 +1198,10 @@ 

  

  The explicit block syntax was added in version 1.13.0.

  

+ SCM checkout can contain multiple spec files (checkouted or created by

+ ``source_cmd``). In such case spec file named same as a checkout directory will

+ be selected.

+ 

  

  Add the host to the createrepo channel

  --------------------------------------

Update of #2014 (py2 compatibility + variable name typo fix)
Related: https://pagure.io/koji/issue/1905

By the way, rpkg does this differently. It picks first spec file that it finds in the os.listdir() list. It's confusing to me when rpkg behaves differently than Koji. Can we unify the two?

It's not clear to me where the SPECS/* convention comes from.

From rpmbuild I believe. That has structure like SOURCES, SPECS.

Metadata Update from @julian8628:
- Pull-request tagged with: testing-ready

2 years ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

2 years ago

Commit b88d87e fixes this pull-request

Pull-Request has been merged by mikem

2 years ago