Skip to content

Commit

Permalink
cbuild: apply git patches one by one
Browse files Browse the repository at this point in the history
While this means losing the benefit of having a clean tree when
a patch fails, it allows logging the patch names being applied
(which we apparently cannot do when passing all the patches at
once as git cannot do it) which makes it a lot more obvious which
particular patch failed.
  • Loading branch information
q66 committed Sep 30, 2024
1 parent 84abd2b commit da3dc1c
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/cbuild/util/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,11 @@ def patch_git(pkg, patch_list, wrksrc=None, apply_args=[]):
pkg.error("failed to initialize repository in source location")

# now apply everything in a batch
srcmd = [
"env",
"HOME=/dev/null",
"git",
"apply",
*apply_args,
*patch_list,
]
if subprocess.run(srcmd, cwd=pkg.srcdir).returncode != 0:
pkg.error("failed to apply patches")
srcmd = ["env", "HOME=/dev/null", "git", "apply", *apply_args]
for p in patch_list:
pkg.log(f"patching: {p.name}")
if subprocess.run([*srcmd, p], cwd=pkg.srcdir).returncode != 0:
pkg.error(f"failed to apply '{p.name}'")

# now remove the repo so we don't give build systems ideas
shutil.rmtree(pkg.srcdir / ".git")

0 comments on commit da3dc1c

Please sign in to comment.