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 @PYTHON_MODULENAME@._rpm import *
39 from @PYTHON_MODULENAME@.transaction import *
40 import @PYTHON_MODULENAME@._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 # backwards compatibility + give the same class both ways
53 def headerLoad(*args, **kwds):
54 """DEPRECATED! Use rpm.hdr() instead."""
55 warnings.warn("Use rpm.hdr() instead.", DeprecationWarning, stacklevel=2)
56 return hdr(*args, **kwds)
59 def _doHeaderListFromFD(rpm_fd, retrofit):
65 h.convert(HEADERCONV_RETROFIT_V3)
73 def readHeaderListFromFD(file_desc, retrofit=True):
74 if not isinstance(file_desc, fd):
75 file_desc = fd(file_desc)
76 return _doHeaderListFromFD(file_desc, retrofit)
79 def readHeaderListFromFile(path, retrofit=True):
81 hlist = _doHeaderListFromFD(f, retrofit)
86 def readHeaderFromFD(file_desc):
87 """Return (header, pos_before_hdr)"""
88 if not isinstance(file_desc, fd):
89 file_desc = fd(file_desc)
91 offset = file_desc.tell()
93 except (_rpm.error, IOError):
100 def signalsCaught(siglist):
101 """Returns list of signals that were caught."""
104 if signalCaught(sig):
110 def dsSingle(TagN, N, EVR="", Flags=RPMSENSE_ANY):
112 Creates a single entry dependency set (ds)
114 dsSingle(RPMTAG_CONFLICTNAME, "rpm") corresponds to "Conflicts: rpm"
116 return ds((N, Flags, EVR), TagN)