diff options
author | Pavel Zhukov <pavel.zhukov@huawei.com> | 2021-12-02 08:56:04 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-12-03 23:37:16 +0000 |
commit | ae57c83f03247b5149c94ae8e8fc25d6ad27dc02 (patch) | |
tree | a453f8e0d296c67bfa294fa18a04da1e90c1dfb5 /meta/lib/oe | |
parent | b1984dd2f5096fca7b7a8b93a45143825b168bda (diff) | |
download | poky-ae57c83f03247b5149c94ae8e8fc25d6ad27dc02.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.
(From OE-Core rev: 6184b56a7a0fc6f5d19fdfb81e7453667f7da940)
Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r-- | meta/lib/oe/patch.py | 16 |
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 @@ | |||
4 | 4 | ||
5 | import oe.path | 5 | import oe.path |
6 | import oe.types | 6 | import oe.types |
7 | import subprocess | ||
7 | 8 | ||
8 | class NotFoundError(bb.BBHandledException): | 9 | class NotFoundError(bb.BBHandledException): |
9 | def __init__(self, path): | 10 | def __init__(self, path): |
@@ -25,7 +26,6 @@ class CmdError(bb.BBHandledException): | |||
25 | 26 | ||
26 | def runcmd(args, dir = None): | 27 | def 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 | |||
59 | class PatchError(Exception): | 60 | class 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): |