1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

util.rpm.is_rpm_installed function added

This commit is contained in:
Игорь Чудов 2019-12-19 16:46:58 +04:00
parent 5bbb481629
commit 897ad54af6
Signed by untrusted user: nir
GPG Key ID: 0F3883600CAE7AAC

16
gpoa/util/rpm.py Normal file
View File

@ -0,0 +1,16 @@
import rpm
def is_rpm_installed(rpm_name):
'''
Check if the package named 'rpm_name' is installed
'''
ts = rpm.TransactionSet()
pm = ts.dbMatch()
pm.pattern('name', rpm.RPMMIRE_GLOB, rpm_name)
for pkg in pm:
if pkg['name'] == rpm_name:
return True
return False