summaryrefslogtreecommitdiffstats
path: root/meta/classes/patch.bbclass
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-12-05 14:36:58 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-12-10 22:45:20 +0000
commit86ab56b55164393924b5e688b20e8f3f3f8fc578 (patch)
treea597401ac22c243fd773abee7483f8bf7d96445b /meta/classes/patch.bbclass
parentc2b0259d90da3f265b954498f98dc01d88d41c5d (diff)
downloadpoky-86ab56b55164393924b5e688b20e8f3f3f8fc578.tar.gz
classes/patch: when PATCHTOOL = "git" double-check the repository
If a bug is present or the user has set PATCHTOOL = "git" on a source tree that isn't git, if we try to perform git operations (such as committing or changing branches) when extracting source, then we might in fact be running those operations on the metadata repository if the build directory is underneath, say, poky or OE-Core, and that could make a mess. Check if the source tree is a git repository and refuse to continue if it isn't. (From OE-Core rev: 59ae5b7cbfeedb216a57c3f77fe52527b6c918cc) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/patch.bbclass')
-rw-r--r--meta/classes/patch.bbclass15
1 files changed, 15 insertions, 0 deletions
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index 930ee33d54..2fc6925e49 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -28,6 +28,21 @@ python patch_task_patch_prefunc() {
28 # Prefunc for do_patch 28 # Prefunc for do_patch
29 srcsubdir = d.getVar('S') 29 srcsubdir = d.getVar('S')
30 30
31 workdir = os.path.abspath(d.getVar('WORKDIR'))
32 testsrcdir = os.path.abspath(srcsubdir)
33 if (testsrcdir + os.sep).startswith(workdir + os.sep):
34 # Double-check that either workdir or S or some directory in-between is a git repository
35 found = False
36 while testsrcdir != '/':
37 if os.path.exists(os.path.join(testsrcdir, '.git')):
38 found = True
39 break
40 if testsrcdir == workdir:
41 break
42 testsrcdir = os.path.dirname(testsrcdir)
43 if not found:
44 bb.fatal('PATCHTOOL = "git" set for source tree that is not a git repository. Refusing to continue as that may result in commits being made in your metadata repository.')
45
31 patchdir = os.path.join(srcsubdir, 'patches') 46 patchdir = os.path.join(srcsubdir, 'patches')
32 if os.path.exists(patchdir): 47 if os.path.exists(patchdir):
33 if os.listdir(patchdir): 48 if os.listdir(patchdir):