Skip to content

Commit

Permalink
kernel_source_installer: optional devtoolset for <3.10
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Boldin <[email protected]>
  • Loading branch information
paboldin committed Nov 5, 2024
1 parent 0e40c4d commit af1fef1
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions lisa/transformers/kernel_source_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -158,28 +158,39 @@ 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(
"make kernelrelease 2>/dev/null",
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,
)
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit af1fef1

Please sign in to comment.