From 8e18652ea6881109c45bb4eee4e04860f362db5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org>
Date: Tue, 2 Jul 2013 23:14:46 +0200
Subject: [PATCH] Replace /usr/bin/dh_python2 with a shell script that invokes
 dh-python's dh_python2 if debian/control mentions dh-python

---
 Makefile         | 3 ++-
 debian/changelog | 5 +++++
 dh_python2       | 1 -
 dh_python2.sh    | 9 +++++++++
 4 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100755 dh_python2.sh

diff --git a/Makefile b/Makefile
index ef627fa..3faf321 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,8 @@ install-dev:
 		$(DESTDIR)$(PREFIX)/share/perl5/Debian/Debhelper/Sequence/
 	$(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)/bin/
+	$(INSTALL) -m 755 dh_python2 $(DESTDIR)$(PREFIX)/share/python/
+	$(INSTALL) -m 755 dh_python2.sh $(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 1af34cb..711ebca 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,7 +1,12 @@
 python-defaults (2.7.5-3) UNRELEASED; urgency=low
 
+  [ Matthias Klose ]
   * Fix libpython-all-dbg doc dir symlink. Closes: #712270.
 
+  [ Piotr Ożarowski ]
+  * Replace /usr/bin/dh_python2 with a shell script that invokes
+    dh-python's dh_python2 if debian/control mentions dh-python
+
  -- Matthias Klose <doko@debian.org>  Mon, 17 Jun 2013 11:09:36 +0200
 
 python-defaults (2.7.5-2) unstable; urgency=low
diff --git a/dh_python2 b/dh_python2
index 911f4a7..e8f4aa1 100755
--- a/dh_python2
+++ b/dh_python2
@@ -32,7 +32,6 @@ from os.path import isabs, isdir, islink, exists, join, normpath, realpath,\
  split
 from shutil import rmtree, copy as fcopy
 from stat import ST_MODE, S_IXUSR, S_IXGRP, S_IXOTH
-sys.path.insert(1, '/usr/share/python/')
 from debpython.debhelper import DebHelper
 from debpython.depends import Dependencies
 from debpython.version import SUPPORTED, DEFAULT, \
diff --git a/dh_python2.sh b/dh_python2.sh
new file mode 100755
index 0000000..a6fd9d7
--- /dev/null
+++ b/dh_python2.sh
@@ -0,0 +1,9 @@
+#! /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