summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oe/patch.py16
-rw-r--r--meta/lib/oeqa/selftest/cases/bbtests.py15
2 files changed, 30 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 @@
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,19 @@ 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 (status, output) = subprocess.getstatusoutput(cmd.split())
308 ## Make sure repo is in builddir to not break top-level git repos
309 return status == 0 and os.path.samedir(output, self.dir)
310
311 def _initRepo(self):
312 runcmd("git init".split(), self.dir)
313 runcmd("git add .".split(), self.dir)
314 runcmd("git commit -a --allow-empty -m Patching_started".split(), self.dir)
301 315
302 @staticmethod 316 @staticmethod
303 def extractPatchHeader(patchfile): 317 def extractPatchHeader(patchfile):
diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py
index 6562364074..9cd14aca4b 100644
--- a/meta/lib/oeqa/selftest/cases/bbtests.py
+++ b/meta/lib/oeqa/selftest/cases/bbtests.py
@@ -300,3 +300,18 @@ INHERIT:remove = \"report-error\"
300 300
301 test_recipe_summary_after = get_bb_var('SUMMARY', test_recipe) 301 test_recipe_summary_after = get_bb_var('SUMMARY', test_recipe)
302 self.assertEqual(expected_recipe_summary, test_recipe_summary_after) 302 self.assertEqual(expected_recipe_summary, test_recipe_summary_after)
303
304 def test_git_patchtool(self):
305 """ PATCHTOOL=git should work with non-git sources like tarballs
306 test recipe for the test must NOT containt git:// repository in SRC_URI
307 """
308 test_recipe = "man-db"
309 self.write_recipeinc(test_recipe, 'PATCHTOOL=\"git\"')
310 src = get_bb_var("SRC_URI",test_recipe)
311 gitscm = re.search("git://", src)
312 self.assertFalse(gitscm, "test_git_patchtool pre-condition failed: {} test recipe contains git repo!".format(test_recipe))
313 result = bitbake('man-db -c patch', ignore_status=False)
314 fatal = re.search("fatal: not a git repository (or any of the parent directories)", result.output)
315 self.assertFalse(fatal, "Failed to patch using PATCHTOOL=\"git\"")
316 self.delete_recipeinc(test_recipe)
317 bitbake('-cclean man-db')