From feff83b3bfa8dfb1af89df3787e1817dfd5cef4a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org>
Date: Sat, 8 Oct 2011 17:16:57 +0200
Subject: [PATCH] add test6 to test private directories that support one Python
 version only

---
 debian/changelog              |  4 ++--
 tests/Makefile                |  2 +-
 tests/t6/Makefile             | 24 ++++++++++++++++++++++++
 tests/t6/bar.py               |  2 ++
 tests/t6/baz.py               |  2 ++
 tests/t6/debian/changelog     |  5 +++++
 tests/t6/debian/compat        |  1 +
 tests/t6/debian/control       | 20 ++++++++++++++++++++
 tests/t6/debian/copyright     |  2 ++
 tests/t6/debian/install       |  6 ++++++
 tests/t6/debian/rules         | 11 +++++++++++
 tests/t6/debian/source/format |  1 +
 tests/t6/foo.py               |  2 ++
 tests/t6/setup.py             |  0
 tests/t6/spam.py              |  1 +
 15 files changed, 80 insertions(+), 3 deletions(-)
 create mode 100644 tests/t6/Makefile
 create mode 100755 tests/t6/bar.py
 create mode 100644 tests/t6/baz.py
 create mode 100644 tests/t6/debian/changelog
 create mode 100644 tests/t6/debian/compat
 create mode 100644 tests/t6/debian/control
 create mode 100644 tests/t6/debian/copyright
 create mode 100644 tests/t6/debian/install
 create mode 100755 tests/t6/debian/rules
 create mode 100644 tests/t6/debian/source/format
 create mode 100755 tests/t6/foo.py
 create mode 100644 tests/t6/setup.py
 create mode 100644 tests/t6/spam.py

diff --git a/debian/changelog b/debian/changelog
index 66f2317..a385796 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,9 @@
-python-defaults (2.7.2-9) UNRELEASED; urgency=low
+python-defaults (2.7.2-9) unstable; urgency=low
 
   * Generate correct dependencies if private directory supports one Python
     version only (closes: #644573)
 
- -- Piotr Ożarowski <piotr@debian.org>  Sat, 08 Oct 2011 14:18:31 +0200
+ -- Piotr Ożarowski <piotr@debian.org>  Sat, 08 Oct 2011 17:16:46 +0200
 
 python-defaults (2.7.2-8) unstable; urgency=high
 
diff --git a/tests/Makefile b/tests/Makefile
index 563a4b7..8cade20 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,7 +1,7 @@
 #!/usr/bin/make -f
 
 # enable or disable tests here:
-TESTS := test1 test2 test3 test4 test5
+TESTS := test1 test2 test3 test4 test5 test6
 
 all: $(TESTS)
 
diff --git a/tests/t6/Makefile b/tests/t6/Makefile
new file mode 100644
index 0000000..b8f141e
--- /dev/null
+++ b/tests/t6/Makefile
@@ -0,0 +1,24 @@
+#!/usr/bin/make -f
+
+all: run check
+
+
+run: clean
+	dpkg-buildpackage -b -us -uc
+
+check:
+	# python2.4 hardcoded via `dh_python2 -V 2.4`
+	grep -q Depends:.*python2.4 debian/foo/DEBIAN/control
+	grep -q '\-V 2.4 /usr/share/baz24' debian/foo/usr/share/python/runtime.d/foo.rtupdate
+	grep -q '/usr/share/baz24 \-V 2.4' debian/foo/DEBIAN/postinst
+	# python2.5 due to X-Python-Version: 2.5
+	grep -q Depends:.*python2.5 debian/foo/DEBIAN/control
+	grep -q '\-V 2.5 /usr/share/bar25' debian/foo/usr/share/python/runtime.d/foo.rtupdate
+	grep -q '/usr/share/bar25 \-V 2.5' debian/foo/DEBIAN/postinst
+	# python2.6 hardcoded via shebang
+	grep -q Depends:.*python2.6 debian/foo/DEBIAN/control
+	grep -q '\-V 2.6 /usr/share/foo' debian/foo/usr/share/python/runtime.d/foo.rtupdate
+	grep -q '/usr/share/foo \-V 2.6' debian/foo/DEBIAN/postinst
+
+clean:
+	./debian/rules clean
diff --git a/tests/t6/bar.py b/tests/t6/bar.py
new file mode 100755
index 0000000..f1d7b7c
--- /dev/null
+++ b/tests/t6/bar.py
@@ -0,0 +1,2 @@
+#!/usr/bin/python
+print("I'm bar")
diff --git a/tests/t6/baz.py b/tests/t6/baz.py
new file mode 100644
index 0000000..aced459
--- /dev/null
+++ b/tests/t6/baz.py
@@ -0,0 +1,2 @@
+#!/usr/bin/python
+print("I'm baz")
diff --git a/tests/t6/debian/changelog b/tests/t6/debian/changelog
new file mode 100644
index 0000000..33f04f8
--- /dev/null
+++ b/tests/t6/debian/changelog
@@ -0,0 +1,5 @@
+foo (0.1.1) unstable; urgency=low
+
+  * Initial release
+
+ -- Piotr Ożarowski <piotr@debian.org>  Sat, 08 Oct 2011 17:13:03 +0200
diff --git a/tests/t6/debian/compat b/tests/t6/debian/compat
new file mode 100644
index 0000000..45a4fb7
--- /dev/null
+++ b/tests/t6/debian/compat
@@ -0,0 +1 @@
+8
diff --git a/tests/t6/debian/control b/tests/t6/debian/control
new file mode 100644
index 0000000..2487e09
--- /dev/null
+++ b/tests/t6/debian/control
@@ -0,0 +1,20 @@
+Source: foo
+Section: misc
+Priority: optional
+Maintainer: Piotr Ożarowski <piotr@debian.org>
+Build-Depends: debhelper (>= 7.0.50~)
+Build-Depends-Indep: python
+Standards-Version: 3.9.1
+X-Python-Version: 2.5
+
+Package: foo
+Architecture: all
+Depends: ${python:Depends}, ${misc:Depends}
+Recommends: ${python:Recommends}
+Suggests: ${python:Suggests}
+Enhances: ${python:Enhances}
+Description: example 6 - private directory with hardcoded Python version
+ exemple package #6 - private directories that support:
+  * python2.4 hardcoded via `dh_python2 -V 2.4`
+  * python2.5 due to X-Python-Version: 2.5
+  * python2.6 hardcoded via shebang
diff --git a/tests/t6/debian/copyright b/tests/t6/debian/copyright
new file mode 100644
index 0000000..69cea75
--- /dev/null
+++ b/tests/t6/debian/copyright
@@ -0,0 +1,2 @@
+The Debian packaging is © 2011, Piotr Ożarowski <piotr@debian.org> and
+is licensed under the MIT License.
diff --git a/tests/t6/debian/install b/tests/t6/debian/install
new file mode 100644
index 0000000..12d2c11
--- /dev/null
+++ b/tests/t6/debian/install
@@ -0,0 +1,6 @@
+foo.py /usr/share/foo/
+spam.py /usr/share/foo/
+bar.py /usr/share/bar25/
+spam.py /usr/share/bar25/
+baz.py /usr/share/baz24/
+spam.py /usr/share/baz24/
diff --git a/tests/t6/debian/rules b/tests/t6/debian/rules
new file mode 100755
index 0000000..c08a390
--- /dev/null
+++ b/tests/t6/debian/rules
@@ -0,0 +1,11 @@
+#!/usr/bin/make -f
+%:
+	dh $@ --buildsystem=python_distutils
+
+override_dh_pysupport:
+	DH_VERBOSE=1 ../../dh_python2
+	DH_VERBOSE=1 ../../dh_python2 /usr/share/bar25
+	DH_VERBOSE=1 ../../dh_python2 /usr/share/baz24 -V 2.4
+
+clean:
+	dh_clean
diff --git a/tests/t6/debian/source/format b/tests/t6/debian/source/format
new file mode 100644
index 0000000..89ae9db
--- /dev/null
+++ b/tests/t6/debian/source/format
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/tests/t6/foo.py b/tests/t6/foo.py
new file mode 100755
index 0000000..d679d96
--- /dev/null
+++ b/tests/t6/foo.py
@@ -0,0 +1,2 @@
+#!/usr/bin/python2.6
+print("I'm foo")
diff --git a/tests/t6/setup.py b/tests/t6/setup.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/t6/spam.py b/tests/t6/spam.py
new file mode 100644
index 0000000..c8b0fd9
--- /dev/null
+++ b/tests/t6/spam.py
@@ -0,0 +1 @@
+print('spam')
-- 
GitLab