Skip to content

Commit

Permalink
kernelci/build.py: Add apply_patch_mbox method
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 a612e09 commit 7f39442
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions kernelci/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "[email protected]"
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)
Expand Down

0 comments on commit 7f39442

Please sign in to comment.