Skip to content

Commit 78d9d0d

Browse files
author
xiaodwan
authored
update the way of getting the release number of a package (avocado-framework#4201)
The previous way will fail when it's like "1.56.0-1.el10.1". Now we only get the release number before the first '.' and ignore other information. Signed-off-by: Xiaodai Wang <xiaodwan@redhat.com>
1 parent 7f04953 commit 78d9d0d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

virttest/utils_v2v.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,11 +1857,12 @@ def compare_version(interval, version=None, cmd=None):
18571857
"""
18581858
if not version:
18591859
if not cmd:
1860-
cmd = "rpm -q --qf '%{RPMTAG_VERSION}-%{RPMTAG_RELEASE}\n' virt-v2v"
1860+
cmd = "rpm -q --qf '%{RPMTAG_VERSION} %{RPMTAG_RELEASE}\n' virt-v2v"
18611861
res = process.run(cmd, shell=True, ignore_status=True)
18621862
if res.exit_status != 0:
18631863
return False
1864-
version = res.stdout_text.rsplit(".", maxsplit=1)[0]
1864+
v, r = res.stdout_text.split()
1865+
version = "-".join((v, r.split(".")[0]))
18651866

18661867
return check_version(version, interval)
18671868

@@ -1889,7 +1890,7 @@ def multiple_versions_compare(interval):
18891890

18901891
pkg_name = re.search(re_pkg_name, ver).group(1)
18911892
_ver_i = re.sub(pkg_name + "-", "", ver_i)
1892-
cmd = 'rpm -q --qf "%{{RPMTAG_VERSION}}-%{{RPMTAG_RELEASE}}\\n" {}'.format(
1893+
cmd = 'rpm -q --qf "%{{RPMTAG_VERSION}} %{{RPMTAG_RELEASE}}\\n" {}'.format(
18931894
pkg_name
18941895
)
18951896
if not compare_version(_ver_i, cmd=cmd):

0 commit comments

Comments
 (0)