From 5207e92cab473627f4a5b5f2bea33c922cbac4d4 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Tue, 21 Nov 2023 21:08:39 -0500 Subject: [PATCH] tools/osbuild-mpp: handle corner case in mpp-format-int If you do math in mpp-format-int it could end up getting converted to a float. Of course if you end up with a decimal value that isn't `.0` that's a problem for an int, but if it is `.0` let's handle it gracefully. For example, math like this could end up with a value with `.0`: mpp-format-int: "{bios_boot_size_mb * 1024 * 1024 / sector_size_bytes}" --- tools/osbuild-mpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/osbuild-mpp b/tools/osbuild-mpp index cce51a89..2bc33ac6 100755 --- a/tools/osbuild-mpp +++ b/tools/osbuild-mpp @@ -1259,6 +1259,11 @@ class ManifestFile: sys.exit(1) if res_type == "int": + # If the value ends with '.0' it could be because of + # some math that ended up converting the value to a + # float. Just trim it off in that case. + if res.endswith('.0'): + res = res.strip('.0') res = int(res) elif res_type == "json": res = json.loads(res)