[kernel] r8982 - in dists/trunk/linux-2.6/debian: bin lib/python/debian_linux

Bastian Blank waldi at alioth.debian.org
Sun Jun 17 10:51:18 UTC 2007


Author: waldi
Date: Sun Jun 17 10:51:18 2007
New Revision: 8982

Log:
debian/bin/gencontrol.py, debian/lib/python/debian_linux: Cleanup.


Modified:
   dists/trunk/linux-2.6/debian/bin/gencontrol.py
   dists/trunk/linux-2.6/debian/lib/python/debian_linux/debian.py
   dists/trunk/linux-2.6/debian/lib/python/debian_linux/gencontrol.py

Modified: dists/trunk/linux-2.6/debian/bin/gencontrol.py
==============================================================================
--- dists/trunk/linux-2.6/debian/bin/gencontrol.py	(original)
+++ dists/trunk/linux-2.6/debian/bin/gencontrol.py	Sun Jun 17 10:51:18 2007
@@ -29,7 +29,7 @@
         headers_arch = self.templates["control.headers.arch"]
         packages_headers_arch = self.process_packages(headers_arch, vars)
         
-        extra['headers_arch_depends'] = packages_headers_arch[-1]['Depends'] = PackageRelationList()
+        extra['headers_arch_depends'] = packages_headers_arch[-1]['Depends'] = PackageRelation()
 
         for package in packages_headers_arch:
             name = package['Package']
@@ -104,16 +104,16 @@
         config_entry_relations = self.config.merge('relations', arch, subarch, flavour)
 
         compiler = config_entry_base.get('compiler', 'gcc')
-        relations_compiler = PackageRelationList(config_entry_relations[compiler])
-        relations_compiler_build_dep = PackageRelationList(config_entry_relations[compiler])
+        relations_compiler = PackageRelation(config_entry_relations[compiler])
+        relations_compiler_build_dep = PackageRelation(config_entry_relations[compiler])
         for group in relations_compiler_build_dep:
             for item in group:
                 item.arches = [arch]
         packages['source']['Build-Depends'].extend(relations_compiler_build_dep)
 
         image_relations = {
-            'conflicts': PackageRelationList(),
-            'depends': PackageRelationList(),
+            'conflicts': PackageRelation(),
+            'depends': PackageRelation(),
         }
         if vars.get('initramfs', True):
             generators = vars['initramfs-generators']
@@ -124,7 +124,7 @@
             for i in generators:
                 i = config_entry_relations.get(i, i)
                 l_depends.append(i)
-                a = PackageRelation(i)
+                a = PackageRelationEntry(i)
                 if a.operator is not None:
                     a.operator = -a.operator
                     image_relations['conflicts'].append(PackageRelationGroup([a]))
@@ -247,7 +247,7 @@
     def process_real_image(self, in_entry, relations, config, vars):
         entry = self.process_package(in_entry, vars)
         for field in 'Depends', 'Provides', 'Suggests', 'Recommends', 'Conflicts':
-            value = entry.get(field, PackageRelationList())
+            value = entry.get(field, PackageRelation())
             t = vars.get(field.lower(), [])
             value.extend(t)
             t = relations.get(field.lower(), [])
@@ -261,7 +261,7 @@
         entry = self.process_package(in_entry, vars)
         versions = [i.version for i in self.changelog[::-1]]
         for i in (('Depends', 'Provides')):
-            value = PackageRelationList()
+            value = PackageRelation()
             value.extend(entry.get(i, []))
             if i == 'Depends':
                 value.append("linux-patch-debian-%(linux_version)s (= %(complete)s)" % self.changelog[0].version.__dict__)

Modified: dists/trunk/linux-2.6/debian/lib/python/debian_linux/debian.py
==============================================================================
--- dists/trunk/linux-2.6/debian/lib/python/debian_linux/debian.py	(original)
+++ dists/trunk/linux-2.6/debian/lib/python/debian_linux/debian.py	Sun Jun 17 10:51:18 2007
@@ -162,90 +162,7 @@
         if str:
             self.long.extend(str.split("\n.\n"))
 
-class PackageRelation(object):
-    __slots__ = "name", "operator", "version", "arches"
-
-    _re = re.compile(r'^(\S+)(?: \((<<|<=|=|!=|>=|>>)\s*([^)]+)\))?(?: \[([^]]+)\])?$')
-
-    class _operator(object):
-        OP_LT = 1
-        OP_LE = 2
-        OP_EQ = 3
-        OP_NE = 4
-        OP_GE = 5
-        OP_GT = 6
-
-        operators = {
-            '<<': OP_LT,
-            '<=': OP_LE,
-            '=':  OP_EQ,
-            '!=': OP_NE,
-            '>=': OP_GE,
-            '>>': OP_GT,
-        }
-        operators_neg = {
-            OP_LT: OP_GE,
-            OP_LE: OP_GT,
-            OP_EQ: OP_NE,
-            OP_NE: OP_EQ,
-            OP_GE: OP_LT,
-            OP_GT: OP_LE,
-        }
-        operators_text = dict([(b, a) for a, b in operators.iteritems()])
-
-        __slots__ = '_op',
-
-        def __init__(self, value):
-            self._op = self.operators[value]
-
-        def __neg__(self):
-            return self.__class__(self.operators_text[self.operators_neg[self._op]])
-
-        def __str__(self):
-            return self.operators_text[self._op]
-
-    def __init__(self, value = None):
-        if value is not None:
-            self.parse(value)
-        else:
-            self.name = None
-            self.operator = None
-            self.version = None
-            self.arches = []
-
-    def __str__(self):
-        ret = [self.name]
-        if self.operator is not None and self.version is not None:
-            ret.extend([' (', str(self.operator), ' ', self.version, ')'])
-        if self.arches:
-            ret.extend([' [', ' '.join(self.arches), ']'])
-        return ''.join(ret)
-
-    def config(self, entry):
-        if self.version is not None or self.arches:
-            return
-        value = entry.get(self.name, None)
-        if value is None:
-            return
-        self.parse(value)
-
-    def parse(self, value):
-        match = self._re.match(value)
-        if match is None:
-            raise RuntimeError, "Can't parse dependency %s" % value
-        match = match.groups()
-        self.name = match[0]
-        if match[1] is not None:
-            self.operator = self._operator(match[1])
-        else:
-            self.operator = None
-        self.version = match[2]
-        if match[3] is not None:
-            self.arches = re.split('\s+', match[3])
-        else:
-            self.arches = []
-
-class PackageRelationList(list):
+class PackageRelation(list):
     def __init__(self, value = None):
         if value is not None:
             self.extend(value)
@@ -268,7 +185,7 @@
         if j:
             j._updateArches(value)
         else:
-            super(PackageRelationList, self).append(value)
+            super(PackageRelation, self).append(value)
 
     def config(self, entry):
         for i in self:
@@ -305,8 +222,8 @@
 
     def append(self, value):
         if isinstance(value, basestring):
-            value = PackageRelation(value)
-        elif not isinstance(value, PackageRelation):
+            value = PackageRelationEntry(value)
+        elif not isinstance(value, PackageRelationEntry):
             raise ValueError
         super(PackageRelationGroup, self).append(value)
 
@@ -322,6 +239,68 @@
         for i in value:
             self.append(i)
 
+class PackageRelationEntry(object):
+    __slots__ = "name", "operator", "version", "arches"
+
+    _re = re.compile(r'^(\S+)(?: \((<<|<=|=|!=|>=|>>)\s*([^)]+)\))?(?: \[([^]]+)\])?$')
+
+    class _operator(object):
+        OP_LT = 1; OP_LE = 2; OP_EQ = 3; OP_NE = 4; OP_GE = 5; OP_GT = 6
+        operators = { '<<': OP_LT, '<=': OP_LE, '=':  OP_EQ, '!=': OP_NE, '>=': OP_GE, '>>': OP_GT }
+        operators_neg = { OP_LT: OP_GE, OP_LE: OP_GT, OP_EQ: OP_NE, OP_NE: OP_EQ, OP_GE: OP_LT, OP_GT: OP_LE }
+        operators_text = dict([(b, a) for a, b in operators.iteritems()])
+
+        __slots__ = '_op',
+
+        def __init__(self, value):
+            self._op = self.operators[value]
+
+        def __neg__(self):
+            return self.__class__(self.operators_text[self.operators_neg[self._op]])
+
+        def __str__(self):
+            return self.operators_text[self._op]
+
+    def __init__(self, value = None):
+        if isinstance(value, basestring):
+            self.parse(value)
+        else:
+            raise ValueError
+
+    def __str__(self):
+        ret = [self.name]
+        if self.operator is not None and self.version is not None:
+            ret.extend([' (', str(self.operator), ' ', self.version, ')'])
+        if self.arches:
+            ret.extend([' [', ' '.join(self.arches), ']'])
+        return ''.join(ret)
+
+    def config(self, entry):
+        if self.version is not None or self.arches:
+            return
+        value = entry.get(self.name, None)
+        if value is None:
+            return
+        print "config:", this
+        self.parse(value)
+        print "config:", this
+
+    def parse(self, value):
+        match = self._re.match(value)
+        if match is None:
+            raise RuntimeError, "Can't parse dependency %s" % value
+        match = match.groups()
+        self.name = match[0]
+        if match[1] is not None:
+            self.operator = self._operator(match[1])
+        else:
+            self.operator = None
+        self.version = match[2]
+        if match[3] is not None:
+            self.arches = re.split('\s+', match[3])
+        else:
+            self.arches = []
+
 class Package(dict):
     _fields = utils.SortedDict((
         ('Package', str),
@@ -332,15 +311,15 @@
         ('Maintainer', str),
         ('Uploaders', str),
         ('Standards-Version', str),
-        ('Build-Depends', PackageRelationList),
-        ('Build-Depends-Indep', PackageRelationList),
-        ('Provides', PackageRelationList),
-        ('Pre-Depends', PackageRelationList),
-        ('Depends', PackageRelationList),
-        ('Recommends', PackageRelationList),
-        ('Suggests', PackageRelationList),
-        ('Replaces', PackageRelationList),
-        ('Conflicts', PackageRelationList),
+        ('Build-Depends', PackageRelation),
+        ('Build-Depends-Indep', PackageRelation),
+        ('Provides', PackageRelation),
+        ('Pre-Depends', PackageRelation),
+        ('Depends', PackageRelation),
+        ('Recommends', PackageRelation),
+        ('Suggests', PackageRelation),
+        ('Replaces', PackageRelation),
+        ('Conflicts', PackageRelation),
         ('Description', PackageDescription),
     ))
 

Modified: dists/trunk/linux-2.6/debian/lib/python/debian_linux/gencontrol.py
==============================================================================
--- dists/trunk/linux-2.6/debian/lib/python/debian_linux/gencontrol.py	(original)
+++ dists/trunk/linux-2.6/debian/lib/python/debian_linux/gencontrol.py	Sun Jun 17 10:51:18 2007
@@ -195,19 +195,11 @@
         pass
 
     def process_relation(self, key, e, in_e, vars):
-        in_dep = in_e[key]
-        dep = PackageRelationList()
-        for in_groups in in_dep:
-            groups = PackageRelationGroup()
-            for in_item in in_groups:
-                item = PackageRelation()
-                item.name = self.substitute(in_item.name, vars)
-                item.operator = in_item.operator
-                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)
+        import copy
+        dep = copy.deepcopy(in_e[key])
+        for groups in dep:
+            for item in groups:
+                item.name = self.substitute(item.name, vars)
         e[key] = dep
 
     def process_description(self, e, in_e, vars):
@@ -221,7 +213,7 @@
     def process_package(self, in_entry, vars):
         e = Package()
         for key, value in in_entry.iteritems():
-            if isinstance(value, PackageRelationList):
+            if isinstance(value, PackageRelation):
                 self.process_relation(key, e, in_entry, vars)
             elif key == 'Description':
                 self.process_description(e, in_entry, vars)



More information about the Kernel-svn-changes mailing list