Skip to contentSkip to conversation

Improve how to determine METADATA_REVISION

PATCH New Peter Kjellerstedt 1 participant 2 messages Apr 29, 2016

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/1 metadata_scm.bbclass: Do not assume ${COREBASE} is a Git repo

In reply to Peter Kjellerstedt

The functions base_detect_revision() and base_detect_branch() try to extract SCM meta information from the path returned by base_get_scmbasepath(), which currently returns ${COREBASE}. However, making the assumption that ${COREBASE} contains SCM meta information can be false. It is true for Poky, but not necessarily other environments. A better option is to look for the SCM meta information based on the meta layer.

Since this works as expected for Git but not SVN, the call to base_get_metadata_svn_revision() from base_detect_revision() was also removed. This is not expected to affect anyone (partly based on the comment in base_get_metadata_svn_revision()).

---
 meta/classes/metadata_scm.bbclass | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
meta/classes/metadata_scm.bbclass +2 -3
index 0f7f423..2e6fac2 100644
@@ -4,8 +4,7 @@ METADATA_REVISION ?= "${@base_detect_revision(d)}"
 def base_detect_revision(d):
     path = base_get_scmbasepath(d)
 
-    scms = [base_get_metadata_git_revision, \
-            base_get_metadata_svn_revision]
+    scms = [base_get_metadata_git_revision]
 
     for scm in scms:
         rev = scm(path, d)
@@ -27,7 +26,7 @@ def base_detect_branch(d):
     return "<unknown>"
 
 def base_get_scmbasepath(d):
-    return d.getVar( 'COREBASE', True)
+    return os.path.join(d.getVar('COREBASE', True), 'meta')
 
 def base_get_metadata_monotone_branch(path, d):
     monotone_branch = "<unknown>"
Signature · 1 line
2.1.0
#0 lore raw

v2 cover Improve how to determine METADATA_REVISION

We noticed that METADATA_REVISION was always set to '<unknown>' in our builds. It turned out that this was because the code in metadata_scm.bbclass that sets it assumed that ${COREBASE} contains a repository. This may be true when working with Poky, but is not necessarily true for other setups. E.g., in our setup we clone Poky, OpenEmbedded and other repositories using the repo tool and then create symbolic links from the base directory to the parts that we want. Since ${COREBASE} is defined based on the path to the meta layer, it should be a better option to use ${COREBASE}/meta when looking for the SCM meta information.

Since this works as expected for Git but not SVN, I removed the option to call base_get_metadata_svn_revision() from base_detect_revision(). I doubt this should affect anyone (partly based on the comment in base_get_metadata_svn_revision()), but if this is not acceptable, it should be trivial to change the code so the meta directory is only used when looking for Git meta information. However, since it would require the introduction of two functions to wrap the Git functions, I refrained from this option until requested otherwise.

PATCHv2: Added note about the removed call to base_get_metadata_svn_revision() to the commit message.

//Peter

The following changes since commit f7b520878babbaa7527151f22c031ae160512753:

poky: Switch to post release name/version (2016-04-29 07:58:46 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib pkj/metadata_scm
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=pkj/metadata_scm

Peter Kjellerstedt (1):
metadata_scm.bbclass: Do not assume ${COREBASE} is a Git repo

 meta/classes/metadata_scm.bbclass | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
2.1.0