repoclosure: add option to use dnf backend
This adds a new option repoclosure_backend that changes what tool is used for repoclosure. Checking build dependencies is currently not supported, as `dnf` does not have the corresponding option. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
95fc0fa4ab
commit
e3fe67be53
@ -152,6 +152,12 @@ Options
|
|||||||
([*str*]) -- list of variants which should be included; if undefined, all
|
([*str*]) -- list of variants which should be included; if undefined, all
|
||||||
variants from variants.xml will be included
|
variants from variants.xml will be included
|
||||||
|
|
||||||
|
**repoclosure_backend**
|
||||||
|
(*str*) -- Select which tool should be used to run repoclosure over created
|
||||||
|
repositories. By default ``yum`` is used, but you can switch to ``dnf``.
|
||||||
|
Please note that when ``dnf`` is used, the build dependencies check is
|
||||||
|
skipped.
|
||||||
|
|
||||||
|
|
||||||
Example
|
Example
|
||||||
-------
|
-------
|
||||||
|
@ -468,6 +468,11 @@ def _make_schema():
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": False,
|
"default": False,
|
||||||
},
|
},
|
||||||
|
"repoclosure_backend": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "yum",
|
||||||
|
"enum": ["yum", "dnf"],
|
||||||
|
},
|
||||||
|
|
||||||
"hashed_directories": {
|
"hashed_directories": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -64,7 +64,8 @@ def run_repoclosure(compose):
|
|||||||
for i, lookaside_url in enumerate(get_lookaside_repos(compose, arch, variant)):
|
for i, lookaside_url in enumerate(get_lookaside_repos(compose, arch, variant)):
|
||||||
lookaside["lookaside-%s.%s-%s" % (variant.uid, arch, i)] = lookaside_url
|
lookaside["lookaside-%s.%s-%s" % (variant.uid, arch, i)] = lookaside_url
|
||||||
|
|
||||||
cmd = repoclosure.get_repoclosure_cmd(repos=repos, lookaside=lookaside, arch=arches)
|
cmd = repoclosure.get_repoclosure_cmd(backend=compose.conf['repoclosure_backend'],
|
||||||
|
repos=repos, lookaside=lookaside, arch=arches)
|
||||||
# Use temp working directory directory as workaround for
|
# Use temp working directory directory as workaround for
|
||||||
# https://bugzilla.redhat.com/show_bug.cgi?id=795137
|
# https://bugzilla.redhat.com/show_bug.cgi?id=795137
|
||||||
tmp_dir = compose.mkdtemp(prefix="repoclosure_")
|
tmp_dir = compose.mkdtemp(prefix="repoclosure_")
|
||||||
@ -87,7 +88,11 @@ def run_repoclosure(compose):
|
|||||||
# In this case, it's an obvious bug in the test.
|
# In this case, it's an obvious bug in the test.
|
||||||
|
|
||||||
# check BuildRequires (self-hosting)
|
# check BuildRequires (self-hosting)
|
||||||
cmd = repoclosure.get_repoclosure_cmd(repos=all_repos, arch=all_arches, builddeps=True)
|
try:
|
||||||
|
cmd = repoclosure.get_repoclosure_cmd(backend=compose.conf['repoclosure_backend'],
|
||||||
|
repos=all_repos, arch=all_arches, builddeps=True)
|
||||||
|
except RuntimeError as exc:
|
||||||
|
compose.log_error('%s, skipping builddeps check...' % str(exc))
|
||||||
# Use temp working directory directory as workaround for
|
# Use temp working directory directory as workaround for
|
||||||
# https://bugzilla.redhat.com/show_bug.cgi?id=795137
|
# https://bugzilla.redhat.com/show_bug.cgi?id=795137
|
||||||
tmp_dir = compose.mkdtemp(prefix="repoclosure_")
|
tmp_dir = compose.mkdtemp(prefix="repoclosure_")
|
||||||
|
@ -19,19 +19,22 @@ import os
|
|||||||
from kobo.shortcuts import force_list
|
from kobo.shortcuts import force_list
|
||||||
|
|
||||||
|
|
||||||
def get_repoclosure_cmd(arch=None, builddeps=False,
|
def get_repoclosure_cmd(backend='yum', arch=None, builddeps=False,
|
||||||
repos=None, lookaside=None):
|
repos=None, lookaside=None):
|
||||||
|
if backend == 'dnf' and builddeps:
|
||||||
|
raise RuntimeError('dnf repoclosure does not support builddeps')
|
||||||
|
|
||||||
|
cmds = {
|
||||||
|
'yum': {'cmd': ['/usr/bin/repoclosure'], 'repoarg': '--repoid=%s', 'lookaside': '--lookaside=%s'},
|
||||||
|
'dnf': {'cmd': ['dnf', 'repoclosure'], 'repoarg': '--repo=%s', 'lookaside': '--repo=%s'},
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
cmd = cmds[backend]['cmd']
|
||||||
|
except KeyError:
|
||||||
|
raise RuntimeError('Unknown repoclosure backend: %s' % backend)
|
||||||
|
|
||||||
cmd = ["/usr/bin/repoclosure"]
|
|
||||||
# There are options that are not exposed here, because we don't need
|
# There are options that are not exposed here, because we don't need
|
||||||
# them. These are:
|
# them.
|
||||||
# --config
|
|
||||||
# --basearch
|
|
||||||
# --tempcache
|
|
||||||
# --quiet
|
|
||||||
# --newest
|
|
||||||
# --pkg
|
|
||||||
# --group
|
|
||||||
|
|
||||||
for i in force_list(arch or []):
|
for i in force_list(arch or []):
|
||||||
cmd.append("--arch=%s" % i)
|
cmd.append("--arch=%s" % i)
|
||||||
@ -42,12 +45,17 @@ def get_repoclosure_cmd(arch=None, builddeps=False,
|
|||||||
repos = repos or {}
|
repos = repos or {}
|
||||||
for repo_id, repo_path in repos.iteritems():
|
for repo_id, repo_path in repos.iteritems():
|
||||||
cmd.append("--repofrompath=%s,%s" % (repo_id, _to_url(repo_path)))
|
cmd.append("--repofrompath=%s,%s" % (repo_id, _to_url(repo_path)))
|
||||||
cmd.append("--repoid=%s" % repo_id)
|
cmd.append(cmds[backend]['repoarg'] % repo_id)
|
||||||
|
if backend == 'dnf':
|
||||||
|
# For dnf we want to add all repos with the --repo option (which
|
||||||
|
# enables only those and not any system repo), and the repos to
|
||||||
|
# check are also listed with the --check option.
|
||||||
|
cmd.append('--check=%s' % repo_id)
|
||||||
|
|
||||||
lookaside = lookaside or {}
|
lookaside = lookaside or {}
|
||||||
for repo_id, repo_path in lookaside.iteritems():
|
for repo_id, repo_path in lookaside.iteritems():
|
||||||
cmd.append("--repofrompath=%s,%s" % (repo_id, _to_url(repo_path)))
|
cmd.append("--repofrompath=%s,%s" % (repo_id, _to_url(repo_path)))
|
||||||
cmd.append("--lookaside=%s" % repo_id)
|
cmd.append(cmds[backend]['lookaside'] % repo_id)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -389,5 +389,17 @@ class TestRegexValidation(ConfigTestCase):
|
|||||||
[])
|
[])
|
||||||
|
|
||||||
|
|
||||||
|
class RepoclosureTestCase(ConfigTestCase):
|
||||||
|
def test_invalid_backend(self):
|
||||||
|
cfg = load_config(
|
||||||
|
PKGSET_REPOS,
|
||||||
|
repoclosure_backend='fnd', # Intentionally with a typo
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertValidation(
|
||||||
|
cfg,
|
||||||
|
["Failed validation in repoclosure_backend: 'fnd' is not one of ['yum', 'dnf']"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -18,6 +18,16 @@ class RepoclosureWrapperTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(rc.get_repoclosure_cmd(),
|
self.assertEqual(rc.get_repoclosure_cmd(),
|
||||||
['/usr/bin/repoclosure'])
|
['/usr/bin/repoclosure'])
|
||||||
|
|
||||||
|
def test_minimal_dnf_command(self):
|
||||||
|
self.assertEqual(rc.get_repoclosure_cmd(backend='dnf'),
|
||||||
|
['dnf', 'repoclosure'])
|
||||||
|
|
||||||
|
def test_unknown_backend(self):
|
||||||
|
with self.assertRaises(RuntimeError) as ctx:
|
||||||
|
rc.get_repoclosure_cmd(backend='rpm')
|
||||||
|
|
||||||
|
self.assertEqual(str(ctx.exception), 'Unknown repoclosure backend: rpm')
|
||||||
|
|
||||||
def test_multiple_arches(self):
|
def test_multiple_arches(self):
|
||||||
self.assertEqual(rc.get_repoclosure_cmd(arch=['x86_64', 'ppc64']),
|
self.assertEqual(rc.get_repoclosure_cmd(arch=['x86_64', 'ppc64']),
|
||||||
['/usr/bin/repoclosure', '--arch=x86_64', '--arch=ppc64'])
|
['/usr/bin/repoclosure', '--arch=x86_64', '--arch=ppc64'])
|
||||||
@ -38,6 +48,22 @@ class RepoclosureWrapperTestCase(unittest.TestCase):
|
|||||||
'--repoid=my-repo',
|
'--repoid=my-repo',
|
||||||
'--lookaside=fedora'])
|
'--lookaside=fedora'])
|
||||||
|
|
||||||
|
def test_full_dnf_command(self):
|
||||||
|
repos = {'my-repo': '/mnt/koji/repo'}
|
||||||
|
lookaside = {'fedora': 'http://kojipkgs.fp.o/repo'}
|
||||||
|
|
||||||
|
cmd = rc.get_repoclosure_cmd(backend='dnf', arch='x86_64',
|
||||||
|
repos=repos, lookaside=lookaside)
|
||||||
|
self.assertEqual(cmd[:2], ['dnf', 'repoclosure'])
|
||||||
|
self.assertItemsEqual(
|
||||||
|
cmd[2:],
|
||||||
|
['--arch=x86_64',
|
||||||
|
'--repofrompath=my-repo,file:///mnt/koji/repo',
|
||||||
|
'--repofrompath=fedora,http://kojipkgs.fp.o/repo',
|
||||||
|
'--repo=my-repo',
|
||||||
|
'--check=my-repo',
|
||||||
|
'--repo=fedora'])
|
||||||
|
|
||||||
def test_expand_repo(self):
|
def test_expand_repo(self):
|
||||||
repos = {
|
repos = {
|
||||||
'local': '/mnt/koji/repo',
|
'local': '/mnt/koji/repo',
|
||||||
|
@ -177,7 +177,7 @@ class TestRepoclosure(PungiTestCase):
|
|||||||
|
|
||||||
@mock.patch('pungi.wrappers.repoclosure.get_repoclosure_cmd')
|
@mock.patch('pungi.wrappers.repoclosure.get_repoclosure_cmd')
|
||||||
@mock.patch('pungi.phases.test.run')
|
@mock.patch('pungi.phases.test.run')
|
||||||
def test_calls_repoclosure(self, mock_run, mock_grc):
|
def test_repoclosure_default_backend(self, mock_run, mock_grc):
|
||||||
compose = DummyCompose(self.topdir, {})
|
compose = DummyCompose(self.topdir, {})
|
||||||
test_phase.run_repoclosure(compose)
|
test_phase.run_repoclosure(compose)
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
@ -189,17 +189,43 @@ class TestRepoclosure(PungiTestCase):
|
|||||||
|
|
||||||
self.assertItemsEqual(
|
self.assertItemsEqual(
|
||||||
mock_grc.call_args_list,
|
mock_grc.call_args_list,
|
||||||
[mock.call(arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
[mock.call(backend='yum', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||||
repos=self._get_repo('Everything', 'amd64')),
|
repos=self._get_repo('Everything', 'amd64')),
|
||||||
mock.call(arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
mock.call(backend='yum', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||||
repos=self._get_repo('Client', 'amd64')),
|
repos=self._get_repo('Client', 'amd64')),
|
||||||
mock.call(arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
mock.call(backend='yum', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||||
repos=self._get_repo('Server', 'amd64')),
|
repos=self._get_repo('Server', 'amd64')),
|
||||||
mock.call(arch=['x86_64', 'noarch'], lookaside={},
|
mock.call(backend='yum', arch=['x86_64', 'noarch'], lookaside={},
|
||||||
repos=self._get_repo('Server', 'x86_64')),
|
repos=self._get_repo('Server', 'x86_64')),
|
||||||
mock.call(arch=['x86_64', 'noarch'], lookaside={},
|
mock.call(backend='yum', arch=['x86_64', 'noarch'], lookaside={},
|
||||||
repos=self._get_repo('Everything', 'x86_64')),
|
repos=self._get_repo('Everything', 'x86_64')),
|
||||||
mock.call(arch={'x86_64', 'amd64', 'noarch'}, builddeps=True, repos=all_repos)])
|
mock.call(backend='yum', arch={'x86_64', 'amd64', 'noarch'}, builddeps=True, repos=all_repos)])
|
||||||
|
|
||||||
|
@mock.patch('pungi.wrappers.repoclosure.get_repoclosure_cmd')
|
||||||
|
@mock.patch('pungi.phases.test.run')
|
||||||
|
def test_repoclosure_dnf_backend(self, mock_run, mock_grc):
|
||||||
|
compose = DummyCompose(self.topdir, {'repoclosure_backend': 'dnf'})
|
||||||
|
test_phase.run_repoclosure(compose)
|
||||||
|
self.maxDiff = None
|
||||||
|
all_repos = {}
|
||||||
|
for variant in compose.variants.itervalues():
|
||||||
|
for arch in variant.arches:
|
||||||
|
all_repos.update(self._get_repo(variant.uid, arch))
|
||||||
|
all_repos.update(self._get_repo(variant.uid, 'src', 'source/tree'))
|
||||||
|
|
||||||
|
self.assertItemsEqual(
|
||||||
|
mock_grc.call_args_list,
|
||||||
|
[mock.call(backend='dnf', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||||
|
repos=self._get_repo('Everything', 'amd64')),
|
||||||
|
mock.call(backend='dnf', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||||
|
repos=self._get_repo('Client', 'amd64')),
|
||||||
|
mock.call(backend='dnf', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||||
|
repos=self._get_repo('Server', 'amd64')),
|
||||||
|
mock.call(backend='dnf', arch=['x86_64', 'noarch'], lookaside={},
|
||||||
|
repos=self._get_repo('Server', 'x86_64')),
|
||||||
|
mock.call(backend='dnf', arch=['x86_64', 'noarch'], lookaside={},
|
||||||
|
repos=self._get_repo('Everything', 'x86_64')),
|
||||||
|
mock.call(backend='dnf', arch={'x86_64', 'amd64', 'noarch'}, builddeps=True, repos=all_repos)])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user