From 5326700b4848f388b7173f46055dcb035bd5981a Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: May 18 2020 14:56:46 +0000 Subject: [PATCH 1/2] BuildSRPMFromSCMTask: Support auto-selecting a matching specfile name 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 --- diff --git a/builder/kojid b/builder/kojid index a105d75..335a70c 100755 --- a/builder/kojid +++ b/builder/kojid @@ -4959,8 +4959,28 @@ class BuildSRPMFromSCMTask(BaseBuildTask): 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) From 6763f9ceac54552b1e2df131c96fd3c054a6e60e Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: May 18 2020 15:09:48 +0000 Subject: [PATCH 2/2] builder: py2 fixes Relates: https://pagure.io/koji/issue/1905 --- diff --git a/builder/kojid b/builder/kojid index 335a70c..f77b4d7 100755 --- a/builder/kojid +++ b/builder/kojid @@ -4961,24 +4961,22 @@ class BuildSRPMFromSCMTask(BaseBuildTask): elif len(spec_files) > 1: # 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)) - ] + 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 specs: + 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: %s" % spec_files) + raise koji.BuildError("Multiple spec files found but none is matching " + "SCM checkout dir name: %s" % spec_files) else: spec_file = spec_files[0] diff --git a/docs/source/server_howto.rst b/docs/source/server_howto.rst index a084e51..db65c55 100644 --- a/docs/source/server_howto.rst +++ b/docs/source/server_howto.rst @@ -1198,6 +1198,10 @@ a host, but allow from it otherwise 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 --------------------------------------