diff options
author | xuhy <huayong.xu@samsung.com> | 2023-11-16 17:39:20 +0800 |
---|---|---|
committer | xuhy <huayong.xu@samsung.com> | 2023-11-16 17:39:20 +0800 |
commit | 76ea0b5d4a1b8180f2552c2729d84388a77beecb (patch) | |
tree | 9a2b028c24c205b075d9386acd7a62a2eb2271a7 /python/rpm/__init__.py.in | |
parent | c30d127e8780dc678168ee121b9f2eeb1a8aaafa (diff) | |
download | librpm-tizen-76ea0b5d4a1b8180f2552c2729d84388a77beecb.tar.gz librpm-tizen-76ea0b5d4a1b8180f2552c2729d84388a77beecb.tar.bz2 librpm-tizen-76ea0b5d4a1b8180f2552c2729d84388a77beecb.zip |
The following issues are fixed:
1. Prevent execution of arbitrary scripts
2. Enable dash(-) in spec file.
3. Ignore bad expressions in %if conditionals.
4. Ignore unknown tags.
5. Ignore error macro.
Change-Id: Id5b7b47c1a78de364ef0d513023fbe9ccc773a87
Signed-off-by: xuhy <huayong.xu@samsung.com>
Diffstat (limited to 'python/rpm/__init__.py.in')
-rw-r--r-- | python/rpm/__init__.py.in | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/python/rpm/__init__.py.in b/python/rpm/__init__.py.in new file mode 100644 index 000000000..4d02d2d02 --- /dev/null +++ b/python/rpm/__init__.py.in @@ -0,0 +1,116 @@ +r"""RPM Module + +This module enables you to manipulate rpms and the rpm database. + +The rpm base module provides the main starting point for +accessing RPM from Python. For most usage, call +the TransactionSet method to get a transaction set (rpmts). + +For example: + import rpm + ts = rpm.TransactionSet() + +The transaction set will open the RPM database as needed, so +in most cases, you do not need to explicitly open the +database. The transaction set is the workhorse of RPM. + +You can open another RPM database, such as one that holds +all packages for a given Linux distribution, to provide +packages used to solve dependencies. To do this, use +the following code: + +rpm.addMacro('_dbpath', '/path/to/alternate/database') +solvets = rpm.TransactionSet() +solvets.openDB() +rpm.delMacro('_dbpath') + +# Open default database +ts = rpm.TransactionSet() + +This code gives you access to two RPM databases through +two transaction sets (rpmts): ts is a transaction set +associated with the default RPM database and solvets +is a transaction set tied to an alternate database, which +is very useful for resolving dependencies. +""" + +import warnings +from @PYTHON_MODULENAME@._rpm import * +from @PYTHON_MODULENAME@.transaction import * +import @PYTHON_MODULENAME@._rpm as _rpm +_RPMVSF_NODIGESTS = _rpm._RPMVSF_NODIGESTS +_RPMVSF_NOHEADER = _rpm._RPMVSF_NOHEADER +_RPMVSF_NOPAYLOAD = _rpm._RPMVSF_NOPAYLOAD +_RPMVSF_NOSIGNATURES = _rpm._RPMVSF_NOSIGNATURES + +__version__ = _rpm.__version__ +__version_info__ = tuple(__version__.split('.')) + +# backwards compatibility + give the same class both ways +ts = TransactionSet + + +def headerLoad(*args, **kwds): + """DEPRECATED! Use rpm.hdr() instead.""" + warnings.warn("Use rpm.hdr() instead.", DeprecationWarning, stacklevel=2) + return hdr(*args, **kwds) + + +def _doHeaderListFromFD(rpm_fd, retrofit): + hlist = [] + while 1: + try: + h = hdr(rpm_fd) + if retrofit: + h.convert(HEADERCONV_RETROFIT_V3) + hlist.append(h) + except _rpm.error: + break + + return hlist + + +def readHeaderListFromFD(file_desc, retrofit=True): + if not isinstance(file_desc, fd): + file_desc = fd(file_desc) + return _doHeaderListFromFD(file_desc, retrofit) + + +def readHeaderListFromFile(path, retrofit=True): + f = fd(path) + hlist = _doHeaderListFromFD(f, retrofit) + f.close() + return hlist + + +def readHeaderFromFD(file_desc): + """Return (header, pos_before_hdr)""" + if not isinstance(file_desc, fd): + file_desc = fd(file_desc) + try: + offset = file_desc.tell() + h = hdr(file_desc) + except (_rpm.error, IOError): + offset = None + h = None + + return (h, offset) + + +def signalsCaught(siglist): + """Returns list of signals that were caught.""" + caught = [] + for sig in siglist: + if signalCaught(sig): + caught.append(sig) + + return caught + + +def dsSingle(TagN, N, EVR="", Flags=RPMSENSE_ANY): + """ + Creates a single entry dependency set (ds) + + dsSingle(RPMTAG_CONFLICTNAME, "rpm") corresponds to "Conflicts: rpm" + """ + return ds((N, Flags, EVR), TagN) |