Skip to content

Commit

Permalink
Add b4 Kernel Source Modifier
Browse files Browse the repository at this point in the history
b4 patch modifier is a modifier for kernel source
installer. It accepts Message_id and apply the .mbx file using git
  • Loading branch information
adityagesh committed Nov 15, 2024
1 parent 6557afe commit 85d626a
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion lisa/transformers/kernel_source_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from lisa.base_tools import Mv
from lisa.node import Node
from lisa.operating_system import CBLMariner, Redhat, Ubuntu
from lisa.tools import Cp, Echo, Git, Make, Sed, Uname
from lisa.tools import Cp, Echo, Git, Make, Sed, Uname, B4
from lisa.tools.gcc import Gcc
from lisa.tools.lscpu import Lscpu
from lisa.util import LisaException, field_metadata, subclasses
Expand Down Expand Up @@ -75,6 +75,12 @@ class PatchModifierSchema(BaseModifierSchema):
file_pattern: str = "*.patch"


@dataclass_json()
@dataclass
class b4PatchModifierSchema(BaseModifierSchema):
message_id: str = field(default="", metadata=field_metadata(required=True))


@dataclass_json()
@dataclass
class SourceInstallerSchema(BaseInstallerSchema):
Expand Down Expand Up @@ -489,3 +495,24 @@ def _get_code_path(path: str, node: Node, default_name: str) -> PurePath:
code_path = node.working_path / default_name

return code_path


class b4PatchModifier(BaseModifier):
@classmethod
def type_name(cls) -> str:
return "b4_patch"

@classmethod
def type_schema(cls) -> Type[schema.TypedSchema]:
return b4PatchModifierSchema

def modify(self) -> None:
runbook: b4PatchModifierSchema = self.runbook

git = self._node.tools[Git]
b4 = self._node.tools[B4]

message_id = runbook.message_id
patch_file = b4.am(message_id=message_id, output_dir=self._code_path)

git.apply(cwd=self._code_path, patches=patch_file)

0 comments on commit 85d626a

Please sign in to comment.