summaryrefslogtreecommitdiff
path: root/meta-phosphor/classes/image_version.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta-phosphor/classes/image_version.bbclass')
-rw-r--r--meta-phosphor/classes/image_version.bbclass18
1 files changed, 18 insertions, 0 deletions
diff --git a/meta-phosphor/classes/image_version.bbclass b/meta-phosphor/classes/image_version.bbclass
index bf3ca9345..17f324e2e 100644
--- a/meta-phosphor/classes/image_version.bbclass
+++ b/meta-phosphor/classes/image_version.bbclass
@@ -26,3 +26,21 @@ def do_get_versionID(d):
version = version.strip('"')
version_id = (hashlib.sha512(version.encode('utf-8')).hexdigest())[:8]
return version_id
+
+def do_get_buildID(d):
+ import configparser
+ import io
+ path = d.getVar('STAGING_DIR_TARGET', True) + d.getVar('sysconfdir', True)
+ path = os.path.join(path, 'os-release')
+ parser = configparser.ConfigParser(strict=False)
+ parser.optionxform = str
+ build_id = ''
+ try:
+ with open(path, 'r') as fd:
+ buf = '[root]\n' + fd.read()
+ fd = io.StringIO(buf)
+ parser.readfp(fd)
+ build_id = parser['root']['BUILD_ID']
+ except:
+ pass
+ return build_id