allow to skip SRPM rebuild for scratch builds
Fixes: https://pagure.io/koji/issue/1719
This commit is contained in:
parent
08236dd8b4
commit
718321298e
3 changed files with 29 additions and 4 deletions
|
|
@ -1071,14 +1071,30 @@ class BuildTask(BaseTaskHandler):
|
|||
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
|
||||
|
|
|
|||
|
|
@ -458,6 +458,10 @@ def handle_build(options, session, args):
|
|||
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 @@ def handle_build(options, session, args):
|
|||
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 @@ def handle_build(options, session, args):
|
|||
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 @@ Options:
|
|||
-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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue