From d894529e8c96527b049f5b7f88973d6cbb180444 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org>
Date: Thu, 17 Feb 2011 20:06:58 +0100
Subject: [PATCH] add test4 to test handling private directories

---
 debian/changelog              |  1 +
 dh_python2                    |  2 +-
 tests/Makefile                |  2 +-
 tests/t4/Makefile             | 19 +++++++++++++++++++
 tests/t4/bar.py               |  2 ++
 tests/t4/baz.py               |  2 ++
 tests/t4/debian/changelog     |  5 +++++
 tests/t4/debian/compat        |  1 +
 tests/t4/debian/control       | 16 ++++++++++++++++
 tests/t4/debian/copyright     |  2 ++
 tests/t4/debian/install       |  3 +++
 tests/t4/debian/rules         | 10 ++++++++++
 tests/t4/debian/source/format |  1 +
 tests/t4/foo.py               |  2 ++
 tests/t4/setup.py             |  0
 15 files changed, 66 insertions(+), 2 deletions(-)
 create mode 100644 tests/t4/Makefile
 create mode 100755 tests/t4/bar.py
 create mode 100644 tests/t4/baz.py
 create mode 100644 tests/t4/debian/changelog
 create mode 100644 tests/t4/debian/compat
 create mode 100644 tests/t4/debian/control
 create mode 100644 tests/t4/debian/copyright
 create mode 100644 tests/t4/debian/install
 create mode 100755 tests/t4/debian/rules
 create mode 100644 tests/t4/debian/source/format
 create mode 100755 tests/t4/foo.py
 create mode 100644 tests/t4/setup.py

diff --git a/debian/changelog b/debian/changelog
index 989a26c..5545591 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ python-defaults (2.6.6-11) UNRELEASED; urgency=low
     - add support for DH_OPTIONS env. variable
     - fix checking shebangs in private directories (executable bit wasn't
       checked correctly)
+    - add test4 to test handling private directories
   * pycompile:
     - --exclude now works with private dirs
     - use /usr/bin/pythonX.Y rather than pythonX.Y (to avoid /usr/local
diff --git a/dh_python2 b/dh_python2
index d760290..675f994 100755
--- a/dh_python2
+++ b/dh_python2
@@ -421,7 +421,7 @@ def scan(package, dname=None):
 
 ################################################################
 def main():
-    usage = '%prog -p PACKAGE [-V [X.Y][-][A.B]] DIR_OR_FILE [-X REGEXPR]\n'
+    usage = '%prog -p PACKAGE [-V [X.Y][-][A.B]] DIR [-X REGEXPR]\n'
     parser = OptionParser(usage, version='%prog 2.0~beta1',
                                    option_class=Option)
     parser.add_option('--no-guessing-versions', action='store_false',
diff --git a/tests/Makefile b/tests/Makefile
index a6fe41f..0322ea0 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,7 +1,7 @@
 #!/usr/bin/make -f
 
 # enable or disable tests here:
-TESTS := test1 test2 test3
+TESTS := test1 test2 test3 test4
 
 all: $(TESTS)
 
diff --git a/tests/t4/Makefile b/tests/t4/Makefile
new file mode 100644
index 0000000..5400f5d
--- /dev/null
+++ b/tests/t4/Makefile
@@ -0,0 +1,19 @@
+#!/usr/bin/make -f
+
+all: run check
+
+
+run: clean
+	dpkg-buildpackage -b -us -uc
+
+check:
+	grep -q python2.6 debian/foo/usr/share/foo/foo.py
+	grep -q Depends:.*python2.6 debian/foo/DEBIAN/control
+	grep -q python2.5 debian/foo/usr/share/bar/bar.py
+	grep -q Depends:.*python2.5 debian/foo/DEBIAN/control
+	grep -q python2.4 debian/foo/usr/share/foo/baz.py
+	test ! -x debian/foo/usr/share/foo/baz.py
+	grep -q Depends:.*python2.5 debian/foo/DEBIAN/control && false || true
+
+clean:
+	./debian/rules clean
diff --git a/tests/t4/bar.py b/tests/t4/bar.py
new file mode 100755
index 0000000..707570e
--- /dev/null
+++ b/tests/t4/bar.py
@@ -0,0 +1,2 @@
+#!/usr/bin/python2.5
+print("I'm bar")
diff --git a/tests/t4/baz.py b/tests/t4/baz.py
new file mode 100644
index 0000000..8a52e9e
--- /dev/null
+++ b/tests/t4/baz.py
@@ -0,0 +1,2 @@
+#!/usr/bin/python2.4
+print("I'm baz - not executable")
diff --git a/tests/t4/debian/changelog b/tests/t4/debian/changelog
new file mode 100644
index 0000000..0f9a168
--- /dev/null
+++ b/tests/t4/debian/changelog
@@ -0,0 +1,5 @@
+foo (0.1.1) unstable; urgency=low
+
+  * Initial release
+
+ -- Piotr Ożarowski <piotr@debian.org>  Sat, 27 Feb 2010 20:42:17 +0100
diff --git a/tests/t4/debian/compat b/tests/t4/debian/compat
new file mode 100644
index 0000000..7f8f011
--- /dev/null
+++ b/tests/t4/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/tests/t4/debian/control b/tests/t4/debian/control
new file mode 100644
index 0000000..fbfc9fd
--- /dev/null
+++ b/tests/t4/debian/control
@@ -0,0 +1,16 @@
+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
+
+Package: foo
+Architecture: all
+Depends: ${python:Depends}, ${misc:Depends}
+Recommends: ${python:Recommends}
+Suggests: ${python:Suggests}
+Enhances: ${python:Enhances}
+Description: example 4 - private directory
+ exemple package #4 - private directory
diff --git a/tests/t4/debian/copyright b/tests/t4/debian/copyright
new file mode 100644
index 0000000..69cea75
--- /dev/null
+++ b/tests/t4/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/t4/debian/install b/tests/t4/debian/install
new file mode 100644
index 0000000..a589a0c
--- /dev/null
+++ b/tests/t4/debian/install
@@ -0,0 +1,3 @@
+foo.py /usr/share/foo/
+bar.py /usr/share/bar/
+baz.py /usr/share/foo/
diff --git a/tests/t4/debian/rules b/tests/t4/debian/rules
new file mode 100755
index 0000000..29b0340
--- /dev/null
+++ b/tests/t4/debian/rules
@@ -0,0 +1,10 @@
+#!/usr/bin/make -f
+%:
+	dh $@ --buildsystem=python_distutils
+
+override_dh_pysupport:
+	DH_VERBOSE=1 ../../dh_python2
+	DH_VERBOSE=1 ../../dh_python2 /usr/share/bar
+
+clean:
+	dh_clean
diff --git a/tests/t4/debian/source/format b/tests/t4/debian/source/format
new file mode 100644
index 0000000..89ae9db
--- /dev/null
+++ b/tests/t4/debian/source/format
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/tests/t4/foo.py b/tests/t4/foo.py
new file mode 100755
index 0000000..d679d96
--- /dev/null
+++ b/tests/t4/foo.py
@@ -0,0 +1,2 @@
+#!/usr/bin/python2.6
+print("I'm foo")
diff --git a/tests/t4/setup.py b/tests/t4/setup.py
new file mode 100644
index 0000000..e69de29
-- 
GitLab