* checks/python.desc: Add description for new tag * checks/python.pm: check shebang of script for references to unversioned python, either directly or via /usr/bin/env. * t/tags/tests/python-script-uses-unversioned-python-in-shebang: new test directory. --- checks/python.desc | 18 ++++++++++++++++++ checks/python.pm | 11 +++++++++++ .../debian/control.in | 16 ++++++++++++++++ .../debian/install | 1 + .../debian/rules | 4 ++++ .../debian/script-bad1 | 1 + .../debian/script-bad2 | 1 + .../debian/script-good1 | 1 + .../debian/script-good2 | 1 + .../desc | 6 ++++++ .../tags | 6 ++++++ 11 files changed, 66 insertions(+) create mode 100644 t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/control.in create mode 100644 t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/install create mode 100755 t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/rules create mode 100644 t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-bad1 create mode 100644 t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-bad2 create mode 100644 t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-good1 create mode 100644 t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-good2 create mode 100644 t/tags/tests/python-script-uses-unversioned-python-in-shebang/desc create mode 100644 t/tags/tests/python-script-uses-unversioned-python-in-shebang/tags
diff --git a/checks/python.desc b/checks/python.desc index f8d73e4fd..a31e7b923 100644 --- a/checks/python.desc +++ b/checks/python.desc @@ -198,3 +198,21 @@ Info: This source package encodes a Python version in its name such . Please override this tag with a suitably-commented override if there is no single upstream codebase that supports both versions. + +Tag: script-uses-unversioned-python-in-shebang +Severity: normal +Certainty: certain +Info: The package contain script with unversion python shebang. + There is discussion in python community to recommend soft-linking + python to python3 on newer distributions. + . + If and when Debian start following this recommendation, the script + will be broken. + . + The 2.x series of Python is due for deprecation and will not be maintained + by upstream past 2020 and will likely be dropped after the release of + Debian "buster". + . + If upstream have not moved or have no intention to move to Python 3, please + be certain that Debian would benefit from the continued inclusion of this + package and, if not, consider removing it. diff --git a/checks/python.pm b/checks/python.pm index ea1545254..65b795552 100644 --- a/checks/python.pm +++ b/checks/python.pm @@ -246,6 +246,17 @@ sub _run_binary { } } + # Check for unversioned python shebang (#909510). + for my $file ($info->sorted_index) { + next unless $file->is_file; + next unless $file =~ m,(usr/)?bin/[^/]+,; + my $fd = $file->open(); + my $line = <$fd>; + tag 'script-uses-unversioned-python-in-shebang', $file + if $line =~ m,^#!\s*(/usr/bin/env\s*)?(/usr/bin/)?python$,; + close($fd); + } + return; } diff --git a/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/control.in b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/control.in new file mode 100644 index 000000000..6bae81f3e --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/control.in @@ -0,0 +1,16 @@ +Source: {$source} +Priority: optional +Section: mail +Maintainer: {$author} +Standards-Version: {$standards_version} +Build-Depends: {$build_depends} +Rules-Requires-Root: no + +Package: prog-{$source} +Architecture: {$package_architecture} +Depends: $\{misc:Depends\}, python, python2.7 +Description: Package with Python script with bad shebang + This is a test package designed to exercise some feature or tag of + Lintian. It is part of the Lintian test suite and may do very odd + things. It should not be installed like a regular package. It may + be an empty package. diff --git a/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/install b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/install new file mode 100644 index 000000000..05e2b7892 --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/install @@ -0,0 +1 @@ +debian/script-* /usr/bin diff --git a/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/rules b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/rules new file mode 100755 index 000000000..2d33f6ac8 --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ diff --git a/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-bad1 b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-bad1 new file mode 100644 index 000000000..013e4b7ec --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-bad1 @@ -0,0 +1 @@ +#!/usr/bin/python diff --git a/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-bad2 b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-bad2 new file mode 100644 index 000000000..ee3ecd22c --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-bad2 @@ -0,0 +1 @@ +#! /usr/bin/env python diff --git a/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-good1 b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-good1 new file mode 100644 index 000000000..18ff53637 --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-good1 @@ -0,0 +1 @@ +#!/usr/bin/env python2 diff --git a/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-good2 b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-good2 new file mode 100644 index 000000000..28a381e11 --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/debian/script-good2 @@ -0,0 +1 @@ +#!/usr/bin/python2.7 diff --git a/t/tags/tests/python-script-uses-unversioned-python-in-shebang/desc b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/desc new file mode 100644 index 000000000..6367a8992 --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/desc @@ -0,0 +1,6 @@ +Skeleton: upload-native +Testname: python-script-uses-unversioned-python-in-shebang +Version: 1.0 +Description: Check for unversioned python in shebang +Test-For: + script-uses-unversioned-python-in-shebang diff --git a/t/tags/tests/python-script-uses-unversioned-python-in-shebang/tags b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/tags new file mode 100644 index 000000000..3ceaa4213 --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/tags @@ -0,0 +1,6 @@ +W: prog-python-script-uses-unversioned-python-in-shebang: binary-without-manpage usr/bin/script-bad1 +W: prog-python-script-uses-unversioned-python-in-shebang: binary-without-manpage usr/bin/script-bad2 +W: prog-python-script-uses-unversioned-python-in-shebang: binary-without-manpage usr/bin/script-good1 +W: prog-python-script-uses-unversioned-python-in-shebang: binary-without-manpage usr/bin/script-good2 +W: prog-python-script-uses-unversioned-python-in-shebang: script-uses-unversioned-python-in-shebang usr/bin/script-bad1 +W: prog-python-script-uses-unversioned-python-in-shebang: script-uses-unversioned-python-in-shebang usr/bin/script-bad2