1
2
3
4
5
6
7
8
9
10
11
12
13
14 import rpm
15 import miscutils
16
17 read_ts = None
18 ts = None
19
20
21
24 self.ts = rpm.TransactionSet(root)
25 self._methods = ['dbMatch',
26 'check',
27 'order',
28 'addErase',
29 'addInstall',
30 'run',
31 'IDTXload',
32 'IDTXglob',
33 'rollback',
34 'pgpImportPubkey',
35 'pgpPrtPkts',
36 'Debug',
37 'problems',
38 'setFlags',
39 'setVSFlags',
40 'setProbFilter',
41 'hdrFromFdno',
42 'next',
43 'clean']
44 self.tsflags = []
45 self.open = True
46
50
52 if self.open:
53 self.ts.closeDB()
54 self.ts = None
55 self.open = False
56
58 if attr in self._methods:
59 return self.getMethod(attr)
60 else:
61 raise AttributeError, attr
62
65
67
68
69 return getattr(self.ts, method)
70
71
72
73
77
81
83 curflags = self.ts.setFlags(0)
84 self.ts.setFlags(curflags | flag)
85
86
87
88
89
90 - def test(self, cb, conf={}):
91 """tests the ts we've setup, takes a callback function and a conf dict
92 for flags and what not"""
93
94 self.addTsFlag(rpm.RPMTRANS_FLAG_TEST)
95
96
97 if conf.has_key('diskspacecheck'):
98 if conf['diskspacecheck'] == 0:
99 self.ts.setProbFilter(rpm.RPMPROB_FILTER_DISKSPACE)
100 tserrors = self.ts.run(cb.callback, '')
101
102 reserrors = []
103 if tserrors:
104 for (descr, (etype, mount, need)) in tserrors:
105 reserrors.append(descr)
106
107 return reserrors
108
109
111 """returns a list of package tuples (n,a,e,v,r) that are not required by
112 any other package on the system
113 If headers is True then it will return a list of (header, index) tuples
114 """
115
116 req = {}
117 orphan = []
118
119 mi = self.dbMatch()
120 if mi is None:
121 return orphan
122
123
124 for h in mi:
125 if h['name'] == 'gpg-pubkey':
126 continue
127 if not h[rpm.RPMTAG_REQUIRENAME]:
128 continue
129 tup = miscutils.pkgTupleFromHeader(h)
130 for r in h[rpm.RPMTAG_REQUIRENAME]:
131 if r not in req:
132 req[r] = set()
133 req[r].add(tup)
134
135
136 mi = self.dbMatch()
137 if mi is None:
138 return orphan
139
140 def _return_all_provides(hdr):
141 """ Return all the provides, via yield. """
142
143 for prov in hdr[rpm.RPMTAG_PROVIDES]:
144 yield prov
145 for prov in hdr[rpm.RPMTAG_FILENAMES]:
146 yield prov
147
148 for h in mi:
149 if h['name'] == 'gpg-pubkey':
150 continue
151 preq = 0
152 tup = miscutils.pkgTupleFromHeader(h)
153 for p in _return_all_provides(h):
154 if req.has_key(p):
155
156 s = req[p]
157 if len(s) > 1 or tup not in s:
158 preq = preq + 1
159 break
160
161 if preq == 0:
162 if headers:
163 orphan.append((h, mi.instance()))
164 else:
165 orphan.append(tup)
166
167 return orphan
168
169
174