From 1e8004f53f60d9128a67c649d3c49006c7350281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org> Date: Thu, 12 Sep 2013 22:46:25 +0200 Subject: [PATCH] Replace /usr/bin/dh_python2 with a Python script that invokes dh-python's dh_python2 if Build-Depends{,-Indep} contains dh-python --- Makefile | 2 +- debian/changelog | 2 ++ dh_python2.py | 36 ++++++++++++++++++++++++++++++++++++ dh_python2.sh | 9 --------- 4 files changed, 39 insertions(+), 10 deletions(-) create mode 100755 dh_python2.py delete mode 100755 dh_python2.sh diff --git a/Makefile b/Makefile index 3faf321..135614d 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ install-dev: $(INSTALL) -m 755 runtime.d/* $(DESTDIR)$(PREFIX)/share/python/runtime.d/ $(INSTALL) -m 644 autoscripts/* $(DESTDIR)$(PREFIX)/share/debhelper/autoscripts/ $(INSTALL) -m 755 dh_python2 $(DESTDIR)$(PREFIX)/share/python/ - $(INSTALL) -m 755 dh_python2.sh $(DESTDIR)$(PREFIX)/bin/dh_python2 + $(INSTALL) -m 755 dh_python2.py $(DESTDIR)$(PREFIX)/bin/dh_python2 $(INSTALL) -m 644 python2.pm $(DESTDIR)$(PREFIX)/share/perl5/Debian/Debhelper/Sequence/ install-runtime: diff --git a/debian/changelog b/debian/changelog index c8b88c4..2aa4056 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,8 @@ python-defaults (2.7.5-5) unstable; urgency=low [ Piotr Ożarowski ] * Set "Multi-Arch: allowed" in python, python-dev, python-minimal, python-dbg, python-all, python-all-dev, python-all-dbg + * Replace /usr/bin/dh_python2 with a Python script that invokes + dh-python's dh_python2 if Build-Depends{,-Indep} contains dh-python -- Piotr Ożarowski <piotr@debian.org> Thu, 12 Sep 2013 21:25:01 +0200 diff --git a/dh_python2.py b/dh_python2.py new file mode 100755 index 0000000..4a8e57a --- /dev/null +++ b/dh_python2.py @@ -0,0 +1,36 @@ +#! /usr/bin/python + +from os.path import exists +from subprocess import call +from sys import argv +from re import compile + +OLD = '/usr/share/python/dh_python2' +NEW = '/usr/share/dh-python/dh_python2' +has_dhpython = compile(r'(^|:|\s|,)dh-python($|\s|,|\()').search + +binary = OLD +if exists(NEW) and exists('debian/control'): + with open('debian/control', 'r') as fp: + inside = False + for line in fp: + if not line: + break + line_lower = line.lower() + if inside: + if line.startswith(' '): + if has_dhpython(line): + binary = NEW + break + continue + elif line.startswith('#'): + continue + inside = False + if line_lower.startswith(('build-depends:', 'build-depends-indep:')): + if has_dhpython(line): + binary = NEW + break + inside = True + +argv[0] = binary +exit(call(argv)) diff --git a/dh_python2.sh b/dh_python2.sh deleted file mode 100755 index a6fd9d7..0000000 --- a/dh_python2.sh +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/sh - -if [ -f /usr/share/dh-python/dh_python2 ] &&\ - grep -q dh-python ./debian/control 2>/dev/null -then - exec /usr/share/dh-python/dh_python2 $@ -else - exec /usr/share/python/dh_python2 $@ -fi -- GitLab