From 063b3aa6047e2179a59444b983d68ca6fc6edd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org> Date: Tue, 26 Jul 2011 20:05:39 +0200 Subject: [PATCH] dh_python2: * no longer moves .so.foo files to pyshared dir (closes: 635316) * replaces .so symlinks with .so.foo files in dist-packages --- debian/changelog | 9 +++++++++ dh_python2 | 29 ++++++++++++++++++----------- tests/t3/Makefile | 5 +++++ tests/t3/debian/rules | 15 ++++++++++++++- 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index 76843de..faeaf98 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +python-defaults (2.7.2-3) UNRELEASED; urgency=low + + [ Piotr Ożarowski ] + * dh_python2: + - no longer moves .so.foo files to pyshared dir (closes: 635316) + - replaces .so symlinks with .so.foo files in dist-packages + + -- Piotr Ożarowski <piotr@debian.org> Tue, 26 Jul 2011 19:58:48 +0200 + python-defaults (2.7.2-2) experimental; urgency=low [ Piotr Ożarowski ] diff --git a/dh_python2 b/dh_python2 index f61715c..2959b16 100755 --- a/dh_python2 +++ b/dh_python2 @@ -28,7 +28,8 @@ import re import sys from filecmp import dircmp, cmpfiles, cmp as fcmp from optparse import OptionParser, SUPPRESS_HELP -from os.path import isabs, isdir, islink, exists, join, normpath, realpath +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/') @@ -53,14 +54,6 @@ log = logging.getLogger(__name__) os.umask(022) EGGnPTH_RE = re.compile(r'(.*?)(-py\d\.\d+)?(.*?)(\.egg-info|\.pth)$') -"""TODO: move it to manpage -Examples: - dh_python2 - dh_python2 -V 2.4- # public files only, Python >= 2.4 - dh_python2 -p python-foo -X 'bar.*' /usr/lib/baz/ # private files in - python-foo package -""" - # naming conventions used in the file: # * version - tuple of integers # * ver - string representation of version @@ -269,7 +262,7 @@ 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'): + if 'so' in fn.split('.'): # foo.so, bar.so.0.1.2, etc. # in unlikely case where extensions are exactly the same continue fpath1 = join(dir1, fn) @@ -368,7 +361,7 @@ def scan(package, dname=None): if name.endswith('.egg-info'): if dbg_package: rmtree(join(root, name)) - dirs.pop(dirs.index(name)) + dirs.remove(name) continue clean_name = clean_egg_name(name) if clean_name != name: @@ -389,6 +382,20 @@ def scan(package, dname=None): os.remove(join(root, fn)) continue if public_dir: + fpath = join(root, fn) + if fext == 'so' and islink(fpath): + dstfpath = fpath + links = set() + while islink(dstfpath): + links.add(dstfpath) + dstfpath = join(root, os.readlink(dstfpath)) + if exists(dstfpath) and '.so.' in split(dstfpath)[-1]: + # rename .so.$FOO symlinks, remove other ones + for lpath in links: + log.info('removing symlink: %s', lpath) + os.remove(lpath) + log.info('renaming %s to %s', dstfpath, fn) + os.rename(dstfpath, fpath) if dbg_package and fext not in ('so', 'h'): os.remove(join(root, fn)) continue diff --git a/tests/t3/Makefile b/tests/t3/Makefile index 6803bfb..96032f8 100644 --- a/tests/t3/Makefile +++ b/tests/t3/Makefile @@ -12,6 +12,11 @@ check: debian/python-foo/DEBIAN/postinst test -f debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/bar.so test ! -f debian/python-foo/usr/share/pyshared/foo/bar.so + test -f debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/spam.so + test ! -f debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/spam.so.0.1 + test -f debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/baz.so + test ! -f debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/baz.so.0.1 + test ! -f debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/baz.so.0.1.2 clean: ./debian/rules clean diff --git a/tests/t3/debian/rules b/tests/t3/debian/rules index 1bba84b..0915111 100755 --- a/tests/t3/debian/rules +++ b/tests/t3/debian/rules @@ -1,9 +1,22 @@ #!/usr/bin/make -f +DPY=$(shell PYTHONPATH=../../ python -c 'import debpython.version as v; print(v.vrepr(v.DEFAULT))') %: 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 \ + dh_install debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/bar.so \ /usr/lib/python-foo/ + # ... and under versioned name with a symlink + cp debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/bar.so \ + debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/spam.so.0 + dh_link /usr/lib/python${DPY}/dist-packages/foo/spam.so.0 \ + /usr/lib/python${DPY}/dist-packages/foo/spam.so + # ... and with multiple symlinks + cp debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/bar.so \ + debian/python-foo/usr/lib/python${DPY}/dist-packages/foo/baz.so.0.1.2 + dh_link /usr/lib/python${DPY}/dist-packages/foo/baz.so.0.1.2 \ + /usr/lib/python${DPY}/dist-packages/foo/baz.so.0.1 + dh_link /usr/lib/python${DPY}/dist-packages/foo/baz.so.0.1 \ + /usr/lib/python${DPY}/dist-packages/foo/baz.so DH_VERBOSE=1 ../../dh_python2 -- GitLab