From af1fef1fcbce19b935ea9b4a92c5731da3c33dd9 Mon Sep 17 00:00:00 2001 From: Pavel Boldin Date: Tue, 5 Nov 2024 17:02:02 +0200 Subject: [PATCH] kernel_source_installer: optional devtoolset for <3.10 Signed-off-by: Pavel Boldin --- lisa/transformers/kernel_source_installer.py | 30 ++++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/lisa/transformers/kernel_source_installer.py b/lisa/transformers/kernel_source_installer.py index 90c4272383..064b12baff 100644 --- a/lisa/transformers/kernel_source_installer.py +++ b/lisa/transformers/kernel_source_installer.py @@ -14,7 +14,7 @@ from lisa.tools import Cp, Echo, Git, Make, Sed, Uname from lisa.tools.gcc import Gcc from lisa.tools.lscpu import Lscpu -from lisa.util import LisaException, field_metadata, subclasses +from lisa.util import LisaException, VersionInfo, field_metadata, subclasses, parse_version from lisa.util.logger import Logger, get_logger from .kernel_installer import BaseInstaller, BaseInstallerSchema @@ -158,11 +158,23 @@ def install(self) -> str: # modify code self._modify_code(node=node, code_path=self._code_path) + + result = node.execute( + "make kernelversion 2>/dev/null", + cwd=self._code_path, + shell=True, + ) + result.assert_exit_code( + 0, + f"failed on get kernel version: {result.stdout}", + ) + kernel_version = parse_version(result.stdout) + kconfig_file = runbook.kernel_config_file self._build_code( - node=node, code_path=self._code_path, kconfig_file=kconfig_file + node=node, code_path=self._code_path, kconfig_file=kconfig_file, + kernel_version=kernel_version ) - self._install_build(node=node, code_path=self._code_path) result = node.execute( @@ -170,16 +182,15 @@ def install(self) -> str: cwd=self._code_path, shell=True, ) - - kernel_version = result.stdout result.assert_exit_code( 0, - f"failed on get kernel version: {kernel_version}", + f"failed on get kernel release: {result.stdout}", ) + kernel_release = result.stdout # copy current config back to system folder. result = node.execute( - f"cp .config /boot/config-{kernel_version}", + f"cp .config /boot/config-{kernel_release}", cwd=self._code_path, sudo=True, ) @@ -227,7 +238,7 @@ def _modify_code(self, node: Node, code_path: PurePath) -> None: self._log.debug(f"modifying code by {modifier.type_name()}") modifier.modify() - def _build_code(self, node: Node, code_path: PurePath, kconfig_file: str) -> None: + def _build_code(self, node: Node, code_path: PurePath, kconfig_file: str, kernel_version: VersionInfo) -> None: self._log.info("building code...") uname = node.tools[Uname] @@ -287,7 +298,8 @@ def _build_code(self, node: Node, code_path: PurePath, kconfig_file: str) -> Non result.assert_exit_code() # the gcc version of Redhat 7.x is too old. Upgrade it. - if isinstance(node.os, Redhat) and node.os.information.version < "8.0.0": + if kernel_version > "3.10.0" and isinstance(node.os, Redhat) and node.os.information.version < "8.0.0": + node.os.install_packages(["centos-release-scl"]) node.os.install_packages(["devtoolset-8"]) node.tools[Mv].move("/bin/gcc", "/bin/gcc_back", overwrite=True, sudo=True) result.assert_exit_code()