Skip to content
Snippets Groups Projects
Commit 6d63d2ad authored by Piotr Ożarowski's avatar Piotr Ożarowski
Browse files

dh_python2: follow Distribute and replace all non-alphanumeric characters with...

dh_python2: follow Distribute and replace all non-alphanumeric characters with underscore in distribution name
parent 676b5534
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,8 @@ python-defaults (2.6.5-9) UNRELEASED; urgency=low ...@@ -3,6 +3,8 @@ python-defaults (2.6.5-9) UNRELEASED; urgency=low
[ Piotr Ożarowski ] [ Piotr Ożarowski ]
* pyclean, pycompile: use .communicate() instead of .wait() to avoid hanging * pyclean, pycompile: use .communicate() instead of .wait() to avoid hanging
`dpkg -L PACKAGE` in few situations `dpkg -L PACKAGE` in few situations
* dh_python2: follow Distribute and replace all non-alphanumeric
characters with underscore in distribution name
[ Matthias Klose ] [ Matthias Klose ]
* Require python (>= 2.6.5-9~) in generated dependencies to use the fixed * Require python (>= 2.6.5-9~) in generated dependencies to use the fixed
......
...@@ -89,7 +89,7 @@ def load(dname='/usr/share/python/dist/', fname='debian/pydist-overrides'): ...@@ -89,7 +89,7 @@ def load(dname='/usr/share/python/dist/', fname='debian/pydist-overrides'):
if line.startswith('#') or not line: if line.startswith('#') or not line:
continue continue
dist = PYDIST_RE.search(line).groupdict() dist = PYDIST_RE.search(line).groupdict()
name = dist['name'].lower() name = safe_name(dist['name'])
dist['versions'] = get_requested_versions(dist['vrange']) dist['versions'] = get_requested_versions(dist['vrange'])
dist['dependency'] = dist['dependency'].strip() dist['dependency'] = dist['dependency'].strip()
if dist['rules']: if dist['rules']:
...@@ -106,6 +106,10 @@ def guess_dependency(req, version=None): ...@@ -106,6 +106,10 @@ def guess_dependency(req, version=None):
if isinstance(version, basestring): if isinstance(version, basestring):
version = getver(version) version = getver(version)
# some upstreams have weird ideas for distribution name...
name, rest = re.compile('([^><= ]+)(.*)').match(req).groups()
req = safe_name(name) + rest
data = load() data = load()
req_dict = REQUIRES_RE.match(req) req_dict = REQUIRES_RE.match(req)
if not req: if not req:
...@@ -143,8 +147,9 @@ def guess_dependency(req, version=None): ...@@ -143,8 +147,9 @@ def guess_dependency(req, version=None):
log.debug("invoking dpkg -S %s", query) log.debug("invoking dpkg -S %s", query)
process = Popen("/usr/bin/dpkg -S %s" % query, \ process = Popen("/usr/bin/dpkg -S %s" % query, \
shell=True, stdout=PIPE, stderr=PIPE) shell=True, stdout=PIPE)
if process.wait() != 0: stdout, stderr = process.communicate()
if process.returncode != 0:
log.error('Cannot find package that provides %s. ' log.error('Cannot find package that provides %s. '
'Please add it to debian/pydist-overrides', name) 'Please add it to debian/pydist-overrides', name)
log.info("hint: `apt-file search -x '(packages|pyshared)/" +\ log.info("hint: `apt-file search -x '(packages|pyshared)/" +\
...@@ -152,7 +157,7 @@ def guess_dependency(req, version=None): ...@@ -152,7 +157,7 @@ def guess_dependency(req, version=None):
exit(8) exit(8)
result = set() result = set()
for line in process.stdout: for line in stdout:
result.add(line.split(':')[0]) result.add(line.split(':')[0])
if len(result) > 1: if len(result) > 1:
log.error('more than one package name found for %s dist', name) log.error('more than one package name found for %s dist', name)
...@@ -179,3 +184,8 @@ def parse_pydep(fname): ...@@ -179,3 +184,8 @@ def parse_pydep(fname):
if dependency: if dependency:
result.append(dependency) result.append(dependency)
return result return result
def safe_name(name):
"""Emulate distribute's safe_name."""
return re.compile('[^A-Za-z0-9.]+').sub('_', name).lower()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment