1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/usr/bin/python
import rpm
import os
import time
def cb(what, amount, total, key, data):
if (what == rpm.RPMCALLBACK_INST_OPEN_FILE):
d = os.open(key, os.O_RDONLY)
return d
## fd = os.open('foo', os.O_RDONLY);
## (h, isSource) = rpm.headerFromPackage(fd)
## print "from foo:", h[rpm.RPMTAG_NAME]
## os.close(fd)
from urllib import *
#url = urlopen ("http://porkchop.redhat.com/msw/i386/RedHat/base/hdlist")
#url = urlretrieve ("http://porkchop.redhat.com/msw/i386/RedHat/base/hdlist", "/tmp/hdlist")
#url = urlopen ("/mnt/test/msw/i386/RedHat/base/hdlist")
#print os.read (url.fileno (), 1)
import httplib
h = httplib.HTTP('porkchop.redhat.com')
h.putrequest('GET', '/msw/i386/RedHat/base/hdlist')
h.endheaders()
#errcode, errmsg, headers = h.getreply()
h.getreply()
#print errcode # Should be 200
f = h.getfile()
print f.fileno ()
print os.read (f.fileno (), 5)
list = rpm.readHeaderListFromFD(f.fileno ())
f.close()
#list = rpm.readHeaderListFromFD('/mnt/test/msw/i386/RedHat/base/hdlist')
#list = rpm.readHeaderListFromFile('/tmp/hdlist')
print "got", len(list), "items"
print "finding upgrade set..."
ugset = rpm.findUpgradeSet (list)
for header in ugset:
print header[rpm.RPMTAG_NAME]
#d = rpm.opendb(0)
#ts = rpm.TransactionSet()
#for h in list:
# ts.add(h, "foo", "a")
#ts.add(list[0], "foo")
#rc = ts.depcheck()
#print rc
#ts.order()
#print "run", ts.run(rpm.RPMTRANS_FLAG_TEST, 0, cb, "arg")
|