diff --git a/kernelci/build.py b/kernelci/build.py index e4ee20ac0c..e078406dd7 100644 --- a/kernelci/build.py +++ b/kernelci/build.py @@ -26,6 +26,7 @@ import tarfile import time import urllib.parse +import tempfile import requests from kernelci import shell_cmd, print_flush, __version__ as kernelci_version @@ -321,6 +322,20 @@ def _download_file(url, dest_filename, chunk_size=1024): return False +def apply_patch_mbox(path, mbox_url): + with tempfile.NamedTemporaryFile(prefix="kernel-patch-") as tmp_f: + if not _download_file(mbox_url, tmp_f.name): + raise FileNotFoundError(f"Error downloading patch mbox {mbox_url}") + + shell_cmd(""" +set -e +cd {path} +git config user.name "kernelci-tsc" +git config user.email "kernelci-tsc@groups.io" +git am --3way {mbox_file} +""".format(path=path, mbox_file=tmp_f.name)) + + def pull_tarball(kdir, url, dest_filename, retries, delete): if os.path.exists(kdir): shutil.rmtree(kdir)