mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
classes/buildcfg: Move git/layer revision code into new OE module buildcfg
There is a load of duplicated git/layer/revision code which makes most sesne as a python library, not bbclass code. Start to refactor as such. (From OE-Core rev: 439cdf8a1e52fd2c4dc81dc40ce7e6af282ce7ac) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -1,44 +1,5 @@
|
||||
def base_detect_revision(d):
|
||||
path = base_get_scmbasepath(d)
|
||||
return base_get_metadata_git_revision(path, d)
|
||||
|
||||
def base_detect_branch(d):
|
||||
path = base_get_scmbasepath(d)
|
||||
return base_get_metadata_git_branch(path, d)
|
||||
|
||||
def base_get_scmbasepath(d):
|
||||
return os.path.join(d.getVar('COREBASE'), 'meta')
|
||||
|
||||
def base_get_metadata_svn_revision(path, d):
|
||||
# This only works with older subversion. For newer versions
|
||||
# this function will need to be fixed by someone interested
|
||||
revision = "<unknown>"
|
||||
try:
|
||||
with open("%s/.svn/entries" % path) as f:
|
||||
revision = f.readlines()[3].strip()
|
||||
except (IOError, IndexError):
|
||||
pass
|
||||
return revision
|
||||
|
||||
def base_get_metadata_git_branch(path, d):
|
||||
import bb.process
|
||||
|
||||
try:
|
||||
rev, _ = bb.process.run('git rev-parse --abbrev-ref HEAD', cwd=path)
|
||||
except bb.process.ExecutionError:
|
||||
rev = '<unknown>'
|
||||
return rev.strip()
|
||||
|
||||
def base_get_metadata_git_revision(path, d):
|
||||
import bb.process
|
||||
|
||||
try:
|
||||
rev, _ = bb.process.run('git rev-parse HEAD', cwd=path)
|
||||
except bb.process.ExecutionError:
|
||||
rev = '<unknown>'
|
||||
return rev.strip()
|
||||
|
||||
METADATA_BRANCH := "${@base_detect_branch(d)}"
|
||||
METADATA_BRANCH := "${@oe.buildcfg.detect_branch(d)}"
|
||||
METADATA_BRANCH[vardepvalue] = "${METADATA_BRANCH}"
|
||||
METADATA_REVISION := "${@base_detect_revision(d)}"
|
||||
METADATA_REVISION := "${@oe.buildcfg.detect_revision(d)}"
|
||||
METADATA_REVISION[vardepvalue] = "${METADATA_REVISION}"
|
||||
|
||||
Reference in New Issue
Block a user