diff --git a/lisa/_kmod.py b/lisa/_kmod.py index 7c767dd5af833806180ba60b293e458a173e6c5d..40afb2f9f09e3ccc2092e1dcd569dfafe75a344e 100644 --- a/lisa/_kmod.py +++ b/lisa/_kmod.py @@ -120,7 +120,6 @@ import re import functools import bisect import threading -import hashlib import itertools import logging import datetime @@ -817,6 +816,7 @@ class KernelTree(Loggable, SerializeViaConstructor): @classmethod def _prepare_tree(cls, path, make_vars, build_env, apply_overlays, overlay_backend): + path = Path(path) logger = cls.get_logger() _make_vars = [ f'{name}={val}' @@ -853,6 +853,26 @@ class KernelTree(Loggable, SerializeViaConstructor): bind_paths = {path: path} + def fixup_kernel_tree(): + # TODO: re-assess + + # The headers in /sys/kheaders.tar.xz generated by + # CONFIG_IKHEADERS=y are broken since kernel/gen_kheaders.sh strip + # some comments from the file. KBuild then proceeds on checking the + # checksum and the check fails. This used to be a simple warning, + # but has now been turned into an error in recent kernels. + # We remove the SHA1 from the file so that the check is skipped. + for _path in (path / 'include' / 'linux' / 'atomic').iterdir(): + content = _path.read_bytes() + lines = [line for line in content.split(b'\n') if line] + if lines and lines[-1].lstrip().startswith(b'//'): + # Remove the last line, containing the sha1 + content = b'\n'.join(lines[:-1]) + b'\n' + sha1 = hashlib.sha1(content).hexdigest() + content += b'// ' + sha1.encode('ascii') + b'\n' + _path.write_bytes(content) + + if build_env == 'alpine': @contextlib.contextmanager def cmd_cm(cmds): @@ -874,11 +894,14 @@ class KernelTree(Loggable, SerializeViaConstructor): # Apply the overlays before running make, so that it sees the # correct headers and conf etc apply_overlays() + fixup_kernel_tree() _subprocess_log(post, logger=logger, level=logging.DEBUG) + # Re-apply the overlays, since we could have overwritten important # things, such as include/linux/vermagic.h apply_overlays() + fixup_kernel_tree() @classmethod