debian/lib/python: PEP8 and other style fixes.
svn path=/dists/trunk/linux-2.6/; revision=18488
This commit is contained in:
parent
42fbf6c05d
commit
9863acaddd
|
@ -10,9 +10,12 @@ class Symbol(object):
|
||||||
# Symbols are resolved to modules by depmod at installation/
|
# Symbols are resolved to modules by depmod at installation/
|
||||||
# upgrade time, not compile time, so moving a symbol between
|
# upgrade time, not compile time, so moving a symbol between
|
||||||
# modules is not an ABI change. Compare everything else.
|
# modules is not an ABI change. Compare everything else.
|
||||||
if self.name != other.name: return False
|
if self.name != other.name:
|
||||||
if self.version != other.version: return False
|
return False
|
||||||
if self.export != other.export: return False
|
if self.version != other.version:
|
||||||
|
return False
|
||||||
|
if self.export != other.export:
|
||||||
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -22,6 +25,7 @@ class Symbol(object):
|
||||||
return ret
|
return ret
|
||||||
return not ret
|
return not ret
|
||||||
|
|
||||||
|
|
||||||
class Symbols(dict):
|
class Symbols(dict):
|
||||||
def __init__(self, file=None):
|
def __init__(self, file=None):
|
||||||
if file:
|
if file:
|
||||||
|
@ -36,4 +40,5 @@ class Symbols(dict):
|
||||||
symbols = self.values()
|
symbols = self.values()
|
||||||
symbols.sort(key=lambda i: i.name)
|
symbols.sort(key=lambda i: i.name)
|
||||||
for s in symbols:
|
for s in symbols:
|
||||||
file.write("%s %s %s %s\n" % (s.version, s.name, s.module, s.export))
|
file.write("%s %s %s %s\n" %
|
||||||
|
(s.version, s.name, s.module, s.export))
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
import os, os.path, re, sys, textwrap
|
import os
|
||||||
|
import os.path
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import textwrap
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'ConfigCoreDump',
|
'ConfigCoreDump',
|
||||||
|
@ -6,6 +10,7 @@ __all__ = [
|
||||||
'ConfigParser',
|
'ConfigParser',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class SchemaItemBoolean(object):
|
class SchemaItemBoolean(object):
|
||||||
def __call__(self, i):
|
def __call__(self, i):
|
||||||
i = i.strip().lower()
|
i = i.strip().lower()
|
||||||
|
@ -15,8 +20,9 @@ class SchemaItemBoolean(object):
|
||||||
return False
|
return False
|
||||||
raise Error
|
raise Error
|
||||||
|
|
||||||
|
|
||||||
class SchemaItemList(object):
|
class SchemaItemList(object):
|
||||||
def __init__(self, type = "\s+"):
|
def __init__(self, type="\s+"):
|
||||||
self.type = type
|
self.type = type
|
||||||
|
|
||||||
def __call__(self, i):
|
def __call__(self, i):
|
||||||
|
@ -25,6 +31,7 @@ class SchemaItemList(object):
|
||||||
return []
|
return []
|
||||||
return [j.strip() for j in re.split(self.type, i)]
|
return [j.strip() for j in re.split(self.type, i)]
|
||||||
|
|
||||||
|
|
||||||
class ConfigCore(dict):
|
class ConfigCore(dict):
|
||||||
def get_merge(self, section, arch, featureset, flavour, key, default=None):
|
def get_merge(self, section, arch, featureset, flavour, key, default=None):
|
||||||
temp = []
|
temp = []
|
||||||
|
@ -55,7 +62,7 @@ class ConfigCore(dict):
|
||||||
|
|
||||||
return ret or default
|
return ret or default
|
||||||
|
|
||||||
def merge(self, section, arch = None, featureset = None, flavour = None):
|
def merge(self, section, arch=None, featureset=None, flavour=None):
|
||||||
ret = {}
|
ret = {}
|
||||||
ret.update(self.get((section,), {}))
|
ret.update(self.get((section,), {}))
|
||||||
if featureset:
|
if featureset:
|
||||||
|
@ -81,8 +88,9 @@ class ConfigCore(dict):
|
||||||
fp.write('%s: %r\n' % (item, items[item]))
|
fp.write('%s: %r\n' % (item, items[item]))
|
||||||
fp.write('\n')
|
fp.write('\n')
|
||||||
|
|
||||||
|
|
||||||
class ConfigCoreDump(ConfigCore):
|
class ConfigCoreDump(ConfigCore):
|
||||||
def __init__(self, config = None, fp = None):
|
def __init__(self, config=None, fp=None):
|
||||||
super(ConfigCoreDump, self).__init__(self)
|
super(ConfigCoreDump, self).__init__(self)
|
||||||
if config is not None:
|
if config is not None:
|
||||||
self.update(config)
|
self.update(config)
|
||||||
|
@ -98,6 +106,7 @@ class ConfigCoreDump(ConfigCore):
|
||||||
data[key] = value_real
|
data[key] = value_real
|
||||||
self[section_real] = data
|
self[section_real] = data
|
||||||
|
|
||||||
|
|
||||||
class ConfigCoreHierarchy(ConfigCore):
|
class ConfigCoreHierarchy(ConfigCore):
|
||||||
config_name = "defines"
|
config_name = "defines"
|
||||||
|
|
||||||
|
@ -134,7 +143,7 @@ class ConfigCoreHierarchy(ConfigCore):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, dirs = []):
|
def __init__(self, dirs=[]):
|
||||||
super(ConfigCoreHierarchy, self).__init__()
|
super(ConfigCoreHierarchy, self).__init__()
|
||||||
self._dirs = dirs
|
self._dirs = dirs
|
||||||
self._read_base()
|
self._read_base()
|
||||||
|
@ -143,8 +152,8 @@ class ConfigCoreHierarchy(ConfigCore):
|
||||||
config = ConfigParser(self.schemas)
|
config = ConfigParser(self.schemas)
|
||||||
config.read(self.get_files("%s/%s" % (arch, self.config_name)))
|
config.read(self.get_files("%s/%s" % (arch, self.config_name)))
|
||||||
|
|
||||||
featuresets = config['base',].get('featuresets', [])
|
featuresets = config['base', ].get('featuresets', [])
|
||||||
flavours = config['base',].get('flavours', [])
|
flavours = config['base', ].get('flavours', [])
|
||||||
|
|
||||||
for section in iter(config):
|
for section in iter(config):
|
||||||
if section[0] in featuresets:
|
if section[0] in featuresets:
|
||||||
|
@ -172,7 +181,7 @@ class ConfigCoreHierarchy(ConfigCore):
|
||||||
config = ConfigParser(self.schemas)
|
config = ConfigParser(self.schemas)
|
||||||
config.read(self.get_files("%s/%s/%s" % (arch, featureset, self.config_name)))
|
config.read(self.get_files("%s/%s/%s" % (arch, featureset, self.config_name)))
|
||||||
|
|
||||||
flavours = config['base',].get('flavours', [])
|
flavours = config['base', ].get('flavours', [])
|
||||||
|
|
||||||
for section in iter(config):
|
for section in iter(config):
|
||||||
real = (section[-1], arch, featureset) + section[:-1]
|
real = (section[-1], arch, featureset) + section[:-1]
|
||||||
|
@ -184,8 +193,8 @@ class ConfigCoreHierarchy(ConfigCore):
|
||||||
config = ConfigParser(self.schemas)
|
config = ConfigParser(self.schemas)
|
||||||
config.read(self.get_files(self.config_name))
|
config.read(self.get_files(self.config_name))
|
||||||
|
|
||||||
arches = config['base',]['arches']
|
arches = config['base', ]['arches']
|
||||||
featuresets = config['base',].get('featuresets', [])
|
featuresets = config['base', ].get('featuresets', [])
|
||||||
|
|
||||||
for section in iter(config):
|
for section in iter(config):
|
||||||
if section[0].startswith('featureset-'):
|
if section[0].startswith('featureset-'):
|
||||||
|
@ -212,6 +221,7 @@ class ConfigCoreHierarchy(ConfigCore):
|
||||||
def get_files(self, name):
|
def get_files(self, name):
|
||||||
return [os.path.join(i, name) for i in self._dirs if i]
|
return [os.path.join(i, name) for i in self._dirs if i]
|
||||||
|
|
||||||
|
|
||||||
class ConfigParser(object):
|
class ConfigParser(object):
|
||||||
__slots__ = '_config', 'schemas'
|
__slots__ = '_config', 'schemas'
|
||||||
|
|
||||||
|
@ -260,7 +270,8 @@ class ConfigParser(object):
|
||||||
for key in data.keys():
|
for key in data.keys():
|
||||||
try:
|
try:
|
||||||
data[key] = schema[key](data[key])
|
data[key] = schema[key](data[key])
|
||||||
except KeyError: pass
|
except KeyError:
|
||||||
|
pass
|
||||||
super(ConfigParser.SectionSchema, self).__init__(data)
|
super(ConfigParser.SectionSchema, self).__init__(data)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -276,4 +287,3 @@ if __name__ == '__main__':
|
||||||
for item in items:
|
for item in items:
|
||||||
print "%s: %s" % (item, items[item])
|
print "%s: %s" % (item, items[item])
|
||||||
print
|
print
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
import itertools, os.path, re, utils
|
import itertools
|
||||||
|
import os.path
|
||||||
|
import re
|
||||||
|
import utils
|
||||||
|
|
||||||
|
|
||||||
class Changelog(list):
|
class Changelog(list):
|
||||||
_rules = r"""
|
_rules = r"""
|
||||||
|
@ -26,7 +30,7 @@ class Changelog(list):
|
||||||
def __init__(self, distribution, source, version):
|
def __init__(self, distribution, source, version):
|
||||||
self.distribution, self.source, self.version = distribution, source, version
|
self.distribution, self.source, self.version = distribution, source, version
|
||||||
|
|
||||||
def __init__(self, dir = '', version = None):
|
def __init__(self, dir='', version=None):
|
||||||
if version is None:
|
if version is None:
|
||||||
version = Version
|
version = Version
|
||||||
f = file(os.path.join(dir, "debian/changelog"))
|
f = file(os.path.join(dir, "debian/changelog"))
|
||||||
|
@ -45,6 +49,7 @@ class Changelog(list):
|
||||||
v = Version(match.group('version'))
|
v = Version(match.group('version'))
|
||||||
self.append(self.Entry(match.group('distribution'), match.group('source'), v))
|
self.append(self.Entry(match.group('distribution'), match.group('source'), v))
|
||||||
|
|
||||||
|
|
||||||
class Version(object):
|
class Version(object):
|
||||||
_version_rules = ur"""
|
_version_rules = ur"""
|
||||||
^
|
^
|
||||||
|
@ -68,7 +73,7 @@ $
|
||||||
def __init__(self, version):
|
def __init__(self, version):
|
||||||
match = self._version_re.match(version)
|
match = self._version_re.match(version)
|
||||||
if match is None:
|
if match is None:
|
||||||
raise RuntimeError, "Invalid debian version"
|
raise RuntimeError("Invalid debian version")
|
||||||
self.epoch = None
|
self.epoch = None
|
||||||
if match.group("epoch") is not None:
|
if match.group("epoch") is not None:
|
||||||
self.epoch = int(match.group("epoch"))
|
self.epoch = int(match.group("epoch"))
|
||||||
|
@ -93,9 +98,10 @@ $
|
||||||
@property
|
@property
|
||||||
def debian(self):
|
def debian(self):
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
warn("debian argument was replaced by revision", DeprecationWarning, stacklevel = 2)
|
warn("debian argument was replaced by revision", DeprecationWarning, stacklevel=2)
|
||||||
return self.revision
|
return self.revision
|
||||||
|
|
||||||
|
|
||||||
class VersionLinux(Version):
|
class VersionLinux(Version):
|
||||||
_version_linux_rules = ur"""
|
_version_linux_rules = ur"""
|
||||||
^
|
^
|
||||||
|
@ -137,7 +143,7 @@ $
|
||||||
super(VersionLinux, self).__init__(version)
|
super(VersionLinux, self).__init__(version)
|
||||||
match = self._version_linux_re.match(version)
|
match = self._version_linux_re.match(version)
|
||||||
if match is None:
|
if match is None:
|
||||||
raise RuntimeError, "Invalid debian linux version"
|
raise RuntimeError("Invalid debian linux version")
|
||||||
d = match.groupdict()
|
d = match.groupdict()
|
||||||
self.linux_modifier = d['modifier']
|
self.linux_modifier = d['modifier']
|
||||||
self.linux_version = d['version']
|
self.linux_version = d['version']
|
||||||
|
@ -148,9 +154,10 @@ $
|
||||||
self.linux_dfsg = d['dfsg']
|
self.linux_dfsg = d['dfsg']
|
||||||
self.linux_revision_experimental = match.group('revision_experimental') and True
|
self.linux_revision_experimental = match.group('revision_experimental') and True
|
||||||
self.linux_revision_other = match.group('revision_other') and True
|
self.linux_revision_other = match.group('revision_other') and True
|
||||||
|
|
||||||
|
|
||||||
class PackageFieldList(list):
|
class PackageFieldList(list):
|
||||||
def __init__(self, value = None):
|
def __init__(self, value=None):
|
||||||
self.extend(value)
|
self.extend(value)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -166,10 +173,11 @@ class PackageFieldList(list):
|
||||||
else:
|
else:
|
||||||
super(PackageFieldList, self).extend(value)
|
super(PackageFieldList, self).extend(value)
|
||||||
|
|
||||||
|
|
||||||
class PackageDescription(object):
|
class PackageDescription(object):
|
||||||
__slots__ = "short", "long"
|
__slots__ = "short", "long"
|
||||||
|
|
||||||
def __init__(self, value = None):
|
def __init__(self, value=None):
|
||||||
self.short = []
|
self.short = []
|
||||||
self.long = []
|
self.long = []
|
||||||
if value is not None:
|
if value is not None:
|
||||||
|
@ -178,7 +186,7 @@ class PackageDescription(object):
|
||||||
self.append_short(short)
|
self.append_short(short)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
wrap = utils.TextWrapper(width = 74, fix_sentence_endings = True).wrap
|
wrap = utils.TextWrapper(width=74, fix_sentence_endings=True).wrap
|
||||||
short = ', '.join(self.short)
|
short = ', '.join(self.short)
|
||||||
long_pars = []
|
long_pars = []
|
||||||
for i in self.long:
|
for i in self.long:
|
||||||
|
@ -203,6 +211,7 @@ class PackageDescription(object):
|
||||||
else:
|
else:
|
||||||
raise TypeError
|
raise TypeError
|
||||||
|
|
||||||
|
|
||||||
class PackageRelation(list):
|
class PackageRelation(list):
|
||||||
def __init__(self, value=None, override_arches=None):
|
def __init__(self, value=None, override_arches=None):
|
||||||
if value:
|
if value:
|
||||||
|
@ -221,7 +230,7 @@ class PackageRelation(list):
|
||||||
if isinstance(value, basestring):
|
if isinstance(value, basestring):
|
||||||
value = PackageRelationGroup(value, override_arches)
|
value = PackageRelationGroup(value, override_arches)
|
||||||
elif not isinstance(value, PackageRelationGroup):
|
elif not isinstance(value, PackageRelationGroup):
|
||||||
raise ValueError, "got %s" % type(value)
|
raise ValueError("got %s" % type(value))
|
||||||
j = self._search_value(value)
|
j = self._search_value(value)
|
||||||
if j:
|
if j:
|
||||||
j._update_arches(value)
|
j._update_arches(value)
|
||||||
|
@ -232,10 +241,11 @@ class PackageRelation(list):
|
||||||
if isinstance(value, basestring):
|
if isinstance(value, basestring):
|
||||||
value = [j.strip() for j in re.split(',', value.strip())]
|
value = [j.strip() for j in re.split(',', value.strip())]
|
||||||
elif not isinstance(value, (list, tuple)):
|
elif not isinstance(value, (list, tuple)):
|
||||||
raise ValueError, "got %s" % type(value)
|
raise ValueError("got %s" % type(value))
|
||||||
for i in value:
|
for i in value:
|
||||||
self.append(i, override_arches)
|
self.append(i, override_arches)
|
||||||
|
|
||||||
|
|
||||||
class PackageRelationGroup(list):
|
class PackageRelationGroup(list):
|
||||||
def __init__(self, value=None, override_arches=None):
|
def __init__(self, value=None, override_arches=None):
|
||||||
if value:
|
if value:
|
||||||
|
@ -272,15 +282,38 @@ class PackageRelationGroup(list):
|
||||||
for i in value:
|
for i in value:
|
||||||
self.append(i, override_arches)
|
self.append(i, override_arches)
|
||||||
|
|
||||||
|
|
||||||
class PackageRelationEntry(object):
|
class PackageRelationEntry(object):
|
||||||
__slots__ = "name", "operator", "version", "arches"
|
__slots__ = "name", "operator", "version", "arches"
|
||||||
|
|
||||||
_re = re.compile(r'^(\S+)(?: \((<<|<=|=|!=|>=|>>)\s*([^)]+)\))?(?: \[([^]]+)\])?$')
|
_re = re.compile(r'^(\S+)(?: \((<<|<=|=|!=|>=|>>)\s*([^)]+)\))?(?: \[([^]]+)\])?$')
|
||||||
|
|
||||||
class _operator(object):
|
class _operator(object):
|
||||||
OP_LT = 1; OP_LE = 2; OP_EQ = 3; OP_NE = 4; OP_GE = 5; OP_GT = 6
|
OP_LT = 1
|
||||||
operators = { '<<': OP_LT, '<=': OP_LE, '=': OP_EQ, '!=': OP_NE, '>=': OP_GE, '>>': OP_GT }
|
OP_LE = 2
|
||||||
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 }
|
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()])
|
operators_text = dict([(b, a) for a, b in operators.iteritems()])
|
||||||
|
|
||||||
__slots__ = '_op',
|
__slots__ = '_op',
|
||||||
|
@ -314,7 +347,7 @@ class PackageRelationEntry(object):
|
||||||
def parse(self, value):
|
def parse(self, value):
|
||||||
match = self._re.match(value)
|
match = self._re.match(value)
|
||||||
if match is None:
|
if match is None:
|
||||||
raise RuntimeError, "Can't parse dependency %s" % value
|
raise RuntimeError("Can't parse dependency %s" % value)
|
||||||
match = match.groups()
|
match = match.groups()
|
||||||
self.name = match[0]
|
self.name = match[0]
|
||||||
if match[1] is not None:
|
if match[1] is not None:
|
||||||
|
@ -327,6 +360,7 @@ class PackageRelationEntry(object):
|
||||||
else:
|
else:
|
||||||
self.arches = []
|
self.arches = []
|
||||||
|
|
||||||
|
|
||||||
class Package(dict):
|
class Package(dict):
|
||||||
_fields = utils.SortedDict((
|
_fields = utils.SortedDict((
|
||||||
('Package', str),
|
('Package', str),
|
||||||
|
@ -355,13 +389,14 @@ class Package(dict):
|
||||||
cls = self._fields[key]
|
cls = self._fields[key]
|
||||||
if not isinstance(value, cls):
|
if not isinstance(value, cls):
|
||||||
value = cls(value)
|
value = cls(value)
|
||||||
except KeyError: pass
|
except KeyError:
|
||||||
|
pass
|
||||||
super(Package, self).__setitem__(key, value)
|
super(Package, self).__setitem__(key, value)
|
||||||
|
|
||||||
def iterkeys(self):
|
def iterkeys(self):
|
||||||
keys = set(self.keys())
|
keys = set(self.keys())
|
||||||
for i in self._fields.iterkeys():
|
for i in self._fields.iterkeys():
|
||||||
if self.has_key(i):
|
if i in self:
|
||||||
keys.remove(i)
|
keys.remove(i)
|
||||||
yield i
|
yield i
|
||||||
for i in keys:
|
for i in keys:
|
||||||
|
@ -374,4 +409,3 @@ class Package(dict):
|
||||||
def itervalues(self):
|
def itervalues(self):
|
||||||
for i in self.iterkeys():
|
for i in self.iterkeys():
|
||||||
yield self[i]
|
yield self[i]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
class FirmwareFile(object):
|
class FirmwareFile(object):
|
||||||
def __init__(self, binary, desc=None, source=None, version=None):
|
def __init__(self, binary, desc=None, source=None, version=None):
|
||||||
self.binary = binary
|
self.binary = binary
|
||||||
|
@ -7,12 +8,14 @@ class FirmwareFile(object):
|
||||||
self.source = source
|
self.source = source
|
||||||
self.version = version
|
self.version = version
|
||||||
|
|
||||||
|
|
||||||
class FirmwareSection(object):
|
class FirmwareSection(object):
|
||||||
def __init__(self, driver, files, licence):
|
def __init__(self, driver, files, licence):
|
||||||
self.driver = driver
|
self.driver = driver
|
||||||
self.files = files
|
self.files = files
|
||||||
self.licence = licence
|
self.licence = licence
|
||||||
|
|
||||||
|
|
||||||
class FirmwareWhence(list):
|
class FirmwareWhence(list):
|
||||||
def __init__(self, file):
|
def __init__(self, file):
|
||||||
self.read(file)
|
self.read(file)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from debian import *
|
from debian import *
|
||||||
from utils import SortedDict
|
from utils import SortedDict
|
||||||
|
|
||||||
|
|
||||||
class PackagesList(SortedDict):
|
class PackagesList(SortedDict):
|
||||||
def append(self, package):
|
def append(self, package):
|
||||||
self[package['Package']] = package
|
self[package['Package']] = package
|
||||||
|
@ -9,12 +10,13 @@ class PackagesList(SortedDict):
|
||||||
for package in packages:
|
for package in packages:
|
||||||
self[package['Package']] = package
|
self[package['Package']] = package
|
||||||
|
|
||||||
|
|
||||||
class Makefile(object):
|
class Makefile(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.rules = {}
|
self.rules = {}
|
||||||
self.add('.NOTPARALLEL')
|
self.add('.NOTPARALLEL')
|
||||||
|
|
||||||
def add(self, name, deps = None, cmds = None):
|
def add(self, name, deps=None, cmds=None):
|
||||||
if name in self.rules:
|
if name in self.rules:
|
||||||
self.rules[name].add(deps, cmds)
|
self.rules[name].add(deps, cmds)
|
||||||
else:
|
else:
|
||||||
|
@ -31,12 +33,12 @@ class Makefile(object):
|
||||||
self.rules[i].write(out)
|
self.rules[i].write(out)
|
||||||
|
|
||||||
class Rule(object):
|
class Rule(object):
|
||||||
def __init__(self, name, deps = None, cmds = None):
|
def __init__(self, name, deps=None, cmds=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.deps, self.cmds = set(), []
|
self.deps, self.cmds = set(), []
|
||||||
self.add(deps, cmds)
|
self.add(deps, cmds)
|
||||||
|
|
||||||
def add(self, deps = None, cmds = None):
|
def add(self, deps=None, cmds=None):
|
||||||
if deps is not None:
|
if deps is not None:
|
||||||
self.deps.update(deps)
|
self.deps.update(deps)
|
||||||
if cmds is not None:
|
if cmds is not None:
|
||||||
|
@ -59,6 +61,7 @@ class Makefile(object):
|
||||||
else:
|
else:
|
||||||
out.write('%s:%s\n' % (self.name, deps_string))
|
out.write('%s:%s\n' % (self.name, deps_string))
|
||||||
|
|
||||||
|
|
||||||
class MakeFlags(dict):
|
class MakeFlags(dict):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
repr = super(flags, self).__repr__()
|
repr = super(flags, self).__repr__()
|
||||||
|
@ -70,12 +73,13 @@ class MakeFlags(dict):
|
||||||
def copy(self):
|
def copy(self):
|
||||||
return self.__class__(super(MakeFlags, self).copy())
|
return self.__class__(super(MakeFlags, self).copy())
|
||||||
|
|
||||||
|
|
||||||
class Gencontrol(object):
|
class Gencontrol(object):
|
||||||
makefile_targets = ('binary-arch', 'build', 'setup', 'source')
|
makefile_targets = ('binary-arch', 'build', 'setup', 'source')
|
||||||
|
|
||||||
def __init__(self, config, templates, version = Version):
|
def __init__(self, config, templates, version=Version):
|
||||||
self.config, self.templates = config, templates
|
self.config, self.templates = config, templates
|
||||||
self.changelog = Changelog(version = version)
|
self.changelog = Changelog(version=version)
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
packages = PackagesList()
|
packages = PackagesList()
|
||||||
|
@ -93,7 +97,7 @@ class Gencontrol(object):
|
||||||
packages['source'] = self.process_package(source)
|
packages['source'] = self.process_package(source)
|
||||||
|
|
||||||
def do_main(self, packages, makefile):
|
def do_main(self, packages, makefile):
|
||||||
config_entry = self.config['base',]
|
config_entry = self.config['base', ]
|
||||||
vars = self.vars.copy()
|
vars = self.vars.copy()
|
||||||
|
|
||||||
makeflags = MakeFlags()
|
makeflags = MakeFlags()
|
||||||
|
@ -108,13 +112,13 @@ class Gencontrol(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def do_main_makefile(self, makefile, makeflags, extra):
|
def do_main_makefile(self, makefile, makeflags, extra):
|
||||||
makefile.add('binary-indep', cmds = ["$(MAKE) -f debian/rules.real binary-indep %s" % makeflags])
|
makefile.add('binary-indep', cmds=["$(MAKE) -f debian/rules.real binary-indep %s" % makeflags])
|
||||||
|
|
||||||
def do_main_packages(self, packages, vars, makeflags, extra):
|
def do_main_packages(self, packages, vars, makeflags, extra):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def do_main_recurse(self, packages, makefile, vars, makeflags, extra):
|
def do_main_recurse(self, packages, makefile, vars, makeflags, extra):
|
||||||
for arch in iter(self.config['base',]['arches']):
|
for arch in iter(self.config['base', ]['arches']):
|
||||||
self.do_arch(packages, makefile, arch, vars.copy(), makeflags.copy(), extra)
|
self.do_arch(packages, makefile, arch, vars.copy(), makeflags.copy(), extra)
|
||||||
|
|
||||||
def do_extra(self, packages, makefile):
|
def do_extra(self, packages, makefile):
|
||||||
|
@ -136,11 +140,11 @@ class Gencontrol(object):
|
||||||
cmds = []
|
cmds = []
|
||||||
for i in extra_arches[arch]:
|
for i in extra_arches[arch]:
|
||||||
tmp = []
|
tmp = []
|
||||||
if i.has_key('X-Version-Overwrite-Epoch'):
|
if 'X-Version-Overwrite-Epoch' in i:
|
||||||
tmp.append("-v1:%s" % self.version['source'])
|
tmp.append("-v1:%s" % self.version['source'])
|
||||||
cmds.append("$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='-p%s' GENCONTROL_ARGS='%s'" % (i['Package'], ' '.join(tmp)))
|
cmds.append("$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='-p%s' GENCONTROL_ARGS='%s'" % (i['Package'], ' '.join(tmp)))
|
||||||
makefile.add('binary-arch_%s' % arch ['binary-arch_%s_extra' % arch])
|
makefile.add('binary-arch_%s' % arch['binary-arch_%s_extra' % arch])
|
||||||
makefile.add("binary-arch_%s_extra" % arch, cmds = cmds)
|
makefile.add("binary-arch_%s_extra" % arch, cmds=cmds)
|
||||||
|
|
||||||
def do_arch(self, packages, makefile, arch, vars, makeflags, extra):
|
def do_arch(self, packages, makefile, arch, vars, makeflags, extra):
|
||||||
vars['arch'] = arch
|
vars['arch'] = arch
|
||||||
|
@ -218,7 +222,7 @@ class Gencontrol(object):
|
||||||
('kernel-arch', 'KERNEL_ARCH'),
|
('kernel-arch', 'KERNEL_ARCH'),
|
||||||
('localversion', 'LOCALVERSION'),
|
('localversion', 'LOCALVERSION'),
|
||||||
):
|
):
|
||||||
if vars.has_key(i[0]):
|
if i[0] in vars:
|
||||||
makeflags[i[1]] = vars[i[0]]
|
makeflags[i[1]] = vars[i[0]]
|
||||||
|
|
||||||
def do_flavour_makefile(self, makefile, arch, featureset, flavour, makeflags, extra):
|
def do_flavour_makefile(self, makefile, arch, featureset, flavour, makeflags, extra):
|
||||||
|
@ -269,8 +273,10 @@ class Gencontrol(object):
|
||||||
def substitute(self, s, vars):
|
def substitute(self, s, vars):
|
||||||
if isinstance(s, (list, tuple)):
|
if isinstance(s, (list, tuple)):
|
||||||
return [self.substitute(i, vars) for i in s]
|
return [self.substitute(i, vars) for i in s]
|
||||||
|
|
||||||
def subst(match):
|
def subst(match):
|
||||||
return vars[match.group(1)]
|
return vars[match.group(1)]
|
||||||
|
|
||||||
return re.sub(r'@([-_a-z]+)@', subst, s)
|
return re.sub(r'@([-_a-z]+)@', subst, s)
|
||||||
|
|
||||||
def write(self, packages, makefile):
|
def write(self, packages, makefile):
|
||||||
|
@ -295,5 +301,3 @@ class Gencontrol(object):
|
||||||
for key, value in entry.iteritems():
|
for key, value in entry.iteritems():
|
||||||
f.write("%s: %s\n" % (key, value))
|
f.write("%s: %s\n" % (key, value))
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ __all__ = (
|
||||||
"KconfigFile",
|
"KconfigFile",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class EntryString(object):
|
class EntryString(object):
|
||||||
__slots__ = "name", "value"
|
__slots__ = "name", "value"
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ class EntryString(object):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "CONFIG_%s=%s" % (self.name, self.value)
|
return "CONFIG_%s=%s" % (self.name, self.value)
|
||||||
|
|
||||||
|
|
||||||
class EntryTristate(object):
|
class EntryTristate(object):
|
||||||
__slots__ = "name", "value"
|
__slots__ = "name", "value"
|
||||||
|
|
||||||
|
@ -23,7 +25,7 @@ class EntryTristate(object):
|
||||||
VALUE_YES = 1
|
VALUE_YES = 1
|
||||||
VALUE_MOD = 2
|
VALUE_MOD = 2
|
||||||
|
|
||||||
def __init__(self, name, value = None):
|
def __init__(self, name, value=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
if value == 'n' or value is None:
|
if value == 'n' or value is None:
|
||||||
self.value = self.VALUE_NO
|
self.value = self.VALUE_NO
|
||||||
|
@ -41,6 +43,7 @@ class EntryTristate(object):
|
||||||
elif self.value == self.VALUE_MOD:
|
elif self.value == self.VALUE_MOD:
|
||||||
return "%s=m" % conf
|
return "%s=m" % conf
|
||||||
|
|
||||||
|
|
||||||
class KconfigFile(SortedDict):
|
class KconfigFile(SortedDict):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
ret = []
|
ret = []
|
||||||
|
@ -54,7 +57,7 @@ class KconfigFile(SortedDict):
|
||||||
if line.startswith("CONFIG_"):
|
if line.startswith("CONFIG_"):
|
||||||
i = line.find('=')
|
i = line.find('=')
|
||||||
option = line[7:i]
|
option = line[7:i]
|
||||||
value = line[i+1:]
|
value = line[i + 1:]
|
||||||
self.set(option, value)
|
self.set(option, value)
|
||||||
elif line.startswith("# CONFIG_"):
|
elif line.startswith("# CONFIG_"):
|
||||||
option = line[9:-11]
|
option = line[9:-11]
|
||||||
|
@ -62,7 +65,7 @@ class KconfigFile(SortedDict):
|
||||||
elif line.startswith("#") or not line:
|
elif line.startswith("#") or not line:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise RuntimeError, "Can't recognize %s" % line
|
raise RuntimeError("Can't recognize %s" % line)
|
||||||
|
|
||||||
def set(self, key, value):
|
def set(self, key, value):
|
||||||
if value in ('y', 'm', 'n'):
|
if value in ('y', 'm', 'n'):
|
||||||
|
@ -74,4 +77,3 @@ class KconfigFile(SortedDict):
|
||||||
def str_iter(self):
|
def str_iter(self):
|
||||||
for key, value in self.iteritems():
|
for key, value in self.iteritems():
|
||||||
yield str(value)
|
yield str(value)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import glob, os, shutil
|
import glob
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
class Operation(object):
|
class Operation(object):
|
||||||
def __init__(self, name, data):
|
def __init__(self, name, data):
|
||||||
self.name, self.data = name, data
|
self.name, self.data = name, data
|
||||||
|
|
||||||
def __call__(self, dir = '.', reverse = False):
|
def __call__(self, dir='.', reverse=False):
|
||||||
try:
|
try:
|
||||||
if not reverse:
|
if not reverse:
|
||||||
self.do(dir)
|
self.do(dir)
|
||||||
|
@ -28,6 +31,7 @@ class Operation(object):
|
||||||
def do_reverse(self, dir):
|
def do_reverse(self, dir):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
class OperationPatch(Operation):
|
class OperationPatch(Operation):
|
||||||
def __init__(self, name, fopen, data):
|
def __init__(self, name, fopen, data):
|
||||||
super(OperationPatch, self).__init__(name, data)
|
super(OperationPatch, self).__init__(name, data)
|
||||||
|
@ -46,18 +50,21 @@ class OperationPatch(Operation):
|
||||||
def patch_pop(self, dir):
|
def patch_pop(self, dir):
|
||||||
self._call(dir, '-R')
|
self._call(dir, '-R')
|
||||||
|
|
||||||
|
|
||||||
class OperationPatchPush(OperationPatch):
|
class OperationPatchPush(OperationPatch):
|
||||||
operation = '+'
|
operation = '+'
|
||||||
|
|
||||||
do = OperationPatch.patch_push
|
do = OperationPatch.patch_push
|
||||||
do_reverse = OperationPatch.patch_pop
|
do_reverse = OperationPatch.patch_pop
|
||||||
|
|
||||||
|
|
||||||
class OperationPatchPop(OperationPatch):
|
class OperationPatchPop(OperationPatch):
|
||||||
operation = '-'
|
operation = '-'
|
||||||
|
|
||||||
do = OperationPatch.patch_pop
|
do = OperationPatch.patch_pop
|
||||||
do_reverse = OperationPatch.patch_push
|
do_reverse = OperationPatch.patch_push
|
||||||
|
|
||||||
|
|
||||||
class SubOperation(Operation):
|
class SubOperation(Operation):
|
||||||
def _log(self, result):
|
def _log(self, result):
|
||||||
if result:
|
if result:
|
||||||
|
@ -66,6 +73,7 @@ class SubOperation(Operation):
|
||||||
s = "FAIL"
|
s = "FAIL"
|
||||||
print """ %-10s %-4s %s""" % ('(%s)' % self.operation, s, self.name)
|
print """ %-10s %-4s %s""" % ('(%s)' % self.operation, s, self.name)
|
||||||
|
|
||||||
|
|
||||||
class SubOperationFilesRemove(SubOperation):
|
class SubOperationFilesRemove(SubOperation):
|
||||||
operation = "remove"
|
operation = "remove"
|
||||||
|
|
||||||
|
@ -77,6 +85,7 @@ class SubOperationFilesRemove(SubOperation):
|
||||||
else:
|
else:
|
||||||
os.unlink(n)
|
os.unlink(n)
|
||||||
|
|
||||||
|
|
||||||
class SubOperationFilesUnifdef(SubOperation):
|
class SubOperationFilesUnifdef(SubOperation):
|
||||||
operation = "unifdef"
|
operation = "unifdef"
|
||||||
|
|
||||||
|
@ -94,6 +103,7 @@ class SubOperationFilesUnifdef(SubOperation):
|
||||||
f1.write(data)
|
f1.write(data)
|
||||||
f1.close()
|
f1.close()
|
||||||
|
|
||||||
|
|
||||||
class OperationFiles(Operation):
|
class OperationFiles(Operation):
|
||||||
operation = 'X'
|
operation = 'X'
|
||||||
|
|
||||||
|
@ -126,7 +136,8 @@ class OperationFiles(Operation):
|
||||||
|
|
||||||
def do(self, dir):
|
def do(self, dir):
|
||||||
for i in self.ops:
|
for i in self.ops:
|
||||||
i(dir = dir)
|
i(dir=dir)
|
||||||
|
|
||||||
|
|
||||||
class PatchSeries(list):
|
class PatchSeries(list):
|
||||||
operations = {
|
operations = {
|
||||||
|
@ -166,20 +177,21 @@ class PatchSeries(list):
|
||||||
|
|
||||||
self.append(self.operations[operation](filename, fopen, data))
|
self.append(self.operations[operation](filename, fopen, data))
|
||||||
|
|
||||||
def __call__(self, cond = bool, dir = '.', reverse = False):
|
def __call__(self, cond=bool, dir='.', reverse=False):
|
||||||
if not reverse:
|
if not reverse:
|
||||||
l = self
|
l = self
|
||||||
else:
|
else:
|
||||||
l = self[::-1]
|
l = self[::-1]
|
||||||
for i in l:
|
for i in l:
|
||||||
if cond(i):
|
if cond(i):
|
||||||
i(dir = dir, reverse = reverse)
|
i(dir=dir, reverse=reverse)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s object for %s>' % (self.__class__.__name__, self.name)
|
return '<%s object for %s>' % (self.__class__.__name__, self.name)
|
||||||
|
|
||||||
|
|
||||||
class PatchSeriesList(list):
|
class PatchSeriesList(list):
|
||||||
def __call__(self, cond = bool, reverse = False):
|
def __call__(self, cond=bool, reverse=False):
|
||||||
if not reverse:
|
if not reverse:
|
||||||
l = self
|
l = self
|
||||||
else:
|
else:
|
||||||
|
@ -189,7 +201,7 @@ class PatchSeriesList(list):
|
||||||
print "--> Try to unapply %s." % i.name
|
print "--> Try to unapply %s." % i.name
|
||||||
else:
|
else:
|
||||||
print "--> Try to apply %s." % i.name
|
print "--> Try to apply %s." % i.name
|
||||||
i(cond = cond, reverse = reverse)
|
i(cond=cond, reverse=reverse)
|
||||||
if reverse:
|
if reverse:
|
||||||
print "--> %s fully unapplied." % i.name
|
print "--> %s fully unapplied." % i.name
|
||||||
else:
|
else:
|
||||||
|
@ -205,4 +217,3 @@ class PatchSeriesList(list):
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import re, os, textwrap
|
import os
|
||||||
|
import re
|
||||||
|
import textwrap
|
||||||
|
|
||||||
_marker = object
|
_marker = object
|
||||||
|
|
||||||
|
|
||||||
class SortedDict(dict):
|
class SortedDict(dict):
|
||||||
__slots__ = '_list',
|
__slots__ = '_list',
|
||||||
|
|
||||||
def __init__(self, entries = None):
|
def __init__(self, entries=None):
|
||||||
super(SortedDict, self).__init__()
|
super(SortedDict, self).__init__()
|
||||||
self._list = []
|
self._list = []
|
||||||
if entries is not None:
|
if entries is not None:
|
||||||
|
@ -35,8 +38,9 @@ class SortedDict(dict):
|
||||||
for i in iter(self._list):
|
for i in iter(self._list):
|
||||||
yield self[i]
|
yield self[i]
|
||||||
|
|
||||||
|
|
||||||
class Templates(object):
|
class Templates(object):
|
||||||
def __init__(self, dirs = ["debian/templates"]):
|
def __init__(self, dirs=["debian/templates"]):
|
||||||
self.dirs = dirs
|
self.dirs = dirs
|
||||||
|
|
||||||
self._cache = {}
|
self._cache = {}
|
||||||
|
@ -67,6 +71,7 @@ class Templates(object):
|
||||||
return default
|
return default
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def read_control(f):
|
def read_control(f):
|
||||||
from .debian import Package
|
from .debian import Package
|
||||||
|
|
||||||
|
@ -96,7 +101,7 @@ def read_control(f):
|
||||||
if i < 0:
|
if i < 0:
|
||||||
raise ValueError("Not a header, not a continuation: ``%s''" % line)
|
raise ValueError("Not a header, not a continuation: ``%s''" % line)
|
||||||
last = line[:i]
|
last = line[:i]
|
||||||
lines = [line[i+1:].lstrip()]
|
lines = [line[i + 1:].lstrip()]
|
||||||
if last:
|
if last:
|
||||||
e[last] = '\n'.join(lines)
|
e[last] = '\n'.join(lines)
|
||||||
if e:
|
if e:
|
||||||
|
@ -104,8 +109,8 @@ def read_control(f):
|
||||||
|
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
|
||||||
class TextWrapper(textwrap.TextWrapper):
|
class TextWrapper(textwrap.TextWrapper):
|
||||||
wordsep_re = re.compile(
|
wordsep_re = re.compile(
|
||||||
r'(\s+|' # any whitespace
|
r'(\s+|' # any whitespace
|
||||||
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
|
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue