Skip to content

Commit

Permalink
Fix local repo query rpm version comparation for leap with rpm<4.18
Browse files Browse the repository at this point in the history
  • Loading branch information
asdil12 committed Jun 2, 2023
1 parent 6c3c33e commit 0104e2d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion opi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ def search_local_repos(package):
repos_by_name = {repo['name']: repo for repo in get_repos()}
local_installables = []
for repo_name, installables in search_results.items():
installables.sort(key=lambda p: cmp_to_key(rpm.labelCompare)(p['version']))
try:
installables.sort(key=lambda p: cmp_to_key(rpm.labelCompare)(p['version']))
except TypeError:
# rpm 4.14 needs a tuple of epoch, version, release - rpm 4.18 can handle a string
installables.sort(key=lambda p: cmp_to_key(rpm.labelCompare)(['1']+p['version'].split('-')))
installable = installables[-1]
installable['repository'] = repos_by_name[repo_name]
installable['name'] = package
Expand Down

0 comments on commit 0104e2d

Please sign in to comment.