mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #2706 from fatbox/rpm-faster-version
Speed up yum/rpm version() if we're not looking for something specific
This commit is contained in:
commit
be8ecf2cd4
@ -175,7 +175,18 @@ def version(name):
|
||||
|
||||
salt '*' pkg.version <package name>
|
||||
'''
|
||||
pkgs = list_pkgs(name)
|
||||
# since list_pkgs is used to support matching complex versions
|
||||
# we can search for a digit in the name and if one doesn't exist
|
||||
# then just use the dbMatch function, which is 1000 times quicker
|
||||
m = re.search("[0-9]", name)
|
||||
if m:
|
||||
pkgs = list_pkgs(name)
|
||||
else:
|
||||
ts = rpm.TransactionSet()
|
||||
mi = ts.dbMatch('name', name)
|
||||
pkgs = {}
|
||||
for h in mi:
|
||||
pkgs[h['name']] = "-".join([h['version'], h['release']])
|
||||
if name in pkgs:
|
||||
return pkgs[name]
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user