aboutsummaryrefslogtreecommitdiffstats
path: root/debian/lib
diff options
context:
space:
mode:
Diffstat (limited to 'debian/lib')
-rw-r--r--debian/lib/python/debian_linux/config.py19
-rw-r--r--debian/lib/python/debian_linux/debian.py128
-rw-r--r--debian/lib/python/debian_linux/gencontrol.py51
-rw-r--r--debian/lib/python/debian_linux/utils.py46
4 files changed, 176 insertions, 68 deletions
diff --git a/debian/lib/python/debian_linux/config.py b/debian/lib/python/debian_linux/config.py
index 4505d5482325..8a0d79267c8a 100644
--- a/debian/lib/python/debian_linux/config.py
+++ b/debian/lib/python/debian_linux/config.py
@@ -6,7 +6,7 @@ _marker = object()
class config_reader(dict):
"""
- Read configs in debian/arch and in the overlay directory.
+ Read configs in debian/arch and in the underlay directory.
"""
class schema_item_boolean(object):
@@ -34,8 +34,8 @@ class config_reader(dict):
config_name = "defines"
- def __init__(self, overlay_dir = None):
- self._overlay_dir = overlay_dir
+ def __init__(self, underlay = None):
+ self._underlay = underlay
self._read_base()
def __getitem__(self, key):
@@ -43,8 +43,8 @@ class config_reader(dict):
def _get_files(self, name):
ret = []
- if self._overlay_dir is not None:
- ret.append(os.path.join(self._overlay_dir, name))
+ if self._underlay is not None:
+ ret.append(os.path.join(self._underlay, name))
ret.append(os.path.join('debian/arch', name))
return ret
@@ -181,21 +181,20 @@ class config_parser(object):
def items(self, section, var = {}):
ret = {}
section = '_'.join(section)
- exception = None
+ exceptions = []
for config in self.configs:
try:
items = config.items(section)
except ConfigParser.NoSectionError, e:
- exception = e
+ exceptions.append(e)
else:
for key, value in items:
try:
value = self.schema[key](value)
except KeyError: pass
ret[key] = value
- exception = None
- if exception is not None:
- raise exception
+ if len(exceptions) == len(self.configs):
+ raise exceptions[0]
return ret
def sections(self):
diff --git a/debian/lib/python/debian_linux/debian.py b/debian/lib/python/debian_linux/debian.py
index e28a0f5283b8..3e98adbacc4d 100644
--- a/debian/lib/python/debian_linux/debian.py
+++ b/debian/lib/python/debian_linux/debian.py
@@ -1,4 +1,4 @@
-import re, utils
+import itertools, re, utils
def read_changelog():
r = re.compile(r"""
@@ -81,3 +81,129 @@ $
ret['source_upstream'] = ret['upstream']
return ret
+class package_relation(object):
+ __slots__ = "name", "version", "arches"
+
+ _re = re.compile(r'^(\S+)(?: \(([^)]+)\))?(?: \[([^]]+)\])?$')
+
+ def __init__(self, value = None):
+ if value is not None:
+ match = self._re.match(value)
+ if match is None:
+ raise RuntimeError, "Can't parse dependency %s" % value
+ match = match.groups()
+ self.name = match[0]
+ self.version = match[1]
+ if match[2] is not None:
+ self.arches = re.split('\s+', match[2])
+ else:
+ self.arches = []
+ else:
+ self.name = None
+ self.version = None
+ self.arches = []
+
+ def __str__(self):
+ ret = [self.name]
+ if self.version is not None:
+ ret.extend([' (', self.version, ')'])
+ if self.arches:
+ ret.extend([' [', ' '.join(self.arches), ']'])
+ return ''.join(ret)
+
+class package_relation_list(list):
+ def __init__(self, value = None):
+ if isinstance(value, (list, tuple)):
+ self.extend(value)
+ elif value is not None:
+ self.extend(value)
+
+ def __str__(self):
+ return ', '.join([str(i) for i in self])
+
+ def _match(self, value):
+ for i in self:
+ if i._match(value):
+ return i
+ return None
+
+ def extend(self, value):
+ if isinstance(value, basestring):
+ value = [package_relation_group(j.strip()) for j in re.split(',', value.strip())]
+ for i in value:
+ if isinstance(i, basestring):
+ i = package_relation_group(i)
+ j = self._match(i)
+ if j:
+ j._update_arches(i)
+ else:
+ self.append(i)
+
+class package_relation_group(list):
+ def __init__(self, value = None):
+ if isinstance(value, package_relation_list):
+ self.extend(value)
+ elif value is not None:
+ self._extend(value)
+
+ def __str__(self):
+ return ' | '.join([str(i) for i in self])
+
+ def _extend(self, value):
+ self.extend([package_relation(j.strip()) for j in re.split('\|', value.strip())])
+
+ def _match(self, value):
+ for i, j in itertools.izip(self, value):
+ if i.name != j.name or i.version != j.version:
+ return None
+ return self
+
+ def _update_arches(self, value):
+ for i, j in itertools.izip(self, value):
+ if i.arches:
+ for arch in j.arches:
+ if arch not in i.arches:
+ i.arches.append(arch)
+
+class package(dict):
+ _fields = utils.sorted_dict((
+ ('Package', str),
+ ('Source', str),
+ ('Architecture', utils.field_list),
+ ('Section', str),
+ ('Priority', str),
+ ('Maintainer', str),
+ ('Uploaders', str),
+ ('Standards-Version', str),
+ ('Build-Depends', package_relation_list),
+ ('Build-Depends-Indep', package_relation_list),
+ ('Provides', package_relation_list),
+ ('Depends', package_relation_list),
+ ('Recommends', package_relation_list),
+ ('Suggests', package_relation_list),
+ ('Replaces', package_relation_list),
+ ('Conflicts', package_relation_list),
+ ('Description', utils.field_string),
+ ))
+
+ def __setitem__(self, key, value):
+ try:
+ value = self._fields[key](value)
+ except KeyError: pass
+ super(package, self).__setitem__(key, value)
+
+ def iterkeys(self):
+ for i in self._fields.iterkeys():
+ if self.has_key(i) and self[i]:
+ yield i
+
+ def iteritems(self):
+ for i in self._fields.iterkeys():
+ if self.has_key(i) and self[i]:
+ yield (i, self[i])
+
+ def itervalues(self):
+ for i in self._fields.iterkeys():
+ if self.has_key(i) and self[i]:
+ yield self[i]
+
diff --git a/debian/lib/python/debian_linux/gencontrol.py b/debian/lib/python/debian_linux/gencontrol.py
index 9de65c08556c..e7e1c71a6b1d 100644
--- a/debian/lib/python/debian_linux/gencontrol.py
+++ b/debian/lib/python/debian_linux/gencontrol.py
@@ -1,3 +1,4 @@
+import warnings
from config import *
from debian import *
from utils import *
@@ -11,9 +12,9 @@ class packages_list(sorted_dict):
self[package['Package']] = package
class gencontrol(object):
- def __init__(self):
+ def __init__(self, underlay = None):
self.changelog = read_changelog()
- self.config = config_reader()
+ self.config = config_reader(underlay)
self.templates = templates()
self.version, self.abiname, self.kpkg_abiname, self.changelog_vars = self.process_changelog({})
@@ -113,7 +114,8 @@ class gencontrol(object):
makefile.append("%s-%s:: %s-%s-real" % (i, arch, i, arch))
def do_arch_packages(self, packages, makefile, arch, vars, makeflags, extra):
- pass
+ for i in (('binary-arch', 'build', 'setup',)):
+ makefile.append("%s-%s-real:" % (i, arch))
def do_arch_packages_post(self, packages, makefile, arch, vars, makeflags, extra):
pass
@@ -143,7 +145,8 @@ class gencontrol(object):
makefile.append("%s-%s-%s:: %s-%s-%s-real" % (i, arch, subarch, i, arch, subarch))
def do_subarch_packages(self, packages, makefile, arch, subarch, vars, makeflags, extra):
- pass
+ for i in (('binary-arch', 'build', 'setup',)):
+ makefile.append("%s-%s-%s-real:" % (i, arch, subarch))
def do_flavour(self, packages, makefile, arch, subarch, flavour, vars, makeflags, extra):
config_entry = self.config['base', arch, subarch, flavour]
@@ -151,17 +154,33 @@ class gencontrol(object):
vars['flavour'] = flavour
if not vars.has_key('class'):
+ warnings.warn('No class entry in config for flavour %s, subarch %s, arch %s' % (flavour, subarch, arch), DeprecationWarning)
vars['class'] = '%s-class' % flavour
if not vars.has_key('longclass'):
vars['longclass'] = vars['class']
+ config_base = self.config.merge('base', arch)
+ config_relations = self.config.merge('relations', arch)
+ compiler = config_base.get('compiler', 'gcc')
+ relations_compiler = package_relation_list(config_relations[compiler])
+ for group in relations_compiler:
+ for item in group:
+ item.arches = [arch]
+ packages['source']['Build-Depends'].extend(relations_compiler)
+
makeflags['FLAVOUR'] = flavour
self.do_flavour_makeflags(makeflags, arch, subarch, flavour)
self.do_flavour_makefile(makefile, arch, subarch, flavour, makeflags)
self.do_flavour_packages(packages, makefile, arch, subarch, flavour, vars, makeflags, extra)
def do_flavour_makeflags(self, makeflags, arch, subarch, flavour):
- pass
+ config_entry = self.config.merge('base', arch, subarch, flavour)
+ for i in (
+ ('compiler', 'COMPILER'),
+ ('kernel-arch', 'KERNEL_ARCH')
+ ):
+ if config_entry.has_key(i[0]):
+ makeflags[i[1]] = config_entry[i[0]]
def do_flavour_makefile(self, makefile, arch, subarch, flavour, makeflags):
for i in ('binary-arch', 'build', 'setup'):
@@ -188,11 +207,17 @@ class gencontrol(object):
def process_relation(self, key, e, in_e, vars):
in_dep = in_e[key]
- dep = type(in_dep)()
- for d in in_dep:
- d = self.substitute(d, vars)
- if d:
- dep.append(d)
+ dep = package_relation_list()
+ for in_groups in in_dep:
+ groups = package_relation_group()
+ for in_item in in_groups:
+ item = package_relation()
+ item.name = self.substitute(in_item.name, vars)
+ if in_item.version is not None:
+ item.version = self.substitute(in_item.version, vars)
+ item.arches = in_item.arches
+ groups.append(item)
+ dep.append(groups)
e[key] = dep
def process_description(self, e, in_e, vars):
@@ -207,15 +232,15 @@ class gencontrol(object):
def process_package(self, in_entry, vars):
e = package()
- for key in in_entry.iterkeys():
- if key in (('Depends', 'Provides', 'Suggests', 'Recommends', 'Conflicts')):
+ for key, value in in_entry.iteritems():
+ if isinstance(value, package_relation_list):
self.process_relation(key, e, in_entry, vars)
elif key == 'Description':
self.process_description(e, in_entry, vars)
elif key[:2] == 'X-':
pass
else:
- e[key] = self.substitute(in_entry[key], vars)
+ e[key] = self.substitute(value, vars)
return e
def process_packages(self, in_entries, vars):
diff --git a/debian/lib/python/debian_linux/utils.py b/debian/lib/python/debian_linux/utils.py
index 22c93b20904d..770fd4829c56 100644
--- a/debian/lib/python/debian_linux/utils.py
+++ b/debian/lib/python/debian_linux/utils.py
@@ -1,4 +1,4 @@
-import re, textwrap
+import debian, re, textwrap
class _sorted_dict(dict):
__slots__ = ('_list')
@@ -77,48 +77,6 @@ class field_string(str):
def __str__(self):
return '\n '.join(self.split('\n'))
-class package(dict):
- _fields = sorted_dict((
- ('Package', str),
- ('Source', str),
- ('Architecture', field_list),
- ('Section', str),
- ('Priority', str),
- ('Maintainer', str),
- ('Uploaders', str),
- ('Standards-Version', str),
- ('Build-Depends', str),
- ('Build-Depends-Indep', str),
- ('Provides', field_list_commata),
- ('Depends', field_list_commata),
- ('Recommends', field_list_commata),
- ('Suggests', field_list_commata),
- ('Replaces', field_list_commata),
- ('Conflicts', field_list_commata),
- ('Description', field_string),
- ))
-
- def __setitem__(self, key, value):
- try:
- value = self._fields[key](value)
- except KeyError: pass
- super(package, self).__setitem__(key, value)
-
- def iterkeys(self):
- for i in self._fields.iterkeys():
- if self.has_key(i) and self[i]:
- yield i
-
- def iteritems(self):
- for i in self._fields.iterkeys():
- if self.has_key(i) and self[i]:
- yield (i, self[i])
-
- def itervalues(self):
- for i in self._fields.iterkeys():
- if self.has_key(i) and self[i]:
- yield self[i]
-
class templates(dict):
def __init__(self, dir = None):
if dir is None:
@@ -143,7 +101,7 @@ class templates(dict):
f = file("%s/%s.in" % (self.dir, filename))
while True:
- e = package()
+ e = debian.package()
while True:
line = f.readline()
if not line: