aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-09-05 11:10:46 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2017-12-05 14:36:11 +1300
commitea98050caef43c9b771ba3e243fbecb55dc130e3 (patch)
treec516f33b237df69d75db468e64148c82aef35453
parent8c94a9aaacf214108a395e0619fad3cdf894da07 (diff)
downloadopenembedded-core-contrib-paule/patch-fixes.tar.gz
classes/patch: when PATCHTOOL = "git" double-check the repositorypaule/patch-fixes
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. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-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() {
# Prefunc for do_patch
srcsubdir = d.getVar('S')
+ workdir = os.path.abspath(d.getVar('WORKDIR'))
+ testsrcdir = os.path.abspath(srcsubdir)
+ if (testsrcdir + os.sep).startswith(workdir + os.sep):
+ # Double-check that either workdir or S or some directory in-between is a git repository
+ found = False
+ while testsrcdir != '/':
+ if os.path.exists(os.path.join(testsrcdir, '.git')):
+ found = True
+ break
+ if testsrcdir == workdir:
+ break
+ testsrcdir = os.path.dirname(testsrcdir)
+ if not found:
+ 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.')
+
patchdir = os.path.join(srcsubdir, 'patches')
if os.path.exists(patchdir):
if os.listdir(patchdir):