Files
linux/debian/lib/python/debian_linux/utils.py
Bastian Blank b37871ac10 * Set compiler build dependencies from config informations.
* Install debian/lib into headers-all package.
* Unlink version file before writing to them.
* debian/README: Remove outdated information.

r5275:  waldi | 2006-01-05 14:00:15 +0100
* debian/lib/python/debian_linux/debian.py: Move package class from utils.
* debian/lib/python/debian_linux/utils.py: Use package class from debian.

r5277:  waldi | 2006-01-05 14:41:45 +0100
* debian/lib/python/debian_linux/debian.py
  - Add package_relation, package_relation_list and package_relation_group
    classes.
  - Use them in the package class.
* debian/lib/python/debian_linux/gencontrol.py
  - Support new relation classes.

r5278:  waldi | 2006-01-05 14:46:55 +0100
debian/bin/gencontrol.py: Use relation objects for tree entry.

r5279:  waldi | 2006-01-05 15:20:00 +0100
* debian/bin/gencontrol.py: Don't fail if some relation fields are empty.
* debian/lib/python/debian_linux/debian.py: Merge relation entries.

r5280:  waldi | 2006-01-05 15:24:08 +0100
* debian/arch/defines, debian/arch/hppa/defines: Set relations for compiler.
* debian/lib/python/debian_linux/gencontrol.py: Set compiler build dependencies
  from config informations.
* debian/templates/control.source.in: Remove compiler from Build-Depends.

r5281:  waldi | 2006-01-05 15:39:45 +0100
* debian/rules.real
  - Install debian/lib into headers-all package.
  - Call dh_python with python version 2.4.
* debian/templates/control.source.in:
  Add python to build-depends, needed by dh_python.

r5282:  waldi | 2006-01-05 16:36:33 +0100
debian/rules.real
- Remove outdated comment about include_common_config.
- Remove support for headers_dirs.

r5283:  waldi | 2006-01-05 16:38:05 +0100
debian/arch/amd64/Makefile.inc, debian/arch/arm/Makefile.inc,
debian/arch/hppa/Makefile.inc, debian/arch/powerpc/Makefile.inc,
debian/arch/sparc/Makefile.inc: Remove not longer supported variables.

r5284:  waldi | 2006-01-05 16:42:33 +0100
debian/lib/python/debian_linux/gencontrol.py:
Warn if the class setting is not available.

r5287:  waldi | 2006-01-05 19:07:05 +0100
debian/arch/powerpc/defines: Set kernel-arch for all except powerpc64 to ppc.

r5288:  waldi | 2006-01-05 19:08:35 +0100
debian/lib/python/debian_linux/config.py:
Only bail out if a section is not found in any config file.

r5294:  waldi | 2006-01-05 19:26:57 +0100
debian/lib/python/debian_linux/gencontrol.py
- Support config underlay.
- Add some small default implementations.

r5295:  waldi | 2006-01-05 19:39:55 +0100
debian/README: Remove outdated information.

r5325:  waldi | 2006-01-06 22:40:17 +0100
debian/bin/apply.py
- Don't reference the debian_linux module, it is not available.
- Unlink version file before writing to them.

svn path=/dists/trunk/linux-2.6/; revision=5327
2006-01-06 22:32:16 +00:00

134 lines
3.7 KiB
Python

import debian, re, textwrap
class _sorted_dict(dict):
__slots__ = ('_list')
def __init__(self, entries = None):
super(_sorted_dict, self).__init__()
self._list = []
if entries is not None:
for key, value in entries:
self[key] = value
def __delitem__(self, key):
super(_sorted_dict, self).__delitem__(key)
self._list.remove(key)
def iterkeys(self):
for i in iter(self._list):
yield i
def iteritems(self):
for i in iter(self._list):
yield (i, self[i])
def itervalues(self):
for i in iter(self._list):
yield self[i]
class sorted_dict(_sorted_dict):
__slots__ = ()
def __setitem__(self, key, value):
super(sorted_dict, self).__setitem__(key, value)
if key not in self._list:
self._list.append(key)
class field_list(list):
TYPE_WHITESPACE = object()
TYPE_COMMATA = object()
def __init__(self, value = None, type = TYPE_WHITESPACE):
self.type = type
if isinstance(value, field_list):
self.type = value.type
self.extend(value)
elif isinstance(value, (list, tuple)):
self.extend(value)
else:
self._extend(value)
def __str__(self):
if self.type is self.TYPE_WHITESPACE:
type = ' '
elif self.type is self.TYPE_COMMATA:
type = ', '
return type.join(self)
def _extend(self, value):
if self.type is self.TYPE_WHITESPACE:
type = '\s'
elif self.type is self.TYPE_COMMATA:
type = ','
if value is not None:
self.extend([j.strip() for j in re.split(type, value.strip())])
def extend(self, value):
if isinstance(value, str):
self._extend(value)
else:
super(field_list, self).extend(value)
class field_list_commata(field_list):
def __init__(self, value = None):
super(field_list_commata, self).__init__(value, field_list.TYPE_COMMATA)
class field_string(str):
def __str__(self):
return '\n '.join(self.split('\n'))
class templates(dict):
def __init__(self, dir = None):
if dir is None:
self.dir = "debian/templates"
else:
self.dir = dir
def __getitem__(self, key):
try:
return dict.__getitem__(self, key)
except KeyError: pass
ret = self._read(key)
dict.__setitem__(self, key, ret)
return ret
def __setitem__(self, key, value):
raise NotImplemented()
def _read(self, filename):
entries = []
f = file("%s/%s.in" % (self.dir, filename))
while True:
e = debian.package()
while True:
line = f.readline()
if not line:
break
line = line.strip('\n')
if not line:
break
if line[0] in ' \t':
if not last:
raise ValueError('Continuation line seen before first header')
e[last] += '\n' + line.lstrip()
continue
i = line.find(':')
if i < 0:
raise ValueError("Not a header, not a continuation: ``%s''" % line)
last = line[:i]
e[last] = line[i+1:].lstrip()
if not e:
break
entries.append(e)
return entries
class wrap(textwrap.TextWrapper):
wordsep_re = re.compile(
r'(\s+|' # any whitespace
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash