debian/bin, debian/lib/python: Fix most errors reported by pycodestyle

Fix coding style violations reported by pycodestyle.  This is
mostly a matter of reformatting code, particularly to eliminate
over-long lines.  I also rename one variable ("l" is considered
visually ambiguous) and change a bare "except" to explicitly
catch all exceptions.

There are three types of error or warning remaining:

- debian/bin/...: E402 module level import not at top of file
  Scripts in debian/bin need to modify the import path before
  importing from debian/lib/python.
- E127 continuation line over-indented for visual indent
  This seems to be a false positive.  pycodestyle doesn't seem to be
  happy with any level of indent (including 0) on a continuation line
  in a "with" statement.
- debian/lib/python/debian_linux/debian.py:15:2: W291 trailing whitespace
  This is a false positive.  The trailing spaces are in a long
  string and are intentional.
This commit is contained in:
Ben Hutchings 2018-10-01 16:22:49 +01:00
parent 79ecbb0832
commit af0098b10a
17 changed files with 481 additions and 249 deletions

View File

@ -1,8 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys import sys
sys.path.append(sys.path[0] + "/../lib/python")
import optparse import optparse
import os import os
import shutil import shutil
@ -11,6 +9,7 @@ import tempfile
from urllib.request import urlopen from urllib.request import urlopen
from urllib.error import HTTPError from urllib.error import HTTPError
sys.path.append(sys.path[0] + "/../lib/python")
from debian_linux.abi import Symbols from debian_linux.abi import Symbols
from debian_linux.config import * from debian_linux.config import *
from debian_linux.debian import * from debian_linux.debian import *
@ -35,25 +34,29 @@ class url_debian_pool(object):
self.base = base self.base = base
def __call__(self, source, filename, arch): def __call__(self, source, filename, arch):
return self.base + "pool/main/" + source[0] + "/" + source + "/" + filename return (self.base + "pool/main/" + source[0] + "/" + source + "/" +
filename)
class url_debian_ports_pool(url_debian_pool): class url_debian_ports_pool(url_debian_pool):
def __call__(self, source, filename, arch): def __call__(self, source, filename, arch):
if arch == 'all': if arch == 'all':
return url_debian_pool.__call__(self, source, filename, arch) return url_debian_pool.__call__(self, source, filename, arch)
return self.base + "pool-" + arch + "/main/" + source[0] + "/" + source + "/" + filename return (self.base + "pool-" + arch + "/main/" + source[0] + "/" +
source + "/" + filename)
class url_debian_security_pool(url_debian_pool): class url_debian_security_pool(url_debian_pool):
def __call__(self, source, filename, arch): def __call__(self, source, filename, arch):
return self.base + "pool/updates/main/" + source[0] + "/" + source + "/" + filename return (self.base + "pool/updates/main/" + source[0] + "/" + source +
"/" + filename)
class Main(object): class Main(object):
dir = None dir = None
def __init__(self, url, url_config=None, arch=None, featureset=None, flavour=None): def __init__(self, url, url_config=None, arch=None, featureset=None,
flavour=None):
self.log = sys.stdout.write self.log = sys.stdout.write
self.url = self.url_config = url self.url = self.url_config = url
@ -72,7 +75,8 @@ class Main(object):
self.version = changelog.version.linux_version self.version = changelog.version.linux_version
self.version_source = changelog.version.complete self.version_source = changelog.version.complete
self.config = ConfigCoreDump(fp=open("debian/config.defines.dump", "rb")) self.config = ConfigCoreDump(fp=open("debian/config.defines.dump",
"rb"))
self.version_abi = self.config['version', ]['abiname'] self.version_abi = self.config['version', ]['abiname']
@ -104,14 +108,16 @@ class Main(object):
def get_abi(self, arch, prefix): def get_abi(self, arch, prefix):
try: try:
version_abi = (self.config['version',]['abiname_base'] + '-' + version_abi = (self.config[('version',)]['abiname_base'] + '-' +
self.config['abi', arch]['abiname']) self.config['abi', arch]['abiname'])
except KeyError: except KeyError:
version_abi = self.version_abi version_abi = self.version_abi
filename = "linux-headers-%s-%s_%s_%s.deb" % (version_abi, prefix, self.version_source, arch) filename = ("linux-headers-%s-%s_%s_%s.deb" %
(version_abi, prefix, self.version_source, arch))
f = self.retrieve_package(self.url, filename, arch) f = self.retrieve_package(self.url, filename, arch)
d = self.extract_package(f, "linux-headers-%s_%s" % (prefix, arch)) d = self.extract_package(f, "linux-headers-%s_%s" % (prefix, arch))
f1 = d + "/usr/src/linux-headers-%s-%s/Module.symvers" % (version_abi, prefix) f1 = d + ("/usr/src/linux-headers-%s-%s/Module.symvers" %
(version_abi, prefix))
s = Symbols(open(f1)) s = Symbols(open(f1))
shutil.rmtree(d) shutil.rmtree(d)
return version_abi, s return version_abi, s
@ -166,7 +172,8 @@ class Main(object):
def update_flavour(self, config, arch, featureset, flavour): def update_flavour(self, config, arch, featureset, flavour):
config_base = config.merge('base', arch, featureset, flavour) config_base = config.merge('base', arch, featureset, flavour)
self.log("Updating ABI for arch %s, featureset %s, flavour %s: " % (arch, featureset, flavour)) self.log("Updating ABI for arch %s, featureset %s, flavour %s: " %
(arch, featureset, flavour))
try: try:
if featureset == 'none': if featureset == 'none':
localversion = flavour localversion = flavour
@ -183,17 +190,26 @@ class Main(object):
import traceback import traceback
traceback.print_exc(None, sys.stdout) traceback.print_exc(None, sys.stdout)
if __name__ == '__main__': if __name__ == '__main__':
options = optparse.OptionParser() options = optparse.OptionParser()
options.add_option("-i", "--incoming", action="store_true", dest="incoming") options.add_option("-i", "--incoming", action="store_true",
options.add_option("--incoming-config", action="store_true", dest="incoming_config") dest="incoming")
options.add_option("--incoming-config", action="store_true",
dest="incoming_config")
options.add_option("--ports", action="store_true", dest="ports") options.add_option("--ports", action="store_true", dest="ports")
options.add_option("--security", action="store_true", dest="security") options.add_option("--security", action="store_true", dest="security")
options.add_option("-u", "--url-base", dest="url_base", default=default_url_base) options.add_option("-u", "--url-base", dest="url_base",
options.add_option("--url-base-incoming", dest="url_base_incoming", default=default_url_base_incoming) default=default_url_base)
options.add_option("--url-base-ports", dest="url_base_ports", default=default_url_base_ports) options.add_option("--url-base-incoming", dest="url_base_incoming",
options.add_option("--url-base-ports-incoming", dest="url_base_ports_incoming", default=default_url_base_ports_incoming) default=default_url_base_incoming)
options.add_option("--url-base-security", dest="url_base_security", default=default_url_base_security) options.add_option("--url-base-ports", dest="url_base_ports",
default=default_url_base_ports)
options.add_option("--url-base-ports-incoming",
dest="url_base_ports_incoming",
default=default_url_base_ports_incoming)
options.add_option("--url-base-security", dest="url_base_security",
default=default_url_base_security)
opts, args = options.parse_args() opts, args = options.parse_args()

View File

@ -1,12 +1,11 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys import sys
sys.path.append('debian/lib/python')
import fnmatch import fnmatch
import glob import glob
import stat import stat
sys.path.append('debian/lib/python')
from debian_linux.abi import Symbols from debian_linux.abi import Symbols
from debian_linux.config import ConfigCoreDump from debian_linux.config import ConfigCoreDump
from debian_linux.debian import * from debian_linux.debian import *
@ -46,19 +45,22 @@ class CheckAbi(object):
self.filename_new = "%s/Module.symvers" % dir self.filename_new = "%s/Module.symvers" % dir
try: try:
version_abi = (self.config['version',]['abiname_base'] + '-' + version_abi = (self.config[('version',)]['abiname_base'] + '-' +
self.config['abi', arch]['abiname']) self.config['abi', arch]['abiname'])
except KeyError: except KeyError:
version_abi = self.config['version',]['abiname'] version_abi = self.config[('version',)]['abiname']
self.filename_ref = "debian/abi/%s/%s_%s_%s" % (version_abi, arch, featureset, flavour) self.filename_ref = ("debian/abi/%s/%s_%s_%s" %
(version_abi, arch, featureset, flavour))
def __call__(self, out): def __call__(self, out):
ret = 0 ret = 0
new = Symbols(open(self.filename_new)) new = Symbols(open(self.filename_new))
unversioned = [name for name in new if new[name].version == '0x00000000'] unversioned = [name for name in new
if new[name].version == '0x00000000']
if unversioned: if unversioned:
out.write("ABI is not completely versioned! Refusing to continue.\n") out.write("ABI is not completely versioned! "
"Refusing to continue.\n")
out.write("\nUnversioned symbols:\n") out.write("\nUnversioned symbols:\n")
for name in sorted(unversioned): for name in sorted(unversioned):
self.SymbolInfo(new[name]).write(out, False) self.SymbolInfo(new[name]).write(out, False)
@ -82,11 +84,13 @@ class CheckAbi(object):
out.write("ABI has changed! Refusing to continue.\n") out.write("ABI has changed! Refusing to continue.\n")
ret = 1 ret = 1
elif change or remove: elif change or remove:
out.write("ABI has changed but all changes have been ignored. Continuing.\n") out.write("ABI has changed but all changes have been ignored. "
"Continuing.\n")
elif add_effective: elif add_effective:
out.write("New symbols have been added. Continuing.\n") out.write("New symbols have been added. Continuing.\n")
elif add: elif add:
out.write("New symbols have been added but have been ignored. Continuing.\n") out.write("New symbols have been added but have been ignored. "
"Continuing.\n")
else: else:
out.write("No ABI changes.\n") out.write("No ABI changes.\n")
@ -149,9 +153,12 @@ class CheckAbi(object):
def _ignore(self, symbols): def _ignore(self, symbols):
# TODO: let config merge this lists # TODO: let config merge this lists
configs = [] configs = []
configs.append(self.config.get(('abi', self.arch, self.featureset, self.flavour), {})) configs.append(self.config.get(('abi', self.arch, self.featureset,
configs.append(self.config.get(('abi', self.arch, None, self.flavour), {})) self.flavour), {}))
configs.append(self.config.get(('abi', self.arch, self.featureset), {})) configs.append(self.config.get(('abi', self.arch, None, self.flavour),
{}))
configs.append(self.config.get(('abi', self.arch, self.featureset),
{}))
configs.append(self.config.get(('abi', self.arch), {})) configs.append(self.config.get(('abi', self.arch), {}))
configs.append(self.config.get(('abi', None, self.featureset), {})) configs.append(self.config.get(('abi', None, self.featureset), {}))
configs.append(self.config.get(('abi',), {})) configs.append(self.config.get(('abi',), {}))
@ -183,13 +190,17 @@ class CheckImage(object):
self.changelog = Changelog(version=VersionLinux)[0] self.changelog = Changelog(version=VersionLinux)[0]
self.config_entry_base = config.merge('base', arch, featureset, flavour) self.config_entry_base = config.merge('base', arch, featureset,
self.config_entry_build = config.merge('build', arch, featureset, flavour) flavour)
self.config_entry_image = config.merge('image', arch, featureset, flavour) self.config_entry_build = config.merge('build', arch, featureset,
flavour)
self.config_entry_image = config.merge('image', arch, featureset,
flavour)
def __call__(self, out): def __call__(self, out):
image = self.config_entry_build.get('image-file') image = self.config_entry_build.get('image-file')
uncompressed_image = self.config_entry_build.get('uncompressed-image-file') uncompressed_image = self.config_entry_build \
.get('uncompressed-image-file')
if not image: if not image:
# TODO: Bail out # TODO: Bail out
@ -236,16 +247,19 @@ class CheckImage(object):
out.write('Continuing.\n') out.write('Continuing.\n')
# Also check the uncompressed image # Also check the uncompressed image
if uncompressed_image and self.config_entry_image.get('check-uncompressed-size'): if uncompressed_image and \
self.config_entry_image.get('check-uncompressed-size'):
value = self.config_entry_image.get('check-uncompressed-size') value = self.config_entry_image.get('check-uncompressed-size')
size = os.stat(uncompressed_image).st_size size = os.stat(uncompressed_image).st_size
usage = (float(size)/value) * 100.0 usage = (float(size)/value) * 100.0
out.write('Uncompressed Image size %d/%d, using %.2f%%. ' % (size, value, usage)) out.write('Uncompressed Image size %d/%d, using %.2f%%. ' %
(size, value, usage))
if size > value: if size > value:
out.write('Too large. Refusing to continue.\n') out.write('Too large. Refusing to continue.\n')
return 1 return 1
elif usage >= 99.0: elif usage >= 99.0:
out.write('Uncompressed Image Under 1%% space in %s. ' % self.changelog.distribution) out.write('Uncompressed Image Under 1%% space in %s. ' %
self.changelog.distribution)
else: else:
out.write('Uncompressed Image fits. ') out.write('Uncompressed Image fits. ')
out.write('Continuing.\n') out.write('Continuing.\n')

View File

@ -1,8 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys import sys
sys.path.append("debian/lib/python")
import locale import locale
import errno import errno
import glob import glob
@ -11,13 +9,15 @@ import os
import os.path import os.path
import subprocess import subprocess
locale.setlocale(locale.LC_CTYPE, "C.UTF-8") sys.path.append("debian/lib/python")
from debian_linux import config from debian_linux import config
from debian_linux.debian import * from debian_linux.debian import *
from debian_linux.gencontrol import Gencontrol as Base, merge_packages from debian_linux.gencontrol import Gencontrol as Base, merge_packages
from debian_linux.utils import Templates, read_control from debian_linux.utils import Templates, read_control
locale.setlocale(locale.LC_CTYPE, "C.UTF-8")
class Gencontrol(Base): class Gencontrol(Base):
config_schema = { config_schema = {
'abi': { 'abi': {
@ -52,7 +52,8 @@ class Gencontrol(Base):
} }
} }
def __init__(self, config_dirs=["debian/config"], template_dirs=["debian/templates"]): def __init__(self, config_dirs=["debian/config"],
template_dirs=["debian/templates"]):
super(Gencontrol, self).__init__( super(Gencontrol, self).__init__(
config.ConfigCoreHierarchy(self.config_schema, config_dirs), config.ConfigCoreHierarchy(self.config_schema, config_dirs),
Templates(template_dirs), Templates(template_dirs),
@ -91,9 +92,12 @@ class Gencontrol(Base):
if os.getenv('DEBIAN_KERNEL_DISABLE_INSTALLER'): if os.getenv('DEBIAN_KERNEL_DISABLE_INSTALLER'):
if self.changelog[0].distribution == 'UNRELEASED': if self.changelog[0].distribution == 'UNRELEASED':
import warnings import warnings
warnings.warn('Disable installer modules on request (DEBIAN_KERNEL_DISABLE_INSTALLER set)') warnings.warn('Disable installer modules on request '
'(DEBIAN_KERNEL_DISABLE_INSTALLER set)')
else: else:
raise RuntimeError('Unable to disable installer modules in release build (DEBIAN_KERNEL_DISABLE_INSTALLER set)') raise RuntimeError(
'Unable to disable installer modules in release build '
'(DEBIAN_KERNEL_DISABLE_INSTALLER set)')
elif self.config.merge('packages').get('installer', True): elif self.config.merge('packages').get('installer', True):
# Add udebs using kernel-wedge # Add udebs using kernel-wedge
kw_env = os.environ.copy() kw_env = os.environ.copy()
@ -104,7 +108,8 @@ class Gencontrol(Base):
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
env=kw_env) env=kw_env)
if not isinstance(kw_proc.stdout, io.IOBase): if not isinstance(kw_proc.stdout, io.IOBase):
udeb_packages = read_control(io.open(kw_proc.stdout.fileno(), closefd=False)) udeb_packages = read_control(io.open(kw_proc.stdout.fileno(),
closefd=False))
else: else:
udeb_packages = read_control(io.TextIOWrapper(kw_proc.stdout)) udeb_packages = read_control(io.TextIOWrapper(kw_proc.stdout))
kw_proc.wait() kw_proc.wait()
@ -123,8 +128,8 @@ class Gencontrol(Base):
# configuration errors before building linux-signed. # configuration errors before building linux-signed.
build_signed = {} build_signed = {}
for arch in arches: for arch in arches:
build_signed[arch] = (self.config.merge('build', arch) build_signed[arch] = self.config.merge('build', arch) \
.get('signed-code', False)) .get('signed-code', False)
for package in udeb_packages: for package in udeb_packages:
# kernel-wedge currently chokes on Build-Profiles so add it now # kernel-wedge currently chokes on Build-Profiles so add it now
@ -135,17 +140,20 @@ class Gencontrol(Base):
# the package list while still being able to # the package list while still being able to
# convince debhelper and kernel-wedge to go # convince debhelper and kernel-wedge to go
# part way to building them. # part way to building them.
package['Build-Profiles'] = '<pkg.linux.udeb-unsigned-test-build>' package['Build-Profiles'] = (
'<pkg.linux.udeb-unsigned-test-build>')
else: else:
package['Build-Profiles'] = '<!stage1>' package['Build-Profiles'] = '<!stage1>'
for arch in package['Architecture']: for arch in package['Architecture']:
self.installer_packages.setdefault(arch, []).append(package) self.installer_packages.setdefault(arch, []) \
.append(package)
def do_main_makefile(self, makefile, makeflags, extra): def do_main_makefile(self, makefile, makeflags, extra):
fs_enabled = [featureset fs_enabled = [featureset
for featureset in self.config['base', ]['featuresets'] for featureset in self.config['base', ]['featuresets']
if self.config.merge('base', None, featureset).get('enabled', True)] if (self.config.merge('base', None, featureset)
.get('enabled', True))]
for featureset in fs_enabled: for featureset in fs_enabled:
makeflags_featureset = makeflags.copy() makeflags_featureset = makeflags.copy()
makeflags_featureset['FEATURESET'] = featureset makeflags_featureset['FEATURESET'] = featureset
@ -165,13 +173,17 @@ class Gencontrol(Base):
super(Gencontrol, self).do_main_makefile(makefile, makeflags, extra) super(Gencontrol, self).do_main_makefile(makefile, makeflags, extra)
def do_main_packages(self, packages, vars, makeflags, extra): def do_main_packages(self, packages, vars, makeflags, extra):
packages.extend(self.process_packages(self.templates["control.main"], self.vars)) packages.extend(self.process_packages(
self.templates["control.main"], self.vars))
if self.config.merge('packages').get('docs', True): if self.config.merge('packages').get('docs', True):
packages.extend(self.process_packages(self.templates["control.docs"], self.vars)) packages.extend(self.process_packages(
self.templates["control.docs"], self.vars))
if self.config.merge('packages').get('tools-unversioned', True): if self.config.merge('packages').get('tools-unversioned', True):
packages.extend(self.process_packages(self.templates["control.tools-unversioned"], self.vars)) packages.extend(self.process_packages(
self.templates["control.tools-unversioned"], self.vars))
if self.config.merge('packages').get('tools-versioned', True): if self.config.merge('packages').get('tools-versioned', True):
packages.extend(self.process_packages(self.templates["control.tools-versioned"], self.vars)) packages.extend(self.process_packages(
self.templates["control.tools-versioned"], self.vars))
self._substitute_file('perf.lintian-overrides', self.vars, self._substitute_file('perf.lintian-overrides', self.vars,
'debian/linux-perf-%s.lintian-overrides' % 'debian/linux-perf-%s.lintian-overrides' %
@ -181,7 +193,8 @@ class Gencontrol(Base):
makeflags['LOCALVERSION'] = vars['localversion'] makeflags['LOCALVERSION'] = vars['localversion']
kernel_arches = set() kernel_arches = set()
for arch in iter(self.config['base', ]['arches']): for arch in iter(self.config['base', ]['arches']):
if self.config.get_merge('base', arch, featureset, None, 'flavours'): if self.config.get_merge('base', arch, featureset, None,
'flavours'):
kernel_arches.add(self.config['base', arch]['kernel-arch']) kernel_arches.add(self.config['base', arch]['kernel-arch'])
makeflags['ALL_KERNEL_ARCHES'] = ' '.join(sorted(list(kernel_arches))) makeflags['ALL_KERNEL_ARCHES'] = ' '.join(sorted(list(kernel_arches)))
@ -197,9 +210,11 @@ class Gencontrol(Base):
headers_featureset = self.templates["control.headers.featureset"] headers_featureset = self.templates["control.headers.featureset"]
packages.extend(self.process_packages(headers_featureset, vars)) packages.extend(self.process_packages(headers_featureset, vars))
cmds_binary_arch = ["$(MAKE) -f debian/rules.real binary-indep-featureset %s" % cmds_binary_arch = ["$(MAKE) -f debian/rules.real "
"binary-indep-featureset %s" %
makeflags] makeflags]
makefile.add('binary-indep_%s_real' % featureset, cmds=cmds_binary_arch) makefile.add('binary-indep_%s_real' % featureset,
cmds=cmds_binary_arch)
arch_makeflags = ( arch_makeflags = (
('kernel-arch', 'KERNEL_ARCH', False), ('kernel-arch', 'KERNEL_ARCH', False),
@ -211,17 +226,19 @@ class Gencontrol(Base):
self._setup_makeflags(self.arch_makeflags, makeflags, config_base) self._setup_makeflags(self.arch_makeflags, makeflags, config_base)
try: try:
gnu_type_bytes = subprocess.check_output(['dpkg-architecture', '-f', gnu_type_bytes = subprocess.check_output(
'-a', arch, ['dpkg-architecture', '-f', '-a', arch,
'-q', 'DEB_HOST_GNU_TYPE'], '-q', 'DEB_HOST_GNU_TYPE'],
stderr=subprocess.DEVNULL) stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
# This sometimes happens for the newest ports :-/ # This sometimes happens for the newest ports :-/
print('W: Unable to get GNU type for %s' % arch, file=sys.stderr) print('W: Unable to get GNU type for %s' % arch, file=sys.stderr)
else: else:
vars['gnu-type-package'] = gnu_type_bytes.decode('utf-8').strip().replace('_', '-') vars['gnu-type-package'] = (
gnu_type_bytes.decode('utf-8').strip().replace('_', '-'))
def do_arch_packages(self, packages, makefile, arch, vars, makeflags, extra): def do_arch_packages(self, packages, makefile, arch, vars, makeflags,
extra):
if self.version.linux_modifier is None: if self.version.linux_modifier is None:
try: try:
abiname_part = '-%s' % self.config['abi', arch]['abiname'] abiname_part = '-%s' % self.config['abi', arch]['abiname']
@ -230,18 +247,20 @@ class Gencontrol(Base):
makeflags['ABINAME'] = vars['abiname'] = \ makeflags['ABINAME'] = vars['abiname'] = \
self.abiname_version + abiname_part self.abiname_version + abiname_part
build_signed = self.config.merge('build', arch).get('signed-code', False) build_signed = self.config.merge('build', arch) \
.get('signed-code', False)
# Some userland architectures require kernels from another # Some userland architectures require kernels from another
# (Debian) architecture, e.g. x32/amd64. # (Debian) architecture, e.g. x32/amd64.
# And some derivatives don't need the headers-all packages # And some derivatives don't need the headers-all packages
# for other reasons. # for other reasons.
if (self.config['base', arch].get('featuresets') and if self.config['base', arch].get('featuresets') and \
self.config.merge('packages').get('headers-all', True)): self.config.merge('packages').get('headers-all', True):
headers_arch = self.templates["control.headers.arch"] headers_arch = self.templates["control.headers.arch"]
packages_headers_arch = self.process_packages(headers_arch, vars) packages_headers_arch = self.process_packages(headers_arch, vars)
packages_headers_arch[-1]['Depends'].extend(PackageRelation()) packages_headers_arch[-1]['Depends'].extend(PackageRelation())
extra['headers_arch_depends'] = packages_headers_arch[-1]['Depends'] extra['headers_arch_depends'] = (
packages_headers_arch[-1]['Depends'])
else: else:
packages_headers_arch = [] packages_headers_arch = []
makeflags['DO_HEADERS_ALL'] = False makeflags['DO_HEADERS_ALL'] = False
@ -254,8 +273,8 @@ class Gencontrol(Base):
merge_packages(packages, packages_headers_arch, arch) merge_packages(packages, packages_headers_arch, arch)
if (self.config['base', arch].get('featuresets') and if self.config['base', arch].get('featuresets') and \
self.config.merge('packages').get('source', True)): self.config.merge('packages').get('source', True):
merge_packages(packages, merge_packages(packages,
self.process_packages( self.process_packages(
self.templates["control.config"], vars), self.templates["control.config"], vars),
@ -263,10 +282,12 @@ class Gencontrol(Base):
else: else:
makeflags['DO_CONFIG'] = False makeflags['DO_CONFIG'] = False
cmds_build_arch = ["$(MAKE) -f debian/rules.real build-arch-arch %s" % makeflags] cmds_build_arch = ["$(MAKE) -f debian/rules.real build-arch-arch %s" %
makeflags]
makefile.add('build-arch_%s_real' % arch, cmds=cmds_build_arch) makefile.add('build-arch_%s_real' % arch, cmds=cmds_build_arch)
cmds_binary_arch = ["$(MAKE) -f debian/rules.real binary-arch-arch %s" % makeflags] cmds_binary_arch = ["$(MAKE) -f debian/rules.real binary-arch-arch %s"
% makeflags]
makefile.add('binary-arch_%s_real' % arch, cmds=cmds_binary_arch, makefile.add('binary-arch_%s_real' % arch, cmds=cmds_binary_arch,
deps=['setup_%s' % arch]) deps=['setup_%s' % arch])
@ -296,16 +317,19 @@ class Gencontrol(Base):
if build_signed: if build_signed:
merge_packages(packages, merge_packages(packages,
self.process_packages( self.process_packages(
self.templates['control.signed-template'], vars), self.templates['control.signed-template'],
vars),
arch) arch)
makefile.add( makefile.add(
'binary-arch_%s' % arch, 'binary-arch_%s' % arch,
cmds=["$(MAKE) -f debian/rules.real install-signed-template_%s %s" % cmds=["$(MAKE) -f debian/rules.real "
"install-signed-template_%s %s" %
(arch, makeflags)]) (arch, makeflags)])
def do_featureset_setup(self, vars, makeflags, arch, featureset, extra): def do_featureset_setup(self, vars, makeflags, arch, featureset, extra):
config_base = self.config.merge('base', arch, featureset) config_base = self.config.merge('base', arch, featureset)
makeflags['LOCALVERSION_HEADERS'] = vars['localversion_headers'] = vars['localversion'] vars['localversion_headers'] = vars['localversion']
makeflags['LOCALVERSION_HEADERS'] = vars['localversion_headers']
flavour_makeflags_base = ( flavour_makeflags_base = (
('compiler', 'COMPILER', False), ('compiler', 'COMPILER', False),
@ -328,34 +352,47 @@ class Gencontrol(Base):
('localversion-image', 'LOCALVERSION_IMAGE', True), ('localversion-image', 'LOCALVERSION_IMAGE', True),
) )
def do_flavour_setup(self, vars, makeflags, arch, featureset, flavour, extra): def do_flavour_setup(self, vars, makeflags, arch, featureset, flavour,
extra):
config_base = self.config.merge('base', arch, featureset, flavour) config_base = self.config.merge('base', arch, featureset, flavour)
config_build = self.config.merge('build', arch, featureset, flavour) config_build = self.config.merge('build', arch, featureset, flavour)
config_description = self.config.merge('description', arch, featureset, flavour) config_description = self.config.merge('description', arch, featureset,
flavour)
config_image = self.config.merge('image', arch, featureset, flavour) config_image = self.config.merge('image', arch, featureset, flavour)
vars['class'] = config_description['hardware'] vars['class'] = config_description['hardware']
vars['longclass'] = config_description.get('hardware-long') or vars['class'] vars['longclass'] = (config_description.get('hardware-long') or
vars['class'])
vars['localversion-image'] = vars['localversion'] vars['localversion-image'] = vars['localversion']
override_localversion = config_image.get('override-localversion', None) override_localversion = config_image.get('override-localversion', None)
if override_localversion is not None: if override_localversion is not None:
vars['localversion-image'] = vars['localversion_headers'] + '-' + override_localversion vars['localversion-image'] = (vars['localversion_headers'] + '-' +
override_localversion)
vars['image-stem'] = config_image.get('install-stem') vars['image-stem'] = config_image.get('install-stem')
self._setup_makeflags(self.flavour_makeflags_base, makeflags, config_base) self._setup_makeflags(self.flavour_makeflags_base, makeflags,
self._setup_makeflags(self.flavour_makeflags_build, makeflags, config_build) config_base)
self._setup_makeflags(self.flavour_makeflags_image, makeflags, config_image) self._setup_makeflags(self.flavour_makeflags_build, makeflags,
config_build)
self._setup_makeflags(self.flavour_makeflags_image, makeflags,
config_image)
self._setup_makeflags(self.flavour_makeflags_other, makeflags, vars) self._setup_makeflags(self.flavour_makeflags_other, makeflags, vars)
def do_flavour_packages(self, packages, makefile, arch, featureset, flavour, vars, makeflags, extra): def do_flavour_packages(self, packages, makefile, arch, featureset,
flavour, vars, makeflags, extra):
headers = self.templates["control.headers"] headers = self.templates["control.headers"]
config_entry_base = self.config.merge('base', arch, featureset, flavour) config_entry_base = self.config.merge('base', arch, featureset,
config_entry_build = self.config.merge('build', arch, featureset, flavour) flavour)
config_entry_description = self.config.merge('description', arch, featureset, flavour) config_entry_build = self.config.merge('build', arch, featureset,
config_entry_image = self.config.merge('image', arch, featureset, flavour) flavour)
config_entry_relations = self.config.merge('relations', arch, featureset, flavour) config_entry_description = self.config.merge('description', arch,
featureset, flavour)
config_entry_image = self.config.merge('image', arch, featureset,
flavour)
config_entry_relations = self.config.merge('relations', arch,
featureset, flavour)
compiler = config_entry_base.get('compiler', 'gcc') compiler = config_entry_base.get('compiler', 'gcc')
@ -363,8 +400,8 @@ class Gencontrol(Base):
# dependencies for cross-builds. Strip any remaining # dependencies for cross-builds. Strip any remaining
# restrictions, as they don't apply to binary Depends. # restrictions, as they don't apply to binary Depends.
relations_compiler_headers = PackageRelation( relations_compiler_headers = PackageRelation(
self.substitute(config_entry_relations.get('headers%' + compiler) or self.substitute(config_entry_relations.get('headers%' + compiler)
config_entry_relations.get(compiler), vars)) or config_entry_relations.get(compiler), vars))
relations_compiler_headers = PackageRelation( relations_compiler_headers = PackageRelation(
PackageRelationGroup(entry for entry in group PackageRelationGroup(entry for entry in group
if 'cross' not in entry.restrictions) if 'cross' not in entry.restrictions)
@ -378,48 +415,54 @@ class Gencontrol(Base):
for group in relations_compiler_build_dep: for group in relations_compiler_build_dep:
for item in group: for item in group:
item.arches = [arch] item.arches = [arch]
packages['source']['Build-Depends-Arch'].extend(relations_compiler_build_dep) packages['source']['Build-Depends-Arch'].extend(
relations_compiler_build_dep)
image_fields = {'Description': PackageDescription()} image_fields = {'Description': PackageDescription()}
for field in 'Depends', 'Provides', 'Suggests', 'Recommends', 'Conflicts', 'Breaks': for field in ('Depends', 'Provides', 'Suggests', 'Recommends',
image_fields[field] = PackageRelation(config_entry_image.get(field.lower(), None), override_arches=(arch,)) 'Conflicts', 'Breaks'):
image_fields[field] = PackageRelation(config_entry_image.get(
field.lower(), None), override_arches=(arch,))
generators = config_entry_image['initramfs-generators'] generators = config_entry_image['initramfs-generators']
l = PackageRelationGroup() group = PackageRelationGroup()
for i in generators: for i in generators:
i = config_entry_relations.get(i, i) i = config_entry_relations.get(i, i)
l.append(i) group.append(i)
a = PackageRelationEntry(i) a = PackageRelationEntry(i)
if a.operator is not None: if a.operator is not None:
a.operator = -a.operator a.operator = -a.operator
image_fields['Breaks'].append(PackageRelationGroup([a])) image_fields['Breaks'].append(PackageRelationGroup([a]))
for item in l: for item in group:
item.arches = [arch] item.arches = [arch]
image_fields['Depends'].append(l) image_fields['Depends'].append(group)
bootloaders = config_entry_image.get('bootloaders') bootloaders = config_entry_image.get('bootloaders')
if bootloaders: if bootloaders:
l = PackageRelationGroup() group = PackageRelationGroup()
for i in bootloaders: for i in bootloaders:
i = config_entry_relations.get(i, i) i = config_entry_relations.get(i, i)
l.append(i) group.append(i)
a = PackageRelationEntry(i) a = PackageRelationEntry(i)
if a.operator is not None: if a.operator is not None:
a.operator = -a.operator a.operator = -a.operator
image_fields['Breaks'].append(PackageRelationGroup([a])) image_fields['Breaks'].append(PackageRelationGroup([a]))
for item in l: for item in group:
item.arches = [arch] item.arches = [arch]
image_fields['Suggests'].append(l) image_fields['Suggests'].append(group)
desc_parts = self.config.get_merge('description', arch, featureset, flavour, 'parts') desc_parts = self.config.get_merge('description', arch, featureset,
flavour, 'parts')
if desc_parts: if desc_parts:
# XXX: Workaround, we need to support multiple entries of the same name # XXX: Workaround, we need to support multiple entries of the same
# name
parts = list(set(desc_parts)) parts = list(set(desc_parts))
parts.sort() parts.sort()
desc = image_fields['Description'] desc = image_fields['Description']
for part in parts: for part in parts:
desc.append(config_entry_description['part-long-' + part]) desc.append(config_entry_description['part-long-' + part])
desc.append_short(config_entry_description.get('part-short-' + part, '')) desc.append_short(config_entry_description
.get('part-short-' + part, ''))
packages_dummy = [] packages_dummy = []
packages_own = [] packages_own = []
@ -440,7 +483,8 @@ class Gencontrol(Base):
package_headers['Depends'].extend(relations_compiler_headers) package_headers['Depends'].extend(relations_compiler_headers)
packages_own.append(package_headers) packages_own.append(package_headers)
if extra.get('headers_arch_depends'): if extra.get('headers_arch_depends'):
extra['headers_arch_depends'].append('%s (= ${binary:Version})' % packages_own[-1]['Package']) extra['headers_arch_depends'].append('%s (= ${binary:Version})' %
packages_own[-1]['Package'])
if config_entry_build.get('vdso', False): if config_entry_build.get('vdso', False):
makeflags['VDSO'] = True makeflags['VDSO'] = True
@ -450,14 +494,18 @@ class Gencontrol(Base):
if os.getenv('DEBIAN_KERNEL_DISABLE_DEBUG'): if os.getenv('DEBIAN_KERNEL_DISABLE_DEBUG'):
if self.changelog[0].distribution == 'UNRELEASED': if self.changelog[0].distribution == 'UNRELEASED':
import warnings import warnings
warnings.warn('Disable debug infos on request (DEBIAN_KERNEL_DISABLE_DEBUG set)') warnings.warn('Disable debug infos on request '
'(DEBIAN_KERNEL_DISABLE_DEBUG set)')
build_debug = False build_debug = False
else: else:
raise RuntimeError('Unable to disable debug infos in release build (DEBIAN_KERNEL_DISABLE_DEBUG set)') raise RuntimeError(
'Unable to disable debug infos in release build '
'(DEBIAN_KERNEL_DISABLE_DEBUG set)')
if build_debug: if build_debug:
makeflags['DEBUG'] = True makeflags['DEBUG'] = True
packages_own.extend(self.process_packages(self.templates['control.image-dbg'], vars)) packages_own.extend(self.process_packages(
self.templates['control.image-dbg'], vars))
merge_packages(packages, packages_own + packages_dummy, arch) merge_packages(packages, packages_own + packages_dummy, arch)
@ -506,12 +554,19 @@ class Gencontrol(Base):
return check_config_files(configs) return check_config_files(configs)
kconfig = check_config('config', True) kconfig = check_config('config', True)
kconfig.extend(check_config("kernelarch-%s/config" % config_entry_base['kernel-arch'], False)) kconfig.extend(check_config("kernelarch-%s/config" %
config_entry_base['kernel-arch'],
False))
kconfig.extend(check_config("%s/config" % arch, True, arch)) kconfig.extend(check_config("%s/config" % arch, True, arch))
kconfig.extend(check_config("%s/config.%s" % (arch, flavour), False, arch, None, flavour)) kconfig.extend(check_config("%s/config.%s" % (arch, flavour), False,
kconfig.extend(check_config("featureset-%s/config" % featureset, False, None, featureset)) arch, None, flavour))
kconfig.extend(check_config("%s/%s/config" % (arch, featureset), False, arch, featureset)) kconfig.extend(check_config("featureset-%s/config" % featureset, False,
kconfig.extend(check_config("%s/%s/config.%s" % (arch, featureset, flavour), False, arch, featureset, flavour)) None, featureset))
kconfig.extend(check_config("%s/%s/config" % (arch, featureset), False,
arch, featureset))
kconfig.extend(check_config("%s/%s/config.%s" %
(arch, featureset, flavour), False,
arch, featureset, flavour))
makeflags['KCONFIG'] = ' '.join(kconfig) makeflags['KCONFIG'] = ' '.join(kconfig)
makeflags['KCONFIG_OPTIONS'] = '' makeflags['KCONFIG_OPTIONS'] = ''
if build_debug: if build_debug:
@ -519,16 +574,24 @@ class Gencontrol(Base):
if build_signed: if build_signed:
makeflags['KCONFIG_OPTIONS'] += ' -o MODULE_SIG=y' makeflags['KCONFIG_OPTIONS'] += ' -o MODULE_SIG=y'
cmds_binary_arch = ["$(MAKE) -f debian/rules.real binary-arch-flavour %s" % makeflags] cmds_binary_arch = ["$(MAKE) -f debian/rules.real binary-arch-flavour "
"%s" %
makeflags]
if packages_dummy: if packages_dummy:
cmds_binary_arch.append( cmds_binary_arch.append(
"$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='%s' %s" "$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='%s' %s"
% (' '.join("-p%s" % i['Package'] for i in packages_dummy), makeflags)) % (' '.join("-p%s" % i['Package'] for i in packages_dummy),
cmds_build = ["$(MAKE) -f debian/rules.real build-arch-flavour %s" % makeflags] makeflags))
cmds_setup = ["$(MAKE) -f debian/rules.real setup-arch-flavour %s" % makeflags] cmds_build = ["$(MAKE) -f debian/rules.real build-arch-flavour %s" %
makefile.add('binary-arch_%s_%s_%s_real' % (arch, featureset, flavour), cmds=cmds_binary_arch) makeflags]
makefile.add('build-arch_%s_%s_%s_real' % (arch, featureset, flavour), cmds=cmds_build) cmds_setup = ["$(MAKE) -f debian/rules.real setup-arch-flavour %s" %
makefile.add('setup_%s_%s_%s_real' % (arch, featureset, flavour), cmds=cmds_setup) makeflags]
makefile.add('binary-arch_%s_%s_%s_real' % (arch, featureset, flavour),
cmds=cmds_binary_arch)
makefile.add('build-arch_%s_%s_%s_real' % (arch, featureset, flavour),
cmds=cmds_build)
makefile.add('setup_%s_%s_%s_real' % (arch, featureset, flavour),
cmds=cmds_setup)
# Substitute kernel version etc. into maintainer scripts, # Substitute kernel version etc. into maintainer scripts,
# translations and lintian overrides # translations and lintian overrides
@ -537,10 +600,12 @@ class Gencontrol(Base):
(vars['abiname'], vars['localversion'])) (vars['abiname'], vars['localversion']))
for name in ['postinst', 'postrm', 'preinst', 'prerm']: for name in ['postinst', 'postrm', 'preinst', 'prerm']:
self._substitute_file('image.%s' % name, vars, self._substitute_file('image.%s' % name, vars,
'debian/%s.%s' % (image_main['Package'], name)) 'debian/%s.%s' %
(image_main['Package'], name))
if build_debug: if build_debug:
debug_lintian_over = ('debian/linux-image-%s%s-dbg.lintian-overrides' % debug_lintian_over = (
(vars['abiname'], vars['localversion'])) 'debian/linux-image-%s%s-dbg.lintian-overrides' %
(vars['abiname'], vars['localversion']))
self._substitute_file('image-dbg.lintian-overrides', vars, self._substitute_file('image-dbg.lintian-overrides', vars,
debug_lintian_over) debug_lintian_over)
os.chmod(debug_lintian_over, 0o755) os.chmod(debug_lintian_over, 0o755)
@ -565,7 +630,8 @@ class Gencontrol(Base):
self.vars = { self.vars = {
'upstreamversion': self.version.linux_upstream, 'upstreamversion': self.version.linux_upstream,
'version': self.version.linux_version, 'version': self.version.linux_version,
'source_basename': re.sub(r'-[\d.]+$', '', self.changelog[0].source), 'source_basename': re.sub(r'-[\d.]+$', '',
self.changelog[0].source),
'source_upstream': self.version.upstream, 'source_upstream': self.version.upstream,
'source_package': self.changelog[0].source, 'source_package': self.changelog[0].source,
'abiname': self.abiname_version + self.abiname_part, 'abiname': self.abiname_version + self.abiname_part,
@ -578,19 +644,24 @@ class Gencontrol(Base):
distribution = self.changelog[0].distribution distribution = self.changelog[0].distribution
if distribution in ('unstable', ): if distribution in ('unstable', ):
if (version.linux_revision_experimental or if version.linux_revision_experimental or \
version.linux_revision_backports or version.linux_revision_backports or \
version.linux_revision_other): version.linux_revision_other:
raise RuntimeError("Can't upload to %s with a version of %s" % (distribution, version)) raise RuntimeError("Can't upload to %s with a version of %s" %
(distribution, version))
if distribution in ('experimental', ): if distribution in ('experimental', ):
if not version.linux_revision_experimental: if not version.linux_revision_experimental:
raise RuntimeError("Can't upload to %s with a version of %s" % (distribution, version)) raise RuntimeError("Can't upload to %s with a version of %s" %
(distribution, version))
if distribution.endswith('-security') or distribution.endswith('-lts'): if distribution.endswith('-security') or distribution.endswith('-lts'):
if version.linux_revision_backports or version.linux_revision_other: if version.linux_revision_backports or \
raise RuntimeError("Can't upload to %s with a version of %s" % (distribution, version)) version.linux_revision_other:
raise RuntimeError("Can't upload to %s with a version of %s" %
(distribution, version))
if distribution.endswith('-backports'): if distribution.endswith('-backports'):
if not version.linux_revision_backports: if not version.linux_revision_backports:
raise RuntimeError("Can't upload to %s with a version of %s" % (distribution, version)) raise RuntimeError("Can't upload to %s with a version of %s" %
(distribution, version))
def process_real_image(self, entry, fields, vars): def process_real_image(self, entry, fields, vars):
entry = self.process_package(entry, vars) entry = self.process_package(entry, vars)
@ -616,5 +687,6 @@ class Gencontrol(Base):
self.write_rfc822(open("debian/tests/control", 'w'), self.write_rfc822(open("debian/tests/control", 'w'),
[self.tests_control]) [self.tests_control])
if __name__ == '__main__': if __name__ == '__main__':
Gencontrol()() Gencontrol()()

View File

@ -1,25 +1,33 @@
#!/usr/bin/python3 #!/usr/bin/python3
import codecs
import hashlib
import io
import json
import os.path
import re
import ssl
import subprocess
import sys import sys
sys.path.append("debian/lib/python") import time
sys.path.append("debian/lib/python")
from debian_linux.config import ConfigCoreDump from debian_linux.config import ConfigCoreDump
from debian_linux.debian import Changelog, PackageDescription, VersionLinux, \ from debian_linux.debian import Changelog, PackageDescription, VersionLinux, \
Package, PackageRelationGroup Package, PackageRelationGroup
from debian_linux.gencontrol import Gencontrol as Base, merge_packages from debian_linux.gencontrol import Gencontrol as Base, merge_packages
from debian_linux.utils import Templates, read_control from debian_linux.utils import Templates, read_control
import os.path, re, codecs, io, json, subprocess, time, ssl, hashlib
class Gencontrol(Base): class Gencontrol(Base):
def __init__(self, arch): def __init__(self, arch):
super(Gencontrol, self).__init__( super(Gencontrol, self).__init__(
ConfigCoreDump(fp = open('debian/config.defines.dump', 'rb')), ConfigCoreDump(fp=open('debian/config.defines.dump', 'rb')),
Templates(['debian/signing_templates', 'debian/templates'])) Templates(['debian/signing_templates', 'debian/templates']))
image_binary_version = self.changelog[0].version.complete image_binary_version = self.changelog[0].version.complete
config_entry = self.config['version',] config_entry = self.config[('version',)]
self.version = VersionLinux(config_entry['source']) self.version = VersionLinux(config_entry['source'])
# Check config version matches changelog version # Check config version matches changelog version
@ -42,7 +50,8 @@ class Gencontrol(Base):
self.template_top_dir = (self.package_dir + self.template_top_dir = (self.package_dir +
'/usr/share/code-signing/%(template)s' % '/usr/share/code-signing/%(template)s' %
self.vars) self.vars)
self.template_debian_dir = self.template_top_dir + '/source-template/debian' self.template_debian_dir = (self.template_top_dir +
'/source-template/debian')
os.makedirs(self.template_debian_dir, exist_ok=True) os.makedirs(self.template_debian_dir, exist_ok=True)
self.image_packages = [] self.image_packages = []
@ -54,7 +63,9 @@ class Gencontrol(Base):
def do_main_setup(self, vars, makeflags, extra): def do_main_setup(self, vars, makeflags, extra):
makeflags['VERSION'] = self.version.linux_version makeflags['VERSION'] = self.version.linux_version
makeflags['GENCONTROL_ARGS'] = ( makeflags['GENCONTROL_ARGS'] = (
'-v%(imagebinaryversion)s -DBuilt-Using="linux (= %(imagesourceversion)s)"' % vars) '-v%(imagebinaryversion)s '
'-DBuilt-Using="linux (= %(imagesourceversion)s)"' %
vars)
makeflags['PACKAGE_VERSION'] = vars['imagebinaryversion'] makeflags['PACKAGE_VERSION'] = vars['imagebinaryversion']
self.installer_packages = {} self.installer_packages = {}
@ -62,9 +73,12 @@ class Gencontrol(Base):
if os.getenv('DEBIAN_KERNEL_DISABLE_INSTALLER'): if os.getenv('DEBIAN_KERNEL_DISABLE_INSTALLER'):
if self.changelog[0].distribution == 'UNRELEASED': if self.changelog[0].distribution == 'UNRELEASED':
import warnings import warnings
warnings.warn('Disable installer modules on request (DEBIAN_KERNEL_DISABLE_INSTALLER set)') warnings.warn('Disable installer modules on request '
'(DEBIAN_KERNEL_DISABLE_INSTALLER set)')
else: else:
raise RuntimeError('Unable to disable installer modules in release build (DEBIAN_KERNEL_DISABLE_INSTALLER set)') raise RuntimeError(
'Unable to disable installer modules in release build '
'(DEBIAN_KERNEL_DISABLE_INSTALLER set)')
elif self.config.merge('packages').get('installer', True): elif self.config.merge('packages').get('installer', True):
# Add udebs using kernel-wedge # Add udebs using kernel-wedge
kw_env = os.environ.copy() kw_env = os.environ.copy()
@ -75,7 +89,8 @@ class Gencontrol(Base):
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
env=kw_env) env=kw_env)
if not isinstance(kw_proc.stdout, io.IOBase): if not isinstance(kw_proc.stdout, io.IOBase):
udeb_packages = read_control(io.open(kw_proc.stdout.fileno(), closefd=False)) udeb_packages = read_control(io.open(kw_proc.stdout.fileno(),
closefd=False))
else: else:
udeb_packages = read_control(io.TextIOWrapper(kw_proc.stdout)) udeb_packages = read_control(io.TextIOWrapper(kw_proc.stdout))
kw_proc.wait() kw_proc.wait()
@ -85,8 +100,10 @@ class Gencontrol(Base):
for package in udeb_packages: for package in udeb_packages:
for arch in package['Architecture']: for arch in package['Architecture']:
if self.config.merge('build', arch).get('signed-code', False): if self.config.merge('build', arch) \
self.installer_packages.setdefault(arch, []).append(package) .get('signed-code', False):
self.installer_packages.setdefault(arch, []) \
.append(package)
def do_main_packages(self, packages, vars, makeflags, extra): def do_main_packages(self, packages, vars, makeflags, extra):
# Assume that arch:all packages do not get binNMU'd # Assume that arch:all packages do not get binNMU'd
@ -95,7 +112,8 @@ class Gencontrol(Base):
def do_main_recurse(self, packages, makefile, vars, makeflags, extra): def do_main_recurse(self, packages, makefile, vars, makeflags, extra):
# Each signed source package only covers a single architecture # Each signed source package only covers a single architecture
self.do_arch(packages, makefile, self.vars['arch'], vars.copy(), makeflags.copy(), extra) self.do_arch(packages, makefile, self.vars['arch'], vars.copy(),
makeflags.copy(), extra)
def do_extra(self, packages, makefile): def do_extra(self, packages, makefile):
pass pass
@ -110,7 +128,8 @@ class Gencontrol(Base):
makeflags['ABINAME'] = vars['abiname'] = \ makeflags['ABINAME'] = vars['abiname'] = \
self.config['version', ]['abiname_base'] + abiname_part self.config['version', ]['abiname_base'] + abiname_part
def do_arch_packages(self, packages, makefile, arch, vars, makeflags, extra): def do_arch_packages(self, packages, makefile, arch, vars, makeflags,
extra):
udeb_packages = self.installer_packages.get(arch, []) udeb_packages = self.installer_packages.get(arch, [])
if udeb_packages: if udeb_packages:
merge_packages(packages, udeb_packages, arch) merge_packages(packages, udeb_packages, arch)
@ -126,13 +145,17 @@ class Gencontrol(Base):
(arch, makeflags, (arch, makeflags,
' '.join(p['Package'] for p in udeb_packages))]) ' '.join(p['Package'] for p in udeb_packages))])
def do_flavour_setup(self, vars, makeflags, arch, featureset, flavour, extra): def do_flavour_setup(self, vars, makeflags, arch, featureset, flavour,
super(Gencontrol, self).do_flavour_setup(vars, makeflags, arch, featureset, flavour, extra) extra):
super(Gencontrol, self).do_flavour_setup(vars, makeflags, arch,
featureset, flavour, extra)
config_image = self.config.merge('image', arch, featureset, flavour) config_image = self.config.merge('image', arch, featureset, flavour)
makeflags['IMAGE_INSTALL_STEM'] = vars['image-stem'] = config_image.get('install-stem') vars['image-stem'] = config_image.get('install-stem')
makeflags['IMAGE_INSTALL_STEM'] = vars['image-stem']
def do_flavour_packages(self, packages, makefile, arch, featureset, flavour, vars, makeflags, extra): def do_flavour_packages(self, packages, makefile, arch, featureset,
flavour, vars, makeflags, extra):
if not (self.config.merge('build', arch, featureset, flavour) if not (self.config.merge('build', arch, featureset, flavour)
.get('signed-code', False)): .get('signed-code', False)):
return return
@ -156,7 +179,8 @@ class Gencontrol(Base):
break break
assert cert_file_name assert cert_file_name
if featureset != "none": if featureset != "none":
cert_file_name = os.path.join('debian/build/source_%s' % featureset, cert_file_name = os.path.join('debian/build/source_%s' %
featureset,
cert_file_name) cert_file_name)
self.image_packages.append((image_suffix, image_package_name, self.image_packages.append((image_suffix, image_package_name,
@ -180,8 +204,11 @@ class Gencontrol(Base):
cmds_binary_arch = [] cmds_binary_arch = []
for i in packages_signed: for i in packages_signed:
cmds_binary_arch += ["$(MAKE) -f debian/rules.real install-signed PACKAGE_NAME='%s' %s" % (i['Package'], makeflags)] cmds_binary_arch += ["$(MAKE) -f debian/rules.real install-signed "
makefile.add('binary-arch_%s_%s_%s_real' % (arch, featureset, flavour), cmds = cmds_binary_arch) "PACKAGE_NAME='%s' %s" %
(i['Package'], makeflags)]
makefile.add('binary-arch_%s_%s_%s_real' % (arch, featureset, flavour),
cmds=cmds_binary_arch)
os.makedirs(self.package_dir + '/usr/share/lintian/overrides', 0o755, os.makedirs(self.package_dir + '/usr/share/lintian/overrides', 0o755,
exist_ok=True) exist_ok=True)
@ -193,7 +220,8 @@ class Gencontrol(Base):
'/linux-image-%s%s.%s' % '/linux-image-%s%s.%s' %
(vars['abiname'], vars['localversion'], (vars['abiname'], vars['localversion'],
script_base)) script_base))
self._substitute_file('image.%s' % script_base, vars, script_name) self._substitute_file('image.%s' % script_base, vars,
script_name)
lintian_overrides.write('%s: script-not-executable %s\n' % lintian_overrides.write('%s: script-not-executable %s\n' %
(self.vars['template'], (self.vars['template'],
os.path.relpath(script_name, os.path.relpath(script_name,
@ -215,16 +243,18 @@ class Gencontrol(Base):
vars['source'] = self.changelog[0].source vars['source'] = self.changelog[0].source
vars['distribution'] = self.changelog[0].distribution vars['distribution'] = self.changelog[0].distribution
vars['urgency'] = self.changelog[0].urgency vars['urgency'] = self.changelog[0].urgency
vars['signedsourceversion'] = (re.sub(r'-', r'+', vars['imagebinaryversion'])) vars['signedsourceversion'] = (re.sub(r'-', r'+',
vars['imagebinaryversion']))
with codecs.open(self.template_debian_dir + '/changelog', 'w', 'utf-8') as f: with codecs.open(self.template_debian_dir + '/changelog', 'w',
'utf-8') as f:
f.write(self.substitute('''\ f.write(self.substitute('''\
linux-signed-@arch@ (@signedsourceversion@) @distribution@; urgency=@urgency@ linux-signed-@arch@ (@signedsourceversion@) @distribution@; urgency=@urgency@
* Sign kernel from @source@ @imagebinaryversion@ * Sign kernel from @source@ @imagebinaryversion@
''', ''',
vars)) vars))
with codecs.open('debian/changelog', 'r', 'utf-8') as changelog_in: with codecs.open('debian/changelog', 'r', 'utf-8') as changelog_in:
# Ignore first two header lines # Ignore first two header lines
@ -269,7 +299,7 @@ linux-signed-@arch@ (@signedsourceversion@) @distribution@; urgency=@urgency@
all_files = {} all_files = {}
for image_suffix, image_package_name, cert_file_name in \ for image_suffix, image_package_name, cert_file_name in \
self.image_packages: self.image_packages:
package_dir = 'debian/%s' % image_package_name package_dir = 'debian/%s' % image_package_name
package_files = [] package_files = []
package_files.append({'sig_type': 'efi', package_files.append({'sig_type': 'efi',
@ -281,7 +311,7 @@ linux-signed-@arch@ (@signedsourceversion@) @distribution@; urgency=@urgency@
package_files.append( package_files.append(
{'sig_type': 'linux-module', {'sig_type': 'linux-module',
'file': '%s/%s' % 'file': '%s/%s' %
(root[len(package_dir) + 1 :], name)}) (root[(len(package_dir) + 1):], name)})
package_certs = [get_cert_fingerprint(cert, 'sha256') package_certs = [get_cert_fingerprint(cert, 'sha256')
for cert in get_certs(cert_file_name)] for cert in get_certs(cert_file_name)]
assert len(package_certs) >= 1 assert len(package_certs) >= 1
@ -293,5 +323,6 @@ linux-signed-@arch@ (@signedsourceversion@) @distribution@; urgency=@urgency@
with codecs.open(self.template_top_dir + '/files.json', 'w') as f: with codecs.open(self.template_top_dir + '/files.json', 'w') as f:
json.dump(all_files, f) json.dump(all_files, f)
if __name__ == '__main__': if __name__ == '__main__':
Gencontrol(sys.argv[1])() Gencontrol(sys.argv[1])()

31
debian/bin/genorig.py vendored
View File

@ -1,8 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys import sys
sys.path.append("debian/lib/python")
import deb822 import deb822
import glob import glob
import os import os
@ -13,6 +11,7 @@ import subprocess
import time import time
import warnings import warnings
sys.path.append("debian/lib/python")
from debian_linux.debian import Changelog, VersionLinux from debian_linux.debian import Changelog, VersionLinux
@ -33,7 +32,8 @@ class Main(object):
if self.version_dfsg is None: if self.version_dfsg is None:
self.version_dfsg = '0' self.version_dfsg = '0'
self.log('Using source name %s, version %s, dfsg %s\n' % (source, version.upstream, self.version_dfsg)) self.log('Using source name %s, version %s, dfsg %s\n' %
(source, version.upstream, self.version_dfsg))
self.orig = '%s-%s' % (source, version.upstream) self.orig = '%s-%s' % (source, version.upstream)
self.orig_tar = '%s_%s.orig.tar.xz' % (source, version.upstream) self.orig_tar = '%s_%s.orig.tar.xz' % (source, version.upstream)
@ -76,7 +76,7 @@ class Main(object):
verify_proc = subprocess.Popen(['git', verify_proc = subprocess.Popen(['git',
'-c', 'gpg.program=%s' % gpg_wrapper, '-c', 'gpg.program=%s' % gpg_wrapper,
'tag', '-v', self.tag], 'tag', '-v', self.tag],
cwd=input_repo) cwd=input_repo)
if verify_proc.wait(): if verify_proc.wait():
raise RuntimeError("GPG tag verification failed") raise RuntimeError("GPG tag verification failed")
@ -94,7 +94,9 @@ class Main(object):
def upstream_extract(self, input_tar): def upstream_extract(self, input_tar):
self.log("Extracting tarball %s\n" % input_tar) self.log("Extracting tarball %s\n" % input_tar)
match = re.match(r'(^|.*/)(?P<dir>linux-\d+\.\d+(\.\d+)?(-\S+)?)\.tar(\.(?P<extension>(bz2|gz|xz)))?$', input_tar) match = re.match(r'(^|.*/)(?P<dir>linux-\d+\.\d+(\.\d+)?(-\S+)?)\.tar'
r'(\.(?P<extension>(bz2|gz|xz)))?$',
input_tar)
if not match: if not match:
raise RuntimeError("Can't identify name of tarball") raise RuntimeError("Can't identify name of tarball")
@ -103,11 +105,14 @@ class Main(object):
if subprocess.Popen(cmdline).wait(): if subprocess.Popen(cmdline).wait():
raise RuntimeError("Can't extract tarball") raise RuntimeError("Can't extract tarball")
os.rename(os.path.join(self.dir, match.group('dir')), os.path.join(self.dir, self.orig)) os.rename(os.path.join(self.dir, match.group('dir')),
os.path.join(self.dir, self.orig))
def upstream_patch(self, input_patch): def upstream_patch(self, input_patch):
self.log("Patching source with %s\n" % input_patch) self.log("Patching source with %s\n" % input_patch)
match = re.match(r'(^|.*/)patch-\d+\.\d+(\.\d+)?(-\S+?)?(\.(?P<extension>(bz2|gz|xz)))?$', input_patch) match = re.match(r'(^|.*/)patch-\d+\.\d+(\.\d+)?(-\S+?)?'
r'(\.(?P<extension>(bz2|gz|xz)))?$',
input_patch)
if not match: if not match:
raise RuntimeError("Can't identify name of patch") raise RuntimeError("Can't identify name of patch")
cmdline = [] cmdline = []
@ -120,7 +125,8 @@ class Main(object):
else: else:
cmdline.append('cat') cmdline.append('cat')
cmdline.append(input_patch) cmdline.append(input_patch)
cmdline.append('| (cd %s; patch -p1 -f -s -t --no-backup-if-mismatch)' % os.path.join(self.dir, self.orig)) cmdline.append('| (cd %s; patch -p1 -f -s -t --no-backup-if-mismatch)'
% os.path.join(self.dir, self.orig))
if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', ' '.join(cmdline)]): if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', ' '.join(cmdline)]):
raise RuntimeError("Can't patch source") raise RuntimeError("Can't patch source")
@ -174,21 +180,24 @@ class Main(object):
try: try:
subprocess.run(cmd, env=env, check=True) subprocess.run(cmd, env=env, check=True)
os.chmod(out, 0o644) os.chmod(out, 0o644)
except: except BaseException:
try: try:
os.unlink(out) os.unlink(out)
except OSError: except OSError:
pass pass
raise raise
try: try:
os.symlink(os.path.join('orig', self.orig_tar), os.path.join('..', self.orig_tar)) os.symlink(os.path.join('orig', self.orig_tar),
os.path.join('..', self.orig_tar))
except OSError: except OSError:
pass pass
if __name__ == '__main__': if __name__ == '__main__':
from optparse import OptionParser from optparse import OptionParser
parser = OptionParser(usage="%prog [OPTION]... {TAR [PATCH] | REPO}") parser = OptionParser(usage="%prog [OPTION]... {TAR [PATCH] | REPO}")
parser.add_option("-V", "--override-version", dest="override_version", help="Override version", metavar="VERSION") parser.add_option("-V", "--override-version", dest="override_version",
help="Override version", metavar="VERSION")
options, args = parser.parse_args() options, args = parser.parse_args()
assert 1 <= len(args) <= 2 assert 1 <= len(args) <= 2

View File

@ -1,6 +1,16 @@
#!/usr/bin/python3 #!/usr/bin/python3
import codecs, errno, io, os, os.path, re, shutil, subprocess, sys, tempfile import codecs
import errno
import io
import os
import os.path
import re
import shutil
import subprocess
import sys
import tempfile
def main(repo, range='torvalds/master..dhowells/efi-lock-down'): def main(repo, range='torvalds/master..dhowells/efi-lock-down'):
patch_dir = 'debian/patches' patch_dir = 'debian/patches'
@ -62,17 +72,20 @@ def main(repo, range='torvalds/master..dhowells/efi-lock-down'):
env['GIT_DIR'] = os.path.join(repo, '.git') env['GIT_DIR'] = os.path.join(repo, '.git')
args = ['git', 'format-patch', '--subject-prefix=', range] args = ['git', 'format-patch', '--subject-prefix=', range]
format_proc = subprocess.Popen(args, format_proc = subprocess.Popen(args,
cwd=os.path.join(patch_dir, lockdown_patch_dir), cwd=os.path.join(patch_dir,
lockdown_patch_dir),
env=env, stdout=subprocess.PIPE) env=env, stdout=subprocess.PIPE)
with io.open(format_proc.stdout.fileno(), encoding='utf-8') as pipe: with io.open(format_proc.stdout.fileno(), encoding='utf-8') as pipe:
for line in pipe: for line in pipe:
name = line.strip('\n') name = line.strip('\n')
with open(os.path.join(patch_dir, lockdown_patch_dir, name)) as \ with open(os.path.join(patch_dir, lockdown_patch_dir, name)) \
source_patch: as source_patch:
patch_from = source_patch.readline() patch_from = source_patch.readline()
match = re.match(r'From ([0-9a-f]{40}) ', patch_from) match = re.match(r'From ([0-9a-f]{40}) ', patch_from)
assert match assert match
origin = 'https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/commit?id=%s' % match.group(1) origin = ('https://git.kernel.org/pub/scm/linux/kernel/'
'git/dhowells/linux-fs.git/commit?id=%s' %
match.group(1))
add_patch(name, source_patch, origin) add_patch(name, source_patch, origin)
for line in series_after: for line in series_after:
@ -87,6 +100,7 @@ def main(repo, range='torvalds/master..dhowells/efi-lock-down'):
for name in old_series: for name in old_series:
print('Obsoleted patch', os.path.join(patch_dir, name)) print('Obsoleted patch', os.path.join(patch_dir, name))
if __name__ == '__main__': if __name__ == '__main__':
if not (2 <= len(sys.argv) <= 3): if not (2 <= len(sys.argv) <= 3):
sys.stderr.write('''\ sys.stderr.write('''\

View File

@ -1,6 +1,16 @@
#!/usr/bin/python3 #!/usr/bin/python3
import codecs, errno, io, os, os.path, re, shutil, subprocess, sys, tempfile import codecs
import errno
import io
import os
import os.path
import re
import shutil
import subprocess
import sys
import tempfile
def main(source, version=None): def main(source, version=None):
patch_dir = 'debian/patches-rt' patch_dir = 'debian/patches-rt'
@ -46,25 +56,29 @@ def main(source, version=None):
# Validate tag signature # Validate tag signature
gpg_wrapper = os.path.join(os.getcwd(), gpg_wrapper = os.path.join(os.getcwd(),
"debian/bin/git-tag-gpg-wrapper") "debian/bin/git-tag-gpg-wrapper")
verify_proc = subprocess.Popen(['git', verify_proc = subprocess.Popen(
'-c', 'gpg.program=%s' % gpg_wrapper, ['git', '-c', 'gpg.program=%s' % gpg_wrapper,
'tag', '-v', 'v%s-rebase' % version], 'tag', '-v', 'v%s-rebase' % version],
env=env) env=env)
if verify_proc.wait(): if verify_proc.wait():
raise RuntimeError("GPG tag verification failed") raise RuntimeError("GPG tag verification failed")
args = ['git', 'format-patch', 'v%s..v%s-rebase' % (up_ver, version)] args = ['git', 'format-patch',
'v%s..v%s-rebase' % (up_ver, version)]
format_proc = subprocess.Popen(args, format_proc = subprocess.Popen(args,
cwd=patch_dir, cwd=patch_dir,
env=env, stdout=subprocess.PIPE) env=env, stdout=subprocess.PIPE)
with io.open(format_proc.stdout.fileno(), encoding='utf-8') as pipe: with io.open(format_proc.stdout.fileno(), encoding='utf-8') \
as pipe:
for line in pipe: for line in pipe:
name = line.strip('\n') name = line.strip('\n')
with open(os.path.join(patch_dir, name)) as source_patch: with open(os.path.join(patch_dir, name)) as source_patch:
patch_from = source_patch.readline() patch_from = source_patch.readline()
match = re.match(r'From ([0-9a-f]{40}) ', patch_from) match = re.match(r'From ([0-9a-f]{40}) ', patch_from)
assert match assert match
origin = 'https://git.kernel.org/cgit/linux/kernel/git/rt/linux-stable-rt.git/commit?id=%s' % match.group(1) origin = ('https://git.kernel.org/cgit/linux/kernel/'
'git/rt/linux-stable-rt.git/commit?id=%s' %
match.group(1))
add_patch(name, source_patch, origin) add_patch(name, source_patch, origin)
else: else:
@ -90,7 +104,7 @@ def main(source, version=None):
not re.search(r'^\[GNUPG:\]\s+VALIDSIG\s', not re.search(r'^\[GNUPG:\]\s+VALIDSIG\s',
codecs.decode(verify_output), codecs.decode(verify_output),
re.MULTILINE): re.MULTILINE):
os.write(2, verify_output) # bytes not str! os.write(2, verify_output) # bytes not str!
raise RuntimeError("GPG signature verification failed") raise RuntimeError("GPG signature verification failed")
temp_dir = tempfile.mkdtemp(prefix='rt-genpatch', dir='debian') temp_dir = tempfile.mkdtemp(prefix='rt-genpatch', dir='debian')
@ -98,16 +112,20 @@ def main(source, version=None):
# Unpack tarball # Unpack tarball
subprocess.check_call(['tar', '-C', temp_dir, '-xaf', source]) subprocess.check_call(['tar', '-C', temp_dir, '-xaf', source])
source_dir = os.path.join(temp_dir, 'patches') source_dir = os.path.join(temp_dir, 'patches')
assert os.path.isdir(source_dir), 'tarball does not contain patches directory' assert os.path.isdir(source_dir), \
'tarball does not contain patches directory'
# Copy patch series # Copy patch series
origin = 'https://www.kernel.org/pub/linux/kernel/projects/rt/%s/older/patches-%s.tar.xz' % (up_ver, version) origin = ('https://www.kernel.org/pub/linux/kernel/projects/'
with open(os.path.join(source_dir, 'series'), 'r') as \ 'rt/%s/older/patches-%s.tar.xz' %
source_series_fh: (up_ver, version))
with open(os.path.join(source_dir, 'series'), 'r') \
as source_series_fh:
for line in source_series_fh: for line in source_series_fh:
name = line.strip() name = line.strip()
if name != '' and name[0] != '#': if name != '' and name[0] != '#':
with open(os.path.join(source_dir, name)) as source_patch: with open(os.path.join(source_dir, name)) \
as source_patch:
add_patch(name, source_patch, origin) add_patch(name, source_patch, origin)
series_fh.write(line) series_fh.write(line)
finally: finally:
@ -122,10 +140,13 @@ def main(source, version=None):
for name in old_series: for name in old_series:
print('Obsoleted patch', os.path.join(patch_dir, name)) print('Obsoleted patch', os.path.join(patch_dir, name))
if __name__ == '__main__': if __name__ == '__main__':
if not (1 <= len(sys.argv) <= 3): if not (1 <= len(sys.argv) <= 3):
print('Usage: %s {TAR [RT-VERSION] | REPO RT-VERSION}' % sys.argv[0], file=sys.stderr) print('Usage: %s {TAR [RT-VERSION] | REPO RT-VERSION}' % sys.argv[0],
file=sys.stderr)
print('TAR is a tarball of patches.', file=sys.stderr) print('TAR is a tarball of patches.', file=sys.stderr)
print('REPO is a git repo containing the given RT-VERSION.', file=sys.stderr) print('REPO is a git repo containing the given RT-VERSION.',
file=sys.stderr)
sys.exit(2) sys.exit(2)
main(*sys.argv[1:]) main(*sys.argv[1:])

View File

@ -1,8 +1,8 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys import sys
sys.path.append(sys.path[0] + "/../lib/python")
sys.path.append(sys.path[0] + "/../lib/python")
from debian_linux.config import ConfigCoreDump from debian_linux.config import ConfigCoreDump
section = tuple(s or None for s in sys.argv[1:-1]) section = tuple(s or None for s in sys.argv[1:-1])
@ -24,4 +24,3 @@ else:
except TypeError: except TypeError:
# Otherwise use the default format # Otherwise use the default format
print(value) print(value)

View File

@ -1,18 +1,21 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys import sys
import os
import re
import subprocess
sys.path.append(sys.path[0] + "/../lib/python") sys.path.append(sys.path[0] + "/../lib/python")
import os, re, subprocess
from debian_linux.debian import Changelog, VersionLinux from debian_linux.debian import Changelog, VersionLinux
def base_version(ver): def base_version(ver):
# Assume base version is at least 3.0, thus only 2 components wanted # Assume base version is at least 3.0, thus only 2 components wanted
match = re.match(r'^(\d+\.\d+)', ver) match = re.match(r'^(\d+\.\d+)', ver)
assert match assert match
return match.group(1) return match.group(1)
def add_update(ver, inc): def add_update(ver, inc):
base = base_version(ver) base = base_version(ver)
if base == ver: if base == ver:
@ -25,9 +28,11 @@ def add_update(ver, inc):
else: else:
return '{}.{}'.format(base, update) return '{}.{}'.format(base, update)
def next_update(ver): def next_update(ver):
return add_update(ver, 1) return add_update(ver, 1)
def print_stable_log(log, cur_ver, new_ver): def print_stable_log(log, cur_ver, new_ver):
major_ver = re.sub(r'^(\d+)\..*', r'\1', cur_ver) major_ver = re.sub(r'^(\d+)\..*', r'\1', cur_ver)
while cur_ver != new_ver: while cur_ver != new_ver:
@ -35,13 +40,14 @@ def print_stable_log(log, cur_ver, new_ver):
print(' https://www.kernel.org/pub/linux/kernel/v{}.x/ChangeLog-{}' print(' https://www.kernel.org/pub/linux/kernel/v{}.x/ChangeLog-{}'
.format(major_ver, next_ver), .format(major_ver, next_ver),
file=log) file=log)
log.flush() # serialise our output with git's log.flush() # serialise our output with git's
subprocess.check_call(['git', 'log', '--reverse', subprocess.check_call(['git', 'log', '--reverse',
'--pretty= - %s', '--pretty= - %s',
'v{}..v{}^'.format(cur_ver, next_ver)], 'v{}..v{}^'.format(cur_ver, next_ver)],
stdout=log) stdout=log)
cur_ver = next_ver cur_ver = next_ver
def main(repo, new_ver): def main(repo, new_ver):
if os.path.exists(os.path.join(repo, '.git')): if os.path.exists(os.path.join(repo, '.git')):
os.environ['GIT_DIR'] = os.path.join(repo, '.git') os.environ['GIT_DIR'] = os.path.join(repo, '.git')
@ -118,6 +124,7 @@ def main(repo, new_ver):
os.rename('debian/changelog.new', 'debian/changelog') os.rename('debian/changelog.new', 'debian/changelog')
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) != 3: if len(sys.argv) != 3:
print('''\ print('''\

1
debian/changelog vendored
View File

@ -5,6 +5,7 @@ linux (4.19~rc6-1~exp1) UNRELEASED; urgency=medium
[ Ben Hutchings ] [ Ben Hutchings ]
* [ppc64el] udeb: Fix relative #include filenames in kernel-image module * [ppc64el] udeb: Fix relative #include filenames in kernel-image module
list (really fixes FTBFS?) list (really fixes FTBFS?)
* debian/bin, debian/lib/python: Fix most errors reported by pycodestyle
-- Ben Hutchings <ben@decadent.org.uk> Thu, 20 Sep 2018 02:40:54 +0100 -- Ben Hutchings <ben@decadent.org.uk> Thu, 20 Sep 2018 02:40:54 +0100

View File

@ -39,4 +39,4 @@ class Symbols(dict):
def write(self, file): def write(self, file):
for s in sorted(self.values(), key=lambda i: i.name): for s in sorted(self.values(), key=lambda i: i.name):
file.write("%s %s %s %s\n" % file.write("%s %s %s %s\n" %
(s.version, s.name, s.module, s.export)) (s.version, s.name, s.module, s.export))

View File

@ -50,7 +50,8 @@ class ConfigCore(collections.OrderedDict):
temp = [] temp = []
if arch and featureset and flavour: if arch and featureset and flavour:
temp.append(self.get((section, arch, featureset, flavour), {}).get(key)) temp.append(self.get((section, arch, featureset, flavour), {})
.get(key))
temp.append(self.get((section, arch, None, flavour), {}).get(key)) temp.append(self.get((section, arch, None, flavour), {}).get(key))
if arch and featureset: if arch and featureset:
temp.append(self.get((section, arch, featureset), {}).get(key)) temp.append(self.get((section, arch, featureset), {}).get(key))
@ -157,7 +158,8 @@ class ConfigCoreHierarchy(object):
base['featuresets'] = featuresets base['featuresets'] = featuresets
del base['flavours'] del base['flavours']
ret['base', arch] = base ret['base', arch] = base
ret['base', arch, 'none'] = {'flavours': flavours, 'implicit-flavour': True} ret['base', arch, 'none'] = {'flavours': flavours,
'implicit-flavour': True}
def read_arch_featureset(self, ret, arch, featureset): def read_arch_featureset(self, ret, arch, featureset):
config = ConfigParser(self.schema) config = ConfigParser(self.schema)
@ -241,7 +243,7 @@ class ConfigParser(object):
value = schema[key](value) value = schema[key](value)
ret[key] = value ret[key] = value
return ret return ret
def keys(self): def keys(self):
return self._convert().keys() return self._convert().keys()
@ -253,7 +255,8 @@ if __name__ == '__main__':
import sys import sys
sys.path.append('debian/lib/python') sys.path.append('debian/lib/python')
config = ConfigCoreDump(open('debian/config.defines.dump', 'rb')) 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])): for section, items in sorted(config.items(),
key=(lambda a: tuple(i or '' for i in a[0]))):
print(u"[%s]" % (section,)) print(u"[%s]" % (section,))
for item, value in sorted(items.items()): for item, value in sorted(items.items()):
print(u"%s: %s" % (item, value)) print(u"%s: %s" % (item, value))

View File

@ -45,7 +45,8 @@ class Changelog(list):
_ignore_re = re.compile(r'^(?: |\s*\n)') _ignore_re = re.compile(r'^(?: |\s*\n)')
class Entry(object): class Entry(object):
__slot__ = 'distribution', 'source', 'version', 'urgency', 'maintainer', 'date' __slot__ = ('distribution', 'source', 'version', 'urgency',
'maintainer', 'date')
def __init__(self, **kwargs): def __init__(self, **kwargs):
for key, value in kwargs.items(): for key, value in kwargs.items():
@ -57,7 +58,8 @@ class Changelog(list):
if file: if file:
self._parse(version, file) self._parse(version, file)
else: else:
with open(os.path.join(dir, "debian/changelog"), encoding="UTF-8") as f: with open(os.path.join(dir, "debian/changelog"),
encoding="UTF-8") as f:
self._parse(version, f) self._parse(version, f)
def _parse(self, version, f): def _parse(self, version, f):
@ -72,7 +74,8 @@ class Changelog(list):
elif top_match is None: elif top_match is None:
top_match = self._top_re.match(line) top_match = self._top_re.match(line)
if not top_match: if not top_match:
raise Exception('invalid top line %d in changelog' % line_no) raise Exception('invalid top line %d in changelog' %
line_no)
try: try:
v = version(top_match.group('version')) v = version(top_match.group('version'))
except Exception: except Exception:
@ -82,16 +85,19 @@ class Changelog(list):
else: else:
bottom_match = self._bottom_re.match(line) bottom_match = self._bottom_re.match(line)
if not bottom_match: if not bottom_match:
raise Exception('invalid bottom line %d in changelog' % line_no) raise Exception('invalid bottom line %d in changelog' %
line_no)
self.append(self.Entry(distribution=top_match.group('distribution'), self.append(self.Entry(
source=top_match.group('source'), distribution=top_match.group('distribution'),
version=v, source=top_match.group('source'),
urgency=top_match.group('urgency'), version=v,
maintainer=bottom_match.group('maintainer'), urgency=top_match.group('urgency'),
date=bottom_match.group('date'))) maintainer=bottom_match.group('maintainer'),
date=bottom_match.group('date')))
top_match = bottom_match = None top_match = bottom_match = None
class Version(object): class Version(object):
_epoch_re = re.compile(r'\d+$') _epoch_re = re.compile(r'\d+$')
_upstream_re = re.compile(r'[0-9][A-Za-z0-9.+\-:~]*$') _upstream_re = re.compile(r'[0-9][A-Za-z0-9.+\-:~]*$')
@ -110,9 +116,9 @@ class Version(object):
upstream, revision = rest, None upstream, revision = rest, None
else: else:
upstream, revision = rest[0:split], rest[split+1:] upstream, revision = rest[0:split], rest[split+1:]
if ((epoch is not None and not self._epoch_re.match(epoch)) or if (epoch is not None and not self._epoch_re.match(epoch)) or \
not self._upstream_re.match(upstream) or not self._upstream_re.match(upstream) or \
(revision is not None and not self._revision_re.match(revision))): (revision is not None and not self._revision_re.match(revision)):
raise RuntimeError(u"Invalid debian version") raise RuntimeError(u"Invalid debian version")
self.epoch = epoch and int(epoch) self.epoch = epoch and int(epoch)
self.upstream = upstream self.upstream = upstream
@ -136,7 +142,8 @@ class Version(object):
@property @property
def debian(self): def debian(self):
from warnings import warn from warnings import warn
warn(u"debian argument was replaced by revision", DeprecationWarning, stacklevel=2) warn(u"debian argument was replaced by revision", DeprecationWarning,
stacklevel=2)
return self.revision return self.revision
@ -379,7 +386,7 @@ class _VersionLinuxTest(unittest.TestCase):
self.assertFalse(v.linux_revision_other) self.assertFalse(v.linux_revision_other)
def test_other_revision(self): def test_other_revision(self):
v = VersionLinux('4.16.5-1+revert+crng+ready') # from #898087 v = VersionLinux('4.16.5-1+revert+crng+ready') # from #898087
self.assertFalse(v.linux_revision_experimental) self.assertFalse(v.linux_revision_experimental)
self.assertFalse(v.linux_revision_security) self.assertFalse(v.linux_revision_security)
self.assertFalse(v.linux_revision_backports) self.assertFalse(v.linux_revision_backports)
@ -537,7 +544,8 @@ class PackageRelationGroup(list):
class PackageRelationEntry(object): class PackageRelationEntry(object):
__slots__ = "name", "operator", "version", "arches", "restrictions" __slots__ = "name", "operator", "version", "arches", "restrictions"
_re = re.compile(r'^(\S+)(?: \((<<|<=|=|!=|>=|>>)\s*([^)]+)\))?(?: \[([^]]+)\])?(?: <([^>]+)>)?$') _re = re.compile(r'^(\S+)(?: \((<<|<=|=|!=|>=|>>)\s*([^)]+)\))?'
r'(?: \[([^]]+)\])?(?: <([^>]+)>)?$')
class _operator(object): class _operator(object):
OP_LT = 1 OP_LT = 1
@ -573,7 +581,8 @@ class PackageRelationEntry(object):
self._op = self.operators[value] self._op = self.operators[value]
def __neg__(self): def __neg__(self):
return self.__class__(self.operators_text[self.operators_neg[self._op]]) return self.__class__(
self.operators_text[self.operators_neg[self._op]])
def __str__(self): def __str__(self):
return self.operators_text[self._op] return self.operators_text[self._op]

View File

@ -80,7 +80,8 @@ class FirmwareWhence(list):
licence = value licence = value
elif licence is not None: elif licence is not None:
licence = (licence + '\n' + licence = (licence + '\n' +
re.sub(r'^(?:[/ ]\*| \*/)?\s*(.*?)\s*$', r'\1', line)) re.sub(r'^(?:[/ ]\*| \*/)?\s*(.*?)\s*$', r'\1',
line))
# Finish last section if non-empty # Finish last section if non-empty
for b in binary: for b in binary:

View File

@ -116,19 +116,25 @@ class Gencontrol(object):
pass pass
def do_main_makefile(self, makefile, makeflags, extra): def do_main_makefile(self, makefile, makeflags, extra):
makefile.add('build-indep', cmds=["$(MAKE) -f debian/rules.real build-indep %s" % makeflags]) makefile.add('build-indep',
makefile.add('binary-indep', cmds=["$(MAKE) -f debian/rules.real binary-indep %s" % makeflags]) cmds=["$(MAKE) -f debian/rules.real build-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 featureset in self.config['base', ]['featuresets']: for featureset in self.config['base', ]['featuresets']:
if self.config.merge('base', None, featureset).get('enabled', True): if self.config.merge('base', None, featureset) \
.get('enabled', True):
self.do_indep_featureset(packages, makefile, featureset, self.do_indep_featureset(packages, makefile, featureset,
vars.copy(), makeflags.copy(), extra) vars.copy(), makeflags.copy(), 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):
templates_extra = self.templates.get("control.extra", None) templates_extra = self.templates.get("control.extra", None)
@ -147,12 +153,15 @@ class Gencontrol(object):
for arch in sorted(extra_arches.keys()): for arch in sorted(extra_arches.keys()):
cmds = [] cmds = []
for i in extra_arches[arch]: for i in extra_arches[arch]:
cmds.append("$(MAKE) -f debian/rules.real install-dummy ARCH='%s' DH_OPTIONS='-p%s'" % (arch, i['Package'])) cmds.append("$(MAKE) -f debian/rules.real install-dummy "
makefile.add('binary-arch_%s' % arch, ['binary-arch_%s_extra' % arch]) "ARCH='%s' DH_OPTIONS='-p%s'" %
makefile.add("binary-arch_%s_extra" % arch, cmds = cmds) (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_indep_featureset(self, packages, makefile, featureset, vars, def do_indep_featureset(self, packages, makefile, featureset, vars,
makeflags, extra): makeflags, extra):
vars['localversion'] = '' vars['localversion'] = ''
if featureset != 'none': if featureset != 'none':
vars['localversion'] = '-' + featureset vars['localversion'] = '-' + featureset
@ -202,14 +211,18 @@ class Gencontrol(object):
makefile.add(target1, [target2]) makefile.add(target1, [target2])
makefile.add(target2, [target3]) makefile.add(target2, [target3])
def do_arch_packages(self, packages, makefile, arch, vars, makeflags, extra): def do_arch_packages(self, packages, makefile, arch, vars, makeflags,
extra):
pass pass
def do_arch_recurse(self, packages, makefile, arch, vars, makeflags, extra): def do_arch_recurse(self, packages, makefile, arch, vars, makeflags,
extra):
for featureset in self.config['base', arch].get('featuresets', ()): for featureset in self.config['base', arch].get('featuresets', ()):
self.do_featureset(packages, makefile, arch, featureset, vars.copy(), makeflags.copy(), extra) self.do_featureset(packages, makefile, arch, featureset,
vars.copy(), makeflags.copy(), extra)
def do_featureset(self, packages, makefile, arch, featureset, vars, makeflags, extra): def do_featureset(self, packages, makefile, arch, featureset, vars,
makeflags, extra):
config_base = self.config.merge('base', arch, featureset) config_base = self.config.merge('base', arch, featureset)
if not config_base.get('enabled', True): if not config_base.get('enabled', True):
return return
@ -219,14 +232,18 @@ class Gencontrol(object):
vars['localversion'] = '-' + featureset vars['localversion'] = '-' + featureset
self.do_featureset_setup(vars, makeflags, arch, featureset, extra) self.do_featureset_setup(vars, makeflags, arch, featureset, extra)
self.do_featureset_makefile(makefile, arch, featureset, makeflags, extra) self.do_featureset_makefile(makefile, arch, featureset, makeflags,
self.do_featureset_packages(packages, makefile, arch, featureset, vars, makeflags, extra) extra)
self.do_featureset_recurse(packages, makefile, arch, featureset, vars, makeflags, extra) self.do_featureset_packages(packages, makefile, arch, featureset, vars,
makeflags, extra)
self.do_featureset_recurse(packages, makefile, arch, featureset, vars,
makeflags, extra)
def do_featureset_setup(self, vars, makeflags, arch, featureset, extra): def do_featureset_setup(self, vars, makeflags, arch, featureset, extra):
pass pass
def do_featureset_makefile(self, makefile, arch, featureset, makeflags, extra): def do_featureset_makefile(self, makefile, arch, featureset, makeflags,
extra):
makeflags['FEATURESET'] = featureset makeflags['FEATURESET'] = featureset
for i in self.makefile_targets: for i in self.makefile_targets:
@ -236,31 +253,40 @@ class Gencontrol(object):
makefile.add(target1, [target2]) makefile.add(target1, [target2])
makefile.add(target2, [target3]) makefile.add(target2, [target3])
def do_featureset_packages(self, packages, makefile, arch, featureset, vars, makeflags, extra): def do_featureset_packages(self, packages, makefile, arch, featureset,
vars, makeflags, extra):
pass pass
def do_featureset_recurse(self, packages, makefile, arch, featureset, vars, makeflags, extra): def do_featureset_recurse(self, packages, makefile, arch, featureset, vars,
makeflags, extra):
for flavour in self.config['base', arch, featureset]['flavours']: for flavour in self.config['base', arch, featureset]['flavours']:
self.do_flavour(packages, makefile, arch, featureset, flavour, vars.copy(), makeflags.copy(), extra) self.do_flavour(packages, makefile, arch, featureset, flavour,
vars.copy(), makeflags.copy(), extra)
def do_flavour(self, packages, makefile, arch, featureset, flavour, vars, makeflags, extra): def do_flavour(self, packages, makefile, arch, featureset, flavour, vars,
makeflags, extra):
config_base = self.config.merge('base', arch, featureset, flavour) config_base = self.config.merge('base', arch, featureset, flavour)
vars['localversion'] += '-' + flavour vars['localversion'] += '-' + flavour
self.do_flavour_setup(vars, makeflags, arch, featureset, flavour, extra) self.do_flavour_setup(vars, makeflags, arch, featureset, flavour,
self.do_flavour_makefile(makefile, arch, featureset, flavour, makeflags, extra) extra)
self.do_flavour_packages(packages, makefile, arch, featureset, flavour, vars, makeflags, extra) self.do_flavour_makefile(makefile, arch, featureset, flavour,
makeflags, extra)
self.do_flavour_packages(packages, makefile, arch, featureset, flavour,
vars, makeflags, extra)
def do_flavour_setup(self, vars, makeflags, arch, featureset, flavour, extra): def do_flavour_setup(self, vars, makeflags, arch, featureset, flavour,
extra):
for i in ( for i in (
('kernel-arch', 'KERNEL_ARCH'), ('kernel-arch', 'KERNEL_ARCH'),
('localversion', 'LOCALVERSION'), ('localversion', 'LOCALVERSION'),
): ):
if i[0] in vars: 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):
makeflags['FLAVOUR'] = flavour makeflags['FLAVOUR'] = flavour
for i in self.makefile_targets: for i in self.makefile_targets:
@ -270,7 +296,8 @@ class Gencontrol(object):
makefile.add(target1, [target2]) makefile.add(target1, [target2])
makefile.add(target2, [target3]) makefile.add(target2, [target3])
def do_flavour_packages(self, packages, makefile, arch, featureset, flavour, vars, makeflags, extra): def do_flavour_packages(self, packages, makefile, arch, featureset,
flavour, vars, makeflags, extra):
pass pass
def process_relation(self, dep, vars): def process_relation(self, dep, vars):
@ -365,6 +392,7 @@ class Gencontrol(object):
f.write(u"%s: %s\n" % (key, value)) f.write(u"%s: %s\n" % (key, value))
f.write('\n') f.write('\n')
def merge_packages(packages, new, arch): def merge_packages(packages, new, arch):
for new_package in new: for new_package in new:
name = new_package['Package'] name = new_package['Package']
@ -372,7 +400,8 @@ def merge_packages(packages, new, arch):
package = packages.get(name) package = packages.get(name)
package['Architecture'].add(arch) package['Architecture'].add(arch)
for field in 'Depends', 'Provides', 'Suggests', 'Recommends', 'Conflicts': for field in ('Depends', 'Provides', 'Suggests', 'Recommends',
'Conflicts'):
if field in new_package: if field in new_package:
if field in package: if field in package:
v = package[field] v = package[field]

View File

@ -19,7 +19,9 @@ class KConfigEntry(object):
return hash(self.name) | hash(self.value) return hash(self.name) | hash(self.value)
def __repr__(self): def __repr__(self):
return '<{}({!r}, {!r}, {!r})>'.format(self.__class__.__name__, self.name, self.value, self.comments) return ('<{}({!r}, {!r}, {!r})>'
.format(self.__class__.__name__, self.name, self.value,
self.comments))
def __str__(self): def __str__(self):
return 'CONFIG_{}={}'.format(self.name, self.value) return 'CONFIG_{}={}'.format(self.name, self.value)

View File

@ -44,10 +44,12 @@ def read_control(f):
from .debian import Package from .debian import Package
return _read_rfc822(f, Package) return _read_rfc822(f, Package)
def read_tests_control(f): def read_tests_control(f):
from .debian import TestsControl from .debian import TestsControl
return _read_rfc822(f, TestsControl) return _read_rfc822(f, TestsControl)
def _read_rfc822(f, cls): def _read_rfc822(f, cls):
entries = [] entries = []
eof = False eof = False
@ -69,14 +71,16 @@ def _read_rfc822(f, cls):
break break
if line[0] in ' \t': if line[0] in ' \t':
if not last: if not last:
raise ValueError('Continuation line seen before first header') raise ValueError(
'Continuation line seen before first header')
lines.append(line.lstrip()) lines.append(line.lstrip())
continue continue
if last: if last:
e[last] = '\n'.join(lines) e[last] = '\n'.join(lines)
i = line.find(':') i = line.find(':')
if i < 0: if i < 0:
raise ValueError(u"Not a header, not a continuation: ``%s''" % line) raise ValueError(u"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: