예제 #1
0
    def _create_mmd(name, stream, version, rpms=None, profiles=None):
        rpms = rpms or []
        profiles = profiles or {}  # profile_name: {pkg_format: [pkg_names]}

        mmd = Modulemd.Module()
        mmd.set_mdversion(int(1))
        mmd.set_name(str(name))
        mmd.set_stream(str(stream))
        mmd.set_version(int(version))
        sset = Modulemd.SimpleSet()
        sset.add("LGPLv2")
        mmd.set_module_licenses(sset)
        mmd.set_summary(str("Fake module"))
        mmd.set_description(mmd.peek_summary())
        artifacts = Modulemd.SimpleSet()
        for rpm in rpms:
            artifacts.add(rpm[:-4])
        mmd.set_rpm_artifacts(artifacts)
        for profile_name in profiles:
            profile = Modulemd.Profile()
            profile.set_name(profile_name)
            profile_rpms = Modulemd.SimpleSet()
            profile_rpms.set(profiles[profile_name].get("rpms", []))
            profile.set_rpms(profile_rpms)
            mmd.add_profile(profile)

        return mmd
예제 #2
0
    def test_issue85(self):
        """
        Component module refs are lost when dumping to YAML
        """
        mmd = Modulemd.Module().new_from_string("""
document: modulemd
version: 1
data:
    summary: A test module in all its beautiful beauty.
    description: >-
        This module demonstrates how to write simple modulemd files And
        can be used for testing the build and release pipeline.
    license:
        module: [ MIT ]
    dependencies:
        buildrequires:
            platform: el8
        requires:
            platform: el8
    references:
        community: https://fedoraproject.org/wiki/Modularity
        documentation: https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules
        tracker: https://taiga.fedorainfracloud.org/project/modularity
    profiles:
        default:
            rpms:
                - acl
    api:
        rpms:
            - acl
    components:
        rpms:
            acl:
                rationale: needed
                ref: rhel-8.0
        modules:
            testmodule:
                ref: private-x
                rationale: Testing module inclusion.
                buildorder: 10
""")
        assert mmd.get_module_components(
        )['testmodule'].peek_ref() == 'private-x'

        mmd2 = Modulemd.Module.copy(mmd)
        assert mmd2.get_module_components(
        )['testmodule'].peek_ref() == 'private-x'

        mmd3 = Modulemd.Module.new_from_string(mmd.dumps())
        assert mmd3.get_module_components(
        )['testmodule'].peek_ref() == 'private-x'
예제 #3
0
    def test_issue24(self):
        # Verify that we can handle boolean variant types
        name = stream = context = "x"
        version = 10

        mmd = Modulemd.Module()
        mmd.set_mdversion(2)
        mmd.set_name(name)
        mmd.set_stream(stream)
        mmd.set_version(int(version))
        mmd.set_context(context)
        mmd.set_summary("foo")
        mmd.set_description("foo")
        licenses = Modulemd.SimpleSet()
        licenses.add("GPL")
        mmd.set_module_licenses(licenses)

        d = {"x": GLib.Variant('b', True)}
        mmd.set_xmd(d)
        mmd.dumps()
예제 #4
0
    def _create_mmd(name, stream, version, rpms=None, profiles=None):
        rpms = rpms or []
        profiles = profiles or {}  # profile_name: {pkg_format: [pkg_names]}

        mmd = Modulemd.Module()
        mmd.set_name(str(name))
        mmd.set_stream(str(stream))
        mmd.set_version(int(version))
        licenses = Modulemd.SimpleSet()
        licenses.add("LGPLv2")
        mmd.set_module_licenses(licenses)
        mmd.set_summary(str("Fake module"))
        mmd.set_description(mmd.get_summary())
        for rpm in rpms:
            mmd.get_rpm_components.add(rpm.rsplit("-", 2)[0], "")
            mmd.get_rpm_artifacts.add(rpm[:-4])
        for profile_name in profiles:

            profile = Modulemd.Profile()
            for rpm in profiles[profile_name].get("rpms", []):
                profile.add_rpm(rpm)
            profile.set_name(profile_name)
            mmd.add_profile(profile)
        return mmd
예제 #5
0
from gi.repository import Modulemd  # noqa

url = 'https://mbs.engineering.redhat.com/module-build-service/1/module-builds/?state=ready&per_page=100&verbose=True'
with open('blacklist.yaml', 'r') as blacklist_file:
    blacklist = yaml.safe_load(blacklist_file)
modules = []
blacklist_req = set(blacklist.get('requires', []))
blacklist_br = set(blacklist.get('buildrequires', []))

while True:
    response = requests.get(url).json()
    for module in response['items']:
        modulemd = yaml.safe_load(module['modulemd'])
        modulemd = json.dumps(modulemd)
        try:
            mmd = Modulemd.Module().new_from_string(modulemd)
            mmd.upgrade()
        except Exception:
            raise ValueError('Invalid modulemd')
        mmd_file = mmd.dumps()
        mmd = yaml.load(mmd_file)
        dependencies = mmd['data']['dependencies']
        module_br = set()
        module_req = set()
        for dependency in dependencies:
            if 'buildrequires' in dependency.keys():
                module_br = module_br.union(set(dependency['buildrequires']))
                overlap_br = set(blacklist_br).intersection(set(module_br))
            if 'requires' in dependency.keys():
                module_req = module_req.union(set(dependency['requires']))
                overlap_req = set(blacklist_req).intersection(set(module_req))
예제 #6
0
                i for i in os.listdir(noarch_module_dir) if i.endswith(".rpm")
            ]
        else:
            noarch_rpms = []

        rpms = sorted(set(rpms) | set(noarch_rpms))

        # HACK: force epoch to make test data compatible with libmodulemd >= 1.4.0
        rpms_with_epoch = []
        for i in rpms:
            n, v, ra = i.rsplit("-", 2)
            nevra = "%s-0:%s-%s" % (n, v, ra)
            rpms_with_epoch.append(nevra)
        rpms = rpms_with_epoch

        mmd = Modulemd.Module()
        mmd.set_mdversion(int(1))
        mmd.set_name(name)
        mmd.set_stream(stream)
        mmd.set_version(int(version))
        sset = Modulemd.SimpleSet()
        sset.add("LGPLv2")
        mmd.set_module_licenses(sset)
        mmd.set_summary("Fake module")
        mmd.set_description(mmd.peek_summary())
        artifacts = Modulemd.SimpleSet()
        for rpm in rpms:
            artifacts.add(rpm[:-4])
        mmd.set_rpm_artifacts(artifacts)
        for profile_name in profiles:
            profile = Modulemd.Profile()