diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2021-10-25 18:58:19 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2021-11-10 00:54:55 +0300 |
commit | cdd91ad2909116d136f5152b645f87592f39a1db (patch) | |
tree | 805ac0036be2747115a4dc57233f232479ea05f5 /meta-phosphor | |
parent | 5577bf45a23118c3d5e34fd35921c59985641c95 (diff) | |
download | openbmc-cdd91ad2909116d136f5152b645f87592f39a1db.tar.xz |
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 <anoo@us.ibm.com>
Diffstat (limited to 'meta-phosphor')
-rw-r--r-- | meta-phosphor/classes/image_types_phosphor.bbclass | 2 | ||||
-rw-r--r-- | meta-phosphor/classes/image_version.bbclass | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/meta-phosphor/classes/image_types_phosphor.bbclass b/meta-phosphor/classes/image_types_phosphor.bbclass index be3bbdf50..64fec000b 100644 --- a/meta-phosphor/classes/image_types_phosphor.bbclass +++ b/meta-phosphor/classes/image_types_phosphor.bbclass @@ -502,11 +502,13 @@ def get_pubkey_path(d): python do_generate_phosphor_manifest() { purpose = d.getVar('VERSION_PURPOSE', True) version = do_get_version(d) + build_id = do_get_buildID(d) target_machine = d.getVar('MACHINE', True) extended_version = (d.getVar('EXTENDED_VERSION', True) or "") with open('MANIFEST', 'w') as fd: fd.write('purpose={}\n'.format(purpose)) fd.write('version={}\n'.format(version.strip('"'))) + fd.write('BuildId={}\n'.format(build_id.strip('"'))) fd.write('ExtendedVersion={}\n'.format(extended_version)) fd.write('KeyType={}\n'.format(get_pubkey_type(d))) fd.write('HashType=RSA-SHA256\n') 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 |