From cdd91ad2909116d136f5152b645f87592f39a1db Mon Sep 17 00:00:00 2001 From: Adriana Kobylak Date: Mon, 25 Oct 2021 15:58:19 +0000 Subject: image_types: Add BUILD_ID to MANIFEST Add the BUILD_ID value to the MANIFEST so that it can be used alongside the VERSION value to generate a version id during firmware updates. Add a function to read BUILD_ID from the os-release file instead of reading it from a variable because the BUILD_ID value could be set via a os_release.bbappend file instead of a .conf file. Tested: Verified the BUILD_ID value was added to the MANIFEST by default, and when BUILD_ID was specified in a .conf file, and on a os-release.bbappend. Ex: $ cat MANIFEST purpose=xyz.openbmc_project.Software.Version.VersionPurpose.BMC version=2.11.0-dev-566-g263df7f852 BuildId=20211025151654 ExtendedVersion= KeyType=OpenBMC HashType=RSA-SHA256 MachineName=p10bmc Change-Id: I3b7beaccbbd47d8820d499180ccdf021b004cf85 Signed-off-by: Adriana Kobylak --- meta-phosphor/classes/image_version.bbclass | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'meta-phosphor/classes/image_version.bbclass') 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 -- cgit v1.2.3