How set the prefix when install a rpm using python.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux