From 7379504ec0e4096a793f0f0cb9ea2a8e8bb09ec7 Mon Sep 17 00:00:00 2001 From: Nikolay Yurin Date: Mon, 31 Jul 2023 13:47:23 -0700 Subject: [PATCH] src/tarball.py: Find and apply patches from Patchwork data Signed-off-by: Nikolay Yurin --- src/tarball.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/tarball.py b/src/tarball.py index 1604e169e..1b6f29ac2 100755 --- a/src/tarball.py +++ b/src/tarball.py @@ -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" @@ -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 )