diff options
author | Bastian Blank <waldi@debian.org> | 2006-01-06 22:32:16 +0000 |
---|---|---|
committer | Bastian Blank <waldi@debian.org> | 2006-01-06 22:32:16 +0000 |
commit | b37871ac10473cf32f6cbe83e15eb18bd9f21a8a (patch) | |
tree | fd28b873a3ee486604b8425523323f40e8de22d0 /debian/lib/python | |
parent | 5008990d6c0aca56bc6cdc430842cbc75d75a569 (diff) | |
download | kernel_replicant_linux-b37871ac10473cf32f6cbe83e15eb18bd9f21a8a.tar.gz kernel_replicant_linux-b37871ac10473cf32f6cbe83e15eb18bd9f21a8a.tar.bz2 kernel_replicant_linux-b37871ac10473cf32f6cbe83e15eb18bd9f21a8a.zip |
* 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
Diffstat (limited to 'debian/lib/python')
-rw-r--r-- | debian/lib/python/debian_linux/config.py | 19 | ||||
-rw-r--r-- | debian/lib/python/debian_linux/debian.py | 128 | ||||
-rw-r--r-- | debian/lib/python/debian_linux/gencontrol.py | 51 | ||||
-rw-r--r-- | debian/lib/python/debian_linux/utils.py | 46 |
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: |