Пример #1
0
    def iter_parse(self, path: str, factory: PackageFactory) -> Iterable[PackageMaker]:
        for pkgdata in iter_sqlite(path, 'MIRRORPKG', ['NAME', 'VERSION', 'ARCH']):
            with factory.begin() as pkg:
                pkg.add_name(pkgdata['NAME'], NameType.KWORT_NAME)
                pkg.set_version(pkgdata['VERSION'])
                pkg.set_arch(pkgdata['ARCH'])

                yield pkg
Пример #2
0
    def iter_parse(self, path: str, factory: PackageFactory,
                   transformer: PackageTransformer) -> Iterable[PackageMaker]:
        normalize_version = VersionStripper().strip_right_greedy('+')

        skipped_archs: Dict[str, int] = Counter()

        wanted_columns = [
            'name', 'version', 'arch', 'epoch', 'release', 'summary', 'url',
            'rpm_group', 'rpm_license', 'arch', 'rpm_packager', 'rpm_sourcerpm'
        ]

        for pkgdata in iter_sqlite(path, 'packages', wanted_columns):
            is_src = pkgdata['arch'] == 'src'

            if (is_src and not self._src) or (not is_src and not self._binary):
                skipped_archs[pkgdata['arch']] += 1
                continue

            with factory.begin() as pkg:
                if is_src:
                    pkg.add_name(pkgdata['name'], NameType.SRCRPM_NAME)
                else:
                    pkg.add_name(pkgdata['name'], NameType.BINRPM_NAME)
                    pkg.add_name(
                        nevra_parse(pkgdata['rpm_sourcerpm'])[0],
                        NameType.BINRPM_SRCNAME)

                version = pkgdata['version']

                match = re.match('0\\.[0-9]+\\.((?:alpha|beta|rc)[0-9]+)\\.',
                                 pkgdata['release'])
                if match:
                    # known pre-release schema: https://fedoraproject.org/wiki/Packaging:Versioning#Prerelease_versions
                    version += '-' + match.group(1)
                elif pkgdata['release'] < '1':
                    # unknown pre-release schema: https://fedoraproject.org/wiki/Packaging:Versioning#Some_definitions
                    # most likely a snapshot
                    pkg.set_flags(PackageFlags.IGNORE)

                pkg.set_version(version, normalize_version)
                pkg.set_rawversion(
                    nevra_construct(None, pkgdata['epoch'], pkgdata['version'],
                                    pkgdata['release']))

                pkg.set_arch(pkgdata['arch'])
                pkg.set_summary(pkgdata['summary'])
                pkg.add_homepages(pkgdata['url'])
                pkg.add_categories(pkgdata['rpm_group'])
                pkg.add_licenses(pkgdata['rpm_license'])
                pkg.set_arch(pkgdata['arch'])
                pkg.add_maintainers(
                    extract_maintainers(pkgdata['rpm_packager']))

                yield pkg