Squashed 'import-layers/meta-openembedded/' changes from df3537259..b40116cf4

Yocto 2.2.2 (Morty)

Change-Id: I3998555f14538d8306be995bcfb366173e04e975
git-subtree-dir: import-layers/meta-openembedded
git-subtree-split: b40116cf457b88a2db14b86fda9627fb34d56ae6
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/import-layers/meta-openembedded/meta-oe/classes/gitver.bbclass b/import-layers/meta-openembedded/meta-oe/classes/gitver.bbclass
index e7b5155..9154143 100644
--- a/import-layers/meta-openembedded/meta-oe/classes/gitver.bbclass
+++ b/import-layers/meta-openembedded/meta-oe/classes/gitver.bbclass
@@ -13,37 +13,45 @@
         return version
 
 GIT_TAGADJUST = "git_drop_tag_prefix(version)"
-GITVER = "${@get_git_pv('${S}', d, tagadjust=lambda version:${GIT_TAGADJUST})}"
-GITSHA = "${@get_git_hash('${S}', d)}"
+GITVER = "${@get_git_pv(d, tagadjust=lambda version:${GIT_TAGADJUST})}"
+GITSHA = "${@get_git_hash(d)}"
 
 def gitrev_run(cmd, path):
     (output, error) = bb.process.run(cmd, cwd=path)
     return output.rstrip()
 
-def get_git_pv(path, d, tagadjust=None):
+def get_git_pv(d, tagadjust=None):
     import os
-    import bb.process
 
-    gitdir = os.path.abspath(os.path.join(d.getVar("S", True), ".git"))
+    srcdir = d.getVar("EXTERNALSRC", True) or d.getVar("S", True)
+    gitdir = os.path.abspath(os.path.join(srcdir, ".git"))
     try:
         ver = gitrev_run("git describe --tags", gitdir)
-    except Exception, exc:
-        bb.fatal(str(exc))
-
-    if not ver:
+    except:
         try:
             ver = gitrev_run("git rev-parse --short HEAD", gitdir)
-        except Exception, exc:
-            bb.fatal(str(exc))
+            if ver:
+                return "0.0+%s" % ver
+            else:
+                return "0.0"
 
-        if ver:
-            return "0.0+%s" % ver
-        else:
-            return "0.0"
-    else:
-        if tagadjust:
-            ver = tagadjust(ver)
-        return ver
+        except Exception as exc:
+            raise bb.parse.SkipPackage(str(exc))
+
+    if ver and tagadjust:
+        ver = tagadjust(ver)
+    return ver
+
+def get_git_hash(d):
+    import os
+
+    srcdir = d.getVar("EXTERNALSRC", True) or d.getVar("S", True)
+    gitdir = os.path.abspath(os.path.join(srcdir, ".git"))
+    try:
+        return gitrev_run("git rev-parse HEAD", gitdir)
+
+    except Exception as exc:
+        bb.fatal(str(exc))
 
 def mark_recipe_dependencies(path, d):
     from bb.parse import mark_dependency
@@ -71,5 +79,6 @@
         mark_dependency(d, tagdir)
 
 python () {
-    mark_recipe_dependencies(d.getVar("S", True), d)
+    srcdir = d.getVar("EXTERNALSRC", True) or d.getVar("S", True)
+    mark_recipe_dependencies(srcdir, d)
 }