How set the prefix when install a rpm using python.
Jorge Cisneros
jorgecis at gmail.com
Wed Nov 23 17:08:15 UTC 2016
Hi All
I using something similar to the follow example to install a rpm from
python, and works fine. Now the problem that I have is how to change the
prefix, something like rpm -i --prefix ....
Any ideas?
Thanks
George
#!/usr/bin/python
import rpm
import sys
import os
class myCallback(object):
def __init__(self):
self._fd = None
def callback(self, event, amount, total, key, mydata):
if event == rpm.RPMCALLBACK_INST_OPEN_FILE:
print "Installing", key
self._fd = os.open(key, os.O_RDONLY)
return self._fd
elif event == rpm.RPMCALLBACK_INST_CLOSE_FILE:
self._fd = os.close(self._fd)
if __name__ == '__main__':
for path in sys.argv[1:]:
fd = os.open(path, os.O_RDONLY)
hdr = ts.hdrFromFdno(fd)
ts.addInstall(hdr, path, 'u')
os.close(fd)
ts.check()
if ts.problems():
rc = 1
else:
cb = myCallback()
rc = (ts.run(cb.callback, None) != None)
sys.exit(rc)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-list/attachments/20161123/168912d0/attachment.html>
More information about the Rpm-list
mailing list