From 417234737e4238a6f2315188c10d1e16f65e9664 Mon Sep 17 00:00:00 2001 From: Saqib Khan Date: Fri, 22 Sep 2017 10:21:30 -0500 Subject: Calculate the version ID of BMC UBI volumes during build time. - When the new ubi layout is flashed onto the BMC, the volumes were named kernel-0 and rofs-0 by default. This tends to be misleading as we can't differentiate between two different BMC versions. - Now the ubi volumes will be named kernel- and rofs- calculated by getting the hash(SHA-512) of the version and taking the first 8 characters. - The Uboot env needs to be updated to point to the correct kernelname which has now changed from kernel-0 to kernel- calculated by getting the HASH(SHA-512) of the version and taking the first 8 characters. Resolves openbmc/openbmc#2323 Change-Id: I258d165b399d1ff59ea86f410006f6d03fe13a2e Signed-off-by: Saqib Khan --- meta-phosphor/classes/image_version.bbclass | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 meta-phosphor/classes/image_version.bbclass (limited to 'meta-phosphor/classes/image_version.bbclass') diff --git a/meta-phosphor/classes/image_version.bbclass b/meta-phosphor/classes/image_version.bbclass new file mode 100644 index 000000000..f9abb5fc9 --- /dev/null +++ b/meta-phosphor/classes/image_version.bbclass @@ -0,0 +1,26 @@ +# Base image version class extension + +def do_get_version(d): + import configparser + import io + path = d.getVar('STAGING_DIR_HOST', True) + d.getVar('sysconfdir', True) + path = os.path.join(path, 'os-release') + parser = configparser.SafeConfigParser(strict=False) + parser.optionxform = str + version = '' + try: + with open(path, 'r') as fd: + buf = '[root]\n' + fd.read() + fd = io.StringIO(buf) + parser.readfp(fd) + version = parser['root']['VERSION_ID'] + except: + pass + return version + +def do_get_versionID(d): + import hashlib + version = do_get_version(d) + version = version.strip('"') + version_id = (hashlib.sha512(version.encode('utf-8')).hexdigest())[:8] + return version_id -- cgit v1.2.3