Example #1
0
 def test_get_macros(self):
     rpm.addMacro('test_macro', 'test_macro value')
     macros = MacroHelper.dump()
     macros = MacroHelper.filter(macros, name='test_macro', level=-1)
     assert len(macros) == 1
     assert macros[0]['name'] == 'test_macro'
     assert macros[0]['value'] == 'test_macro value'
     assert macros[0]['level'] == -1
 def test_get_macros(self):
     rpm.addMacro('test_macro', 'test_macro value')
     macros = MacroHelper.dump()
     macros = MacroHelper.filter(macros, name='test_macro', level=-1)
     assert len(macros) == 1
     assert macros[0]['name'] == 'test_macro'
     assert macros[0]['value'] == 'test_macro value'
     assert macros[0]['level'] == -1
Example #3
0
 def get_arches():
     """Gets list of all known architectures"""
     arches = ['aarch64', 'noarch', 'ppc', 'riscv64', 's390', 's390x', 'src', 'x86_64']
     macros = MacroHelper.dump()
     macros = [m for m in macros if m['name'] in ('ix86', 'arm', 'mips', 'sparc', 'alpha', 'power64')]
     for m in macros:
         arches.extend(MacroHelper.expand(m['value'], '').split())
     return arches
Example #4
0
def mocked_spec_object(spec_attributes):
    spec = SpecFile.__new__(SpecFile)
    spec.save = lambda: None
    for attribute, value in spec_attributes.items():
        if attribute == 'macros':
            for macro, properties in value.items():
                rpm.addMacro(macro, properties.get('value', ''))
            macros = MacroHelper.dump()
            for macro, properties in value.items():
                for m in macros:
                    if m['name'] == macro:
                        for prop, v in properties.items():
                            if prop != 'value':
                                m[prop] = v
            value = macros
        if attribute == 'spec_content' and isinstance(value, str):
            value = SpecContent(value)
        setattr(spec, attribute, value)
    if hasattr(spec, 'spec_content') and not hasattr(spec, 'tags'):
        spec.tags = Tags(spec.spec_content, spec.spec_content)
    return spec
Example #5
0
    def _update_data(self):
        """
        Function updates data from given SPEC file

        :return:
        """
        def guess_category():
            for pkg in self.spc.packages:
                header = RpmHeader(pkg.header)
                for category in PackageCategory:
                    if category.value.match(header.name):
                        return category
                    for provide in header.providename:
                        if category.value.match(provide):
                            return category
            return None
        self.category = guess_category()
        self.sources = self._get_spec_sources_list(self.spc)
        self.prep_section = self.spc.prep
        self.main_source_index = self._identify_main_source(self.spc)
        self.patches = self._get_initial_patches()
        self.macros = MacroHelper.dump()