#2083 allow to skip SRPM rebuild for scratch builds
Merged 4 years ago by tkopecek. Opened 4 years ago by tkopecek.
tkopecek/koji issue1719  into  master

file modified
+19 -3
@@ -1071,14 +1071,30 @@ 

              self.tagBuild(build_id, dest_tag)

  

      def getSRPM(self, src, build_tag, repo_id):

-         """Get srpm from src"""

+         """

+         Get srpm from src - it can fetch SCM and build SRPM from there or

+         alternatively get downloaded SRPM (and rebuild it if needed).

+ 

+         Buildroot has extra.rebuild_srpm field with default value of True. For

+         scratch builds we allow overriding by user, for regular builds only

+         buildtag's option can affect it.

+ 

+         :param str src:

+            SCM url or filename

+         :param str|dict build_tag:

+            build tag used for re/building srpm

+         :param int repo_id:

+            repo id to be used

+         """

          if isinstance(src, str):

              if SCM.is_scm_url(src):

                  return self.getSRPMFromSCM(src, build_tag, repo_id)

              else:

                  buildconfig = self.session.getBuildConfig(build_tag, event=self.event_id)

-                 if buildconfig['extra'].get('rebuild_srpm', True):

-                     # default is to always rebuild

+                 rebuild = buildconfig['extra'].get('rebuild_srpm', True)

+                 if self.opts.get('scratch') and self.opts.get('rebuild_srpm') is not None:

+                     rebuild = self.opts.get('rebuild_srpm')

+                 if rebuild:

                      return self.getSRPMFromSRPM(src, build_tag, repo_id)

                  else:

                      return src

file modified
+8 -1
@@ -458,6 +458,10 @@ 

                        help=_("Do not attempt to tag package"))

      parser.add_option("--scratch", action="store_true",

                        help=_("Perform a scratch build"))

+     parser.add_option("--rebuild-srpm", action="store_true", dest="rebuild_srpm",

+                       help=_("Force rebuilding SRPM for scratch build only"))

+     parser.add_option("--no-rebuild-srpm", action="store_false", dest="rebuild_srpm",

+                       help=_("Force not to rebuild srpm for scratch build only"))

      parser.add_option("--wait", action="store_true",

                        help=_("Wait on the build, even if running in the background"))

      parser.add_option("--nowait", action="store_false", dest="wait",
@@ -480,6 +484,8 @@ 

      if len(args) != 2:

          parser.error(_("Exactly two arguments (a build target and a SCM URL or srpm file) are "

                         "required"))

+     if build_opts.rebuild_srpm is not None and not build_opts.scratch:

+         parser.error(_("--no-/rebuild-srpm is only allowed for --scratch builds"))

      if build_opts.arch_override and not build_opts.scratch:

          parser.error(_("--arch_override is only allowed for --scratch builds"))

      activate_session(session, options)
@@ -500,7 +506,8 @@ 

      opts = {}

      if build_opts.arch_override:

          opts['arch_override'] = koji.parse_arches(build_opts.arch_override)

-     for key in ('skip_tag', 'scratch', 'repo_id', 'fail_fast', 'wait_repo', 'wait_builds'):

+     for key in ('skip_tag', 'scratch', 'repo_id', 'fail_fast', 'wait_repo', 'wait_builds',

+                 'rebuild_srpm'):

          val = getattr(build_opts, key)

          if val is not None:

              opts[key] = val

@@ -199,6 +199,8 @@ 

    -h, --help            show this help message and exit

    --skip-tag            Do not attempt to tag package

    --scratch             Perform a scratch build

+   --rebuild-srpm        Force rebuilding SRPM for scratch build only

+   --no-rebuild-srpm     Force not to rebuild srpm for scratch build only

    --wait                Wait on the build, even if running in the background

    --nowait              Don't wait on build

    --wait-repo           Wait for the actual buildroot repo of given target

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

4 years ago

Looks good overall, just a couple things.

There's a typo in the updated docstring for getSRPM -- "hase". Also, as long as we're updating this docstring, I wonder if we should modernize it.

    def getSRPM(self, src, build_tag, repo_id, rebuild_srpm=None, scratch=False):

I'm wondering if it makes sense to pass these explicitly. We could just access self.opts instead. The scratch option is less a natural parameter for this function and more a top level option for the whole task.

rebased onto 7183212

4 years ago

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

4 years ago

Commit 2bde581 fixes this pull-request

Pull-Request has been merged by tkopecek

4 years ago