Ejemplo n.º 1
0
#!/usr/bin/python3

from lintian_brush.fixer import control, LintianIssue, report_result
from debmutate.control import get_relation, drop_dependency
from debmutate._rules import RulesEditor
from lintian_brush.debhelper import add_sequence

with control:
    for binary in control.binaries:
        try:
            rel = get_relation(binary.get('Depends', ''), 'vim-addon-manager')
        except KeyError:
            continue
        issue = LintianIssue(binary, 'obsolete-vim-addon-manager')
        if not issue.should_fix():
            continue
        binary['Depends'] = drop_dependency(binary['Depends'],
                                            'vim-addon-manager')
        with RulesEditor() as rules:
            add_sequence(control, rules, 'vim-addon')
        issue.report_fixed()

report_result('Migrate from vim-addon-manager to dh-vim-addon.')
from lintian_brush.patches import rules_find_patches_directory


def drop_quilt_with(line, target):
    newline = dh_invoke_drop_with(line, b'quilt')
    if line != newline:
        issue = LintianIssue(
            'source', 'dh-quilt-addon-but-quilt-source-format',
            'dh ... --with quilt (line XX)')
        if issue.should_fix():
            issue.report_fixed()
        else:
            newline = line
    return newline


try:
    with open('debian/source/format', 'r') as f:
        if f.read().strip() == '3.0 (quilt)':
            with RulesEditor() as updater:
                if rules_find_patches_directory(
                        updater.makefile) in ('debian/patches', None):
                    updater.legacy_update(command_line_cb=drop_quilt_with)
except FileNotFoundError:
    pass


report_result(
    "Don't specify --with=quilt, since package uses "
    "'3.0 (quilt)' source format.")
def get_archs():
    archs = set()

    # TODO(jelmer): Not really an 'update'
    with control as updater:
        for binary in updater.binaries:
            archs.add(binary['Architecture'])
    return archs


added = []


if not os.path.exists('debian/rules'):
    sys.exit(2)
with RulesEditor() as editor:
    has_build_arch = bool(list(editor.makefile.iter_rules(b'build-arch', exact=False)))
    has_build_indep = bool(list(editor.makefile.iter_rules(b'build-indep', exact=False)))

    if has_build_arch and has_build_indep:
        sys.exit(0)

    if any([line.lstrip(b' -').startswith(b'include ')
            for line in editor.makefile.dump_lines()]):
        # No handling of includes for the moment.
        sys.exit(0)

    archs = get_archs()
    if not has_build_indep:
        issue = LintianIssue(
            'source', 'debian-rules-missing-recommended-target',