From 94843c964a743ca3de56eb87d58fa6c452a65b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org> Date: Sun, 19 Dec 2010 20:35:51 +0100 Subject: [PATCH] * dh_python2: fix a crash in packages with private extension (closes: 607555) - test3 added (to test architecture dependent packages) --- debian/changelog | 7 +++++++ dh_python2 | 10 ++++++++-- tests/Makefile | 2 +- tests/t3/Makefile | 18 ++++++++++++++++++ tests/t3/debian/changelog | 5 +++++ tests/t3/debian/compat | 1 + tests/t3/debian/control | 19 +++++++++++++++++++ tests/t3/debian/copyright | 2 ++ tests/t3/debian/install | 2 ++ tests/t3/debian/rules | 9 +++++++++ tests/t3/debian/source/format | 1 + tests/t3/lib/__init__.py | 0 tests/t3/lib/bar.c | 0 tests/t3/lib/foo.py | 5 +++++ tests/t3/setup.py | 13 +++++++++++++ 15 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 tests/t3/Makefile create mode 100644 tests/t3/debian/changelog create mode 100644 tests/t3/debian/compat create mode 100644 tests/t3/debian/control create mode 100644 tests/t3/debian/copyright create mode 100644 tests/t3/debian/install create mode 100755 tests/t3/debian/rules create mode 100644 tests/t3/debian/source/format create mode 100644 tests/t3/lib/__init__.py create mode 100644 tests/t3/lib/bar.c create mode 100644 tests/t3/lib/foo.py create mode 100755 tests/t3/setup.py diff --git a/debian/changelog b/debian/changelog index 3514cc5..c605afa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-defaults (2.6.6-9) experimental; urgency=low + + * dh_python2: fix a crash in packages with private extension (closes: 607555) + - test3 added (to test architecture dependent packages) + + -- Piotr Ożarowski <piotr@debian.org> Sun, 19 Dec 2010 20:27:23 +0100 + python-defaults (2.6.6-8) experimental; urgency=low * Fix typo in minimum required python version for packages generated with diff --git a/dh_python2 b/dh_python2 index 1404f52..8bbee3a 100755 --- a/dh_python2 +++ b/dh_python2 @@ -252,6 +252,9 @@ def share_2x(dir1, dir2, dc=None): common_files = cmpfiles(dir1, dir2, common_files, shallow=False)[0] for fn in common_files: + if fn.endswith('.so'): + # in unlikely case where extensions are exactly the same + continue fpath1 = join(dir1, fn) fpath2 = join(dir2, fn) fpath3 = join(dstdir, fn) @@ -323,6 +326,8 @@ def scan(package, dname=None): if root.endswith('-packages'): r['public_vers'].add(version) else: + # TODO: find a way to specify Python version private + # extension was build for version = False for i in private_to_check: if root.startswith(join('debian', package, i)): @@ -373,7 +378,7 @@ def scan(package, dname=None): if fext == 'so': (r if public_dir else r['private_dirs'].setdefault(private_dir, {}))\ - ['public_ext'].add(version) + .setdefault('public_ext', set()).add(version) continue elif fext == 'py': (r if public_dir else @@ -553,7 +558,8 @@ def main(): if ext_for is None: # no extension if options.vrange and options.vrange != (None, None): args += " -V %s" % vrange_str(options.vrange) - elif ext_for is False: # extension's version not detected + elif False in ext_for: + # at least one extension's version not detected if options.vrange and '-' not in vrange_str(options.vrange): ver = vrange_str(options.vrange) else: # try shebang or default Python version diff --git a/tests/Makefile b/tests/Makefile index 61610d2..a6fe41f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,7 @@ #!/usr/bin/make -f # enable or disable tests here: -TESTS := test1 test2 +TESTS := test1 test2 test3 all: $(TESTS) diff --git a/tests/t3/Makefile b/tests/t3/Makefile new file mode 100644 index 0000000..891a239 --- /dev/null +++ b/tests/t3/Makefile @@ -0,0 +1,18 @@ +#!/usr/bin/make -f + +all: run check + +DPY=$(shell pyversions -d) + +run: clean + dpkg-buildpackage -b -us -uc + +check: + grep -q "pycompile -p python-foo /usr/lib/python-foo -V $(shell pyversions -vd)"\ + debian/python-foo/DEBIAN/postinst + test -f debian/python-foo/usr/lib/${DPY}/dist-packages/foo/bar.so + test ! -f debian/python-foo/usr/share/pyshared/foo/bar.so + +clean: + ./debian/rules clean + rm -rf lib/Foo.egg-info build diff --git a/tests/t3/debian/changelog b/tests/t3/debian/changelog new file mode 100644 index 0000000..d91e7a7 --- /dev/null +++ b/tests/t3/debian/changelog @@ -0,0 +1,5 @@ +foo (0.1.1) unstable; urgency=low + + * Initial release + + -- Piotr Ożarowski <piotr@debian.org> Sun, 19 Dec 2010 19:40:33 +0100 diff --git a/tests/t3/debian/compat b/tests/t3/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/tests/t3/debian/compat @@ -0,0 +1 @@ +7 diff --git a/tests/t3/debian/control b/tests/t3/debian/control new file mode 100644 index 0000000..c4e1f5f --- /dev/null +++ b/tests/t3/debian/control @@ -0,0 +1,19 @@ +Source: foo +Section: python +Priority: optional +Maintainer: Piotr Ożarowski <piotr@debian.org> +Build-Depends: debhelper (>= 7.0.50~), python-all-dev +Standards-Version: 3.9.1 +X-Python-Version: >= 2.6 + +Package: python-foo +Architecture: any +Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} +Recommends: ${python:Recommends} +Suggests: ${python:Suggests} +Enhances: ${python:Enhances} +Breaks: ${python:Breaks} +Provides: ${python:Provides} +XB-Python-Version: ${python:Versions} +Description: foo to rule them all + exemple package #3 - Python extension diff --git a/tests/t3/debian/copyright b/tests/t3/debian/copyright new file mode 100644 index 0000000..6382944 --- /dev/null +++ b/tests/t3/debian/copyright @@ -0,0 +1,2 @@ +The Debian packaging is © 2010, Piotr Ożarowski <piotr@debian.org> and +is licensed under the MIT License. diff --git a/tests/t3/debian/install b/tests/t3/debian/install new file mode 100644 index 0000000..380db41 --- /dev/null +++ b/tests/t3/debian/install @@ -0,0 +1,2 @@ +# private module in architecture dependent dir +lib/foo.py /usr/lib/python-foo/ diff --git a/tests/t3/debian/rules b/tests/t3/debian/rules new file mode 100755 index 0000000..1bba84b --- /dev/null +++ b/tests/t3/debian/rules @@ -0,0 +1,9 @@ +#!/usr/bin/make -f +%: + dh $@ --buildsystem=python_distutils + +override_dh_pysupport: + # install also as private extension + dh_install debian/python-foo/usr/lib/`pyversions -d`/dist-packages/foo/bar.so \ + /usr/lib/python-foo/ + DH_VERBOSE=1 ../../dh_python2 diff --git a/tests/t3/debian/source/format b/tests/t3/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/tests/t3/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/tests/t3/lib/__init__.py b/tests/t3/lib/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/t3/lib/bar.c b/tests/t3/lib/bar.c new file mode 100644 index 0000000..e69de29 diff --git a/tests/t3/lib/foo.py b/tests/t3/lib/foo.py new file mode 100644 index 0000000..11c51ef --- /dev/null +++ b/tests/t3/lib/foo.py @@ -0,0 +1,5 @@ +import foo.bar + +class Foo(object): + def __init__(self): + pass diff --git a/tests/t3/setup.py b/tests/t3/setup.py new file mode 100755 index 0000000..4835818 --- /dev/null +++ b/tests/t3/setup.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +from distutils.core import setup, Extension +setup(name="distutils-test", + version = "0.1", + author="jbailey", + author_email="jbailey@debian.org", + url="http://www.python.org/sigs/distutils-sig/", + ext_modules=[Extension('foo/bar', ['lib/bar.c'])], + #py_modules=['package'], + packages = ["foo"], + package_dir = {'foo': 'lib'} + ) + -- GitLab