Ejemplo n.º 1
0
 def _extra_handling(self, pkg: PackageMaker, pkgdata: dict[str,
                                                            str]) -> None:
     if 'Binary' not in pkgdata or 'Source' in pkgdata:
         raise RuntimeError(
             'Sanity check failed, expected Package descriptions with Binary, but without Source field'
         )
     pkg.add_name(pkgdata['Package'], NameType.DEBIAN_SOURCE_PACKAGE)
     pkg.add_binnames(pkgdata['Binary'].split(', '))
Ejemplo n.º 2
0
def add_patch_files(pkg: PackageMaker,
                    path: str,
                    pattern: Optional[str] = None) -> None:
    # skip symlinked directory - in most cases we can't construct links out of these
    if not os.path.isdir(path) or os.path.islink(path):
        return

    filenames = os.listdir(path)
    if pattern is not None:
        filenames = [fn for fn in filenames if fnmatch.fnmatch(fn, pattern)]

    if filenames:
        pkg.set_extra_field('patch', sorted(filenames))
Ejemplo n.º 3
0
def _construct_upstream_link(upstream_type: str, arg: str, pkg: PackageMaker) -> Optional[str]:
    if   upstream_type == 'bitbucket':      return 'https://bitbucket.org/{}'.format(arg)  # noqa
    elif upstream_type == 'cpan':           return 'https://metacpan.org/release/{}'.format(arg)  # noqa
    elif upstream_type == 'cpan-module':    return None  # should be handled by cpan  # noqa
    elif upstream_type == 'cpe':            return None  # ignore  # noqa
    elif upstream_type == 'ctan':           return 'https://www.ctan.org/pkg/{}'.format(arg)  # noqa
    elif upstream_type == 'freecode':       return 'http://freecode.com/projects/{}'.format(arg)  # noqa
    elif upstream_type == 'freshmeat':      return 'http://freshmeat.net/projects/{}/'.format(arg)  # noqa
    elif upstream_type == 'github':         return 'https://github.com/{}'.format(arg)  # noqa
    elif upstream_type == 'gitlab':         return 'https://gitlab.com/{}'.format(arg)  # noqa
    elif upstream_type == 'google-code':    return 'https://code.google.com/p/{}/'.format(arg)  # noqa
    elif upstream_type == 'launchpad':      return 'https://launchpad.net/{}'.format(arg)  # noqa
    elif upstream_type == 'pear':           return 'http://pear.php.net/package/{}'.format(arg)  # noqa
    elif upstream_type == 'pypi':           return 'https://pypi.org/project/{}/'.format(arg)  # noqa
    elif upstream_type == 'rubygems':       return 'https://rubygems.org/gems/{}'.format(arg)  # noqa
    elif upstream_type == 'sourceforge':    return 'https://sourceforge.net/projects/{}/'.format(arg)  # noqa
    elif upstream_type == 'sourceforge-jp': return 'https://osdn.net/projects/{}/'.format(arg)  # noqa

    pkg.log('Unsupported upstream type {}'.format(upstream_type), Logger.ERROR)
    return None
Ejemplo n.º 4
0
 def _extra_handling(self, pkg: PackageMaker, pkgdata: Dict[str,
                                                            str]) -> None:
     source = pkgdata.get('Source')
     if source:
         pkgpath = source.split('/')
         pkg.set_basename(pkgpath[-1])
         pkg.set_extra_field('srcname', pkgpath[-1])
         pkg.set_extra_field('path', '/'.join(pkgpath[2:]))
         if pkgpath[2:4] == ['lang', 'python']:
             # All python modules are in lang/python, but not of lang/python are python modules
             # some are prefixe by python- or python3-, some are not
             # as a result, there's no reliable way to detect python modules and there may be
             # name clashes, (itsdangerous, xmltodict)
             # Prevent these by marking as untrusted
             pkg.set_flags(PackageFlags.UNTRUSTED)
Ejemplo n.º 5
0
    def _extra_handling(self, pkg: PackageMaker, pkgdata: Dict[str,
                                                               str]) -> None:
        pkgpath = pkgdata['Source'].split('/')
        pkg.add_name(pkgdata['Package'], NameType.OPENWRT_PACKAGE)
        pkg.add_name(pkgpath[-1], NameType.OPENWRT_SOURCEDIR)
        pkg.add_name(pkgdata['Source'], NameType.OPENWRT_SOURCE)
        if 'SourceName' in pkgdata:  # not present in openwrt < 19_07
            pkg.add_name(pkgdata['SourceName'], NameType.OPENWRT_SOURCENAME)
        pkg.set_arch(pkgdata['Architecture'])

        if pkgpath[2:4] == ['lang', 'python']:
            # All python modules are in lang/python, but not all of lang/python are python modules
            # some are prefixed by python- or python3-, some are not
            # as a result, there's no reliable way to detect python modules and there may be
            # name clashes, (itsdangerous, xmltodict)
            # Prevent these by marking as untrusted
            pkg.set_flags(PackageFlags.UNTRUSTED)

        if pkgpath[2:4] == ['lang' 'erlang']:
            # modules with their own versions packages as a single entity
            pkg.set_flags(PackageFlags.UNTRUSTED)
Ejemplo n.º 6
0
 def _extra_handling(self, pkg: PackageMaker, pkgdata: Dict[str,
                                                            str]) -> None:
     assert ('Binary' in pkgdata)
     assert ('Source' not in pkgdata)
     pkg.add_name(pkgdata['Package'], NameType.DEBIAN_SOURCE_PACKAGE)
Ejemplo n.º 7
0
def _parse_package(pkg: PackageMaker,
                   fields: dict[str, Any]) -> tuple[str, PackageMaker]:
    distribution = _as_str(fields['distribution'])
    pkg.add_name(distribution, NameType.CPAN_NAME)

    version = _as_str(fields['version'])
    pkg.set_version(version)

    author = _as_maybe_str(fields['author'])
    if author:
        pkg.add_maintainers(author.lower() + '@cpan')

    pkg.add_licenses(_as_list(fields['license']))
    pkg.set_summary(_as_maybe_str(fields.get('abstract')))
    pkg.add_homepages(_as_maybe_str(fields.get('resources.homepage')))
    pkg.add_downloads(_as_list(fields.get('download_url')))

    name = _as_str(fields['name'])
    if version not in name:
        pkg.set_flags(PackageFlags.UNTRUSTED)

    return distribution, pkg
Ejemplo n.º 8
0
def _parse_package(pkg: PackageMaker, fields: Dict[str, Any]) -> PackageMaker:
    pkg.set_name(_as_str(fields['distribution']))
    pkg.set_version(_as_str(fields['version']))

    author = _as_str(fields['author'])
    if author:
        pkg.add_maintainers(author.lower() + '@cpan')

    pkg.add_licenses(_as_list(fields['license']))
    pkg.set_summary(_as_str(fields.get('abstract')))
    pkg.add_homepages(_as_str(fields.get('resources.homepage')))
    pkg.add_downloads(_as_list(fields.get('download_url')))

    return pkg
Ejemplo n.º 9
0
def _parse_package(pkg: PackageMaker,
                   fields: Dict[str, Any]) -> Tuple[str, PackageMaker]:
    distribution = _as_str(fields['distribution'])
    assert (distribution is not None)

    pkg.add_name(distribution, NameType.CPAN_NAME)
    pkg.set_version(_as_str(fields['version']))

    author = _as_str(fields['author'])
    if author:
        pkg.add_maintainers(author.lower() + '@cpan')

    pkg.add_licenses(_as_list(fields['license']))
    pkg.set_summary(_as_str(fields.get('abstract')))
    pkg.add_homepages(_as_str(fields.get('resources.homepage')))
    pkg.add_downloads(_as_list(fields.get('download_url')))

    return distribution, pkg