diff --git a/lisa/transformers/kernel_source_installer.py b/lisa/transformers/kernel_source_installer.py index 9cbbd20b14..289883583a 100644 --- a/lisa/transformers/kernel_source_installer.py +++ b/lisa/transformers/kernel_source_installer.py @@ -155,6 +155,27 @@ def install(self) -> str: self._install_build_tools(node, runbook.build_deps) + # Ubuntu sort kernels by version. If installed kernel version is lower than default + # one extra steps needed to ensure boot into correct kernel. + if isinstance(node.os, Ubuntu): + result = node.execute( + "cat > /tmp/grub-lisa.cfg < str: ) result.assert_exit_code() + if isinstance(node.os, Ubuntu): + result = node.execute("find /boot -name 'grub.cfg'", sudo=True) + result.assert_exit_code() + + grub_config = result.stdout + result = node.execute(f"grep 'menuentry ' {grub_config}", sudo=True) + result.assert_exit_code() + + for idx, menuentry in enumerate(result.stdout.splitlines()): + if kernel_version in menuentry: + node.execute(f"grub-set-default {idx}", sudo=True) + result.assert_exit_code() + break + return kernel_version def _install_build(self, node: Node, code_path: PurePath) -> None: