[2019-02-11 19:23] Chris Lamb <la...@debian.org> > > part text/plain 414 > Hi Dmitry, > > > Yes. Sorry, but I do not understand, how to test tags with severity > > 'classification'. It seems to not appear in output, that is > > compared with t/tags/checks/*/tags. > > Look at how, for example: > > t/tags/checks/scripts/scripts-maintainer-script-classification > > … works. :)
Thank you. Found. Options -L classification -C python. One more attempt. From ffed4731e2b79091a965e0536ce2f9763948dc6e Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov <kact...@debian.org> Date: Sat, 2 Feb 2019 01:39:59 +0000 Subject: [PATCH] New tag: script-uses-unversioned-python-in-shebang * 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 | 12 ++++++++++++ .../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 | 5 +++++ .../tags | 2 ++ 11 files changed, 62 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..661e6cc86 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: classification +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..0a6a2eb6d 100644 --- a/checks/python.pm +++ b/checks/python.pm @@ -246,6 +246,18 @@ sub _run_binary { } } + # Check for unversioned python shebang (#909510). + for my $file ($info->sorted_index) { + next unless $file->is_file; + next unless $file->is_open_ok; + 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..cb6e30c40 --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/desc @@ -0,0 +1,5 @@ +Skeleton: upload-native +Testname: python-script-uses-unversioned-python-in-shebang +Version: 1.0 +Description: Check for unversioned python in shebang +Options: -L +classification -C python 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..6327587ef --- /dev/null +++ b/t/tags/tests/python-script-uses-unversioned-python-in-shebang/tags @@ -0,0 +1,2 @@ +C: prog-python-script-uses-unversioned-python-in-shebang: script-uses-unversioned-python-in-shebang usr/bin/script-bad1 +C: prog-python-script-uses-unversioned-python-in-shebang: script-uses-unversioned-python-in-shebang usr/bin/script-bad2 -- Note, that I send and fetch email in batch, once every 24 hours. If matter is urgent, try https://t.me/kaction --