createrepo: Include empty modules
A module without any RPMs is still valid and should be included. It should also be in the metadata. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
38f1a8509e
commit
096075848b
@ -224,27 +224,23 @@ def create_variant_repo(compose, arch, variant, pkg_type, modules_metadata=None)
|
|||||||
artifacts = repo_mmd.get_rpm_artifacts()
|
artifacts = repo_mmd.get_rpm_artifacts()
|
||||||
|
|
||||||
# Modules without RPMs are also valid.
|
# Modules without RPMs are also valid.
|
||||||
if not artifacts or artifacts.size() == 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
module_rpms = set()
|
module_rpms = set()
|
||||||
repo_artifacts = Modulemd.SimpleSet()
|
if artifacts and artifacts.size() > 0:
|
||||||
rpm_licenses = Modulemd.SimpleSet()
|
repo_artifacts = Modulemd.SimpleSet()
|
||||||
for rpm_nevra in rpm_nevras:
|
rpm_licenses = Modulemd.SimpleSet()
|
||||||
if artifacts.contains(rpm_nevra):
|
for rpm_nevra in rpm_nevras:
|
||||||
repo_artifacts.add(rpm_nevra)
|
if artifacts.contains(rpm_nevra):
|
||||||
module_rpms.add(rpm_nevra)
|
repo_artifacts.add(rpm_nevra)
|
||||||
# Not all RPMs have license data (*-debuginfo does not),
|
module_rpms.add(rpm_nevra)
|
||||||
# so add any that do and don't worry about the remainder.
|
# Not all RPMs have license data (*-debuginfo does not),
|
||||||
if rpm_nevra in license_data:
|
# so add any that do and don't worry about the remainder.
|
||||||
rpm_licenses.add(license_data[rpm_nevra])
|
if rpm_nevra in license_data:
|
||||||
repo_mmd.set_rpm_artifacts(repo_artifacts)
|
rpm_licenses.add(license_data[rpm_nevra])
|
||||||
repo_mmd.set_content_licenses(rpm_licenses)
|
repo_mmd.set_rpm_artifacts(repo_artifacts)
|
||||||
if module_rpms: # do not create metadata if there is empty rpm list
|
repo_mmd.set_content_licenses(rpm_licenses)
|
||||||
if modules_metadata: # some unittests call this method without parameter modules_metadata and its default is None
|
|
||||||
metadata.append((module_id, module_rpms))
|
if modules_metadata:
|
||||||
else:
|
metadata.append((module_id, module_rpms))
|
||||||
raise AttributeError("module_metadata parameter was not passed and it is needed for module processing")
|
|
||||||
modules.append(repo_mmd)
|
modules.append(repo_mmd)
|
||||||
|
|
||||||
module_names = set([x.get_name() for x in modules])
|
module_names = set([x.get_name() for x in modules])
|
||||||
|
@ -745,10 +745,12 @@ class TestCreateVariantRepo(PungiTestCase):
|
|||||||
self.assertEqual(f.read(), 'Packages/b/bash-4.3.30-2.fc21.src.rpm\n')
|
self.assertEqual(f.read(), 'Packages/b/bash-4.3.30-2.fc21.src.rpm\n')
|
||||||
|
|
||||||
@unittest.skipUnless(Modulemd is not None, 'Skipped test, no module support.')
|
@unittest.skipUnless(Modulemd is not None, 'Skipped test, no module support.')
|
||||||
|
@mock.patch('pungi.phases.createrepo.find_file_in_repodata')
|
||||||
@mock.patch('pungi.phases.createrepo.run')
|
@mock.patch('pungi.phases.createrepo.run')
|
||||||
@mock.patch('pungi.phases.createrepo.CreaterepoWrapper')
|
@mock.patch('pungi.phases.createrepo.CreaterepoWrapper')
|
||||||
def test_variant_repo_modules_artifacts_not_in_compose(
|
def test_variant_repo_modules_artifacts_not_in_compose(
|
||||||
self, CreaterepoWrapperCls, run):
|
self, CreaterepoWrapperCls, run, modulemd_filename
|
||||||
|
):
|
||||||
compose = DummyCompose(self.topdir, {
|
compose = DummyCompose(self.topdir, {
|
||||||
'createrepo_checksum': 'sha256',
|
'createrepo_checksum': 'sha256',
|
||||||
})
|
})
|
||||||
@ -778,8 +780,10 @@ class TestCreateVariantRepo(PungiTestCase):
|
|||||||
repodata_dir = os.path.join(
|
repodata_dir = os.path.join(
|
||||||
compose.paths.compose.os_tree('x86_64', compose.variants['Server']),
|
compose.paths.compose.os_tree('x86_64', compose.variants['Server']),
|
||||||
'repodata')
|
'repodata')
|
||||||
|
modulemd_filename.return_value = "Server/x86_64/os/repodata/3511d16a7-modules.yaml.gz"
|
||||||
|
modules_metadata = mock.Mock()
|
||||||
|
|
||||||
create_variant_repo(compose, 'x86_64', compose.variants['Server'], 'rpm')
|
create_variant_repo(compose, 'x86_64', compose.variants['Server'], 'rpm', modules_metadata)
|
||||||
|
|
||||||
self.assertItemsEqual(
|
self.assertItemsEqual(
|
||||||
repo.get_modifyrepo_cmd.mock_calls,
|
repo.get_modifyrepo_cmd.mock_calls,
|
||||||
|
Loading…
Reference in New Issue
Block a user