mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +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:
@@ -7,12 +7,11 @@ inherit staging
|
|||||||
inherit mirrors
|
inherit mirrors
|
||||||
inherit utils
|
inherit utils
|
||||||
inherit utility-tasks
|
inherit utility-tasks
|
||||||
inherit metadata_scm
|
|
||||||
inherit logging
|
inherit logging
|
||||||
|
|
||||||
OE_EXTRA_IMPORTS ?= ""
|
OE_EXTRA_IMPORTS ?= ""
|
||||||
|
|
||||||
OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license oe.qa oe.reproducible oe.rust ${OE_EXTRA_IMPORTS}"
|
OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license oe.qa oe.reproducible oe.rust oe.buildcfg ${OE_EXTRA_IMPORTS}"
|
||||||
OE_IMPORTS[type] = "list"
|
OE_IMPORTS[type] = "list"
|
||||||
|
|
||||||
PACKAGECONFIG_CONFARGS ??= ""
|
PACKAGECONFIG_CONFARGS ??= ""
|
||||||
@@ -35,6 +34,8 @@ def oe_import(d):
|
|||||||
# We need the oe module name space early (before INHERITs get added)
|
# We need the oe module name space early (before INHERITs get added)
|
||||||
OE_IMPORTED := "${@oe_import(d)}"
|
OE_IMPORTED := "${@oe_import(d)}"
|
||||||
|
|
||||||
|
inherit metadata_scm
|
||||||
|
|
||||||
def lsb_distro_identifier(d):
|
def lsb_distro_identifier(d):
|
||||||
adjust = d.getVar('LSB_DISTRO_ADJUST')
|
adjust = d.getVar('LSB_DISTRO_ADJUST')
|
||||||
adjust_func = None
|
adjust_func = None
|
||||||
@@ -219,8 +220,8 @@ def get_source_date_epoch_value(d):
|
|||||||
def get_layers_branch_rev(d):
|
def get_layers_branch_rev(d):
|
||||||
layers = (d.getVar("BBLAYERS") or "").split()
|
layers = (d.getVar("BBLAYERS") or "").split()
|
||||||
layers_branch_rev = ["%-20s = \"%s:%s\"" % (os.path.basename(i), \
|
layers_branch_rev = ["%-20s = \"%s:%s\"" % (os.path.basename(i), \
|
||||||
base_get_metadata_git_branch(i, None).strip(), \
|
oe.buildcfg.get_metadata_git_branch(i, None).strip(), \
|
||||||
base_get_metadata_git_revision(i, None)) \
|
oe.buildcfg.get_metadata_git_revision(i, None)) \
|
||||||
for i in layers]
|
for i in layers]
|
||||||
i = len(layers_branch_rev)-1
|
i = len(layers_branch_rev)-1
|
||||||
p1 = layers_branch_rev[i].find("=")
|
p1 = layers_branch_rev[i].find("=")
|
||||||
|
|||||||
@@ -761,8 +761,8 @@ def buildhistory_get_metadata_revs(d):
|
|||||||
# We want an easily machine-readable format here, so get_layers_branch_rev isn't quite what we want
|
# We want an easily machine-readable format here, so get_layers_branch_rev isn't quite what we want
|
||||||
layers = (d.getVar("BBLAYERS") or "").split()
|
layers = (d.getVar("BBLAYERS") or "").split()
|
||||||
medadata_revs = ["%-17s = %s:%s%s" % (os.path.basename(i), \
|
medadata_revs = ["%-17s = %s:%s%s" % (os.path.basename(i), \
|
||||||
base_get_metadata_git_branch(i, None).strip(), \
|
oe.buildcfg.get_metadata_git_branch(i, None).strip(), \
|
||||||
base_get_metadata_git_revision(i, None), \
|
oe.buildcfg.get_metadata_git_revision(i, None), \
|
||||||
buildhistory_get_modified(i)) \
|
buildhistory_get_modified(i)) \
|
||||||
for i in layers]
|
for i in layers]
|
||||||
return '\n'.join(medadata_revs)
|
return '\n'.join(medadata_revs)
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ def get_layer_git_status(path):
|
|||||||
def get_layer_revs(d):
|
def get_layer_revs(d):
|
||||||
layers = (d.getVar("BBLAYERS") or "").split()
|
layers = (d.getVar("BBLAYERS") or "").split()
|
||||||
medadata_revs = ["%-17s = %s:%s %s" % (os.path.basename(i), \
|
medadata_revs = ["%-17s = %s:%s %s" % (os.path.basename(i), \
|
||||||
base_get_metadata_git_branch(i, None).strip(), \
|
oe.buildcfg.get_metadata_git_branch(i, None).strip(), \
|
||||||
base_get_metadata_git_revision(i, None), \
|
oe.buildcfg.get_metadata_git_revision(i, None), \
|
||||||
get_layer_git_status(i)) \
|
get_layer_git_status(i)) \
|
||||||
for i in layers]
|
for i in layers]
|
||||||
return '\n'.join(medadata_revs)
|
return '\n'.join(medadata_revs)
|
||||||
|
|||||||
@@ -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):
|
METADATA_BRANCH := "${@oe.buildcfg.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[vardepvalue] = "${METADATA_BRANCH}"
|
METADATA_BRANCH[vardepvalue] = "${METADATA_BRANCH}"
|
||||||
METADATA_REVISION := "${@base_detect_revision(d)}"
|
METADATA_REVISION := "${@oe.buildcfg.detect_revision(d)}"
|
||||||
METADATA_REVISION[vardepvalue] = "${METADATA_REVISION}"
|
METADATA_REVISION[vardepvalue] = "${METADATA_REVISION}"
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ python errorreport_handler () {
|
|||||||
data['target_sys'] = e.data.getVar("TARGET_SYS")
|
data['target_sys'] = e.data.getVar("TARGET_SYS")
|
||||||
data['failures'] = []
|
data['failures'] = []
|
||||||
data['component'] = " ".join(e.getPkgs())
|
data['component'] = " ".join(e.getPkgs())
|
||||||
data['branch_commit'] = str(base_detect_branch(e.data)) + ": " + str(base_detect_revision(e.data))
|
data['branch_commit'] = str(oe.buildcfg.detect_branch(e.data)) + ": " + str(oe.buildcfg.detect_revision(e.data))
|
||||||
data['bitbake_version'] = e.data.getVar("BB_VERSION")
|
data['bitbake_version'] = e.data.getVar("BB_VERSION")
|
||||||
data['layer_version'] = get_layers_branch_rev(e.data)
|
data['layer_version'] = get_layers_branch_rev(e.data)
|
||||||
data['local_conf'] = get_conf_data(e, 'local.conf')
|
data['local_conf'] = get_conf_data(e, 'local.conf')
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
import subprocess
|
||||||
|
import bb.process
|
||||||
|
|
||||||
|
def detect_revision(d):
|
||||||
|
path = get_scmbasepath(d)
|
||||||
|
return get_metadata_git_revision(path, d)
|
||||||
|
|
||||||
|
def detect_branch(d):
|
||||||
|
path = get_scmbasepath(d)
|
||||||
|
return get_metadata_git_branch(path, d)
|
||||||
|
|
||||||
|
def get_scmbasepath(d):
|
||||||
|
return os.path.join(d.getVar('COREBASE'), 'meta')
|
||||||
|
|
||||||
|
def 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 get_metadata_git_branch(path, d):
|
||||||
|
try:
|
||||||
|
rev, _ = bb.process.run('git rev-parse --abbrev-ref HEAD', cwd=path)
|
||||||
|
except bb.process.ExecutionError:
|
||||||
|
rev = '<unknown>'
|
||||||
|
return rev.strip()
|
||||||
|
|
||||||
|
def get_metadata_git_revision(path, d):
|
||||||
|
try:
|
||||||
|
rev, _ = bb.process.run('git rev-parse HEAD', cwd=path)
|
||||||
|
except bb.process.ExecutionError:
|
||||||
|
rev = '<unknown>'
|
||||||
|
return rev.strip()
|
||||||
|
|
||||||
Reference in New Issue
Block a user