Skip to content

Commit

Permalink
src/tarball.py: Find and apply patches from Patchwork data
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolay Yurin <[email protected]>
  • Loading branch information
yurinnick committed Aug 1, 2023
1 parent 75e0f19 commit 7379504
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/tarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ def _update_repo(self, config):
kernelci.build.update_repo(config, self._kdir)
self.log.info("Repo updated")

def _find_patchwork_patches(self, node):
node_data = node.get('data')
if not node_data:
return []

if patchwork_data := node_data.get('patchwork'):
config_version = patchwork_data["version"]
if config_version == 1:
return [patch_metadata['mbox'] for patch_metadata in patchwork_data['payload']['patches']]
else:
self.log.error(f"Unsupported patchwork config version {config_version}")

return []

def _apply_patches(self, patch_mbox_urls):
# Appling patches in the reverse order
for patch_mbox_url in patch_mbox_urls[::-1]:
self.log.info(
f"Applying patch to the repo, patch mbox url: {patch_mbox_url}"
)
kernelci.build.apply_patch_mbox(self._kdir, patch_mbox_url)

def _make_tarball(self, config, describe):
name = '-'.join(['linux', config.tree.name, config.branch, describe])
tarball = f"{name}.tar.gz"
Expand Down Expand Up @@ -134,6 +156,11 @@ def _run(self, sub_id):
continue

self._update_repo(build_config)

patches = self._find_patchwork_patches(checkout_node)
if patches:
self._apply_patches(patches)

describe = kernelci.build.git_describe(
build_config.tree.name, self._kdir
)
Expand Down

0 comments on commit 7379504

Please sign in to comment.