def upgrade_to_debhelper_13():

    # dh_installtempfiles will handle d/tmpfile{,s}.  It prefer the latter
    # and warns about the former.

    with control as updater:
        for binary in updater.binaries:
            name = binary['Package']
            tmpfile = os.path.join('debian', name + ".tmpfile")
            if os.path.isfile(tmpfile):
                os.rename(tmpfile, tmpfile + 's')
                subitems.add('Rename %s to %ss.' % (tmpfile, tmpfile))
        if os.path.isfile(os.path.join('debian', "tmpfile")):
            tmpfile = os.path.join('debian', "tmpfile")
            os.rename(tmpfile, tmpfile + 's')
            subitems.add('Rename %s to %ss.' % (tmpfile, tmpfile))

    update_rules(
        [
            # The dh_missing command will now default to --fail-missing.  This can
            # be reverted to a non-fatal warning by explicitly passing
            # --list-missing like it was in compat 12.
            drop_dh_missing_fail,
        ],
        rule_cb=override_dh_auto_test_drop_options)
Ejemplo n.º 2
0
def add_sequence(control, rules, sequence):
    control.source['Build-Depends'] = add_dependency(
        control.source.get('Build-Depends'), 'dh-vim-addon')

    def add_with(line, target):
        if line.startswith(b'dh ') or line.startswith(b'dh_'):
            return dh_invoke_add_with(line,
                                      sequence.replace('-', '_').encode())
        return line

    update_rules(add_with)
def upgrade_to_debhelper_12():

    pybuild_upgrader = PybuildUpgrader()
    dh_missing_upgrader = DhMissingUpgrader()
    update_rules([
        debhelper_argument_order,
        replace_deprecated_same_arch,
        pybuild_upgrader.fix_line,
        upgrade_to_dh_prep,
        upgrade_to_no_stop_on_upgrade,
        dh_missing_upgrader.fix_line,
    ],
                 makefile_cb=dh_missing_upgrader.fix_makefile)
Ejemplo n.º 4
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
def upgrade_to_debhelper_11():

    update_rules([upgrade_to_installsystemd],
                 rule_cb=rename_installsystemd_target)
    for name in os.listdir('debian'):
        parts = name.split('.')
        if len(parts) < 2 or parts[-1] != 'upstart':
            continue
        if len(parts) == 3:
            package = parts[0]
            service = parts[1]
        elif len(parts) == 2:
            package = service = parts[0]
        os.unlink(os.path.join('debian', name))
        subitems.add('Drop obsolete upstart file %s.' % name)
        with MaintscriptEditor('debian/%s.maintscript' % package) as e:
            e.append(
                MaintscriptRemoveConffile(
                    conffile='/etc/init/%s.conf' % service,
                    prior_version=current_package_version(),
                    package=None))
Ejemplo n.º 6
0
def enable_dh_autoreconf(context, phase):
    # Debhelper >= 10 depends on dh-autoreconf and enables autoreconf by
    # default.
    debhelper_compat_version = get_debhelper_compat_level(
        context.tree.abspath("."))
    if debhelper_compat_version is not None and debhelper_compat_version < 10:

        def add_with_autoreconf(line, target):
            if target != b"%":
                return line
            if not line.startswith(b"dh "):
                return line
            return dh_invoke_add_with(line, b"autoreconf")

        if update_rules(command_line_cb=add_with_autoreconf):
            return add_dependency(context, phase,
                                  AptRequirement.simple("dh-autoreconf"))

    return False
Ejemplo n.º 7
0
def fix_missing_config_status_input(error, phase, context):
    autogen_path = "autogen.sh"
    rules_path = "debian/rules"
    if context.subpath not in (".", ""):
        autogen_path = os.path.join(context.subpath, autogen_path)
        rules_path = os.path.join(context.subpath, rules_path)
    if not context.tree.has_filename(autogen_path):
        return False

    def add_autogen(mf):
        rule = any(mf.iter_rules(b"override_dh_autoreconf"))
        if rule:
            return
        rule = mf.add_rule(b"override_dh_autoreconf")
        rule.append_command(b"dh_autoreconf ./autogen.sh")

    if not update_rules(makefile_cb=add_autogen, path=rules_path):
        return False

    return context.commit("Run autogen.sh during build.")
Ejemplo n.º 8
0
            # Nothing wrong here
            return line
    lineno = -1  # TODO(jelmer): Pass this up
    fixed_lintian_tag('source',
                      'debian-rules-sets-dpkg-architecture-variable',
                      info='%s (line %d)' % (variable, lineno))
    if architecture_included:
        message = 'Rely on existing architecture.mk include.'
        return None
    return re.sub(b'([:?]?=)', b'?=', line)


if opinionated():
    try:
        mf = Makefile.from_path('debian/rules')
    except FileNotFoundError:
        pass
    else:
        for line in mf.contents:
            if (isinstance(line, bytes)
                    and is_dpkg_architecture_line(line)[1:3] == (True, True)):
                update_rules(global_line_cb=drop_arch_line)
                message = (
                    'Rely on pre-initialized dpkg-architecture variables.')
                break
else:
    message = 'Use ?= for assignments to architecture variables.'
    update_rules(global_line_cb=update_assignment_kind)

report_result(message)
Ejemplo n.º 9
0
    LintianIssue,
    )
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()
Ejemplo n.º 10
0
#!/usr/bin/python3

from debmutate._rules import update_rules
from lintian_brush.fixer import report_result, LintianIssue


def update_line(line, target):
    if line.strip() == b'dh_clean -k':
        issue = LintianIssue('source', "dh-clean-k-is-deprecated", '')
        if issue.should_fix():
            issue.report_fixed()
            return b'dh_prep'
    return line


update_rules(update_line)
report_result("debian/rules: Use dh_prep rather than \"dh_clean -k\".")
    if origline.startswith(b'export '):
        prefix = b'export '
        line = origline[len(prefix):]
    else:
        prefix = b''
        line = origline
    try:
        (name, value) = line.split(b'=', 1)
    except ValueError:
        # Simple export of a variable, not an assignment
        return origline
    name = name.strip()
    value = value.strip()
    if name == b'DEB_LDFLAGS_MAINT_APPEND' and b'-Wl,--as-needed' in value:
        issue = LintianIssue('source', 'debian-rules-uses-as-needed-linker-flag', 'line X')
        if issue.should_fix():
            issue.report_fixed()
            args = shlex.split(value.decode())
            args.remove('-Wl,--as-needed')
            if not args:
                return None
            return prefix + b'%s = %s' % (name, shlex.join(args).encode())
        return origline
    return origline


update_rules(global_line_cb=check_global)


report_result('Avoid explicitly specifying -Wl,--as-needed linker flag.')
Ejemplo n.º 12
0
    control_compat_version = get_debhelper_compat_level_from_control(
        control.source)

if control_compat_version is not None and file_compat_version is not None:
    os.remove('debian/compat')
    compat_version = control_compat_version
elif control_compat_version is not None:
    compat_version = control_compat_version
elif file_compat_version is not None:
    compat_version = file_compat_version
else:
    sys.exit(0)


def drop_explicit_dh_compat(line):
    m = re.match(b'export DH_COMPAT[ \t]*=[ \t]*([0-9]+)', line)
    if m:
        issue = LintianIssue(
            'source',
            'declares-possibly-conflicting-debhelper-compat-versions',
            info='rules=%d compat=%s' % (compat_version, m.group(1)))
        if issue.should_fix():
            issue.report_fixed()
            return []
    return line


update_rules(global_line_cb=drop_explicit_dh_compat)
report_result('Avoid setting debhelper compat version in debian/rules '
              'and debian/compat.')
            info='dh_autotools-dev_restoreconfig')
        if issue.should_fix():
            issue.report_fixed()
            return []
    newline = dh_invoke_drop_with(line, b'autotools-dev')
    if newline != line:
        issue = LintianIssue(
            'source',
            'debhelper-tools-from-autotools-dev-are-deprecated',
            info='dh ... --with autotools-dev')
        if issue.should_fix():
            line = newline
            issue.report_fixed()
    newline = dh_invoke_drop_with(line, b'autotools_dev')
    if newline != line:
        issue = LintianIssue(
            'source',
            'debhelper-tools-from-autotools-dev-are-deprecated',
            info='dh ... --with autotools_dev')
        if issue.should_fix():
            line = newline
            issue.report_fixed()
    return line


if update_rules(cb):
    with control as updater:
        ensure_minimum_debhelper_version(updater.source, "9.20160114")

report_result("Drop use of autotools-dev debhelper.")