1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-10 16:10:04 +00:00

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>
This commit is contained in:
Paul Eggleton
2017-12-05 14:36:58 +13:00
committed by Richard Purdie
parent c2b0259d90
commit 86ab56b551
+15
View File
@@ -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):