From b5b67adcc17e3e74dbcda09ff3f8a4636aa53486 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 18 May 2024 19:40:22 +0200 Subject: Merging debian version 6.7.7-1. Signed-off-by: Daniel Baumann --- debian/bin/buildcheck.py | 6 +- debian/bin/diff-gencontrol | 30 +++ debian/bin/gencontrol.py | 544 +++++++++++++++++++-------------------------- debian/bin/getconfig.py | 25 --- 4 files changed, 260 insertions(+), 345 deletions(-) create mode 100755 debian/bin/diff-gencontrol delete mode 100755 debian/bin/getconfig.py (limited to 'debian/bin') diff --git a/debian/bin/buildcheck.py b/debian/bin/buildcheck.py index 92dba9347c..ecf265f6c1 100755 --- a/debian/bin/buildcheck.py +++ b/debian/bin/buildcheck.py @@ -4,7 +4,6 @@ import sys import glob import os -from debian_linux.config import ConfigCoreDump from debian_linux.debian import Changelog, VersionLinux @@ -96,12 +95,13 @@ class Main(object): def __init__(self, dir, arch, featureset, flavour): self.args = dir, arch, featureset, flavour - self.config = ConfigCoreDump(open("debian/config.defines.dump", "rb")) + # TODO + # self.config = ConfigCoreDump(open("debian/config.defines.dump", "rb")) def __call__(self): fail = 0 - for c in (CheckImage, ): + for c in (): fail |= c(self.config, *self.args)(sys.stdout) return fail diff --git a/debian/bin/diff-gencontrol b/debian/bin/diff-gencontrol new file mode 100755 index 0000000000..b84823e031 --- /dev/null +++ b/debian/bin/diff-gencontrol @@ -0,0 +1,30 @@ +#!/bin/bash +set -euE + +REF_BASE=${1:-master} + +REPO=$(git rev-parse --show-toplevel) +COMMIT_BASE=$(git merge-base --fork-point "$REF_BASE") + +TMP=$(mktemp -d) +trap "rm -rf '$TMP'" EXIT + +function git { + command git -c advice.detachedHead=false -c init.defaultBranch=main -C "$TMP" "$@" +} + +git init -q +git remote add origin "$REPO" +git fetch -q --depth 1 origin "$COMMIT_BASE" +git checkout -q FETCH_HEAD + +for i in "$TMP" "$REPO"; do + pushd "$i" > /dev/null + echo "Running gencontrol in '$i'" + ./debian/bin/gencontrol.py + popd > /dev/null +done + +for i in control rules.gen generated.signed-amd64 generated.signed-arm64; do + diff -ruN "$TMP"/debian/$i "$REPO"/debian/$i | wdiff -dn | colordiff +done diff --git a/debian/bin/gencontrol.py b/debian/bin/gencontrol.py index 8568d7f27b..2acbbbb90f 100755 --- a/debian/bin/gencontrol.py +++ b/debian/bin/gencontrol.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 -import sys +from __future__ import annotations + import json import locale import os @@ -9,14 +10,20 @@ import pathlib import subprocess import re import tempfile -from typing import Any - -from debian_linux import config +from typing import cast + +from debian_linux.config_v2 import ( + Config, + ConfigMerged, + ConfigMergedDebianarch, + ConfigMergedFeatureset, + ConfigMergedFlavour, +) from debian_linux.debian import \ PackageRelationEntry, PackageRelationGroup, \ - VersionLinux, BinaryPackage, TestsControl + VersionLinux, BinaryPackage from debian_linux.gencontrol import Gencontrol as Base, PackagesBundle, \ - iter_featuresets, iter_flavours + MakeFlags from debian_linux.utils import Templates locale.setlocale(locale.LC_CTYPE, "C.UTF-8") @@ -26,52 +33,25 @@ class Gencontrol(Base): disable_installer: bool disable_signed: bool - tests_control_headers: TestsControl | None - - config_schema = { - 'build': { - 'signed-code': config.SchemaItemBoolean(), - 'vdso': config.SchemaItemBoolean(), - }, - 'description': { - 'parts': config.SchemaItemList(), - }, - 'image': { - 'configs': config.SchemaItemList(), - 'check-size': config.SchemaItemInteger(), - 'check-size-with-dtb': config.SchemaItemBoolean(), - 'check-uncompressed-size': config.SchemaItemInteger(), - 'depends': config.SchemaItemList(','), - 'provides': config.SchemaItemList(','), - 'suggests': config.SchemaItemList(','), - 'recommends': config.SchemaItemList(','), - 'conflicts': config.SchemaItemList(','), - 'breaks': config.SchemaItemList(','), - }, - 'packages': { - 'docs': config.SchemaItemBoolean(), - 'installer': config.SchemaItemBoolean(), - 'libc-dev': config.SchemaItemBoolean(), - 'meta': config.SchemaItemBoolean(), - 'tools-unversioned': config.SchemaItemBoolean(), - 'tools-versioned': config.SchemaItemBoolean(), - 'source': config.SchemaItemBoolean(), - } - } - env_flags = [ ('DEBIAN_KERNEL_DISABLE_INSTALLER', 'disable_installer', 'installer modules'), ('DEBIAN_KERNEL_DISABLE_SIGNED', 'disable_signed', 'signed code'), ] - def __init__(self, config_dirs=["debian/config", "debian/config.local"], - template_dirs=["debian/templates"]) -> None: - super(Gencontrol, self).__init__( - config.ConfigCoreHierarchy(self.config_schema, config_dirs), + def __init__( + self, + config_dirs=[ + pathlib.Path('debian/config'), + pathlib.Path('debian/config.local'), + ], + template_dirs=["debian/templates"], + ) -> None: + super().__init__( + Config.read_orig(config_dirs).merged, Templates(template_dirs), VersionLinux) - self.process_changelog() self.config_dirs = config_dirs + self.process_changelog() for env, attr, desc in self.env_flags: setattr(self, attr, False) @@ -89,8 +69,13 @@ class Gencontrol(Base): if src in data or not optional: makeflags[dst] = data[src] - def do_main_setup(self, vars, makeflags) -> None: - super(Gencontrol, self).do_main_setup(vars, makeflags) + def do_main_setup( + self, + config: ConfigMerged, + vars: dict[str, str], + makeflags: MakeFlags, + ) -> None: + super().do_main_setup(config, vars, makeflags) makeflags.update({ 'VERSION': self.version.linux_version, 'UPSTREAMVERSION': self.version.linux_upstream, @@ -102,102 +87,118 @@ class Gencontrol(Base): # Prepare to generate debian/tests/control self.tests_control = self.templates.get_tests_control('main.tests-control', vars) - self.tests_control_image = None - self.tests_control_headers = None - def do_main_makefile(self, makeflags) -> None: - for featureset in iter_featuresets(self.config): + def do_main_makefile( + self, + config: ConfigMerged, + vars: dict[str, str], + makeflags: MakeFlags, + ) -> None: + for featureset in self.config.root_featuresets: makeflags_featureset = makeflags.copy() - makeflags_featureset['FEATURESET'] = featureset + makeflags_featureset['FEATURESET'] = featureset.name - self.bundle.makefile.add_rules(f'source_{featureset}', + self.bundle.makefile.add_rules(f'source_{featureset.name}', 'source', makeflags_featureset) - self.bundle.makefile.add_deps('source', [f'source_{featureset}']) + self.bundle.makefile.add_deps('source', [f'source_{featureset.name}']) makeflags = makeflags.copy() - makeflags['ALL_FEATURESETS'] = ' '.join(iter_featuresets(self.config)) - super().do_main_makefile(makeflags) - - def do_main_packages(self, vars, makeflags) -> None: + makeflags['ALL_FEATURESETS'] = ' '.join(i.name for i in self.config.root_featuresets) + super().do_main_makefile(config, vars, makeflags) + + def do_main_packages( + self, + config: ConfigMerged, + vars: dict[str, str], + makeflags: MakeFlags, + ) -> None: self.bundle.add('main', (), makeflags, vars) # Only build the metapackages if their names won't exactly match # the packages they depend on - do_meta = self.config.merge('packages').get('meta', True) \ + do_meta = config.packages.meta \ and vars['source_suffix'] != '-' + vars['version'] - if self.config.merge('packages').get('docs', True): + if config.packages.docs: self.bundle.add('docs', (), makeflags, vars) if do_meta: self.bundle.add('docs.meta', (), makeflags, vars) - if self.config.merge('packages').get('source', True): + if config.packages.source: self.bundle.add('sourcebin', (), makeflags, vars) if do_meta: self.bundle.add('sourcebin.meta', (), makeflags, vars) - if self.config.merge('packages').get('libc-dev', True): + if config.packages.libc_dev: + libcdev_debianarches = set() libcdev_kernelarches = set() libcdev_multiarches = set() - for arch in iter(self.config['base', ]['arches']): - libcdev_kernelarch = self.config['base', arch]['kernel-arch'] - libcdev_multiarch = subprocess.check_output( - ['dpkg-architecture', '-f', '-a', arch, - '-q', 'DEB_HOST_MULTIARCH'], - stderr=subprocess.DEVNULL, - encoding='utf-8').strip() - libcdev_kernelarches.add(libcdev_kernelarch) - libcdev_multiarches.add(f'{libcdev_multiarch}:{libcdev_kernelarch}') + for kernelarch in self.config.kernelarchs: + libcdev_kernelarches.add(kernelarch.name) + for debianarch in kernelarch.debianarchs: + libcdev_debianarches.add(debianarch.name) + libcdev_multiarches.add( + f'{debianarch.defs_debianarch.multiarch}:{kernelarch.name}' + ) libcdev_makeflags = makeflags.copy() libcdev_makeflags['ALL_LIBCDEV_KERNELARCHES'] = ' '.join(sorted(libcdev_kernelarches)) libcdev_makeflags['ALL_LIBCDEV_MULTIARCHES'] = ' '.join(sorted(libcdev_multiarches)) - self.bundle.add('libc-dev', (), libcdev_makeflags, vars) - - def do_indep_featureset_setup(self, vars, makeflags, featureset) -> None: + for package in self.bundle.add('libc-dev', (), libcdev_makeflags, vars): + package.setdefault('Provides').extend([ + PackageRelationGroup( + f'{package["Package"]}-{arch}-cross (= ${{binary:Version}})' + ) + for arch in sorted(libcdev_debianarches) + ]) + + def do_indep_featureset_setup( + self, + config: ConfigMergedFeatureset, + vars: dict[str, str], + makeflags: MakeFlags, + ) -> None: 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']) + for kernelarch in self.config.kernelarchs: + for debianarch in kernelarch.debianarchs: + for featureset in debianarch.featuresets: + if config.name_featureset in featureset.name: + kernel_arches.add(kernelarch.name) 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'] + if config.name_featureset != 'none': + desc = config.description vars['featureset_desc'] = (' with the %s featureset' % - desc['part-short-%s' % desc_parts[0]]) - - def do_indep_featureset_packages(self, featureset, vars, makeflags) -> None: - self.bundle.add('headers.featureset', (featureset, ), makeflags, vars) + desc.short[desc.parts[0]]) + + def do_indep_featureset_packages( + self, + config: ConfigMergedFeatureset, + vars: dict[str, str], + makeflags: MakeFlags, + ) -> None: + self.bundle.add('headers.featureset', (config.name_featureset, ), makeflags, vars) + + def do_arch_setup( + self, + config: ConfigMergedDebianarch, + vars: dict[str, str], + makeflags: MakeFlags, + ) -> None: + makeflags['KERNEL_ARCH'] = config.name_kernelarch + + def do_arch_packages( + self, + config: ConfigMergedDebianarch, + vars: dict[str, str], + makeflags: MakeFlags, + ) -> None: + arch = config.name - arch_makeflags = ( - ('kernel-arch', 'KERNEL_ARCH', False), - ) - - def do_arch_setup(self, vars, makeflags, arch) -> None: - config_base = self.config.merge('base', arch) - - self._setup_makeflags(self.arch_makeflags, makeflags, config_base) - - try: - gnu_type = subprocess.check_output( - ['dpkg-architecture', '-f', '-a', arch, - '-q', 'DEB_HOST_GNU_TYPE'], - stderr=subprocess.DEVNULL, - encoding='utf-8') - 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.strip().replace('_', '-') - - def do_arch_packages(self, arch, vars, makeflags) -> None: if not self.disable_signed: - build_signed = self.config.merge('build', arch) \ - .get('signed-code', False) + build_signed = config.build.enable_signed else: build_signed = False @@ -226,112 +227,68 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur * Sign kernel from {self.changelog[0].source} @signedtemplate_binaryversion@ ''') - if self.config['base', arch].get('featuresets') and \ - self.config.merge('packages').get('source', True): + if config.packages.source and list(config.featuresets): self.bundle.add('config', (arch, ), makeflags, vars) - if self.config.merge('packages').get('tools-unversioned', True): + if config.packages.tools_unversioned: self.bundle.add('tools-unversioned', (arch, ), makeflags, vars) - if self.config.merge('packages').get('tools-versioned', True): + if config.packages.tools_versioned: self.bundle.add('tools-versioned', (arch, ), makeflags, vars) - def do_featureset_setup(self, vars, makeflags, arch, featureset) -> None: + def do_featureset_setup( + self, + featureset: ConfigMergedFeatureset, + vars: dict[str, str], + makeflags: MakeFlags, + ) -> None: vars['localversion_headers'] = vars['localversion'] makeflags['LOCALVERSION_HEADERS'] = vars['localversion_headers'] - self.default_flavour = self.config.merge('base', arch, featureset) \ - .get('default-flavour') - if self.default_flavour is not None: - if featureset != 'none': - raise RuntimeError("default-flavour set for %s %s," - " but must only be set for featureset none" - % (arch, featureset)) - if self.default_flavour \ - not in iter_flavours(self.config, arch, featureset): - raise RuntimeError("default-flavour %s for %s %s does not exist" - % (self.default_flavour, arch, featureset)) - - self.quick_flavour = self.config.merge('base', arch, featureset) \ - .get('quick-flavour') - - flavour_makeflags_base = ( - ('compiler', 'COMPILER', False), - ('compiler-filename', 'COMPILER', True), - ('kernel-arch', 'KERNEL_ARCH', False), - ('cflags', 'KCFLAGS', True), - ('kernel-deb-arch', 'KERNEL_DEB_ARCH', True), - ('kernel-gnu-type', 'KERNEL_GNU_TYPE', True), - ('compat-deb-arch', 'COMPAT_DEB_ARCH', True), - ('compat-gnu-type', 'COMPAT_GNU_TYPE', True), - ) - - flavour_makeflags_build = ( - ('image-file', 'IMAGE_FILE', True), - ) - - flavour_makeflags_image = ( - ('install-stem', 'IMAGE_INSTALL_STEM', True), - ) - - flavour_makeflags_other = ( - ('localversion', 'LOCALVERSION', False), - ('localversion-image', 'LOCALVERSION_IMAGE', True), - ) - - def do_flavour_setup(self, vars, makeflags, arch, featureset, flavour) -> None: - config_base = self.config.merge('base', arch, featureset, flavour) - config_build = self.config.merge('build', arch, featureset, flavour) - config_description = self.config.merge('description', arch, featureset, - flavour) - config_image = self.config.merge('image', arch, featureset, flavour) - + def do_flavour_setup( + self, + config: ConfigMergedFlavour, + vars: dict[str, str], + makeflags: MakeFlags, + ) -> None: vars['flavour'] = vars['localversion'][1:] - vars['class'] = config_description['hardware'] - vars['longclass'] = (config_description.get('hardware-long') - or vars['class']) + vars['class'] = config.description.hardware or '' + vars['longclass'] = config.description.hardware_long or vars['class'] 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) - vars['image-stem'] = config_image.get('install-stem') - - self._setup_makeflags(self.flavour_makeflags_base, makeflags, - config_base) - 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) - - def do_flavour_packages(self, arch, featureset, - flavour, vars, makeflags) -> None: - ruleid = (arch, featureset, flavour) + + vars['image-stem'] = cast(str, config.build.kernel_stem) + + if t := config.build.cflags: + makeflags['KCFLAGS'] = t + makeflags['COMPILER'] = config.build.compiler + if t := config.build.compiler_gnutype: + makeflags['KERNEL_GNU_TYPE'] = t + if t := config.build.compiler_gnutype_compat: + makeflags['COMPAT_GNU_TYPE'] = t + makeflags['IMAGE_FILE'] = config.build.kernel_file + makeflags['IMAGE_INSTALL_STEM'] = config.build.kernel_stem + + makeflags['LOCALVERSION'] = vars['localversion'] + makeflags['LOCALVERSION_IMAGE'] = vars['localversion-image'] + + def do_flavour_packages( + self, + config: ConfigMergedFlavour, + vars: dict[str, str], + makeflags: MakeFlags, + ) -> None: + arch = config.name_debianarch + ruleid = (arch, config.name_featureset, config.name_flavour) packages_headers = ( self.bundle.add('headers', ruleid, makeflags, vars, arch=arch) ) assert len(packages_headers) == 1 - do_meta = self.config.merge('packages').get('meta', True) - config_entry_base = self.config.merge('base', arch, featureset, - flavour) - config_entry_build = self.config.merge('build', arch, featureset, - flavour) - config_entry_description = self.config.merge('description', arch, - featureset, flavour) - config_entry_packages = self.config.merge('packages', arch, featureset, - flavour) - - def config_entry_image(key, *args, **kwargs) -> Any: - return self.config.get_merge( - 'image', arch, featureset, flavour, key, *args, **kwargs) - - compiler = config_entry_base.get('compiler', 'gcc') + do_meta = config.packages.meta - relation_compiler = PackageRelationEntry(compiler) + relation_compiler = PackageRelationEntry(cast(str, config.build.compiler)) relation_compiler_header = PackageRelationGroup([relation_compiler]) @@ -350,7 +307,7 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur self.bundle.packages['source']['Build-Depends-Arch'].merge([ PackageRelationEntry( relation_compiler, - name=f'{relation_compiler.name}-{vars["gnu-type-package"]}', + name=f'{relation_compiler.name}-{config.defs_debianarch.gnutype_package}', arches={arch}, restrictions='', ) @@ -358,32 +315,34 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur # Generate compiler build-depends for kernel: # gcc-13-hppa64-linux-gnu [hppa] - if gnutype := config_entry_base.get('kernel-gnu-type'): - self.bundle.packages['source']['Build-Depends-Arch'].merge([ - PackageRelationEntry( - relation_compiler, - name=f'{relation_compiler.name}-{gnutype}', - arches={arch}, - restrictions='', - ) - ]) + if gnutype := config.build.compiler_gnutype: + if gnutype != config.defs_debianarch.gnutype: + self.bundle.packages['source']['Build-Depends-Arch'].merge([ + PackageRelationEntry( + relation_compiler, + name=f'{relation_compiler.name}-{gnutype.replace("_", "-")}', + arches={arch}, + restrictions='', + ) + ]) # Generate compiler build-depends for compat: # gcc-arm-linux-gnueabihf [arm64] # XXX: Linux uses various definitions for this, all ending with "gcc", not $CC - if gnutype := config_entry_base.get('compat-gnu-type'): - self.bundle.packages['source']['Build-Depends-Arch'].merge([ - PackageRelationEntry( - f'gcc-{gnutype}', - arches={arch}, - restrictions='', - ) - ]) + if gnutype := config.build.compiler_gnutype_compat: + if gnutype != config.defs_debianarch.gnutype: + self.bundle.packages['source']['Build-Depends-Arch'].merge([ + PackageRelationEntry( + f'gcc-{gnutype.replace("_", "-")}', + arches={arch}, + restrictions='', + ) + ]) packages_own = [] if not self.disable_signed: - build_signed = config_entry_build.get('signed-code') + build_signed = config.build.enable_signed else: build_signed = False @@ -392,29 +351,32 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur else: bundle_signed = self.bundle - vars.setdefault('desc', None) - - packages_image = [] + vars.setdefault('desc', '') if build_signed: + packages_image_unsigned = ( + self.bundle.add('image-unsigned', ruleid, makeflags, vars, arch=arch) + ) + packages_image = packages_image_unsigned[:] packages_image.extend( - bundle_signed.add('signed.image', ruleid, makeflags, vars, arch=arch)) - packages_image.extend( - self.bundle.add('image-unsigned', ruleid, makeflags, vars, arch=arch)) + bundle_signed.add('signed.image', ruleid, makeflags, vars, arch=arch) + ) else: - packages_image.extend(bundle_signed.add('image', ruleid, makeflags, vars, arch=arch)) + packages_image = packages_image_unsigned = ( + bundle_signed.add('image', ruleid, makeflags, vars, arch=arch) + ) for field in ('Depends', 'Provides', 'Suggests', 'Recommends', 'Conflicts', 'Breaks'): - for i in config_entry_image(field.lower(), ()): + for i in getattr(config.relations.image, field.lower(), []): for package_image in packages_image: package_image.setdefault(field).merge( PackageRelationGroup(i, arches={arch}) ) for field in ('Depends', 'Suggests', 'Recommends'): - for i in config_entry_image(field.lower(), ()): + for i in getattr(config.relations.image, field.lower(), []): group = PackageRelationGroup(i, arches={arch}) for entry in group: if entry.operator is not None: @@ -422,9 +384,7 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur for package_image in packages_image: package_image.setdefault('Breaks').append(PackageRelationGroup([entry])) - desc_parts = self.config.get_merge('description', arch, featureset, - flavour, 'parts') - if desc_parts: + if desc_parts := config.description.parts: # XXX: Workaround, we need to support multiple entries of the same # name parts = list(set(desc_parts)) @@ -432,9 +392,8 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur for package_image in packages_image: desc = package_image['Description'] for part in parts: - desc.append(config_entry_description['part-long-' + part]) - desc.append_short(config_entry_description - .get('part-short-' + part, '')) + desc.append(config.description.long[part]) + desc.append_short(config.description.short[part]) packages_headers[0]['Depends'].merge(relation_compiler_header) packages_own.extend(packages_image) @@ -457,8 +416,11 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur ) assert len(packages_meta) == 2 - if flavour == self.default_flavour \ - and not self.vars['source_suffix']: + if ( + config.name_featureset == 'none' + and config.defs_flavour.is_default + and not self.vars['source_suffix'] + ): packages_meta[0].setdefault('Provides') \ .append('linux-image-generic') packages_meta[1].setdefault('Provides') \ @@ -466,7 +428,7 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur packages_own.extend(packages_meta) - if config_entry_build.get('vdso', False): + if config.build.enable_vdso: makeflags['VDSO'] = True packages_own.extend( @@ -478,80 +440,34 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur ) # In a quick build, only build the quick flavour (if any). - if flavour != self.quick_flavour: + if ( + config.name_featureset != 'none' + or not config.defs_flavour.is_quick + ): for package in packages_own: package['Build-Profiles'][0].neg.add('pkg.linux.quick') - tests_control = self.templates.get_tests_control('image.tests-control', vars)[0] - tests_control['Depends'].merge( - PackageRelationGroup(package_image['Package'], - arches={arch})) - if self.tests_control_image: - for i in tests_control['Depends']: - self.tests_control_image['Depends'].merge(i) - else: - self.tests_control_image = tests_control - self.tests_control.append(tests_control) - - if flavour == (self.quick_flavour or self.default_flavour): - if not self.tests_control_headers: - self.tests_control_headers = \ - self.templates.get_tests_control('headers.tests-control', vars)[0] - self.tests_control.append(self.tests_control_headers) - assert self.tests_control_headers is not None - self.tests_control_headers['Architecture'].add(arch) - self.tests_control_headers['Depends'].merge( - PackageRelationGroup(packages_headers[0]['Package'], - arches={arch})) - - def get_config(*entry_name) -> Any: - 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) -> list[str]: - 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) -> list[str]: - 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) -> list[str]: - 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) - # XXX: We have no way to override kernelarch-X configs - kconfig.extend(check_config_default(False, - "kernelarch-%s/config" % config_entry_base['kernel-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("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)) + tests_control_image = self.templates.get_tests_control('image.tests-control', vars) + for c in tests_control_image: + c.setdefault('Depends').extend( + [i['Package'] for i in packages_image_unsigned] + ) + + tests_control_headers = self.templates.get_tests_control('headers.tests-control', vars) + for c in tests_control_headers: + c.setdefault('Depends').extend( + [i['Package'] for i in packages_headers] + + [i['Package'] for i in packages_image_unsigned] + ) + + self.tests_control.extend(tests_control_image) + self.tests_control.extend(tests_control_headers) + + kconfig = [] + for c in config.config: + for d in self.config_dirs: + if (f := d / c).exists(): + kconfig.append(str(f)) makeflags['KCONFIG'] = ' '.join(kconfig) makeflags['KCONFIG_OPTIONS'] = '' # Add "salt" to fix #872263 @@ -559,12 +475,16 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur ' -o "BUILD_SALT=\\"%(abiname)s%(localversion)s\\""' % vars merged_config = ('debian/build/config.%s_%s_%s' % - (arch, featureset, flavour)) + (config.name_debianarch, config.name_featureset, config.name_flavour)) self.bundle.makefile.add_cmds(merged_config, ["$(MAKE) -f debian/rules.real %s %s" % (merged_config, makeflags)]) - if not self.disable_installer and config_entry_packages.get('installer'): + if ( + config.name_featureset == 'none' + and not self.disable_installer + and config.packages.installer + ): with tempfile.TemporaryDirectory(prefix='linux-gencontrol') as config_dir: base_path = pathlib.Path('debian/installer').absolute() config_path = pathlib.Path(config_dir) @@ -603,7 +523,7 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur bundle_signed.add_packages( udeb_packages, - (arch, featureset, flavour), + (config.name_debianarch, config.name_featureset, config.name_flavour), makeflags_local, arch=arch, ) @@ -624,7 +544,7 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur self.bundle.add_packages( udeb_packages, - (arch, featureset, flavour), + (config.name_debianarch, config.name_featureset, config.name_flavour), makeflags, arch=arch, check_packages=False, ) @@ -644,24 +564,14 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur } self.vars['source_suffix'] = \ self.changelog[0].source[len(self.vars['source_basename']):] - self.config['version', ] = {'source': self.version.complete, - 'upstream': self.version.linux_upstream, - 'abiname_base': self.abiname, - 'abiname': self.abiname} distribution = self.changelog[0].distribution def write(self) -> None: - self.write_config() super().write() self.write_tests_control() self.write_signed() - def write_config(self) -> None: - f = open("debian/config.defines.dump", 'wb') - self.config.dump(f) - f.close() - def write_signed(self) -> None: for bundle in self.bundles.values(): pkg_sign_entries = {} diff --git a/debian/bin/getconfig.py b/debian/bin/getconfig.py deleted file mode 100755 index b719a17a12..0000000000 --- a/debian/bin/getconfig.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python3 - -import sys - -from debian_linux.config import ConfigCoreDump - -section = tuple(s or None for s in sys.argv[1:-1]) -key = sys.argv[-1] -config = ConfigCoreDump(fp=open("debian/config.defines.dump", "rb")) -try: - value = config[section][key] -except KeyError: - sys.exit(1) - -if isinstance(value, str): - # Don't iterate over it - print(value) -else: - # In case it's a sequence, try printing each item - try: - for item in value: - print(item) - except TypeError: - # Otherwise use the default format - print(value) -- cgit v1.2.3