diff mbox series

package_rpm: Fix Linux 6.1.0 perf 1.0 version mistranslation

Message ID 20221217045738.643519-1-marex@denx.de
State Accepted, archived
Commit bf2096a43d56c2d633a4b6e3db9e4390da4be6e2
Headers show
Series package_rpm: Fix Linux 6.1.0 perf 1.0 version mistranslation | expand

Commit Message

Marek Vasut Dec. 17, 2022, 4:57 a.m. UTC
With Linux 6.1.0 and perf 1.0-r9, a build which includes perf-dev fails due
to perf-dev depending on perf 6.6.1.0-r9 . This is because translate_vers()
operates on perf-dev and mangles its version. The following scenario occurs:

  ver=6.1.0-r9
  pv=1.0
  pkgv=6.1.0
  reppv=6.1.0

With Linux 6.1.0, a corner case is hit where pv is a substring of ver, which
yields this corrupted version 6.6.1.0-r9 . Example in python3:

  >>> "6.1.0-r9".replace("1.0", "6.1.0")
  '6.6.1.0-r9'
  >>> "6.0.13-r9".replace("1.0", "6.0.13")
  '6.0.13-r9'

The fix is to only replace pv with reppv in case pv is at the beginning
of ver , instead of replacing all occurences.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Pavel Zhukov <pavel.zhukov@huawei.com>
Cc: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes-global/package_rpm.bbclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-global/package_rpm.bbclass b/meta/classes-global/package_rpm.bbclass
index 81a2060b68..39efcc328e 100644
--- a/meta/classes-global/package_rpm.bbclass
+++ b/meta/classes-global/package_rpm.bbclass
@@ -159,7 +159,9 @@  python write_specfile () {
                             pv = subd['PV']
                             pkgv = subd['PKGV']
                             reppv = pkgv.replace('-', '+')
-                            ver = ver.replace(pv, reppv).replace(pkgv, reppv)
+                            if ver.startswith(pv):
+                                ver = ver.replace(pv, reppv)
+                            ver = ver.replace(pkgv, reppv)
                         if 'PKGR' in subd:
                             # Make sure PKGR rather than PR in ver
                             pr = '-' + subd['PR']