Beispiel #1
0
#!/usr/bin/python3

from lintian_brush.fixer import control, report_result, LintianIssue

with control as updater:
    try:
        old = updater.source["DM-Upload-Allowed"]
    except KeyError:
        pass
    else:
        issue = LintianIssue(updater.source,
                             'malformed-dm-upload-allowed',
                             info=old)
        if issue.should_fix():
            del updater.source["DM-Upload-Allowed"]
            issue.report_fixed()

report_result("Remove malformed and unnecessary DM-Upload-Allowed field in "
              "debian/control.")
Beispiel #2
0
    is_debcargo_package,
    meets_minimum_certainty,
    warn,
)
import os
import sys

if is_debcargo_package():
    sys.exit(0)

description = None

if not os.path.exists('debian/source/format'):
    orig_format = None
    format = '1.0'
    missing_source_format_issue = LintianIssue('source',
                                               'missing-debian-source-format')
    if not missing_source_format_issue.should_fix():
        sys.exit(0)
    missing_source_format_issue.report_fixed()
    description = "Explicitly specify source format."
else:
    with open('debian/source/format', 'r') as f:
        format = orig_format = f.read().strip()

if orig_format not in (None, '1.0'):
    sys.exit(0)

older_source_format_issue = LintianIssue('source',
                                         'older-source-format',
                                         info=(orig_format or '1.0'))
#!/usr/bin/python3

import sys

from debmutate.watch import WatchEditor

from lintian_brush.fixer import report_result, LintianIssue

OBSOLETE_WATCH_FILE_FORMAT = 2
WATCH_FILE_LATEST_VERSION = 4

with WatchEditor() as editor:
    if editor.watch_file is None:
        sys.exit(0)
    if editor.watch_file.version >= WATCH_FILE_LATEST_VERSION:
        pass
    else:
        if editor.watch_file.version <= OBSOLETE_WATCH_FILE_FORMAT:
            tag = 'obsolete-debian-watch-file-standard'
        else:
            tag = 'older-debian-watch-file-standard'
        issue = LintianIssue('source', tag, '%d' % editor.watch_file.version)
        if issue.should_fix():
            editor.watch_file.version = WATCH_FILE_LATEST_VERSION
            issue.report_fixed()

report_result('Update watch file format version to %s.' %
              WATCH_FILE_LATEST_VERSION)
tabs_replaced = False
unicode_linebreaks_replaced = False

try:
    lines = []
    with open('debian/copyright', 'rb') as f:
        line = f.readline()
        if line.rstrip().rstrip(b'/') != EXPECTED_HEADER:
            # Not a machine-readable copyright file
            sys.exit(0)
        lines.append(line)
        prev_value_offset = None
        for lineno, line in enumerate(f, start=2):
            if line.startswith(b'\t'):
                issue = LintianIssue(
                    'source',
                    'tab-in-license-text',
                    info='debian/copyright (paragraph at line %d)' % lineno)
                if issue.should_fix():
                    for option in [
                            b' \t' + line[1:], b' \t' + line[2:],
                            b' ' * 8 + line[1:]
                    ]:
                        if value_offset(option) == prev_value_offset:
                            line = option
                            break
                    else:
                        line = b' \t' + line[1:]
                    tabs_replaced = True
                    issue.report_fixed()
            if UNICODE_PARAGRAPH_SEPARATOR in line:
                # Not quite the same thing, but close enough..
Beispiel #5
0
#!/usr/bin/python3

from debmutate.watch import WatchEditor
from urllib.parse import urlparse

from lintian_brush.fixer import report_result, LintianIssue

with WatchEditor() as updater:
    for w in getattr(updater.watch_file, 'entries', []):
        parsed_url = urlparse(w.url)
        if parsed_url.netloc != 'githubredir.debian.net':
            continue
        parts = parsed_url.path.strip('/').split('/')
        if parts[0] != 'github':
            # Hmm.
            continue
        issue = LintianIssue('source',
                             'debian-watch-file-uses-deprecated-githubredir',
                             info='%s %s' % (w.url, w.matching_pattern))
        if issue.should_fix():
            w.url = 'https://github.com/%s/%s/tags' % (parts[1], parts[2])
            w.matching_pattern = '.*/' + w.matching_pattern.rsplit('/', 1)[-1]
            issue.report_fixed()

report_result(
    'Remove use of githubredir - see '
    'https://lists.debian.org/debian-devel-announce/2014/10/msg00000.html '
    'for details.')
def cb(line, target):
    if line.strip() == b'dh_autotools-dev_updateconfig':
        issue = LintianIssue(
            'source',
            'debhelper-tools-from-autotools-dev-are-deprecated',
            info='dh_autotools-dev_updateconfig')
        if issue.should_fix():
            issue.report_fixed()
            return []
    if line.strip() == b'dh_autotools-dev_restoreconfig':
        issue = LintianIssue(
            'source',
            'debhelper-tools-from-autotools-dev-are-deprecated',
            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