-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernelci/build.py: Add apply_patch_mbox method
Signed-off-by: Nikolay Yurin <[email protected]>
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import re | ||
import shutil | ||
import tarfile | ||
import tempfile | ||
import time | ||
import urllib.parse | ||
|
||
|
@@ -321,6 +322,37 @@ def _download_file(url, dest_filename, chunk_size=1024): | |
return False | ||
|
||
|
||
def apply_patch_mbox( | ||
kdir, | ||
mbox_url, | ||
git_username="kernelci-tsc", | ||
git_email="[email protected]" | ||
): | ||
"""Download patch mbox from URL and apply with 3-way merge | ||
*kdir* is the path to a kernel source directory | ||
*mbox_url* is the URL to patch mbox content | ||
*git_username* is the username used to apply the patch | ||
*git_email* is the email used to apply the patch | ||
""" | ||
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 {kdir} | ||
git config user.name "{git_username}" | ||
git config user.email "{git_email}" | ||
git am --3way {mbox_file} | ||
""".format( | ||
kdir=kdir, | ||
mbox_file=tmp_f.name, | ||
git_username=git_username, | ||
git_email=git_email | ||
)) | ||
|
||
|
||
def pull_tarball(kdir, url, dest_filename, retries, delete): | ||
if os.path.exists(kdir): | ||
shutil.rmtree(kdir) | ||
|