[Rpm-maint] [rpm-software-management/rpm] Add real-life examples of Python RPM (PR #3177)
Jakub Kadlčík
notifications at github.com
Fri Jun 21 10:06:15 UTC 2024
@FrostyX commented on this pull request.
> @@ -0,0 +1,15 @@
+#!/usr/bin/python3
+
+# Install a package from a file stored on your system.
+# A Python equivalent for `rpm -i hello-2.12.1-4.fc40.x86_64.rpm`
+
+import os
+import rpm
+
+ts = rpm.TransactionSet()
+path = "/tmp/hello-2.12.1-4.fc40.x86_64.rpm"
+with open(path, "r") as fp:
+ filename = os.path.basename(path)
+ hdr = ts.hdrFromFdno(fp.fileno())
+ ts.addInstall(hdr, filename, "i")
+ts.run(lambda *args: print(args), {})
I have never actually installed anything through the Python API in real life, so I am not sure what the `ts.run` arguments should be. Same for the erasing example above.
Also, this script fails with
```
# FIXME this snippet fails with
TypeError: 'NoneType' object cannot be interpreted as an integer
FATAL ERROR: python callback ??? failed, aborting!
```
Can you please help me finish this example?
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177#pullrequestreview-2132306697
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/pull/3177/review/2132306697 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20240621/0b2d2a8b/attachment-0001.html>
More information about the Rpm-maint
mailing list