2015-08-29 20:48:39 +00:00
|
|
|
#!/usr/bin/env python3
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2012-01-11 17:00:17 +00:00
|
|
|
import sys
|
2008-05-01 07:54:28 +00:00
|
|
|
sys.path.append("debian/lib/python")
|
|
|
|
|
2017-10-20 01:56:35 +00:00
|
|
|
import locale
|
2013-08-17 11:35:06 +00:00
|
|
|
import errno
|
|
|
|
import glob
|
2014-02-15 09:44:36 +00:00
|
|
|
import io
|
2012-01-11 17:00:17 +00:00
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
import subprocess
|
|
|
|
|
2017-10-20 01:56:35 +00:00
|
|
|
locale.setlocale(locale.LC_CTYPE, "C.UTF-8")
|
|
|
|
|
2012-01-11 20:42:40 +00:00
|
|
|
from debian_linux import config
|
2008-05-01 07:54:28 +00:00
|
|
|
from debian_linux.debian import *
|
2016-05-29 13:27:04 +00:00
|
|
|
from debian_linux.gencontrol import Gencontrol as Base, merge_packages
|
2011-09-25 03:12:12 +00:00
|
|
|
from debian_linux.utils import Templates, read_control
|
2008-05-01 07:54:28 +00:00
|
|
|
|
|
|
|
class Gencontrol(Base):
|
2012-01-11 20:42:40 +00:00
|
|
|
config_schema = {
|
|
|
|
'abi': {
|
|
|
|
'ignore-changes': config.SchemaItemList(),
|
|
|
|
},
|
|
|
|
'build': {
|
|
|
|
'debug-info': config.SchemaItemBoolean(),
|
2018-04-05 20:30:30 +00:00
|
|
|
'signed-code': config.SchemaItemBoolean(),
|
2016-01-13 11:02:36 +00:00
|
|
|
'vdso': config.SchemaItemBoolean(),
|
2012-01-11 20:42:40 +00:00
|
|
|
},
|
|
|
|
'description': {
|
|
|
|
'parts': config.SchemaItemList(),
|
|
|
|
},
|
|
|
|
'image': {
|
|
|
|
'bootloaders': config.SchemaItemList(),
|
|
|
|
'configs': config.SchemaItemList(),
|
|
|
|
'initramfs-generators': config.SchemaItemList(),
|
2014-12-10 16:37:52 +00:00
|
|
|
'check-size': config.SchemaItemInteger(),
|
2014-12-10 16:50:18 +00:00
|
|
|
'check-size-with-dtb': config.SchemaItemBoolean(),
|
2017-09-01 15:30:02 +00:00
|
|
|
'check-uncompressed-size': config.SchemaItemInteger(),
|
2012-01-11 20:42:40 +00:00
|
|
|
},
|
|
|
|
'relations': {
|
|
|
|
},
|
2015-11-12 20:17:54 +00:00
|
|
|
'packages': {
|
|
|
|
'docs': config.SchemaItemBoolean(),
|
2015-12-19 16:54:59 +00:00
|
|
|
'headers-all': config.SchemaItemBoolean(),
|
2015-11-12 20:33:20 +00:00
|
|
|
'installer': config.SchemaItemBoolean(),
|
2015-11-12 22:02:36 +00:00
|
|
|
'libc-dev': config.SchemaItemBoolean(),
|
2018-04-29 17:31:05 +00:00
|
|
|
'tools-unversioned': config.SchemaItemBoolean(),
|
|
|
|
'tools-versioned': config.SchemaItemBoolean(),
|
2018-05-08 17:34:58 +00:00
|
|
|
'source': config.SchemaItemBoolean(),
|
2012-01-11 20:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-11 17:00:17 +00:00
|
|
|
def __init__(self, config_dirs=["debian/config"], template_dirs=["debian/templates"]):
|
2013-10-26 21:04:10 +00:00
|
|
|
super(Gencontrol, self).__init__(
|
|
|
|
config.ConfigCoreHierarchy(self.config_schema, config_dirs),
|
|
|
|
Templates(template_dirs),
|
|
|
|
VersionLinux)
|
2008-05-01 07:54:28 +00:00
|
|
|
self.process_changelog()
|
|
|
|
self.config_dirs = config_dirs
|
|
|
|
|
2010-04-20 19:18:56 +00:00
|
|
|
def _setup_makeflags(self, names, makeflags, data):
|
|
|
|
for src, dst, optional in names:
|
|
|
|
if src in data or not optional:
|
|
|
|
makeflags[dst] = data[src]
|
|
|
|
|
2016-03-20 21:39:38 +00:00
|
|
|
def _substitute_file(self, template, vars, target, append=False):
|
2017-10-20 01:56:35 +00:00
|
|
|
with open(target, 'a' if append else 'w') as f:
|
2016-03-20 21:39:38 +00:00
|
|
|
f.write(self.substitute(self.templates[template], vars))
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def do_main_setup(self, vars, makeflags, extra):
|
|
|
|
super(Gencontrol, self).do_main_setup(vars, makeflags, extra)
|
|
|
|
makeflags.update({
|
|
|
|
'VERSION': self.version.linux_version,
|
|
|
|
'UPSTREAMVERSION': self.version.linux_upstream,
|
2014-11-04 04:47:19 +00:00
|
|
|
'ABINAME': self.abiname_version + self.abiname_part,
|
2008-05-01 07:54:28 +00:00
|
|
|
'SOURCEVERSION': self.version.complete,
|
|
|
|
})
|
2018-05-08 15:58:54 +00:00
|
|
|
if not self.config.merge('packages').get('tools-unversioned', True):
|
|
|
|
makeflags['DO_TOOLS_UNVERSIONED'] = False
|
|
|
|
if not self.config.merge('packages').get('tools-versioned', True):
|
|
|
|
makeflags['DO_TOOLS_VERSIONED'] = False
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2015-08-11 22:21:41 +00:00
|
|
|
# Prepare to generate debian/tests/control
|
|
|
|
self.tests_control = None
|
|
|
|
|
2012-06-13 21:54:55 +00:00
|
|
|
def do_main_makefile(self, makefile, makeflags, extra):
|
2012-12-16 15:35:51 +00:00
|
|
|
fs_enabled = [featureset
|
|
|
|
for featureset in self.config['base', ]['featuresets']
|
|
|
|
if self.config.merge('base', None, featureset).get('enabled', True)]
|
|
|
|
for featureset in fs_enabled:
|
2012-06-03 20:54:42 +00:00
|
|
|
makeflags_featureset = makeflags.copy()
|
|
|
|
makeflags_featureset['FEATURESET'] = featureset
|
|
|
|
cmds_source = ["$(MAKE) -f debian/rules.real source-featureset %s"
|
|
|
|
% makeflags_featureset]
|
|
|
|
makefile.add('source_%s_real' % featureset, cmds=cmds_source)
|
|
|
|
makefile.add('source_%s' % featureset,
|
|
|
|
['source_%s_real' % featureset])
|
|
|
|
makefile.add('source', ['source_%s' % featureset])
|
|
|
|
|
2013-07-22 00:02:50 +00:00
|
|
|
triplet_enabled = []
|
|
|
|
for arch in iter(self.config['base', ]['arches']):
|
|
|
|
for featureset in self.config['base', arch].get('featuresets', ()):
|
|
|
|
if self.config.merge('base', None, featureset).get('enabled', True):
|
|
|
|
for flavour in self.config['base', arch, featureset]['flavours']:
|
|
|
|
triplet_enabled.append('%s_%s_%s' %
|
|
|
|
(arch, featureset, flavour))
|
|
|
|
|
2012-06-13 21:54:55 +00:00
|
|
|
makeflags = makeflags.copy()
|
2012-12-16 15:35:51 +00:00
|
|
|
makeflags['ALL_FEATURESETS'] = ' '.join(fs_enabled)
|
2013-07-22 00:02:50 +00:00
|
|
|
makeflags['ALL_TRIPLETS'] = ' '.join(triplet_enabled)
|
2015-11-12 20:17:54 +00:00
|
|
|
if not self.config.merge('packages').get('docs', True):
|
2015-11-11 11:45:36 +00:00
|
|
|
makeflags['DO_DOCS'] = False
|
2018-05-08 17:34:58 +00:00
|
|
|
if not self.config.merge('packages').get('source', True):
|
|
|
|
makeflags['DO_SOURCE'] = False
|
2012-06-13 21:54:55 +00:00
|
|
|
super(Gencontrol, self).do_main_makefile(makefile, makeflags, extra)
|
|
|
|
|
2013-07-22 00:02:50 +00:00
|
|
|
# linux-source-$UPSTREAMVERSION will contain all kconfig files
|
|
|
|
makefile.add('binary-indep', deps=['setup'])
|
|
|
|
|
2012-06-13 21:54:55 +00:00
|
|
|
def do_main_packages(self, packages, vars, makeflags, extra):
|
|
|
|
packages.extend(self.process_packages(self.templates["control.main"], self.vars))
|
2015-11-12 20:17:54 +00:00
|
|
|
if self.config.merge('packages').get('docs', True):
|
2015-11-10 17:42:38 +00:00
|
|
|
packages.extend(self.process_packages(self.templates["control.docs"], self.vars))
|
2018-04-29 17:31:05 +00:00
|
|
|
if self.config.merge('packages').get('tools-unversioned', True):
|
|
|
|
packages.extend(self.process_packages(self.templates["control.tools-unversioned"], self.vars))
|
|
|
|
if self.config.merge('packages').get('tools-versioned', True):
|
|
|
|
packages.extend(self.process_packages(self.templates["control.tools-versioned"], self.vars))
|
2016-03-20 22:25:02 +00:00
|
|
|
|
2017-10-01 00:34:32 +00:00
|
|
|
self._substitute_file('perf.lintian-overrides', self.vars,
|
2016-03-20 22:25:02 +00:00
|
|
|
'debian/linux-perf-%s.lintian-overrides' %
|
|
|
|
self.vars['version'])
|
2012-06-03 20:54:42 +00:00
|
|
|
|
2016-11-17 16:29:12 +00:00
|
|
|
def do_indep_featureset_setup(self, vars, makeflags, featureset, extra):
|
|
|
|
makeflags['LOCALVERSION'] = vars['localversion']
|
|
|
|
kernel_arches = set()
|
|
|
|
for arch in iter(self.config['base', ]['arches']):
|
|
|
|
if self.config.get_merge('base', arch, featureset, None, 'flavours'):
|
|
|
|
kernel_arches.add(self.config['base', arch]['kernel-arch'])
|
|
|
|
makeflags['ALL_KERNEL_ARCHES'] = ' '.join(sorted(list(kernel_arches)))
|
|
|
|
|
|
|
|
vars['featureset_desc'] = ''
|
|
|
|
if featureset != 'none':
|
|
|
|
desc = self.config[('description', None, featureset)]
|
|
|
|
desc_parts = desc['parts']
|
|
|
|
vars['featureset_desc'] = (' with the %s featureset' %
|
|
|
|
desc['part-short-%s' % desc_parts[0]])
|
|
|
|
|
|
|
|
def do_indep_featureset_packages(self, packages, makefile, featureset,
|
|
|
|
vars, makeflags, extra):
|
|
|
|
headers_featureset = self.templates["control.headers.featureset"]
|
|
|
|
packages.extend(self.process_packages(headers_featureset, vars))
|
|
|
|
|
|
|
|
cmds_binary_arch = ["$(MAKE) -f debian/rules.real binary-indep-featureset %s" %
|
|
|
|
makeflags]
|
|
|
|
makefile.add('binary-indep_%s_real' % featureset, cmds=cmds_binary_arch)
|
|
|
|
|
2010-04-20 19:18:56 +00:00
|
|
|
arch_makeflags = (
|
|
|
|
('kernel-arch', 'KERNEL_ARCH', False),
|
|
|
|
)
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def do_arch_setup(self, vars, makeflags, arch, extra):
|
|
|
|
config_base = self.config.merge('base', arch)
|
2013-08-17 11:35:06 +00:00
|
|
|
|
2010-04-20 19:18:56 +00:00
|
|
|
self._setup_makeflags(self.arch_makeflags, makeflags, config_base)
|
2009-02-19 15:40:47 +00:00
|
|
|
|
2016-06-12 19:45:36 +00:00
|
|
|
try:
|
2016-09-26 21:29:13 +00:00
|
|
|
gnu_type_bytes = subprocess.check_output(['dpkg-architecture', '-f',
|
2016-06-12 19:45:36 +00:00
|
|
|
'-a', arch,
|
|
|
|
'-q', 'DEB_HOST_GNU_TYPE'],
|
|
|
|
stderr=subprocess.DEVNULL)
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
# This sometimes happens for the newest ports :-/
|
|
|
|
print('W: Unable to get GNU type for %s' % arch, file=sys.stderr)
|
|
|
|
else:
|
|
|
|
vars['gnu-type-package'] = gnu_type_bytes.decode('utf-8').strip().replace('_', '-')
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def do_arch_packages(self, packages, makefile, arch, vars, makeflags, extra):
|
2011-05-09 15:42:48 +00:00
|
|
|
if self.version.linux_modifier is None:
|
|
|
|
try:
|
2013-10-31 03:58:28 +00:00
|
|
|
abiname_part = '-%s' % self.config['abi', arch]['abiname']
|
2011-05-09 15:42:48 +00:00
|
|
|
except KeyError:
|
2013-10-31 03:58:28 +00:00
|
|
|
abiname_part = self.abiname_part
|
|
|
|
makeflags['ABINAME'] = vars['abiname'] = \
|
2014-11-04 04:47:19 +00:00
|
|
|
self.abiname_version + abiname_part
|
2011-05-09 15:42:48 +00:00
|
|
|
|
2018-04-05 21:13:20 +00:00
|
|
|
build_signed = self.config.merge('build', arch).get('signed-code', False)
|
|
|
|
|
2015-12-19 16:54:59 +00:00
|
|
|
# Some userland architectures require kernels from another
|
|
|
|
# (Debian) architecture, e.g. x32/amd64.
|
|
|
|
# And some derivatives don't need the headers-all packages
|
|
|
|
# for other reasons.
|
|
|
|
if (self.config['base', arch].get('featuresets') and
|
|
|
|
self.config.merge('packages').get('headers-all', True)):
|
2012-06-18 14:50:18 +00:00
|
|
|
headers_arch = self.templates["control.headers.arch"]
|
|
|
|
packages_headers_arch = self.process_packages(headers_arch, vars)
|
2015-11-12 22:02:36 +00:00
|
|
|
packages_headers_arch[-1]['Depends'].extend(PackageRelation())
|
|
|
|
extra['headers_arch_depends'] = packages_headers_arch[-1]['Depends']
|
2015-12-19 16:54:59 +00:00
|
|
|
else:
|
|
|
|
packages_headers_arch = []
|
|
|
|
makeflags['DO_HEADERS_ALL'] = False
|
2015-11-12 22:02:36 +00:00
|
|
|
|
|
|
|
if self.config.merge('packages').get('libc-dev', True):
|
|
|
|
libc_dev = self.templates["control.libc-dev"]
|
|
|
|
packages_headers_arch[0:0] = self.process_packages(libc_dev, {})
|
|
|
|
else:
|
|
|
|
makeflags['DO_LIBC'] = False
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2016-05-09 11:44:27 +00:00
|
|
|
if not self.config.merge('packages').get('tools', True):
|
|
|
|
makeflags['DO_TOOLS'] = False
|
2012-01-11 17:00:17 +00:00
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2016-05-29 13:27:04 +00:00
|
|
|
merge_packages(packages, packages_headers_arch, arch)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2016-03-20 22:25:02 +00:00
|
|
|
cmds_build_arch = ["$(MAKE) -f debian/rules.real build-arch-arch %s" % makeflags]
|
|
|
|
makefile.add('build-arch_%s_real' % arch, cmds=cmds_build_arch)
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
cmds_binary_arch = ["$(MAKE) -f debian/rules.real binary-arch-arch %s" % makeflags]
|
2012-01-11 17:00:17 +00:00
|
|
|
makefile.add('binary-arch_%s_real' % arch, cmds=cmds_binary_arch)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2015-11-10 13:25:18 +00:00
|
|
|
# For stage1 build profile
|
2011-07-29 14:24:17 +00:00
|
|
|
makefile.add('binary-libc-dev_%s' % arch,
|
2012-06-03 20:54:42 +00:00
|
|
|
['source_none_real'],
|
2011-07-29 14:24:17 +00:00
|
|
|
["$(MAKE) -f debian/rules.real install-libc-dev_%s %s" %
|
|
|
|
(arch, makeflags)])
|
|
|
|
|
2013-12-15 17:35:29 +00:00
|
|
|
if os.getenv('DEBIAN_KERNEL_DISABLE_INSTALLER'):
|
2012-11-21 17:24:33 +00:00
|
|
|
if self.changelog[0].distribution == 'UNRELEASED':
|
|
|
|
import warnings
|
2015-08-29 20:48:39 +00:00
|
|
|
warnings.warn('Disable installer modules on request (DEBIAN_KERNEL_DISABLE_INSTALLER set)')
|
2012-11-21 17:24:33 +00:00
|
|
|
else:
|
2015-08-29 20:48:39 +00:00
|
|
|
raise RuntimeError('Unable to disable installer modules in release build (DEBIAN_KERNEL_DISABLE_INSTALLER set)')
|
2015-11-12 20:33:20 +00:00
|
|
|
elif self.config.merge('packages').get('installer', True):
|
2012-06-14 08:30:37 +00:00
|
|
|
# Add udebs using kernel-wedge
|
|
|
|
installer_def_dir = 'debian/installer'
|
|
|
|
installer_arch_dir = os.path.join(installer_def_dir, arch)
|
|
|
|
if os.path.isdir(installer_arch_dir):
|
|
|
|
kw_env = os.environ.copy()
|
|
|
|
kw_env['KW_DEFCONFIG_DIR'] = installer_def_dir
|
|
|
|
kw_env['KW_CONFIG_DIR'] = installer_arch_dir
|
|
|
|
kw_proc = subprocess.Popen(
|
2014-11-04 04:47:19 +00:00
|
|
|
['kernel-wedge', 'gen-control', vars['abiname']],
|
2012-06-14 08:30:37 +00:00
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
env=kw_env)
|
2014-02-15 09:44:36 +00:00
|
|
|
if not isinstance(kw_proc.stdout, io.IOBase):
|
2017-10-20 01:56:35 +00:00
|
|
|
udeb_packages = read_control(io.open(kw_proc.stdout.fileno(), closefd=False))
|
2014-02-15 09:44:36 +00:00
|
|
|
else:
|
2017-10-20 01:56:35 +00:00
|
|
|
udeb_packages = read_control(io.TextIOWrapper(kw_proc.stdout))
|
2012-06-14 08:30:37 +00:00
|
|
|
kw_proc.wait()
|
|
|
|
if kw_proc.returncode != 0:
|
|
|
|
raise RuntimeError('kernel-wedge exited with code %d' %
|
|
|
|
kw_proc.returncode)
|
|
|
|
|
2018-04-05 21:13:20 +00:00
|
|
|
# If we're going to build signed udebs later, don't actually
|
|
|
|
# generate udebs. Just test that we *can* build, so we find
|
|
|
|
# configuration errors before building linux-signed.
|
|
|
|
|
2018-04-06 20:14:14 +00:00
|
|
|
# kernel-wedge currently chokes on Build-Profiles so add it now
|
|
|
|
for package in udeb_packages:
|
|
|
|
if build_signed:
|
|
|
|
# XXX This is a hack to exclude the udebs from
|
|
|
|
# the package list while still being able to
|
|
|
|
# convince debhelper and kernel-wedge to go
|
|
|
|
# part way to building them.
|
|
|
|
package['Build-Profiles'] = '<pkg.linux.udeb-unsigned-test-build>'
|
|
|
|
else:
|
|
|
|
package['Build-Profiles'] = '<!stage1>'
|
|
|
|
|
|
|
|
merge_packages(packages, udeb_packages, arch)
|
2012-06-14 08:30:37 +00:00
|
|
|
|
|
|
|
# These packages must be built after the per-flavour/
|
2013-04-08 04:37:51 +00:00
|
|
|
# per-featureset packages. Also, this won't work
|
|
|
|
# correctly with an empty package list.
|
|
|
|
if udeb_packages:
|
|
|
|
makefile.add(
|
|
|
|
'binary-arch_%s' % arch,
|
|
|
|
cmds=["$(MAKE) -f debian/rules.real install-udeb_%s %s "
|
2016-05-29 13:11:57 +00:00
|
|
|
"PACKAGE_NAMES='%s' UDEB_UNSIGNED_TEST_BUILD=%s" %
|
2013-04-08 04:37:51 +00:00
|
|
|
(arch, makeflags,
|
2016-05-29 13:11:57 +00:00
|
|
|
' '.join(p['Package'] for p in udeb_packages),
|
2018-04-05 21:13:20 +00:00
|
|
|
build_signed)])
|
|
|
|
|
|
|
|
# This also needs to be built after the per-flavour/per-featureset
|
|
|
|
# packages.
|
|
|
|
if build_signed:
|
|
|
|
merge_packages(packages,
|
|
|
|
self.process_packages(
|
|
|
|
self.templates['control.signed-template'], vars),
|
|
|
|
arch)
|
|
|
|
makefile.add(
|
|
|
|
'binary-arch_%s' % arch,
|
|
|
|
cmds=["$(MAKE) -f debian/rules.real install-signed-template_%s %s" %
|
|
|
|
(arch, makeflags)])
|
2011-09-25 03:12:12 +00:00
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def do_featureset_setup(self, vars, makeflags, arch, featureset, extra):
|
2008-05-11 19:05:06 +00:00
|
|
|
config_base = self.config.merge('base', arch, featureset)
|
2008-05-01 07:54:28 +00:00
|
|
|
makeflags['LOCALVERSION_HEADERS'] = vars['localversion_headers'] = vars['localversion']
|
|
|
|
|
2010-04-20 19:18:56 +00:00
|
|
|
flavour_makeflags_base = (
|
|
|
|
('compiler', 'COMPILER', False),
|
2018-04-16 14:03:31 +00:00
|
|
|
('compiler-filename', 'COMPILER', True),
|
2010-04-20 19:18:56 +00:00
|
|
|
('kernel-arch', 'KERNEL_ARCH', False),
|
|
|
|
('cflags', 'CFLAGS_KERNEL', True),
|
|
|
|
('override-host-type', 'OVERRIDE_HOST_TYPE', True),
|
|
|
|
)
|
|
|
|
|
2014-04-21 01:28:25 +00:00
|
|
|
flavour_makeflags_build = (
|
|
|
|
('image-file', 'IMAGE_FILE', True),
|
|
|
|
)
|
|
|
|
|
2010-04-20 19:18:56 +00:00
|
|
|
flavour_makeflags_image = (
|
2014-04-21 01:28:25 +00:00
|
|
|
('install-stem', 'IMAGE_INSTALL_STEM', True),
|
2010-04-20 19:18:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
flavour_makeflags_other = (
|
|
|
|
('localversion', 'LOCALVERSION', False),
|
|
|
|
('localversion-image', 'LOCALVERSION_IMAGE', True),
|
|
|
|
)
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def do_flavour_setup(self, vars, makeflags, arch, featureset, flavour, extra):
|
2008-05-11 18:26:27 +00:00
|
|
|
config_base = self.config.merge('base', arch, featureset, flavour)
|
2014-04-21 01:28:25 +00:00
|
|
|
config_build = self.config.merge('build', arch, featureset, flavour)
|
2009-10-27 16:35:16 +00:00
|
|
|
config_description = self.config.merge('description', arch, featureset, flavour)
|
2008-05-01 07:54:28 +00:00
|
|
|
config_image = self.config.merge('image', arch, featureset, flavour)
|
|
|
|
|
2009-10-27 16:35:16 +00:00
|
|
|
vars['class'] = config_description['hardware']
|
|
|
|
vars['longclass'] = config_description.get('hardware-long') or vars['class']
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
vars['localversion-image'] = vars['localversion']
|
|
|
|
override_localversion = config_image.get('override-localversion', None)
|
|
|
|
if override_localversion is not None:
|
|
|
|
vars['localversion-image'] = vars['localversion_headers'] + '-' + override_localversion
|
2014-04-21 01:28:25 +00:00
|
|
|
vars['image-stem'] = config_image.get('install-stem')
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2010-04-20 19:18:56 +00:00
|
|
|
self._setup_makeflags(self.flavour_makeflags_base, makeflags, config_base)
|
2014-04-21 01:28:25 +00:00
|
|
|
self._setup_makeflags(self.flavour_makeflags_build, makeflags, config_build)
|
2010-04-20 19:18:56 +00:00
|
|
|
self._setup_makeflags(self.flavour_makeflags_image, makeflags, config_image)
|
|
|
|
self._setup_makeflags(self.flavour_makeflags_other, makeflags, vars)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
|
|
|
def do_flavour_packages(self, packages, makefile, arch, featureset, flavour, vars, makeflags, extra):
|
|
|
|
headers = self.templates["control.headers"]
|
|
|
|
|
|
|
|
config_entry_base = self.config.merge('base', arch, featureset, flavour)
|
2012-01-11 17:05:44 +00:00
|
|
|
config_entry_build = self.config.merge('build', arch, featureset, flavour)
|
2009-10-27 16:35:16 +00:00
|
|
|
config_entry_description = self.config.merge('description', arch, featureset, flavour)
|
2008-05-11 18:42:39 +00:00
|
|
|
config_entry_image = self.config.merge('image', arch, featureset, flavour)
|
2008-05-01 07:54:28 +00:00
|
|
|
config_entry_relations = self.config.merge('relations', arch, featureset, flavour)
|
|
|
|
|
|
|
|
compiler = config_entry_base.get('compiler', 'gcc')
|
2013-11-21 01:15:15 +00:00
|
|
|
|
2016-06-12 19:45:36 +00:00
|
|
|
# Work out dependency from linux-headers to compiler. Drop
|
|
|
|
# dependencies for cross-builds. Strip any remaining
|
2015-11-10 13:25:18 +00:00
|
|
|
# restrictions, as they don't apply to binary Depends.
|
2013-11-24 09:03:51 +00:00
|
|
|
relations_compiler_headers = PackageRelation(
|
2016-06-12 19:45:36 +00:00
|
|
|
self.substitute(config_entry_relations.get('headers%' + compiler) or
|
|
|
|
config_entry_relations.get(compiler), vars))
|
|
|
|
relations_compiler_headers = PackageRelation(
|
|
|
|
PackageRelationGroup(entry for entry in group
|
|
|
|
if 'cross' not in entry.restrictions)
|
|
|
|
for group in relations_compiler_headers)
|
2015-11-10 13:25:18 +00:00
|
|
|
for group in relations_compiler_headers:
|
|
|
|
for entry in group:
|
|
|
|
entry.restrictions = []
|
2013-11-21 01:15:15 +00:00
|
|
|
|
2016-06-12 19:45:36 +00:00
|
|
|
relations_compiler_build_dep = PackageRelation(
|
|
|
|
self.substitute(config_entry_relations[compiler], vars))
|
2008-05-01 07:54:28 +00:00
|
|
|
for group in relations_compiler_build_dep:
|
|
|
|
for item in group:
|
|
|
|
item.arches = [arch]
|
2017-09-30 13:07:22 +00:00
|
|
|
packages['source']['Build-Depends-Arch'].extend(relations_compiler_build_dep)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2008-06-25 12:55:37 +00:00
|
|
|
image_fields = {'Description': PackageDescription()}
|
2011-02-16 17:06:01 +00:00
|
|
|
for field in 'Depends', 'Provides', 'Suggests', 'Recommends', 'Conflicts', 'Breaks':
|
2009-09-14 09:46:17 +00:00
|
|
|
image_fields[field] = PackageRelation(config_entry_image.get(field.lower(), None), override_arches=(arch,))
|
2008-05-11 19:12:37 +00:00
|
|
|
|
2014-06-27 15:38:07 +00:00
|
|
|
generators = config_entry_image['initramfs-generators']
|
|
|
|
l = PackageRelationGroup()
|
|
|
|
for i in generators:
|
|
|
|
i = config_entry_relations.get(i, i)
|
|
|
|
l.append(i)
|
|
|
|
a = PackageRelationEntry(i)
|
|
|
|
if a.operator is not None:
|
|
|
|
a.operator = -a.operator
|
|
|
|
image_fields['Breaks'].append(PackageRelationGroup([a]))
|
|
|
|
for item in l:
|
|
|
|
item.arches = [arch]
|
|
|
|
image_fields['Depends'].append(l)
|
2011-02-16 17:06:01 +00:00
|
|
|
|
|
|
|
bootloaders = config_entry_image.get('bootloaders')
|
|
|
|
if bootloaders:
|
|
|
|
l = PackageRelationGroup()
|
|
|
|
for i in bootloaders:
|
|
|
|
i = config_entry_relations.get(i, i)
|
|
|
|
l.append(i)
|
|
|
|
a = PackageRelationEntry(i)
|
|
|
|
if a.operator is not None:
|
|
|
|
a.operator = -a.operator
|
|
|
|
image_fields['Breaks'].append(PackageRelationGroup([a]))
|
|
|
|
for item in l:
|
|
|
|
item.arches = [arch]
|
|
|
|
image_fields['Suggests'].append(l)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2009-10-27 16:35:16 +00:00
|
|
|
desc_parts = self.config.get_merge('description', arch, featureset, flavour, 'parts')
|
2008-12-28 16:55:48 +00:00
|
|
|
if desc_parts:
|
2010-02-28 18:59:01 +00:00
|
|
|
# XXX: Workaround, we need to support multiple entries of the same name
|
|
|
|
parts = list(set(desc_parts))
|
|
|
|
parts.sort()
|
2008-06-25 12:55:37 +00:00
|
|
|
desc = image_fields['Description']
|
2010-02-28 18:59:01 +00:00
|
|
|
for part in parts:
|
2009-10-27 16:35:16 +00:00
|
|
|
desc.append(config_entry_description['part-long-' + part])
|
|
|
|
desc.append_short(config_entry_description.get('part-short-' + part, ''))
|
2008-06-25 12:55:37 +00:00
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
packages_dummy = []
|
|
|
|
packages_own = []
|
|
|
|
|
2018-04-05 20:30:30 +00:00
|
|
|
build_signed = config_entry_build.get('signed-code')
|
2016-06-08 22:31:55 +00:00
|
|
|
|
|
|
|
image = self.templates[build_signed and "control.image-unsigned"
|
|
|
|
or "control.image"]
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2008-05-11 18:53:46 +00:00
|
|
|
vars.setdefault('desc', None)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2015-08-11 22:21:41 +00:00
|
|
|
image_main = self.process_real_image(image[0], image_fields, vars)
|
|
|
|
packages_own.append(image_main)
|
2016-06-08 22:31:55 +00:00
|
|
|
makeflags['IMAGE_PACKAGE_NAME'] = image_main['Package']
|
2008-05-01 07:54:28 +00:00
|
|
|
packages_own.extend(self.process_packages(image[1:], vars))
|
|
|
|
|
2016-01-26 23:25:59 +00:00
|
|
|
package_headers = self.process_package(headers[0], vars)
|
|
|
|
package_headers['Depends'].extend(relations_compiler_headers)
|
|
|
|
packages_own.append(package_headers)
|
|
|
|
if extra.get('headers_arch_depends'):
|
|
|
|
extra['headers_arch_depends'].append('%s (= ${binary:Version})' % packages_own[-1]['Package'])
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2016-01-13 11:02:36 +00:00
|
|
|
if config_entry_build.get('vdso', False):
|
|
|
|
makeflags['VDSO'] = True
|
|
|
|
|
2012-01-11 17:05:44 +00:00
|
|
|
build_debug = config_entry_build.get('debug-info')
|
2012-01-12 11:28:06 +00:00
|
|
|
|
2012-11-21 17:24:33 +00:00
|
|
|
if os.getenv('DEBIAN_KERNEL_DISABLE_DEBUG'):
|
|
|
|
if self.changelog[0].distribution == 'UNRELEASED':
|
|
|
|
import warnings
|
2015-08-29 20:48:39 +00:00
|
|
|
warnings.warn('Disable debug infos on request (DEBIAN_KERNEL_DISABLE_DEBUG set)')
|
2012-11-21 17:24:33 +00:00
|
|
|
build_debug = False
|
|
|
|
else:
|
2015-08-29 20:48:39 +00:00
|
|
|
raise RuntimeError('Unable to disable debug infos in release build (DEBIAN_KERNEL_DISABLE_DEBUG set)')
|
2012-01-12 11:28:06 +00:00
|
|
|
|
2010-04-27 08:50:30 +00:00
|
|
|
if build_debug:
|
|
|
|
makeflags['DEBUG'] = True
|
2017-01-12 15:44:11 +00:00
|
|
|
packages_own.extend(self.process_packages(self.templates['control.image-dbg'], vars))
|
2010-04-27 08:50:30 +00:00
|
|
|
|
2016-05-29 13:27:04 +00:00
|
|
|
merge_packages(packages, packages_own + packages_dummy, arch)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2015-08-11 22:21:41 +00:00
|
|
|
tests_control = self.process_package(
|
|
|
|
self.templates['tests-control.main'][0], vars)
|
|
|
|
tests_control['Depends'].append(
|
|
|
|
PackageRelationGroup(image_main['Package'],
|
|
|
|
override_arches=(arch,)))
|
|
|
|
if self.tests_control:
|
|
|
|
self.tests_control['Depends'].extend(tests_control['Depends'])
|
|
|
|
else:
|
|
|
|
self.tests_control = tests_control
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def get_config(*entry_name):
|
|
|
|
entry_real = ('image',) + entry_name
|
|
|
|
entry = self.config.get(entry_real, None)
|
|
|
|
if entry is None:
|
|
|
|
return None
|
|
|
|
return entry.get('configs', None)
|
|
|
|
|
|
|
|
def check_config_default(fail, f):
|
|
|
|
for d in self.config_dirs[::-1]:
|
|
|
|
f1 = d + '/' + f
|
|
|
|
if os.path.exists(f1):
|
|
|
|
return [f1]
|
|
|
|
if fail:
|
|
|
|
raise RuntimeError("%s unavailable" % f)
|
|
|
|
return []
|
|
|
|
|
|
|
|
def check_config_files(files):
|
|
|
|
ret = []
|
|
|
|
for f in files:
|
|
|
|
for d in self.config_dirs[::-1]:
|
|
|
|
f1 = d + '/' + f
|
|
|
|
if os.path.exists(f1):
|
|
|
|
ret.append(f1)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
raise RuntimeError("%s unavailable" % f)
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def check_config(default, fail, *entry_name):
|
|
|
|
configs = get_config(*entry_name)
|
|
|
|
if configs is None:
|
|
|
|
return check_config_default(fail, default)
|
|
|
|
return check_config_files(configs)
|
|
|
|
|
|
|
|
kconfig = check_config('config', True)
|
2012-11-26 22:31:06 +00:00
|
|
|
kconfig.extend(check_config("kernelarch-%s/config" % config_entry_base['kernel-arch'], False))
|
2008-05-01 07:54:28 +00:00
|
|
|
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("featureset-%s/config" % featureset, False, 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)
|
2016-06-06 17:12:47 +00:00
|
|
|
makeflags['KCONFIG_OPTIONS'] = ''
|
2010-04-27 08:50:30 +00:00
|
|
|
if build_debug:
|
2016-06-06 17:12:47 +00:00
|
|
|
makeflags['KCONFIG_OPTIONS'] += ' -o DEBUG_INFO=y'
|
2016-06-08 22:31:55 +00:00
|
|
|
if build_signed:
|
2016-06-06 17:12:47 +00:00
|
|
|
makeflags['KCONFIG_OPTIONS'] += ' -o MODULE_SIG=y'
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2008-05-11 19:19:30 +00:00
|
|
|
cmds_binary_arch = ["$(MAKE) -f debian/rules.real binary-arch-flavour %s" % makeflags]
|
2008-05-01 07:54:28 +00:00
|
|
|
if packages_dummy:
|
2013-10-26 21:04:10 +00:00
|
|
|
cmds_binary_arch.append(
|
|
|
|
"$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='%s' %s"
|
|
|
|
% (' '.join("-p%s" % i['Package'] for i in packages_dummy), makeflags))
|
2016-03-20 21:51:13 +00:00
|
|
|
cmds_build = ["$(MAKE) -f debian/rules.real build-arch-flavour %s" % makeflags]
|
|
|
|
cmds_setup = ["$(MAKE) -f debian/rules.real setup-arch-flavour %s" % makeflags]
|
2012-01-11 17:00:17 +00:00
|
|
|
makefile.add('binary-arch_%s_%s_%s_real' % (arch, featureset, flavour), cmds=cmds_binary_arch)
|
2012-06-14 14:39:30 +00:00
|
|
|
makefile.add('build-arch_%s_%s_%s_real' % (arch, featureset, flavour), cmds=cmds_build)
|
2012-01-11 17:00:17 +00:00
|
|
|
makefile.add('setup_%s_%s_%s_real' % (arch, featureset, flavour), cmds=cmds_setup)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2013-08-17 11:35:06 +00:00
|
|
|
# Substitute kernel version etc. into maintainer scripts,
|
|
|
|
# translations and lintian overrides
|
2016-03-20 21:39:38 +00:00
|
|
|
self._substitute_file('headers.postinst', vars,
|
|
|
|
'debian/linux-headers-%s%s.postinst' %
|
|
|
|
(vars['abiname'], vars['localversion']))
|
2016-06-06 15:10:52 +00:00
|
|
|
for name in ['postinst', 'postrm', 'preinst', 'prerm']:
|
2016-03-20 21:39:38 +00:00
|
|
|
self._substitute_file('image.%s' % name, vars,
|
2016-06-08 22:31:55 +00:00
|
|
|
'debian/%s.%s' % (image_main['Package'], name))
|
2013-08-17 11:35:06 +00:00
|
|
|
if build_debug:
|
2017-10-01 00:39:32 +00:00
|
|
|
debug_lintian_over = ('debian/linux-image-%s%s-dbg.lintian-overrides' %
|
2016-03-20 21:39:38 +00:00
|
|
|
(vars['abiname'], vars['localversion']))
|
2017-10-01 00:39:32 +00:00
|
|
|
self._substitute_file('image-dbg.lintian-overrides', vars,
|
|
|
|
debug_lintian_over)
|
|
|
|
os.chmod(debug_lintian_over, 0o755)
|
2013-08-17 11:35:06 +00:00
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def process_changelog(self):
|
2011-12-01 12:19:31 +00:00
|
|
|
act_upstream = self.changelog[0].version.upstream
|
2008-05-01 07:54:28 +00:00
|
|
|
versions = []
|
|
|
|
for i in self.changelog:
|
2011-12-01 12:19:31 +00:00
|
|
|
if i.version.upstream != act_upstream:
|
2008-05-01 07:54:28 +00:00
|
|
|
break
|
|
|
|
versions.append(i.version)
|
|
|
|
self.versions = versions
|
2009-11-24 18:30:52 +00:00
|
|
|
version = self.version = self.changelog[0].version
|
2008-05-01 07:54:28 +00:00
|
|
|
if self.version.linux_modifier is not None:
|
2011-10-28 19:02:10 +00:00
|
|
|
self.abiname_part = ''
|
2008-05-01 07:54:28 +00:00
|
|
|
else:
|
2012-01-11 17:00:17 +00:00
|
|
|
self.abiname_part = '-%s' % self.config['abi', ]['abiname']
|
2014-11-04 04:47:19 +00:00
|
|
|
# We need to keep at least three version components to avoid
|
|
|
|
# userland breakage (e.g. #742226, #745984).
|
|
|
|
self.abiname_version = re.sub('^(\d+\.\d+)(?=-|$)', r'\1.0',
|
|
|
|
self.version.linux_upstream)
|
2008-05-01 07:54:28 +00:00
|
|
|
self.vars = {
|
|
|
|
'upstreamversion': self.version.linux_upstream,
|
|
|
|
'version': self.version.linux_version,
|
2018-04-29 17:36:20 +00:00
|
|
|
'source_basename': re.sub(r'-[\d.]+$', '', self.changelog[0].source),
|
2008-05-01 07:54:28 +00:00
|
|
|
'source_upstream': self.version.upstream,
|
2011-05-30 18:54:31 +00:00
|
|
|
'source_package': self.changelog[0].source,
|
2014-11-04 04:47:19 +00:00
|
|
|
'abiname': self.abiname_version + self.abiname_part,
|
2008-05-01 07:54:28 +00:00
|
|
|
}
|
2013-11-10 05:40:33 +00:00
|
|
|
self.config['version', ] = {'source': self.version.complete,
|
|
|
|
'upstream': self.version.linux_upstream,
|
2014-12-15 22:01:58 +00:00
|
|
|
'abiname_base': self.abiname_version,
|
2014-11-04 04:47:19 +00:00
|
|
|
'abiname': (self.abiname_version +
|
|
|
|
self.abiname_part)}
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2009-11-24 18:30:52 +00:00
|
|
|
distribution = self.changelog[0].distribution
|
|
|
|
if distribution in ('unstable', ):
|
|
|
|
if (version.linux_revision_experimental or
|
2013-08-11 21:30:14 +00:00
|
|
|
version.linux_revision_backports or
|
|
|
|
version.linux_revision_other):
|
2013-10-26 21:04:10 +00:00
|
|
|
raise RuntimeError("Can't upload to %s with a version of %s" % (distribution, version))
|
2009-11-24 18:30:52 +00:00
|
|
|
if distribution in ('experimental', ):
|
|
|
|
if not version.linux_revision_experimental:
|
2013-10-26 21:04:10 +00:00
|
|
|
raise RuntimeError("Can't upload to %s with a version of %s" % (distribution, version))
|
2015-04-27 19:44:59 +00:00
|
|
|
if distribution.endswith('-security') or distribution.endswith('-lts'):
|
2018-04-28 20:42:12 +00:00
|
|
|
if version.linux_revision_backports or version.linux_revision_other:
|
2015-04-27 19:44:59 +00:00
|
|
|
raise RuntimeError("Can't upload to %s with a version of %s" % (distribution, version))
|
2013-08-11 21:30:14 +00:00
|
|
|
if distribution.endswith('-backports'):
|
|
|
|
if not version.linux_revision_backports:
|
2013-10-26 21:04:10 +00:00
|
|
|
raise RuntimeError("Can't upload to %s with a version of %s" % (distribution, version))
|
2009-11-24 18:30:52 +00:00
|
|
|
|
2008-06-25 12:15:17 +00:00
|
|
|
def process_real_image(self, entry, fields, vars):
|
2008-05-11 19:16:33 +00:00
|
|
|
entry = self.process_package(entry, vars)
|
2014-02-15 09:44:36 +00:00
|
|
|
for key, value in fields.items():
|
2008-06-25 12:15:17 +00:00
|
|
|
if key in entry:
|
|
|
|
real = entry[key]
|
|
|
|
real.extend(value)
|
|
|
|
elif value:
|
|
|
|
entry[key] = value
|
2008-05-01 07:54:28 +00:00
|
|
|
return entry
|
|
|
|
|
|
|
|
def write(self, packages, makefile):
|
|
|
|
self.write_config()
|
|
|
|
super(Gencontrol, self).write(packages, makefile)
|
2015-08-11 22:21:41 +00:00
|
|
|
self.write_tests_control()
|
2008-05-01 07:54:28 +00:00
|
|
|
|
|
|
|
def write_config(self):
|
2014-02-15 09:44:36 +00:00
|
|
|
f = open("debian/config.defines.dump", 'wb')
|
2008-05-01 07:54:28 +00:00
|
|
|
self.config.dump(f)
|
|
|
|
f.close()
|
|
|
|
|
2015-08-11 22:21:41 +00:00
|
|
|
def write_tests_control(self):
|
2017-10-20 01:56:35 +00:00
|
|
|
self.write_rfc822(open("debian/tests/control", 'w'),
|
2015-08-11 22:21:41 +00:00
|
|
|
[self.tests_control])
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
Gencontrol()()
|