Beispiel #1
0
def set_status(result, pkgs, python_versions):
    # Look at the Python dependencies of given packages, based on the
    # name only (this means different arches are grouped into one)
    name_by_version = collections.defaultdict(set)
    pkg_by_version = collections.defaultdict(set)
    name_by_arch = collections.defaultdict(set)
    for p in pkgs:
        name_by_arch[p.arch].add(f'{p.name}.{p.arch}')
        for v in python_versions[p]:
            name_by_version[v].add(f'{p.name}.{p.arch}')
            pkg_by_version[v].add(p)

    if (name_by_version[2] & name_by_version[3]) - name_by_arch['src']:
        # If a package depends on *both* py2 and py3, it's not ported
        result['status'] = 'mispackaged'
        result['note'] = (
            'A single package depends on both Python 2 and '
            'Python 3.\n'
            'It should be split into a python2 and python3 subpackages '
            'to prevent it from always dragging the py2 dependency in.')
    elif not name_by_version[2]:
        # Hooray!
        result['status'] = 'py3-only'
    else:
        # Otherwise, a srpm isn't ported if it has more packages that need py2
        # than those that need py3
        if len(name_by_version[3]) >= len(name_by_version[2]):
            if have_binaries(pkg_by_version[2]) and not have_binaries(
                    pkg_by_version[3]):
                # Identify packages with py2 only binaries.
                result['status'] = 'mispackaged'
                result['nonblocking'] = True
                result['note'] = (
                    'The Python 3 package is missing binaries available '
                    'in a Python 2 package.\n')
            elif all(result['rpms'][format_rpm_name(pkg)]['almost_leaf']
                     or result['rpms'][format_rpm_name(pkg)]['arch'] == 'src'
                     for pkg in pkg_by_version[2]) and any(
                         result['rpms'][format_rpm_name(pkg)]['arch'] != 'src'
                         for pkg in pkg_by_version[2]):
                # Packages with py2 subpackages not required by anything.
                # (source packages don't count)
                result['status'] = 'legacy-leaf'
            else:
                result['status'] = 'released'
        else:
            result['status'] = 'idle'

    for pkg in pkg_by_version[2]:
        if pkg.arch != 'src':
            is_misnamed = check_naming_policy(pkg, name_by_version)
            if is_misnamed and pkg.name != 'python-unversioned-command':
                rpm_name = format_rpm_name(pkg)
                result['rpms'].get(rpm_name, {})['is_misnamed'] = is_misnamed
def test_package_is_named_correctly(pkgglob, name_by_version):
    assert not check_naming_policy(gpkg(pkgglob), name_by_version)
def test_package_is_misnamed(pkgglob, name_by_version):
    assert check_naming_policy(gpkg(pkgglob), name_by_version)
def test_package_is_named_correctly(pkgglob, name_by_version):
    assert not check_naming_policy(gpkg(pkgglob), name_by_version)
def test_package_is_misnamed(pkgglob, name_by_version):
    assert check_naming_policy(gpkg(pkgglob), name_by_version)