mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-03 05:03:43 +08:00
MockModuleBuilder: Don't rewrite mock config to add SCM options
When we want to pass in SCM options particular to a specific module build, do that on the mock command line rather than by modifying mock.cfg - this avoids invalidating the root cache.
This commit is contained in:
@@ -811,42 +811,44 @@ class SRPMBuilder(BaseBuilder):
|
||||
class SCMBuilder(BaseBuilder):
|
||||
def __init__(self, config, resultsdir, source, artifact_name):
|
||||
super(SCMBuilder, self).__init__(config, resultsdir)
|
||||
with open(config, "a") as f:
|
||||
repo_path, branch = source.split("?#")
|
||||
distgit_cmds = self._get_distgit_commands(source)
|
||||
# Supply the artifact name for "{0}" and the full path to the repo for "{repo_path}"
|
||||
distgit_get = distgit_cmds[0].format(artifact_name, repo_path=repo_path)
|
||||
|
||||
# mock-scm cannot checkout particular commit hash, but only branch.
|
||||
# We therefore use a command that combines the distgit-command with
|
||||
# checking out a particular commit hash.
|
||||
# See https://bugzilla.redhat.com/show_bug.cgi?id=1459437 for
|
||||
# more info. Once mock-scm supports this feature, we can remove
|
||||
# this code.
|
||||
distgit_get_branch = "sh -c {}'; git -C {} checkout {}'".format(
|
||||
pipes.quote(distgit_get), artifact_name, branch)
|
||||
repo_path, branch = source.split("?#")
|
||||
distgit_cmds = self._get_distgit_commands(source)
|
||||
# Supply the artifact name for "{0}" and the full path to the repo for "{repo_path}"
|
||||
distgit_get = distgit_cmds[0].format(artifact_name, repo_path=repo_path)
|
||||
|
||||
f.writelines([
|
||||
"config_opts['scm'] = True\n",
|
||||
"config_opts['scm_opts']['method'] = 'distgit'\n",
|
||||
"config_opts['scm_opts']['package'] = '{}'\n".format(artifact_name),
|
||||
"config_opts['scm_opts']['distgit_get'] = {!r}\n".format(distgit_get_branch),
|
||||
])
|
||||
# mock-scm cannot checkout particular commit hash, but only branch.
|
||||
# We therefore use a command that combines the distgit-command with
|
||||
# checking out a particular commit hash.
|
||||
# See https://bugzilla.redhat.com/show_bug.cgi?id=1459437 for
|
||||
# more info. Once mock-scm supports this feature, we can remove
|
||||
# this code.
|
||||
distgit_get_branch = "sh -c {}'; git -C {} checkout {}'".format(
|
||||
pipes.quote(distgit_get), artifact_name, branch)
|
||||
|
||||
# Set distgit_src_get only if it's defined.
|
||||
if distgit_cmds[1]:
|
||||
f.write(
|
||||
"config_opts['scm_opts']['distgit_src_get'] = '{}'\n".format(distgit_cmds[1]))
|
||||
scm_options = [
|
||||
('method', 'distgit'),
|
||||
('package', artifact_name),
|
||||
('distgit_get', distgit_get_branch),
|
||||
]
|
||||
|
||||
# The local git repositories cloned by `fedpkg clone` typically do not have
|
||||
# the tarballs with sources committed in a git repo. They normally live in lookaside
|
||||
# cache on remote server, but we should not try getting them from there for true
|
||||
# local builds.
|
||||
# Instead, get them from local path with git repository by passing that path to Mock
|
||||
# using the `ext_src_dir`.
|
||||
if repo_path.startswith("file://"):
|
||||
src_dir = repo_path[len("file://"):]
|
||||
f.write("config_opts['scm_opts']['ext_src_dir'] = '{}'\n".format(src_dir))
|
||||
# Set distgit_src_get only if it's defined.
|
||||
if distgit_cmds[1]:
|
||||
scm_options.append(('distgit_src_get', distgit_cmds[1]))
|
||||
|
||||
# The local git repositories cloned by `fedpkg clone` typically do not have
|
||||
# the tarballs with sources committed in a git repo. They normally live in lookaside
|
||||
# cache on remote server, but we should not try getting them from there for true
|
||||
# local builds.
|
||||
# Instead, get them from local path with git repository by passing that path to Mock
|
||||
# using the `ext_src_dir`.
|
||||
if repo_path.startswith("file://"):
|
||||
src_dir = repo_path[len("file://"):]
|
||||
scm_options.append(('ext_src_dir', src_dir))
|
||||
|
||||
self.cmd.append('--scm-enable')
|
||||
for name, value in scm_options:
|
||||
self.cmd.extend(('--scm-option', '{}={}'.format(name, value)))
|
||||
|
||||
def _get_distgit_commands(self, source):
|
||||
for host, cmds in conf.distgits.items():
|
||||
|
||||
Reference in New Issue
Block a user