mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
lib/buildcfg: Share common clean/dirty layer function
The comments even say this was copy/paste code. Move to a shared library function. (From OE-Core rev: ac3de2f850a418673b87e1c454970cb099e191b0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -741,29 +741,13 @@ def buildhistory_get_build_id(d):
|
|||||||
statusheader = d.getVar('BUILDCFG_HEADER')
|
statusheader = d.getVar('BUILDCFG_HEADER')
|
||||||
return('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines)))
|
return('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines)))
|
||||||
|
|
||||||
def buildhistory_get_modified(path):
|
|
||||||
# copied from get_layer_git_status() in image-buildinfo.bbclass
|
|
||||||
import subprocess
|
|
||||||
try:
|
|
||||||
subprocess.check_output("""cd %s; export PSEUDO_UNLOAD=1; set -e;
|
|
||||||
git diff --quiet --no-ext-diff
|
|
||||||
git diff --quiet --no-ext-diff --cached""" % path,
|
|
||||||
shell=True,
|
|
||||||
stderr=subprocess.STDOUT)
|
|
||||||
return ""
|
|
||||||
except subprocess.CalledProcessError as ex:
|
|
||||||
# Silently treat errors as "modified", without checking for the
|
|
||||||
# (expected) return code 1 in a modified git repo. For example, we get
|
|
||||||
# output and a 129 return code when a layer isn't a git repo at all.
|
|
||||||
return " -- modified"
|
|
||||||
|
|
||||||
def buildhistory_get_metadata_revs(d):
|
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), \
|
||||||
oe.buildcfg.get_metadata_git_branch(i, None).strip(), \
|
oe.buildcfg.get_metadata_git_branch(i, None).strip(), \
|
||||||
oe.buildcfg.get_metadata_git_revision(i, None), \
|
oe.buildcfg.get_metadata_git_revision(i, None), \
|
||||||
buildhistory_get_modified(i)) \
|
oe.buildcfg.is_layer_modified(i)) \
|
||||||
for i in layers]
|
for i in layers]
|
||||||
return '\n'.join(medadata_revs)
|
return '\n'.join(medadata_revs)
|
||||||
|
|
||||||
|
|||||||
@@ -26,29 +26,13 @@ def image_buildinfo_outputvars(vars, d):
|
|||||||
ret += "%s = %s\n" % (var, value)
|
ret += "%s = %s\n" % (var, value)
|
||||||
return ret.rstrip('\n')
|
return ret.rstrip('\n')
|
||||||
|
|
||||||
# Gets git branch's status (clean or dirty)
|
|
||||||
def get_layer_git_status(path):
|
|
||||||
import subprocess
|
|
||||||
try:
|
|
||||||
subprocess.check_output("""cd %s; export PSEUDO_UNLOAD=1; set -e;
|
|
||||||
git diff --quiet --no-ext-diff
|
|
||||||
git diff --quiet --no-ext-diff --cached""" % path,
|
|
||||||
shell=True,
|
|
||||||
stderr=subprocess.STDOUT)
|
|
||||||
return ""
|
|
||||||
except subprocess.CalledProcessError as ex:
|
|
||||||
# Silently treat errors as "modified", without checking for the
|
|
||||||
# (expected) return code 1 in a modified git repo. For example, we get
|
|
||||||
# output and a 129 return code when a layer isn't a git repo at all.
|
|
||||||
return "-- modified"
|
|
||||||
|
|
||||||
# Returns layer revisions along with their respective status
|
# Returns layer revisions along with their respective status
|
||||||
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), \
|
||||||
oe.buildcfg.get_metadata_git_branch(i, None).strip(), \
|
oe.buildcfg.get_metadata_git_branch(i, None).strip(), \
|
||||||
oe.buildcfg.get_metadata_git_revision(i, None), \
|
oe.buildcfg.get_metadata_git_revision(i, None), \
|
||||||
get_layer_git_status(i)) \
|
oe.buildcfg.is_layer_modified(i)) \
|
||||||
for i in layers]
|
for i in layers]
|
||||||
return '\n'.join(medadata_revs)
|
return '\n'.join(medadata_revs)
|
||||||
|
|
||||||
|
|||||||
@@ -38,3 +38,16 @@ def get_metadata_git_revision(path, d):
|
|||||||
rev = '<unknown>'
|
rev = '<unknown>'
|
||||||
return rev.strip()
|
return rev.strip()
|
||||||
|
|
||||||
|
def is_layer_modified(path):
|
||||||
|
try:
|
||||||
|
subprocess.check_output("""cd %s; export PSEUDO_UNLOAD=1; set -e;
|
||||||
|
git diff --quiet --no-ext-diff
|
||||||
|
git diff --quiet --no-ext-diff --cached""" % path,
|
||||||
|
shell=True,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
|
return ""
|
||||||
|
except subprocess.CalledProcessError as ex:
|
||||||
|
# Silently treat errors as "modified", without checking for the
|
||||||
|
# (expected) return code 1 in a modified git repo. For example, we get
|
||||||
|
# output and a 129 return code when a layer isn't a git repo at all.
|
||||||
|
return " -- modified"
|
||||||
|
|||||||
Reference in New Issue
Block a user