mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Use the rpm python module rather than execing rpm
Using the rpm module prevent a uneeded fork, and permit to skip the signature checking which slow down a bit the operation, and which would be done by yum on installation anyway.
This commit is contained in:
parent
605a5a5b53
commit
2dfc7122af
1 changed files with 15 additions and 9 deletions
|
@ -25,6 +25,7 @@
|
||||||
import traceback
|
import traceback
|
||||||
import os
|
import os
|
||||||
import yum
|
import yum
|
||||||
|
import rpm
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from yum.misc import find_unfinished_transactions, find_ts_remaining
|
from yum.misc import find_unfinished_transactions, find_ts_remaining
|
||||||
|
@ -108,7 +109,7 @@ options:
|
||||||
|
|
||||||
notes: []
|
notes: []
|
||||||
# informational: requirements for nodes
|
# informational: requirements for nodes
|
||||||
requirements: [ yum, rpm ]
|
requirements: [ yum ]
|
||||||
author: Seth Vidal
|
author: Seth Vidal
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -400,13 +401,18 @@ def transaction_exists(pkglist):
|
||||||
def local_nvra(module, path):
|
def local_nvra(module, path):
|
||||||
"""return nvra of a local rpm passed in"""
|
"""return nvra of a local rpm passed in"""
|
||||||
|
|
||||||
cmd = ['/bin/rpm', '-qp' ,'--qf',
|
ts = rpm.TransactionSet()
|
||||||
'%{name}-%{version}-%{release}.%{arch}\n', path ]
|
ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
|
||||||
rc, out, err = module.run_command(cmd)
|
fd = os.open(path, os.O_RDONLY)
|
||||||
if rc != 0:
|
try:
|
||||||
return None
|
header = ts.hdrFromFdno(fd)
|
||||||
nvra = out.split('\n')[0]
|
finally:
|
||||||
return nvra
|
os.close(fd)
|
||||||
|
|
||||||
|
return '%s-%s-%s.%s' % (header[rpm.RPMTAG_NAME],
|
||||||
|
header[rpm.RPMTAG_VERSION],
|
||||||
|
header[rpm.RPMTAG_RELEASE],
|
||||||
|
header[rpm.RPMTAG_ARCH])
|
||||||
|
|
||||||
def pkg_to_dict(pkgstr):
|
def pkg_to_dict(pkgstr):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue