Package: python-defaults
Severity: normal
Tags: patch
There is an (real, but a little simplified) example of problem.
I have following CDBS-based rule for customized installing of python-uwsgicc
package
DEFAULT_PYVER := $(shell pyversions -dv)
binary-install/python-uwsgicc::
# uWSGI control center (uwsgicc) is a simple Flask-based webapp
# Install .py files to /usr/lib/pythonX.Y/dist-packages
# Install resources (templates, images, scripts) to /usr/share/python-
uwsgicc
dh_install -p $(cdbs_curpkg) -Xstatic -Xtemplates \
uwsgicc \
usr/lib/python$(DEFAULT_PYVER)/dist-packages
dh_install -p $(cdbs_curpkg) \
uwsgicc/static uwsgicc/templates \
usr/share/python-uwsgicc
# Make symbolic links to resources in dist-packages
dh_link -p $(cdbs_curpkg) \
usr/share/python-uwsgicc/static \
usr/lib/python$(DEFAULT_PYVER)/dist-packages/uwsgicc/static
dh_link -p $(cdbs_curpkg) \
usr/share/python-uwsgicc/templates \
usr/lib/python$(DEFAULT_PYVER)/dist-packages/uwsgicc/templates
dh_python2 -p $(cdbs_curpkg)
After building of package I see following directory structure:
% ls -l debian/python-uwsgicc/usr/share/pyshared/uwsgicc/
итого 8
-rw-r--r-- 1 user user 43 Апр 18 19:15 __init__.py
drwxr-xr-x 4 user user 96 Май 26 01:04 static
drwxr-xr-x 2 user user 80 Май 26 01:04 templates
-rw-r--r-- 1 user user 1121 Апр 18 19:15 uwsgicc.py
% ls -l debian/python-uwsgicc/usr/lib/python2.6/dist-packages/uwsgicc/
итого 0
lrwxrwxrwx 1 user user 46 Май 26 01:04 __init__.py ->
.../../../../share/pyshared/uwsgicc/__init__.py
lrwxrwxrwx 1 user user 39 Май 26 01:04 static -> ../../../../share/python-
uwsgicc/static
lrwxrwxrwx 1 user user 42 Май 26 01:04 templates -> ../../../../share
/python-uwsgicc/templates
lrwxrwxrwx 1 user user 45 Май 26 01:04 uwsgicc.py ->
.../../../../share/pyshared/uwsgicc/uwsgicc.py
% ls -l debian/python-uwsgicc/usr/lib/python2.7/dist-packages/uwsgicc/
итого 0
lrwxrwxrwx 1 user user 46 Май 26 01:04 __init__.py ->
.../../../../share/pyshared/uwsgicc/__init__.py
drwxr-xr-x 4 user user 96 Май 26 01:04 static
drwxr-xr-x 2 user user 80 Май 26 01:04 templates
lrwxrwxrwx 1 user user 45 Май 26 01:04 uwsgicc.py ->
.../../../../share/pyshared/uwsgicc/uwsgicc.py
But another directory structure is expected (by me, at least):
% ls -l debian/python-uwsgicc/usr/share/pyshared/uwsgicc/
итого 8
-rw-r--r-- 1 user user 43 Апр 18 19:15 __init__.py
lrwxrwxrwx 1 user user 27 Май 26 01:37 static -> ../../python-
uwsgicc/static
lrwxrwxrwx 1 user user 30 Май 26 01:37 templates -> ../../python-
uwsgicc/templates
-rw-r--r-- 1 user user 1121 Апр 18 19:15 uwsgicc.py
% ls -l debian/python-uwsgicc/usr/lib/python2.6/dist-packages/uwsgicc/
итого 0
lrwxrwxrwx 1 user user 46 Май 26 01:37 __init__.py ->
.../../../../share/pyshared/uwsgicc/__init__.py
lrwxrwxrwx 1 user user 41 Май 26 01:37 static ->
.../../../../share/pyshared/uwsgicc/static
lrwxrwxrwx 1 user user 44 Май 26 01:37 templates ->
.../../../../share/pyshared/uwsgicc/templates
lrwxrwxrwx 1 user user 45 Май 26 01:37 uwsgicc.py ->
.../../../../share/pyshared/uwsgicc/uwsgicc.py
% ls -l debian/python-uwsgicc/usr/lib/python2.7/dist-packages/uwsgicc/
итого 0
lrwxrwxrwx 1 user user 46 Май 26 01:37 __init__.py ->
.../../../../share/pyshared/uwsgicc/__init__.py
lrwxrwxrwx 1 user user 41 Май 26 01:37 static ->
.../../../../share/pyshared/uwsgicc/static
lrwxrwxrwx 1 user user 44 Май 26 01:37 templates ->
.../../../../share/pyshared/uwsgicc/templates
lrwxrwxrwx 1 user user 45 Май 26 01:37 uwsgicc.py ->
.../../../../share/pyshared/uwsgicc/uwsgicc.py
Patch for changing dh_python2 behavior (from creating of first directory
structure to creating of second) is attached.
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (990, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.39-1-686-pae (SMP w/2 CPU cores)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
=== modified file 'dh_python2'
--- dh_python2 2011-05-05 20:46:03 +0000
+++ dh_python2 2011-05-25 22:34:26 +0000
@@ -28,7 +28,7 @@
import sys
from filecmp import dircmp, cmpfiles, cmp as fcmp
from optparse import OptionParser, SUPPRESS_HELP
-from os.path import isdir, islink, exists, join, realpath
+from os.path import isdir, islink, isabs, exists, join, realpath, normpath
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/')
@@ -169,7 +169,7 @@
for i in os.listdir(dir1):
fpath1 = join(dir1, i)
- if isdir(fpath1):
+ if isdir(fpath1) and not islink(fpath1):
if any(fn for fn in os.listdir(fpath1) if fext(fn) != 'so'):
# at least one file that is not an extension
move_to_pyshared(join(dir1, i))
@@ -180,7 +180,16 @@
if not exists(fpath2):
if not exists(dstdir):
os.makedirs(dstdir)
- os.rename(fpath1, fpath2)
+ if islink(fpath1):
+ fpath1_target = os.readlink(fpath1)
+ if isabs(fpath1_target):
+ os.symlink(fpath1_target, fpath2)
+ else:
+ fpath1_target = normpath(join(dir1, fpath1_target))
+ relative_symlink(fpath1_target, fpath2)
+ os.remove(fpath1)
+ else:
+ os.rename(fpath1, fpath2)
relative_symlink(fpath2, fpath1)
@@ -241,7 +250,8 @@
common_dirs = []
common_files = []
for i in os.listdir(dir1):
- if isdir(join(dir1, i)):
+ subdir1 = join(dir1, i)
+ if isdir(subdir1) and not islink(subdir1):
common_dirs.append([i, None])
else:
# directories with .so files will be blocked earlier