summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/patch.py
diff options
context:
space:
mode:
authorPavel Zhukov <pavel.zhukov@huawei.com>2021-12-02 08:56:04 +0100
committerAnuj Mittal <anuj.mittal@intel.com>2021-12-10 12:28:43 +0800
commitc3e8317b15b1b78511a6f9aedfed54b59ab6972f (patch)
treed4ea7a8c770be1c074a21102323f6ea4c2212ed2 /meta/lib/oe/patch.py
parent39e5b3b37c3a0116fb01be6183b320d9afea3bfe (diff)
downloadopenembedded-core-contrib-c3e8317b15b1b78511a6f9aedfed54b59ab6972f.tar.gz
patch.py: Initialize git repo before patching
If PATCHTOOL="git" has been specified but workdir is not git repo bitbake fails to apply the patches with error message: Command Error: 'git rev-parse --show-toplevel' exited with 0 Output: fatal: not a git repository (or any of the parent directories): .git Fix this by initializing the repo before patching. This allows binary git patches to be applied. Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 6184b56a7a0fc6f5d19fdfb81e7453667f7da940) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'meta/lib/oe/patch.py')
-rw-r--r--meta/lib/oe/patch.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index fccbedb519..950fe723dc 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -4,6 +4,7 @@
import oe.path
import oe.types
+import subprocess
class NotFoundError(bb.BBHandledException):
def __init__(self, path):
@@ -25,7 +26,6 @@ class CmdError(bb.BBHandledException):
def runcmd(args, dir = None):
import pipes
- import subprocess
if dir:
olddir = os.path.abspath(os.curdir)
@@ -56,6 +56,7 @@ def runcmd(args, dir = None):
if dir:
os.chdir(olddir)
+
class PatchError(Exception):
def __init__(self, msg):
self.msg = msg
@@ -298,6 +299,19 @@ class GitApplyTree(PatchTree):
PatchTree.__init__(self, dir, d)
self.commituser = d.getVar('PATCH_GIT_USER_NAME')
self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL')
+ if not self._isInitialized():
+ self._initRepo()
+
+ def _isInitialized(self):
+ cmd = "git rev-parse --show-toplevel"
+ (status, output) = subprocess.getstatusoutput(cmd.split())
+ ## Make sure repo is in builddir to not break top-level git repos
+ return status == 0 and os.path.samedir(output, self.dir)
+
+ def _initRepo(self):
+ runcmd("git init".split(), self.dir)
+ runcmd("git add .".split(), self.dir)
+ runcmd("git commit -a --allow-empty -m Patching_started".split(), self.dir)
@staticmethod
def extractPatchHeader(patchfile):