Skip to contentSkip to conversation

patch class fixes

PATCH New Paul Eggleton 1 participant 3 messages Dec 5, 2017

lore
Share & tools
lore
#0 lore raw

cover patch class fixes

A couple of fixes for the patch class.

The following changes since commit a7cd9d1183be603777fc9c8c448281fe01224f7b:

lib/oe/utils: remove param_bool() (2017-12-02 11:24:38 +0000)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib paule/patch-fixes
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=paule/patch-fixes

Paul Eggleton (2):
classes/patch: remove unused variable
classes/patch: when PATCHTOOL = "git" double-check the repository

 meta/classes/patch.bbclass | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
Signature · 1 line
2.9.5
#1 lore raw

PATCH 1/2 classes/patch: remove unused variable

---
 meta/classes/patch.bbclass | 1 -
 1 file changed, 1 deletion(-)
meta/classes/patch.bbclass +0 -1
index 8f35cb4..930ee33 100644
@@ -26,7 +26,6 @@ python () {
 
 python patch_task_patch_prefunc() {
     # Prefunc for do_patch
-    func = d.getVar('BB_RUNTASK')
     srcsubdir = d.getVar('S')
 
     patchdir = os.path.join(srcsubdir, 'patches')
Signature · 1 line
2.9.5
#2 lore raw

PATCH 2/2 classes/patch: when PATCHTOOL = "git" double-check the repository

In reply to Paul Eggleton

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.

---
 meta/classes/patch.bbclass | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
meta/classes/patch.bbclass +15 -0
index 930ee33..2fc6925 100644
@@ -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):
Signature · 1 line
2.9.5