Commit e11cdd20 authored by Jelmer Vernooij's avatar Jelmer Vernooij

* Don't use functionality that is not available in stable by default;

  add a --modern flag to disable this.
* Don't use functionality that is not available in stable by default;
  add a --modern flag to enable use of unstable-only functionality
  (such as debhelper compat levels).
parent 9a1dcd5f
......@@ -4,6 +4,11 @@ lintian-brush (0.10) UNRELEASED; urgency=medium
* Add --update-changelog option to force updating of changelog.
* Add support for systemd-service-file-pidfile-refers-to-var-run.
Closes: #917565
* Don't use functionality that is not available in stable by default;
add a --modern flag to disable this.
* Don't use functionality that is not available in stable by default;
add a --modern flag to enable use of unstable-only functionality
(such as debhelper compat levels).
-- Jelmer Vernooij <jelmer@debian.org> Sat, 15 Dec 2018 17:18:50 +0000
......
......@@ -9,6 +9,7 @@ Build-Depends: debhelper (>= 11),
python3-breezy (>= 3.0.0~bzr7199-1),
python3-breezy.tests,
python3-dulwich (>= 0.19.7),
python3-distro-info,
python3-debian,
python3-setuptools,
gpg
......@@ -21,6 +22,7 @@ Architecture: all
Depends: python3-breezy (>= 3.0.0~bzr7199-1),
python3-debian,
python3-dulwich (>= 0.19.7),
python3-distro-info,
${misc:Depends},
${python3:Depends}
Recommends: lintian, dos2unix, gpg
......
......@@ -62,7 +62,9 @@ Fix-Script: package-uses-deprecated-source-override-location.sh
Lintian-Tags: package-uses-deprecated-source-override-location
Fix-Script: package-uses-deprecated-debhelper-compat-version.py
Lintian-Tags: package-uses-deprecated-debhelper-compat-version
Lintian-Tags:
package-uses-deprecated-debhelper-compat-version,
package-uses-old-debhelper-compat-version
Fix-Script: priority-extra-is-replaced-by-priority-optional.py
Lintian-Tags: priority-extra-is-replaced-by-priority-optional
......
......@@ -6,19 +6,25 @@ from lintian_brush.control import (
update_control,
)
# TODO(jelmer): Can we get these elsewhere rather than
# hardcoding them here?
minimum_debhelper_version = 9
default_debhelper_version = 11
default_debhelper_version = 12
compat_release = os.environ.get('COMPAT_RELEASE', 'sid')
if compat_release == 'sid':
new_debhelper_version = 12
elif compat_release == 'stretch':
new_debhelper_version = 10
else:
new_debhelper_version = minimum_debhelper_version
if os.path.exists('debian/compat'):
with open('debian/compat', 'r') as f:
current = int(f.read().strip())
if current < minimum_debhelper_version:
new = default_debhelper_version
current_debhelper_version = int(f.read().strip())
if current_debhelper_version < new_debhelper_version:
with open('debian/compat', 'w') as f:
f.write('%s\n' % new)
f.write('%s\n' % new_debhelper_version)
else:
# Nothing to do
sys.exit(2)
......@@ -30,9 +36,16 @@ def bump_debhelper(control):
control["Build-Depends"] = ensure_minimum_version(
control["Build-Depends"],
"debhelper",
"%d~" % new)
"%d~" % new_debhelper_version)
update_control(source_package_cb=bump_debhelper)
print("Bump debhelper from deprecated %s to %s." % (current, new))
print("Fixed-Lintian-Tags: package-uses-deprecated-debhelper-compat-version")
if current_debhelper_version < minimum_debhelper_version:
kind = "deprecated"
tag = "package-uses-deprecated-debhelper-compat-version"
else:
kind = "old"
tag = "package-uses-old-debhelper-compat-version"
print("Bump debhelper from %s %s to %s." % (
kind, current_debhelper_version, new_debhelper_version))
print("Fixed-Lintian-Tags: %s" % tag)
......@@ -40,6 +40,7 @@ from breezy.trace import note
from breezy.transform import revert
from debian.deb822 import Deb822
import distro_info
__version__ = (0, 10)
......@@ -123,11 +124,14 @@ class Fixer(object):
self.name = name
self.lintian_tags = lintian_tags
def run(self, basedir):
def run(self, basedir, current_version, compat):
"""Apply this fixer script.
Args:
basedir: Directory in which to run
current_version: The version of the package that is being created or
updated
compat: Compatibility level (a Debian release name)
Returns:
A FixerResult object
"""
......@@ -144,9 +148,10 @@ class ScriptFixer(Fixer):
def __repr__(self):
return "<ScriptFixer(%r)>" % self.name
def run(self, basedir, current_version):
def run(self, basedir, current_version, compat_release):
env = dict(os.environ.items())
env['CURRENT_VERSION'] = str(current_version)
env['COMPAT_RELEASE'] = compat_release
with tempfile.SpooledTemporaryFile() as stderr:
p = subprocess.Popen(self.script_path, cwd=basedir,
stdout=subprocess.PIPE, stderr=stderr,
......@@ -323,7 +328,7 @@ def only_changes_last_changelog_block(tree):
def run_lintian_fixer(local_tree, fixer, committer=None,
update_changelog=None):
update_changelog=None, compat_release=None):
"""Run a lintian fixer on a tree.
Args:
......@@ -331,6 +336,8 @@ def run_lintian_fixer(local_tree, fixer, committer=None,
fixer: Fixer object to apply
committer: Optional committer (name and email)
update_changelog: Whether to add a new entry to the changelog
compat_release: Minimum release that the package should be usable on
(e.g. 'stable' or 'unstable')
Returns:
tuple with set of FixerResult, summary of the changes
"""
......@@ -348,8 +355,11 @@ def run_lintian_fixer(local_tree, fixer, committer=None,
else:
current_version = cl.version
increment_version(current_version)
if compat_release is None:
compat_release = 'sid'
try:
result = fixer.run(local_tree.basedir, current_version=current_version)
result = fixer.run(local_tree.basedir, current_version=current_version,
compat_release=compat_release)
except BaseException:
revert(local_tree, local_tree.branch.basis_tree(), None)
deletables = list(iter_deletables(
......@@ -398,7 +408,8 @@ def run_lintian_fixer(local_tree, fixer, committer=None,
def run_lintian_fixers(local_tree, fixers, update_changelog=True,
verbose=False, committer=None):
verbose=False, committer=None,
compat_release=None):
"""Run a set of lintian fixers on a tree.
Args:
......@@ -407,6 +418,8 @@ def run_lintian_fixers(local_tree, fixers, update_changelog=True,
update_changelog: Whether to add an entry to the changelog
verbose: Whether to be verbose
committer: Optional committer (name and email)
compat_release: Minimum release that the package should be usable on
(e.g. 'sid' or 'stretch')
Returns:
Tuple with two lists:
list of tuples with (lintian-tag, certainty, description) of fixers
......@@ -422,7 +435,7 @@ def run_lintian_fixers(local_tree, fixers, update_changelog=True,
try:
result, summary = run_lintian_fixer(
local_tree, fixer, update_changelog=update_changelog,
committer=committer)
committer=committer, compat_release=compat_release)
except FixerFailed as e:
failed_fixers.append(fixer.name)
if verbose:
......
......@@ -41,6 +41,8 @@ import breezy.bzr # noqa: E402
from breezy.trace import note # noqa: E402
import distro_info
from . import ( # noqa: E402
NotDebianPackage,
PendingChanges,
......@@ -81,6 +83,11 @@ def main(argv=None):
'Do not make any changes to the current repository. '
'Note: currently creates a temporary clone of the repository.'),
action='store_true')
parser.add_argument(
'--modern', help=(
'Use features/compatibility levels that are not available in '
'stable. (makes backporting harder)'),
action='store_true', default=False)
parser.add_argument(
'fixers', metavar='FIXER', nargs='*',
help='specific fixer to run')
......@@ -124,11 +131,18 @@ def main(argv=None):
since_revid = wt.last_revision()
if args.fixers:
fixers = [f for f in fixers if f.name in args.fixers]
debian_info = distro_info.DebianDistroInfo()
if args.modern:
compat_release = debian_info.unstable()
else:
compat_release = debian_info.stable()
note('Compat release is %s', compat_release)
with wt.lock_write():
try:
applied, failed = run_lintian_fixers(
wt, fixers,
update_changelog=args.update_changelog,
compat_release=compat_release,
verbose=args.verbose)
except NotDebianPackage:
note("%s: Not a debian package.", wt.basedir)
......
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