Skip to contentSkip to conversation

externalsrc: Handle .git not being a directory

PATCH Superseded Joshua Watt 2 participants 3 messages Aug 5, 2017 – Aug 7, 2017

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 externalsrc: Handle .git not being a directory

If EXTERNALSRC points to a git submodule, the .git entry will not be a directory, but rather a file that points to the actual .git location (in the parent repository). If this still can't be resolved to a directory, ignore it and fall back to the non-git method for hashing.

---
 meta/classes/externalsrc.bbclass | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
meta/classes/externalsrc.bbclass +13 -1
index 9aabb426d9e..ab5cd636051 100644
@@ -182,13 +182,25 @@ def srctree_hash_files(d, srcdir=None):
     import shutil
     import subprocess
     import tempfile
+    import re
 
     s_dir = srcdir or d.getVar('EXTERNALSRC')
     git_dir = os.path.join(s_dir, '.git')
+
+    if os.path.exists(git_dir) and os.path.isfile(git_dir):
+        with open(git_dir, 'r') as f:
+            m = re.match(r'gitdir: (.*)$', f.read())
+            if m is not None:
+                path = m.group(1)
+                if os.path.isabs(path):
+                    git_dir = path
+                else:
+                    git_dir = os.path.join(git_dir, path)
+
     oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1')
 
     ret = " "
-    if os.path.exists(git_dir):
+    if os.path.exists(git_dir) and os.path.isdir(git_dir):
         with tempfile.NamedTemporaryFile(prefix='oe-devtool-index') as tmp_index:
             # Clone index
             shutil.copyfile(os.path.join(git_dir, 'index'), tmp_index.name)
Signature · 1 line
2.13.3
#1 lore raw
Quoted 7 lines · Joshua Watt

If EXTERNALSRC points to a git submodule, the .git entry will not be a directory, but rather a file that points to the actual .git location (in the parent repository). If this still can't be resolved to a directory, ignore it and fall back to the non-git method for hashing.

We shouldn’t be assuming knowledge of how .git works, IMO we should call out to git rev-parse to query the info we need.

Signature · 4 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics
#2 lore raw

On Aug 5, 2017 18:37, "Christopher Larson" <[email protected]> wrote:

Quoted 7 lines · Joshua Watt

If EXTERNALSRC points to a git submodule, the .git entry will not be a directory, but rather a file that points to the actual .git location (in the parent repository). If this still can't be resolved to a directory, ignore it and fall back to the non-git method for hashing.

We shouldn’t be assuming knowledge of how .git works, IMO we should call out to git rev-parse to query the info we need.

Ya that makes sense. I'll fix it.

Signature · 4 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics