debian/bin,debian/control,debian/lib/python,debian/rules: Use Python 3
debian/lib/python: Sync with linux package
This commit is contained in:
parent
ad62cfffb2
commit
277d4945c7
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
sys.path.append("debian/lib/python")
|
||||
|
@ -21,7 +21,7 @@ class gencontrol(Gencontrol):
|
|||
self.do_source(packages)
|
||||
self.do_main(packages, makefile)
|
||||
|
||||
self.write_control(packages.itervalues())
|
||||
self.write_control(packages.values())
|
||||
self.write_makefile(makefile)
|
||||
|
||||
def do_source(self, packages):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
sys.path.append("debian/lib/python")
|
||||
|
@ -186,7 +186,7 @@ class Main(object):
|
|||
try:
|
||||
if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', ' '.join(cmdline)]):
|
||||
raise RuntimeError("Can't patch source")
|
||||
os.chmod(out, 0644)
|
||||
os.chmod(out, 0o644)
|
||||
except:
|
||||
try:
|
||||
os.unlink(out)
|
||||
|
|
|
@ -2,6 +2,10 @@ linux-tools (4.2-1) UNRELEASED; urgency=medium
|
|||
|
||||
* New upstream release
|
||||
|
||||
[ Ben Hutchings ]
|
||||
* debian/bin,debian/control,debian/lib/python,debian/rules: Use Python 3
|
||||
- debian/lib/python: Sync with linux package
|
||||
|
||||
-- Ben Hutchings <ben@decadent.org.uk> Fri, 25 Sep 2015 18:42:20 +0100
|
||||
|
||||
linux-tools (4.2~rc7-1~exp1) experimental; urgency=medium
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
import os
|
||||
import os.path
|
||||
import pickle
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
import cPickle
|
||||
|
||||
try:
|
||||
from configparser import RawConfigParser
|
||||
except ImportError:
|
||||
from ConfigParser import RawConfigParser
|
||||
|
||||
__all__ = [
|
||||
'ConfigCoreDump',
|
||||
|
@ -22,6 +27,14 @@ class SchemaItemBoolean(object):
|
|||
raise Error
|
||||
|
||||
|
||||
class SchemaItemInteger(object):
|
||||
def __call__(self, i):
|
||||
try:
|
||||
return int(i.strip(), 0)
|
||||
except ValueError:
|
||||
raise Error
|
||||
|
||||
|
||||
class SchemaItemList(object):
|
||||
def __init__(self, type="\s+"):
|
||||
self.type = type
|
||||
|
@ -78,12 +91,12 @@ class ConfigCore(dict):
|
|||
return ret
|
||||
|
||||
def dump(self, fp):
|
||||
cPickle.dump(self, fp, 0)
|
||||
pickle.dump(self, fp, 0)
|
||||
|
||||
|
||||
class ConfigCoreDump(object):
|
||||
def __new__(self, fp):
|
||||
return cPickle.load(fp)
|
||||
return pickle.load(fp)
|
||||
|
||||
|
||||
class ConfigCoreHierarchy(object):
|
||||
|
@ -98,7 +111,7 @@ class ConfigCoreHierarchy(object):
|
|||
|
||||
def __new__(cls, schema, dirs=[]):
|
||||
schema_complete = cls.schema_base.copy()
|
||||
for key, value in schema.iteritems():
|
||||
for key, value in schema.items():
|
||||
schema_complete.setdefault(key, {}).update(value)
|
||||
return cls.Reader(dirs, schema_complete)()
|
||||
|
||||
|
@ -195,7 +208,6 @@ class ConfigParser(object):
|
|||
def __init__(self, schemas):
|
||||
self.schemas = schemas
|
||||
|
||||
from ConfigParser import RawConfigParser
|
||||
self._config = config = RawConfigParser()
|
||||
|
||||
def __getitem__(self, key):
|
||||
|
@ -225,7 +237,7 @@ class ConfigParser(object):
|
|||
|
||||
def _convert_one(self, schema, data):
|
||||
ret = {}
|
||||
for key, value in data.iteritems():
|
||||
for key, value in data.items():
|
||||
if key in schema:
|
||||
value = schema[key](value)
|
||||
ret[key] = value
|
||||
|
@ -241,9 +253,9 @@ class ConfigParser(object):
|
|||
if __name__ == '__main__':
|
||||
import sys
|
||||
sys.path.append('debian/lib/python')
|
||||
config = ConfigCoreDump(open('debian/config.defines.dump'))
|
||||
for section, items in sorted(config.iteritems()):
|
||||
print u"[%s]" % (section,)
|
||||
for item, value in sorted(items.iteritems()):
|
||||
print u"%s: %s" % (item, value)
|
||||
print
|
||||
config = ConfigCoreDump(open('debian/config.defines.dump', 'rb'))
|
||||
for section, items in sorted(config.items(), key=lambda a:tuple(i or '' for i in a[0])):
|
||||
print(u"[%s]" % (section,))
|
||||
for item, value in sorted(items.items()):
|
||||
print(u"%s: %s" % (item, value))
|
||||
print()
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import collections
|
||||
import itertools
|
||||
import os.path
|
||||
import re
|
||||
|
||||
|
@ -35,7 +34,7 @@ class Changelog(list):
|
|||
def __init__(self, dir='', version=None):
|
||||
if version is None:
|
||||
version = Version
|
||||
f = file(os.path.join(dir, "debian/changelog"))
|
||||
f = open(os.path.join(dir, "debian/changelog"), encoding="UTF-8")
|
||||
while True:
|
||||
line = f.readline()
|
||||
if not line:
|
||||
|
@ -53,7 +52,7 @@ class Changelog(list):
|
|||
|
||||
|
||||
class Version(object):
|
||||
_version_rules = ur"""
|
||||
_version_rules = r"""
|
||||
^
|
||||
(?:
|
||||
(?P<epoch>
|
||||
|
@ -82,7 +81,7 @@ $
|
|||
self.upstream = match.group("upstream")
|
||||
self.revision = match.group("revision")
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.complete
|
||||
|
||||
@property
|
||||
|
@ -105,14 +104,15 @@ $
|
|||
|
||||
|
||||
class VersionLinux(Version):
|
||||
_version_linux_rules = ur"""
|
||||
_version_linux_rules = r"""
|
||||
^
|
||||
(?P<version>
|
||||
\d+\.\d+
|
||||
)
|
||||
(?P<update>
|
||||
\.\d+
|
||||
)?
|
||||
(?:\.\d+)?
|
||||
(?:-[a-z]+\d+)?
|
||||
)
|
||||
(?:
|
||||
~
|
||||
(?P<modifier>
|
||||
|
@ -130,13 +130,20 @@ class VersionLinux(Version):
|
|||
(\.\d+)?
|
||||
(?:
|
||||
(?P<revision_experimental>
|
||||
~experimental\.\d+
|
||||
~exp\d+
|
||||
)
|
||||
|
|
||||
(?P<revision_security>
|
||||
[~+]deb\d+u\d+
|
||||
)?
|
||||
(?P<revision_backports>
|
||||
~bpo\d+\+\d+
|
||||
)?
|
||||
|
|
||||
(?P<revision_other>
|
||||
[^-]+
|
||||
)
|
||||
)?
|
||||
)
|
||||
$
|
||||
"""
|
||||
_version_linux_re = re.compile(_version_linux_rules, re.X)
|
||||
|
@ -151,12 +158,14 @@ $
|
|||
self.linux_version = d['version']
|
||||
if d['modifier'] is not None:
|
||||
assert not d['update']
|
||||
self.linux_upstream = u'-'.join((d['version'], d['modifier']))
|
||||
self.linux_upstream = '-'.join((d['version'], d['modifier']))
|
||||
else:
|
||||
self.linux_upstream = d['version']
|
||||
self.linux_upstream_full = self.linux_upstream + (d['update'] or u'')
|
||||
self.linux_upstream_full = self.linux_upstream + d['update']
|
||||
self.linux_dfsg = d['dfsg']
|
||||
self.linux_revision_experimental = match.group('revision_experimental') and True
|
||||
self.linux_revision_security = match.group('revision_security') and True
|
||||
self.linux_revision_backports = match.group('revision_backports') and True
|
||||
self.linux_revision_other = match.group('revision_other') and True
|
||||
|
||||
|
||||
|
@ -177,8 +186,8 @@ class PackageArchitecture(collections.MutableSet):
|
|||
def __len__(self):
|
||||
return self._data.__len__()
|
||||
|
||||
def __unicode__(self):
|
||||
return u' '.join(sorted(self))
|
||||
def __str__(self):
|
||||
return ' '.join(sorted(self))
|
||||
|
||||
def add(self, value):
|
||||
self._data.add(value)
|
||||
|
@ -187,7 +196,7 @@ class PackageArchitecture(collections.MutableSet):
|
|||
self._data.discard(value)
|
||||
|
||||
def extend(self, value):
|
||||
if isinstance(value, basestring):
|
||||
if isinstance(value, str):
|
||||
for i in re.split('\s', value.strip()):
|
||||
self.add(i)
|
||||
else:
|
||||
|
@ -205,14 +214,14 @@ class PackageDescription(object):
|
|||
self.append(long)
|
||||
self.append_short(short)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
wrap = utils.TextWrapper(width=74, fix_sentence_endings=True).wrap
|
||||
short = u', '.join(self.short)
|
||||
short = ', '.join(self.short)
|
||||
long_pars = []
|
||||
for i in self.long:
|
||||
long_pars.append(wrap(i))
|
||||
long = u'\n .\n '.join([u'\n '.join(i) for i in long_pars])
|
||||
return short + u'\n ' + long
|
||||
long = '\n .\n '.join(['\n '.join(i) for i in long_pars])
|
||||
return short + '\n ' + long
|
||||
|
||||
def append(self, str):
|
||||
str = str.strip()
|
||||
|
@ -237,8 +246,8 @@ class PackageRelation(list):
|
|||
if value:
|
||||
self.extend(value, override_arches)
|
||||
|
||||
def __unicode__(self):
|
||||
return u', '.join((unicode(i) for i in self))
|
||||
def __str__(self):
|
||||
return ', '.join(str(i) for i in self)
|
||||
|
||||
def _search_value(self, value):
|
||||
for i in self:
|
||||
|
@ -247,7 +256,7 @@ class PackageRelation(list):
|
|||
return None
|
||||
|
||||
def append(self, value, override_arches=None):
|
||||
if isinstance(value, basestring):
|
||||
if isinstance(value, str):
|
||||
value = PackageRelationGroup(value, override_arches)
|
||||
elif not isinstance(value, PackageRelationGroup):
|
||||
raise ValueError(u"got %s" % type(value))
|
||||
|
@ -258,8 +267,8 @@ class PackageRelation(list):
|
|||
super(PackageRelation, self).append(value)
|
||||
|
||||
def extend(self, value, override_arches=None):
|
||||
if isinstance(value, basestring):
|
||||
value = (j.strip() for j in re.split(u',', value.strip()))
|
||||
if isinstance(value, str):
|
||||
value = (j.strip() for j in re.split(',', value.strip()))
|
||||
for i in value:
|
||||
self.append(i, override_arches)
|
||||
|
||||
|
@ -269,31 +278,31 @@ class PackageRelationGroup(list):
|
|||
if value:
|
||||
self.extend(value, override_arches)
|
||||
|
||||
def __unicode__(self):
|
||||
return u' | '.join((unicode(i) for i in self))
|
||||
def __str__(self):
|
||||
return ' | '.join(str(i) for i in self)
|
||||
|
||||
def _search_value(self, value):
|
||||
for i, j in itertools.izip(self, value):
|
||||
for i, j in zip(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):
|
||||
for i, j in zip(self, value):
|
||||
if i.arches:
|
||||
for arch in j.arches:
|
||||
if arch not in i.arches:
|
||||
i.arches.append(arch)
|
||||
|
||||
def append(self, value, override_arches=None):
|
||||
if isinstance(value, basestring):
|
||||
if isinstance(value, str):
|
||||
value = PackageRelationEntry(value, override_arches)
|
||||
elif not isinstance(value, PackageRelationEntry):
|
||||
raise ValueError
|
||||
super(PackageRelationGroup, self).append(value)
|
||||
|
||||
def extend(self, value, override_arches=None):
|
||||
if isinstance(value, basestring):
|
||||
if isinstance(value, str):
|
||||
value = (j.strip() for j in re.split('\|', value.strip()))
|
||||
for i in value:
|
||||
self.append(i, override_arches)
|
||||
|
@ -313,12 +322,12 @@ class PackageRelationEntry(object):
|
|||
OP_GT = 6
|
||||
|
||||
operators = {
|
||||
u'<<': OP_LT,
|
||||
u'<=': OP_LE,
|
||||
u'=': OP_EQ,
|
||||
u'!=': OP_NE,
|
||||
u'>=': OP_GE,
|
||||
u'>>': OP_GT,
|
||||
'<<': OP_LT,
|
||||
'<=': OP_LE,
|
||||
'=': OP_EQ,
|
||||
'!=': OP_NE,
|
||||
'>=': OP_GE,
|
||||
'>>': OP_GT,
|
||||
}
|
||||
|
||||
operators_neg = {
|
||||
|
@ -330,7 +339,7 @@ class PackageRelationEntry(object):
|
|||
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.items())
|
||||
|
||||
__slots__ = '_op',
|
||||
|
||||
|
@ -340,11 +349,11 @@ class PackageRelationEntry(object):
|
|||
def __neg__(self):
|
||||
return self.__class__(self.operators_text[self.operators_neg[self._op]])
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.operators_text[self._op]
|
||||
|
||||
def __init__(self, value=None, override_arches=None):
|
||||
if not isinstance(value, basestring):
|
||||
if not isinstance(value, str):
|
||||
raise ValueError
|
||||
|
||||
self.parse(value)
|
||||
|
@ -352,13 +361,13 @@ class PackageRelationEntry(object):
|
|||
if override_arches:
|
||||
self.arches = list(override_arches)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
ret = [self.name]
|
||||
if self.operator is not None and self.version is not None:
|
||||
ret.extend((u' (', unicode(self.operator), u' ', self.version, u')'))
|
||||
ret.extend((' (', str(self.operator), ' ', self.version, ')'))
|
||||
if self.arches:
|
||||
ret.extend((u' [', u' '.join(self.arches), u']'))
|
||||
return u''.join(ret)
|
||||
ret.extend((' [', ' '.join(self.arches), ']'))
|
||||
return ''.join(ret)
|
||||
|
||||
def parse(self, value):
|
||||
match = self._re.match(value)
|
||||
|
@ -379,14 +388,14 @@ class PackageRelationEntry(object):
|
|||
|
||||
class Package(dict):
|
||||
_fields = collections.OrderedDict((
|
||||
('Package', unicode),
|
||||
('Source', unicode),
|
||||
('Package', str),
|
||||
('Source', str),
|
||||
('Architecture', PackageArchitecture),
|
||||
('Section', unicode),
|
||||
('Priority', unicode),
|
||||
('Maintainer', unicode),
|
||||
('Uploaders', unicode),
|
||||
('Standards-Version', unicode),
|
||||
('Section', str),
|
||||
('Priority', str),
|
||||
('Maintainer', str),
|
||||
('Uploaders', str),
|
||||
('Standards-Version', str),
|
||||
('Build-Depends', PackageRelation),
|
||||
('Build-Depends-Indep', PackageRelation),
|
||||
('Provides', PackageRelation),
|
||||
|
@ -411,7 +420,7 @@ class Package(dict):
|
|||
|
||||
def iterkeys(self):
|
||||
keys = set(self.keys())
|
||||
for i in self._fields.iterkeys():
|
||||
for i in self._fields.keys():
|
||||
if i in self:
|
||||
keys.remove(i)
|
||||
yield i
|
||||
|
|
|
@ -29,9 +29,7 @@ class Makefile(object):
|
|||
self.rules[i] = self.Rule(i)
|
||||
|
||||
def write(self, out):
|
||||
r = self.rules.keys()
|
||||
r.sort()
|
||||
for i in r:
|
||||
for i in sorted(self.rules.keys()):
|
||||
self.rules[i].write(out)
|
||||
|
||||
class Rule(object):
|
||||
|
@ -70,7 +68,7 @@ class MakeFlags(dict):
|
|||
return "%s(%s)" % (self.__class__.__name__, repr)
|
||||
|
||||
def __str__(self):
|
||||
return ' '.join(["%s='%s'" % i for i in sorted(self.iteritems())])
|
||||
return ' '.join("%s='%s'" % i for i in sorted(self.items()))
|
||||
|
||||
def copy(self):
|
||||
return self.__class__(super(MakeFlags, self).copy())
|
||||
|
@ -129,25 +127,21 @@ class Gencontrol(object):
|
|||
if templates_extra is None:
|
||||
return
|
||||
|
||||
packages.extend(self.process_packages(templates_extra, {}))
|
||||
packages_extra = self.process_packages(templates_extra, self.vars)
|
||||
packages.extend(packages_extra)
|
||||
extra_arches = {}
|
||||
for package in templates_extra:
|
||||
for package in packages_extra:
|
||||
arches = package['Architecture']
|
||||
for arch in arches:
|
||||
i = extra_arches.get(arch, [])
|
||||
i.append(package)
|
||||
extra_arches[arch] = i
|
||||
archs = extra_arches.keys()
|
||||
archs.sort()
|
||||
for arch in archs:
|
||||
for arch in sorted(extra_arches.keys()):
|
||||
cmds = []
|
||||
for i in extra_arches[arch]:
|
||||
tmp = []
|
||||
if 'X-Version-Overwrite-Epoch' in i:
|
||||
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)))
|
||||
makefile.add('binary-arch_%s' % arch['binary-arch_%s_extra' % arch])
|
||||
makefile.add("binary-arch_%s_extra" % arch, cmds=cmds)
|
||||
cmds.append("$(MAKE) -f debian/rules.real install-dummy ARCH='%s' DH_OPTIONS='-p%s'" % (arch, i['Package']))
|
||||
makefile.add('binary-arch_%s' % arch, ['binary-arch_%s_extra' % arch])
|
||||
makefile.add("binary-arch_%s_extra" % arch, cmds = cmds)
|
||||
|
||||
def do_arch(self, packages, makefile, arch, vars, makeflags, extra):
|
||||
vars['arch'] = arch
|
||||
|
@ -280,10 +274,10 @@ class Gencontrol(object):
|
|||
def subst(match):
|
||||
return vars[match.group(1)]
|
||||
|
||||
return re.sub(r'@([-_a-z]+)@', subst, unicode(s))
|
||||
return re.sub(r'@([-_a-z0-9]+)@', subst, str(s))
|
||||
|
||||
def write(self, packages, makefile):
|
||||
self.write_control(packages.itervalues())
|
||||
self.write_control(packages.values())
|
||||
self.write_makefile(makefile)
|
||||
|
||||
def write_config(self):
|
||||
|
@ -295,7 +289,7 @@ class Gencontrol(object):
|
|||
self.write_rfc822(codecs.open("debian/control", 'w', 'utf-8'), list)
|
||||
|
||||
def write_makefile(self, makefile):
|
||||
f = file("debian/rules.gen", 'w')
|
||||
f = open("debian/rules.gen", 'w')
|
||||
makefile.write(f)
|
||||
f.close()
|
||||
|
||||
|
@ -303,4 +297,4 @@ class Gencontrol(object):
|
|||
for entry in list:
|
||||
for key, value in entry.iteritems():
|
||||
f.write(u"%s: %s\n" % (key, value))
|
||||
f.write(u'\n')
|
||||
f.write('\n')
|
||||
|
|
|
@ -19,13 +19,14 @@ class Templates(object):
|
|||
def _read(self, name):
|
||||
prefix, id = name.split('.', 1)
|
||||
|
||||
for dir in self.dirs:
|
||||
filename = "%s/%s.in" % (dir, name)
|
||||
if os.path.exists(filename):
|
||||
f = codecs.open(filename, 'r', 'utf-8')
|
||||
if prefix == 'control':
|
||||
return read_control(f)
|
||||
return f.read()
|
||||
for suffix in ['.in', '']:
|
||||
for dir in self.dirs:
|
||||
filename = "%s/%s%s" % (dir, name, suffix)
|
||||
if os.path.exists(filename):
|
||||
f = codecs.open(filename, 'r', 'utf-8')
|
||||
if prefix == 'control':
|
||||
return read_control(f)
|
||||
return f.read()
|
||||
|
||||
def get(self, key, default=None):
|
||||
if key in self._cache:
|
||||
|
@ -57,11 +58,11 @@ def read_control(f):
|
|||
break
|
||||
if line[0] in ' \t':
|
||||
if not last:
|
||||
raise ValueError(u'Continuation line seen before first header')
|
||||
raise ValueError('Continuation line seen before first header')
|
||||
lines.append(line.lstrip())
|
||||
continue
|
||||
if last:
|
||||
e[last] = u'\n'.join(lines)
|
||||
e[last] = '\n'.join(lines)
|
||||
i = line.find(':')
|
||||
if i < 0:
|
||||
raise ValueError(u"Not a header, not a continuation: ``%s''" % line)
|
||||
|
|
|
@ -41,7 +41,7 @@ maintainerclean:
|
|||
clean: debian/control
|
||||
dh_testdir
|
||||
make -C $(BUILD_DIR) clean top_srcdir=$(CURDIR)
|
||||
rm -rf $(STAMPS_DIR) debian/lib/python/debian_linux/*.pyc
|
||||
rm -rf $(STAMPS_DIR) debian/lib/python/debian_linux/__pycache__
|
||||
dh_clean
|
||||
|
||||
binary-indep:
|
||||
|
|
|
@ -5,7 +5,7 @@ Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org>
|
|||
Uploaders: Bastian Blank <waldi@debian.org>, Ben Hutchings <ben@decadent.org.uk>, Jonathan Nieder <jrnieder@gmail.com>
|
||||
Standards-Version: 3.9.4
|
||||
Build-Depends:
|
||||
debhelper (>> 7), python,
|
||||
debhelper (>> 7), python3,
|
||||
asciidoc, bison, flex, gcc-multilib [amd64 ppc64 s390x sparc64], libaudit-dev, libdw-dev, libelf-dev, libiberty-dev | binutils-dev (<< 2.23.91.20131123-1), libnewt-dev, libnuma-dev [amd64 arm64 hppa i386 mips mips64 mips64el mipsel powerpc powerpcspe ppc64 ppc64el sparc x32], libperl-dev, libunwind8-dev [amd64 armel armhf arm64 i386], python-dev, xmlto,
|
||||
autoconf, automake, libtool, libglib2.0-dev, libudev-dev, libwrap0-dev,
|
||||
dh-systemd
|
||||
|
|
Loading…
Reference in New Issue