File: debian-rules-uses-special-shell-variable.py

package info (click to toggle)
lintian-brush 0.147
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,872 kB
  • sloc: python: 17,649; makefile: 814; sh: 140; xml: 119; javascript: 3; ansic: 2
file content (23 lines) | stat: -rwxr-xr-x 811 bytes parent folder | download
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.')