Skip to content

Commit 7379504

Browse files
committed
src/tarball.py: Find and apply patches from Patchwork data
Signed-off-by: Nikolay Yurin <[email protected]>
1 parent 75e0f19 commit 7379504

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/tarball.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,28 @@ def _update_repo(self, config):
5959
kernelci.build.update_repo(config, self._kdir)
6060
self.log.info("Repo updated")
6161

62+
def _find_patchwork_patches(self, node):
63+
node_data = node.get('data')
64+
if not node_data:
65+
return []
66+
67+
if patchwork_data := node_data.get('patchwork'):
68+
config_version = patchwork_data["version"]
69+
if config_version == 1:
70+
return [patch_metadata['mbox'] for patch_metadata in patchwork_data['payload']['patches']]
71+
else:
72+
self.log.error(f"Unsupported patchwork config version {config_version}")
73+
74+
return []
75+
76+
def _apply_patches(self, patch_mbox_urls):
77+
# Appling patches in the reverse order
78+
for patch_mbox_url in patch_mbox_urls[::-1]:
79+
self.log.info(
80+
f"Applying patch to the repo, patch mbox url: {patch_mbox_url}"
81+
)
82+
kernelci.build.apply_patch_mbox(self._kdir, patch_mbox_url)
83+
6284
def _make_tarball(self, config, describe):
6385
name = '-'.join(['linux', config.tree.name, config.branch, describe])
6486
tarball = f"{name}.tar.gz"
@@ -134,6 +156,11 @@ def _run(self, sub_id):
134156
continue
135157

136158
self._update_repo(build_config)
159+
160+
patches = self._find_patchwork_patches(checkout_node)
161+
if patches:
162+
self._apply_patches(patches)
163+
137164
describe = kernelci.build.git_describe(
138165
build_config.tree.name, self._kdir
139166
)

0 commit comments

Comments
 (0)