Skip to content

Commit 7f39442

Browse files
committed
kernelci/build.py: Add apply_patch_mbox method
Signed-off-by: Nikolay Yurin <[email protected]>
1 parent a612e09 commit 7f39442

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

kernelci/build.py

+15
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import tarfile
2727
import time
2828
import urllib.parse
29+
import tempfile
2930

3031
import requests
3132
from kernelci import shell_cmd, print_flush, __version__ as kernelci_version
@@ -321,6 +322,20 @@ def _download_file(url, dest_filename, chunk_size=1024):
321322
return False
322323

323324

325+
def apply_patch_mbox(path, mbox_url):
326+
with tempfile.NamedTemporaryFile(prefix="kernel-patch-") as tmp_f:
327+
if not _download_file(mbox_url, tmp_f.name):
328+
raise FileNotFoundError(f"Error downloading patch mbox {mbox_url}")
329+
330+
shell_cmd("""
331+
set -e
332+
cd {path}
333+
git config user.name "kernelci-tsc"
334+
git config user.email "[email protected]"
335+
git am --3way {mbox_file}
336+
""".format(path=path, mbox_file=tmp_f.name))
337+
338+
324339
def pull_tarball(kdir, url, dest_filename, retries, delete):
325340
if os.path.exists(kdir):
326341
shutil.rmtree(kdir)

0 commit comments

Comments
 (0)