1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#!/usr/bin/python3
from contextlib import suppress
from debmutate.reformatting import check_generated_file
from lintian_brush.fixer import report_result, LintianIssue
from lintian_brush.line_editor import LineEditor
check_generated_file('debian/rules')
with suppress(FileNotFoundError), LineEditor('debian/rules', 'b') as e:
for lineno, line in e:
newline = line.replace(
b'$(dir $(_))', b'$(dir $(firstword $(MAKEFILE_LIST)))')
if newline != line:
issue = LintianIssue(
'source', 'debian-rules-uses-special-shell-variable',
info='line %d' % lineno)
if issue.should_fix():
e[lineno] = newline
issue.report_fixed()
report_result('Avoid using $(_) to discover source package directory.')
|