Commit e17703ad authored by Jelmer Vernooij's avatar Jelmer Vernooij

Add support for fixing useless-autoreconf-build-depends.

parent b8b6d746
#!/usr/bin/python3
from lintian_brush import available_lintian_fixers
import os
import re
with open('README.md', 'r') as f:
......@@ -20,4 +19,4 @@ with open('README.md', 'w') as f:
f.write(re.sub(
r'(subset of the issues:\n\n).*(\nWriting new fixers\n)',
'\\1' + replacement_text + '\\2', contents,
flags=re.MULTILINE|re.DOTALL))
flags=re.MULTILINE | re.DOTALL))
......@@ -2,6 +2,7 @@ lintian-brush (0.4) UNRELEASED; urgency=medium
* (Build-)Depend at least on a version of python3-breezy that has some
common Git issues fixed.
* Add support for fixing useless-autoreconf-build-depends.
-- Jelmer Vernooij <jelmer@debian.org> Thu, 01 Nov 2018 00:50:34 +0000
......
......@@ -67,6 +67,9 @@ Lintian-Tags: unnecessary-testsuite-autopkgtest-field
Fix-Script: unversioned-copyright-format-uri.sh
Lintian-Tags: unversioned-copyright-format-uri
Fix-Script: useless-autoreconf-build-depends.py
Lintian-Tags: useless-autoreconf-build-depends
Fix-Script: vcs-field-uses-insecure-uri.sh
Lintian-Tags: vcs-field-uses-insecure-uri
......
#!/usr/bin/python3
from debian.changelog import Version
from io import StringIO
import re
from lintian_brush.control import (
drop_dependency,
ensure_minimum_version,
update_control,
)
def bump_debhelper(control):
control["Build-Depends"] = ensure_minimum_version(
control["Build-Depends"],
"debhelper", Version("10"))
control["Build-Depends"] = drop_dependency(
control["Build-Depends"],
"dh-autoreconf")
update_control(source_package_cb=bump_debhelper)
outf = StringIO()
with open('debian/rules', 'r') as f:
for line in f:
line = re.sub(" --with[ =]autoreconf( .+|)$", "\\1", line)
line = re.sub(" --with[ =]autoreconf,", " --with=", line)
line = re.sub(" --with[ =]([^ ]),autoreconf([ ,])", " --with=\\1\\2",
line)
outf.write(line)
with open('debian/rules', 'w') as f:
f.write(outf.getvalue())
print("Drop unnecessary dependency on dh-autoconf.")
print("Fixed-Lintian-Tags: useless-autoreconf-build-depends")
......@@ -157,7 +157,7 @@ def ensure_minimum_version(relationstr, package, minimum_version):
Args:
relationstr: package relation string
package; package name
package: package name
minimum_version: Minimum version
Returns:
updated relation string
......@@ -171,7 +171,7 @@ def ensure_minimum_version(relationstr, package, minimum_version):
continue
names = [r.name for r in relation]
if len(names) > 1 and names[0] == package:
raise Exception("Complex rule for debhelper, aborting")
raise Exception("Complex rule for %s , aborting" % package)
if names != [package]:
continue
found = True
......@@ -189,3 +189,29 @@ def ensure_minimum_version(relationstr, package, minimum_version):
return format_relations(relations)
# Just return the original; we don't preserve all formatting yet.
return relationstr
def drop_dependency(relationstr, package):
"""Drop a dependency from a depends line.
Args:
relationstr: package relation string
package: package name
Returns:
updated relation string
"""
relations = parse_relations(relationstr)
ret = []
for entry in relations:
(head_whitespace, relation, tail_whitespace) = entry
if isinstance(relation, str): # formatting
ret.append(entry)
continue
names = [r.name for r in relation]
if set(names) != set([package]):
ret.append(entry)
continue
if relations != ret:
return format_relations(ret)
# Just return the original; we don't preserve all formatting yet.
return relationstr
......@@ -24,6 +24,7 @@ from breezy.tests import (
from lintian_brush.control import (
can_preserve_deb822,
drop_dependency,
ensure_minimum_version,
update_control,
GeneratedFile,
......@@ -192,3 +193,15 @@ class EnsureMinimumVersionTests(TestCase):
self.assertEqual(
'blah, debhelper (>= 9)',
ensure_minimum_version('blah, debhelper (>= 8)', 'debhelper', '9'))
class DropDependencyTests(TestCase):
def test_deleted(self):
self.assertEqual(
'debhelper (>= 9)',
drop_dependency('debhelper (>= 9), dh-autoreconf',
'dh-autoreconf'))
self.assertEqual(
' dh-autoreconf',
drop_dependency('debhelper (>= 9), dh-autoreconf', 'debhelper'))
Source: blah
Maintainer: Team Maintainers <team@lists.alioth.debian.org>
Uploaders: Joe Example <joe@example.com>
Section: math
Priority: optional
Build-Depends: debhelper (>= 10),
dh-autoreconf
Standards-Version: 4.1.1
Package: blah
Architecture: any
Description: Description
More description
#! /usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
dh $@ --with autoreconf
Drop unnecessary dependency on dh-autoconf.
Fixed-Lintian-Tags: useless-autoreconf-build-depends
Source: blah
Maintainer: Team Maintainers <team@lists.alioth.debian.org>
Uploaders: Joe Example <joe@example.com>
Section: math
Priority: optional
Build-Depends: debhelper (>= 10)
Standards-Version: 4.1.1
Package: blah
Architecture: any
Description: Description
More description
#! /usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
dh $@
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment