summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/patch.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/patch.py')
-rw-r--r--meta/lib/oe/patch.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index fccbedb519..9034fcae03 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -4,6 +4,7 @@
4 4
5import oe.path 5import oe.path
6import oe.types 6import oe.types
7import subprocess
7 8
8class NotFoundError(bb.BBHandledException): 9class NotFoundError(bb.BBHandledException):
9 def __init__(self, path): 10 def __init__(self, path):
@@ -25,7 +26,6 @@ class CmdError(bb.BBHandledException):
25 26
26def runcmd(args, dir = None): 27def runcmd(args, dir = None):
27 import pipes 28 import pipes
28 import subprocess
29 29
30 if dir: 30 if dir:
31 olddir = os.path.abspath(os.curdir) 31 olddir = os.path.abspath(os.curdir)
@@ -56,6 +56,7 @@ def runcmd(args, dir = None):
56 if dir: 56 if dir:
57 os.chdir(olddir) 57 os.chdir(olddir)
58 58
59
59class PatchError(Exception): 60class PatchError(Exception):
60 def __init__(self, msg): 61 def __init__(self, msg):
61 self.msg = msg 62 self.msg = msg
@@ -298,6 +299,24 @@ class GitApplyTree(PatchTree):
298 PatchTree.__init__(self, dir, d) 299 PatchTree.__init__(self, dir, d)
299 self.commituser = d.getVar('PATCH_GIT_USER_NAME') 300 self.commituser = d.getVar('PATCH_GIT_USER_NAME')
300 self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL') 301 self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL')
302 if not self._isInitialized():
303 self._initRepo()
304
305 def _isInitialized(self):
306 cmd = "git rev-parse --show-toplevel"
307 try:
308 output = runcmd(cmd.split(), self.dir).strip()
309 except CmdError as err:
310 ## runcmd returned non-zero which most likely means 128
311 ## Not a git directory
312 return False
313 ## Make sure repo is in builddir to not break top-level git repos
314 return os.path.samefile(output, self.dir)
315
316 def _initRepo(self):
317 runcmd("git init".split(), self.dir)
318 runcmd("git add .".split(), self.dir)
319 runcmd("git commit -a --allow-empty -m bitbake_patching_started".split(), self.dir)
301 320
302 @staticmethod 321 @staticmethod
303 def extractPatchHeader(patchfile): 322 def extractPatchHeader(patchfile):