3 This module enables you to manipulate rpms and the rpm database.
5 The rpm base module provides the main starting point for
6 accessing RPM from Python. For most usage, call
7 the TransactionSet method to get a transaction set (rpmts).
11 ts = rpm.TransactionSet()
13 The transaction set will open the RPM database as needed, so
14 in most cases, you do not need to explicitly open the
15 database. The transaction set is the workhorse of RPM.
17 You can open another RPM database, such as one that holds
18 all packages for a given Linux distribution, to provide
19 packages used to solve dependencies. To do this, use
22 rpm.addMacro('_dbpath', '/path/to/alternate/database')
23 solvets = rpm.TransactionSet()
25 rpm.delMacro('_dbpath')
27 # Open default database
28 ts = rpm.TransactionSet()
30 This code gives you access to two RPM databases through
31 two transaction sets (rpmts): ts is a transaction set
32 associated with the default RPM database and solvets
33 is a transaction set tied to an alternate database, which
34 is very useful for resolving dependencies.
38 from rpm._rpm import *
39 from rpm.transaction import *
40 import rpm._rpm as _rpm
41 _RPMVSF_NODIGESTS = _rpm._RPMVSF_NODIGESTS
42 _RPMVSF_NOHEADER = _rpm._RPMVSF_NOHEADER
43 _RPMVSF_NOPAYLOAD = _rpm._RPMVSF_NOPAYLOAD
44 _RPMVSF_NOSIGNATURES = _rpm._RPMVSF_NOSIGNATURES
46 __version__ = _rpm.__version__
47 __version_info__ = tuple(__version__.split('.'))
49 # try to import build bits but dont require it
51 from rpm._rpmb import *
55 # try to import signing bits but dont require it
57 from rpm._rpms import *
61 # backwards compatibility + give the same class both ways
65 def headerLoad(*args, **kwds):
66 """DEPRECATED! Use rpm.hdr() instead."""
67 warnings.warn("Use rpm.hdr() instead.", DeprecationWarning, stacklevel=2)
68 return hdr(*args, **kwds)
71 def _doHeaderListFromFD(rpm_fd, retrofit):
77 h.convert(HEADERCONV_RETROFIT_V3)
85 def readHeaderListFromFD(file_desc, retrofit=True):
86 if not isinstance(file_desc, fd):
87 file_desc = fd(file_desc)
88 return _doHeaderListFromFD(file_desc, retrofit)
91 def readHeaderListFromFile(path, retrofit=True):
93 hlist = _doHeaderListFromFD(f, retrofit)
98 def readHeaderFromFD(file_desc):
99 """Return (header, pos_before_hdr)"""
100 if not isinstance(file_desc, fd):
101 file_desc = fd(file_desc)
103 offset = file_desc.tell()
105 except (_rpm.error, IOError):
112 def signalsCaught(siglist):
113 """Returns list of signals that were caught."""
116 if signalCaught(sig):
122 def dsSingle(TagN, N, EVR="", Flags=RPMSENSE_ANY):
124 Creates a single entry dependency set (ds)
126 dsSingle(RPMTAG_CONFLICTNAME, "rpm") corresponds to "Conflicts: rpm"
128 return ds((N, Flags, EVR), TagN)