From: Michael Opdenacker <michael.opdenac...@bootlin.com> The upcoming introduction of "passthrough" PR servers will add non integer PR values, such as '0.3'.
With such a value, the current conversion of this value to a string, to define the package file name, can result in incorrect strings such as "0.30000000000000004"! Introduce a safe_str() function which, when given a float value, rounds it up to the 6th decimal first, before the conversion to string. Signed-off-by: Michael Opdenacker <michael.opdenac...@bootlin.com> CC: thomas.petazz...@bootlin.com --- Notes: this has been tested successfully on the "master" branch. No obvious regression was found and the package file names look normal. --- meta/classes-global/package.bbclass | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass index aa1eb5e901..82747d5467 100644 --- a/meta/classes-global/package.bbclass +++ b/meta/classes-global/package.bbclass @@ -250,6 +250,13 @@ package_get_auto_pr[vardeps] += "PRSERV_ACTIVE" python package_get_auto_pr() { import oe.prservice + def safe_str(pr): + # Avoids turning 0.3 to 0.30000000000000004 (for example) + # during the conversion of a float to a string + if type(pr) == float: + pr = round(pr, 6) + return str(pr) + def get_do_package_hash(pn): if d.getVar("BB_RUNTASK") != "do_package": taskdepdata = d.getVar("BB_TASKDEPDATA", False) @@ -289,7 +296,7 @@ python package_get_auto_pr() { auto_pr = d.getVar('PRAUTO_' + version + '_' + pkgarch) or d.getVar('PRAUTO_' + version) or None if auto_pr is None: bb.fatal("Can NOT get PRAUTO from lockdown exported file") - d.setVar('PRAUTO',str(auto_pr)) + d.setVar('PRAUTO', safe_str(auto_pr)) return try: @@ -299,7 +306,7 @@ python package_get_auto_pr() { srcpv = bb.fetch2.get_srcrev(d) base_ver = "AUTOINC-%s" % version[:version.find(srcpv)] value = conn.getPR(base_ver, pkgarch, srcpv) - d.setVar("PRSERV_PV_AUTOINC", str(value)) + d.setVar("PRSERV_PV_AUTOINC", safe_str(value)) auto_pr = conn.getPR(version, pkgarch, checksum) conn.close() @@ -307,7 +314,7 @@ python package_get_auto_pr() { bb.fatal("Can NOT get PRAUTO, exception %s" % str(e)) if auto_pr is None: bb.fatal("Can NOT get PRAUTO from remote PR service") - d.setVar('PRAUTO',str(auto_pr)) + d.setVar('PRAUTO', safe_str(auto_pr)) } # -- 2.34.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#197920): https://lists.openembedded.org/g/openembedded-core/message/197920 Mute This Topic: https://lists.openembedded.org/mt/105308894/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-