Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v3] externalsrc: Handle .git not being a directory
@ 2017-08-08  1:46 Joshua Watt
  2017-08-08 19:32 ` Burton, Ross
  0 siblings, 1 reply; 4+ messages in thread
From: Joshua Watt @ 2017-08-08  1:46 UTC (permalink / raw)
  To: openembedded-core

Use git rev-parse to determine the location of the .git directory, in
case it is not an immediate child of EXTERNALSRC (e.g. when using
submodules). In the event git can't resolve the .git directory, fall
back to the non-git method for hashing.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 meta/classes/externalsrc.bbclass | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
index 9aabb426d9e..ea0faaf4193 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -184,11 +184,16 @@ def srctree_hash_files(d, srcdir=None):
     import tempfile
 
     s_dir = srcdir or d.getVar('EXTERNALSRC')
-    git_dir = os.path.join(s_dir, '.git')
-    oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1')
+    git_dir = None
+
+    try:
+        git_dir = subprocess.check_output(['git', 'rev-parse', '--absolute-git-dir'], cwd=s_dir).decode("utf-8").rstrip()
+    except subprocess.CalledProcessError:
+        pass
 
     ret = " "
-    if os.path.exists(git_dir):
+    if git_dir is not None:
+        oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1')
         with tempfile.NamedTemporaryFile(prefix='oe-devtool-index') as tmp_index:
             # Clone index
             shutil.copyfile(os.path.join(git_dir, 'index'), tmp_index.name)
-- 
2.13.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] externalsrc: Handle .git not being a directory
  2017-08-08  1:46 [PATCH v3] externalsrc: Handle .git not being a directory Joshua Watt
@ 2017-08-08 19:32 ` Burton, Ross
  2017-08-08 19:46   ` Leonardo Sandoval
  0 siblings, 1 reply; 4+ messages in thread
From: Burton, Ross @ 2017-08-08 19:32 UTC (permalink / raw)
  To: Joshua Watt; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 656 bytes --]

On 8 August 2017 at 02:46, Joshua Watt <jpewhacker@gmail.com> wrote:

> +        git_dir = subprocess.check_output(['git', 'rev-parse',
> '--absolute-git-dir'], cwd=s_dir).decode("utf-8").rstrip()
>

Doesn't work with my old git:

bb.data_smart.ExpansionError: Failure expanding variable
do_compile[file-checksums], expression was ${@srctree_hash_files(d)} which
triggered exception FileNotFoundError: [Errno 2] No such file or directory:
'--absolute-git-dir/index'
Summary: There was 1 ERROR message shown, returning a non-zero exit code.

$ git rev-parse --absolute-git-dir
--absolute-git-dir
$ git --version
git version 2.11.0

Ross

[-- Attachment #2: Type: text/html, Size: 1194 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] externalsrc: Handle .git not being a directory
  2017-08-08 19:32 ` Burton, Ross
@ 2017-08-08 19:46   ` Leonardo Sandoval
  2017-08-08 20:57     ` Joshua Watt
  0 siblings, 1 reply; 4+ messages in thread
From: Leonardo Sandoval @ 2017-08-08 19:46 UTC (permalink / raw)
  To: Burton, Ross; +Cc: OE-core

On Tue, 2017-08-08 at 20:32 +0100, Burton, Ross wrote:
> On 8 August 2017 at 02:46, Joshua Watt <jpewhacker@gmail.com> wrote:
>         +        git_dir = subprocess.check_output(['git',
>         'rev-parse', '--absolute-git-dir'],
>         cwd=s_dir).decode("utf-8").rstrip()
> 
> 
> Doesn't work with my old git:
> 
> 
> bb.data_smart.ExpansionError: Failure expanding variable
> do_compile[file-checksums], expression was ${@srctree_hash_files(d)}
> which triggered exception FileNotFoundError: [Errno 2] No such file or
> directory: '--absolute-git-dir/index'
> Summary: There was 1 ERROR message shown, returning a non-zero exit
> code.
> 
> 
> 
> $ git rev-parse --absolute-git-dir
> --absolute-git-dir
> $ git --version
> git version 2.11.0
> 
I also tried it and got same log. my git is a bit newer (2.12.3).

Leo
> 
> Ross
> -- 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] externalsrc: Handle .git not being a directory
  2017-08-08 19:46   ` Leonardo Sandoval
@ 2017-08-08 20:57     ` Joshua Watt
  0 siblings, 0 replies; 4+ messages in thread
From: Joshua Watt @ 2017-08-08 20:57 UTC (permalink / raw)
  To: Leonardo Sandoval, Burton, Ross; +Cc: OE-core

On Tue, 2017-08-08 at 14:46 -0500, Leonardo Sandoval wrote:
> On Tue, 2017-08-08 at 20:32 +0100, Burton, Ross wrote:
> > On 8 August 2017 at 02:46, Joshua Watt <jpewhacker@gmail.com>
> > wrote:
> >         +        git_dir = subprocess.check_output(['git',
> >         'rev-parse', '--absolute-git-dir'],
> >         cwd=s_dir).decode("utf-8").rstrip()
> > 
> > 
> > Doesn't work with my old git:
> > 
> > 
> > bb.data_smart.ExpansionError: Failure expanding variable
> > do_compile[file-checksums], expression was ${@srctree_hash_files(d)
> > }
> > which triggered exception FileNotFoundError: [Errno 2] No such file
> > or
> > directory: '--absolute-git-dir/index'
> > Summary: There was 1 ERROR message shown, returning a non-zero exit
> > code.
> > 
> > 
> > 
> > $ git rev-parse --absolute-git-dir
> > --absolute-git-dir
> > $ git --version
> > git version 2.11.0
> > 
> 
> I also tried it and got same log. my git is a bit newer (2.12.3).

Ok. I wasn't sure exactly when that option was added, I'll use the
older one.

> 
> Leo
> > 
> > Ross
> > -- 
> > _______________________________________________
> > Openembedded-core mailing list
> > Openembedded-core@lists.openembedded.org
> > http://lists.openembedded.org/mailman/listinfo/openembedded-core
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-08 20:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-08  1:46 [PATCH v3] externalsrc: Handle .git not being a directory Joshua Watt
2017-08-08 19:32 ` Burton, Ross
2017-08-08 19:46   ` Leonardo Sandoval
2017-08-08 20:57     ` Joshua Watt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox