Files
SDK_SG200x_V2/freertos/Test/CBMC/patches/patch.py
carbon 0545e9dc6d init version 2024-05-07
commit d1edce71135cc6d98c0a4b5729774542b676e769
Author: sophgo-forum-service <forum_service@sophgo.com>
Date:   Fri Mar 15 16:07:33 2024 +0800

    [fix] recommend using ssh method to clone repo.
    [fix] fix sensor driver repo branch name.
2024-05-07 19:36:36 +08:00

37 lines
1.0 KiB
Python
Executable File

#!/usr/bin/env python3
import logging
import os
import subprocess
import sys
from glob import glob
from patches_constants import PATCHES_DIR
def patch():
if os.path.isfile("patched"):
sys.exit()
applied_patches = []
failed_patches = []
for tmpfile in glob(os.path.join(PATCHES_DIR, "*.patch")):
print("patch", tmpfile)
result = subprocess.run(["git", "apply", "--ignore-space-change", "--ignore-whitespace", tmpfile],
cwd=os.path.join("..", "..", "..", ".."))
if result.returncode:
failed_patches.append(tmpfile)
logging.error("patching failed: %s", tmpfile)
else:
applied_patches.append(tmpfile)
with open(os.path.join(PATCHES_DIR, "patched"), "w") as outp:
print("Success:", file=outp)
print("\n".join(map(lambda x: "\t" + x, applied_patches)), file=outp)
print("Failure:", file=outp)
print("\n".join(map(lambda x: "\t" + x, failed_patches)), file=outp)
if __name__ == "__main__":
patch()