File: rpm-qa.py

package info (click to toggle)
rpm 6.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,580 kB
  • sloc: cpp: 53,319; ansic: 13,888; sh: 2,038; python: 1,175; makefile: 35; xml: 26
file content (17 lines) | stat: -rwxr-xr-x 410 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/python3

# Query all packages that match part of their name with the searched string.
# If package name isn't specified, query all installed packages.
# A Python equivalent for `rpm -qa kernel*` and `rpm -qa`

import sys
import rpm

ts = rpm.TransactionSet()
mi = ts.dbMatch()

for name in sys.argv[1:]:
    mi.pattern("name", rpm.RPMMIRE_GLOB, name)

for hdr in mi:
    print(hdr[rpm.RPMTAG_NVRA])