示例#1
0
def drop_sequence(control, rules, sequence):
    new_depends = drop_dependency(control.source.get("Build-Depends", ""),
                                  "dh-" + sequence)
    if new_depends != control.source['Build-Depends']:

        def drop_with(line, target):
            return dh_invoke_drop_with(line,
                                       sequence.replace('-', '_').encode())

        update_rules(drop_with)
    new_depends = drop_dependency(new_depends, "dh-sequence-" + sequence)
    if control['Build-Depends'] == new_depends:
        return False
    control['Build-Depends'] = new_depends
    return True
示例#2
0
#!/usr/bin/python3

import sys
from debmutate.control import drop_dependency
from lintian_brush.fixer import control, report_result, fixed_lintian_tag

try:
    with open('debian/rules', 'rb') as f:
        for line in f:
            if b'/usr/share/cdbs/' in line:
                uses_cdbs = True
                break
        else:
            uses_cdbs = False
except FileNotFoundError:
    # Unsure whether it actually needs cdbs
    sys.exit(2)

if not uses_cdbs:
    with control as updater:
        new_depends = drop_dependency(updater.source.get("Build-Depends", ""),
                                      "cdbs")
        if new_depends != updater.source['Build-Depends']:
            fixed_lintian_tag(updater.source,
                              'unused-build-dependency-on-cdbs', '')
            updater.source["Build-Depends"] = new_depends
        if not updater.source["Build-Depends"]:
            del updater.source["Build-Depends"]

report_result("Drop unused build-dependency on cdbs.")
示例#3
0
#!/usr/bin/python3

from debmutate.control import drop_dependency
from lintian_brush.fixer import control, report_result, LintianIssue

with control as updater:
    for field in ['Build-Depends', 'Build-Depends-Indep']:
        try:
            updater.source[field] = drop_dependency(updater.source[field],
                                                    "build-essential")
        except KeyError:
            pass
        else:
            issue = LintianIssue(updater.source,
                                 'build-depends-on-build-essential', field)
            # TODO(jelmer): Check overrides
            issue.report_fixed()

report_result("Drop unnecessary dependency on build-essential.")
示例#4
0
#!/usr/bin/python3
from debmutate.control import drop_dependency
from debmutate.debhelper import ensure_minimum_debhelper_version
from lintian_brush.fixer import control, report_result, LintianIssue

with control as updater:
    for field in [
            "Build-Depends", "Build-Depends-Indep", "Build-Depends-Arch"
    ]:
        try:
            old_build_depends = updater.source[field]
        except KeyError:
            continue
        issue = LintianIssue(updater.source,
                             'build-depends-on-obsolete-package',
                             info='%s: %s' % (field.lower(), 'dh-systemd'))
        if not issue.should_fix():
            continue
        updater.source[field] = drop_dependency(old_build_depends,
                                                "dh-systemd")
        if old_build_depends != updater.source[field]:
            ensure_minimum_debhelper_version(updater.source, "9.20160709")
            issue.report_fixed()

report_result(
    "Depend on newer debhelper (>= 9.20160709) rather than dh-systemd.")
示例#5
0
#!/usr/bin/python3

from debmutate.control import (
    get_relation,
    add_dependency,
    drop_dependency,
)
from lintian_brush.fixer import control, report_result

with control as updater:
    try:
        pos, old = get_relation(updater.source.get('Build-Depends-Indep', ''),
                                'debhelper-compat')
    except KeyError:
        pass
    else:
        updater.source['Build-Depends'] = add_dependency(
            updater.source.get('Build-Depends', ''), old)
        updater.source['Build-Depends-Indep'] = drop_dependency(
            updater.source.get('Build-Depends-Indep', ''), 'debhelper-compat')
        if not updater.source['Build-Depends-Indep'].strip():
            del updater.source['Build-Depends-Indep']

report_result(
    'Move debhelper-compat from Build-Depends-Indep to Build-Depends.')
示例#6
0
                          'golang-any')):
        go_package = True
    if not go_package:
        sys.exit(0)

    default_architecture = updater.source.get('Architecture')

    for binary in updater.binaries:
        if binary.get('Architecture', default_architecture) == 'all':
            if 'Built-Using' in binary:
                issue = LintianIssue(
                    updater.source,
                    'built-using-field-on-arch-all-package',
                    binary['Package'])
                if issue.should_fix():
                    binary['Built-Using'] = drop_dependency(
                        binary['Built-Using'], '${misc:Built-Using}')
                    if not binary['Built-Using']:
                        del binary['Built-Using']
                    removed.append(binary['Package'])
                    issue.report_fixed()
        else:
            built_using = binary.get('Built-Using', '')
            try:
                get_relation(built_using, "${misc:Built-Using}")
            except KeyError:
                issue = LintianIssue(
                    updater.source,
                    'missing-built-using-field-for-golang-package',
                    binary['Package'])
                if issue.should_fix():
                    binary["Built-Using"] = add_dependency(
示例#7
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.')
示例#8
0
from debmutate._rules import (
    dh_invoke_drop_with,
    update_rules,
    )


def drop_with_autoreconf(line, target):
    return dh_invoke_drop_with(line, b'autoreconf')


if maximum_debhelper_compat_version(compat_release()) < 10:
    sys.exit(0)

if not update_rules(drop_with_autoreconf):
    sys.exit(2)


with control as updater:
    ensure_minimum_debhelper_version(updater.source, "10~")
    new_depends = drop_dependency(
        updater.source.get("Build-Depends", ""), "dh-autoreconf")
    if new_depends != updater.source['Build-Depends']:
        issue = LintianIssue(
            updater.source, 'useless-autoreconf-build-depends',
            'dh-autoreconf')
        if issue.should_fix():
            updater.source['Build-Depends'] = new_depends
            issue.report_fixed()

report_result("Drop unnecessary dependency on dh-autoreconf.")
    get_relation,
    drop_dependency,
    add_dependency,
    )
from lintian_brush.fixer import control, report_result, LintianIssue


with control as updater:
    try:
        get_relation(
            updater.source.get('Build-Depends-Indep', ''),
            'libmodule-build-perl')
    except KeyError:
        pass
    else:
        issue = LintianIssue(
            updater.source,
            'libmodule-build-perl-needs-to-be-in-build-depends', '')
        if issue.should_fix():
            updater.source['Build-Depends-Indep'] = drop_dependency(
                updater.source['Build-Depends-Indep'],
                'libmodule-build-perl')
            updater.source['Build-Depends'] = add_dependency(
                updater.source.get('Build-Depends', ''),
                'libmodule-build-perl')
            issue.report_fixed()


report_result(
    'Move libmodule-build-perl from Build-Depends-Indep to Build-Depends.')