Merge lp:~paul-eggleton/smart/yocto-smart-fixes into lp:smart
- yocto-smart-fixes
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~paul-eggleton/smart/yocto-smart-fixes |
Merge into: | lp:smart |
Diff against target: |
1794 lines (+730/-71) 26 files modified
smart/backends/rpm/base.py (+36/-7) smart/backends/rpm/header.py (+12/-5) smart/backends/rpm/metadata.py (+21/-8) smart/backends/rpm/pm.py (+17/-0) smart/cache.py (+72/-3) smart/ccache.c (+355/-24) smart/channels/rpm_sys.py (+4/-4) smart/commands/channel.py (+15/-2) smart/commands/check.py (+3/-0) smart/commands/config.py (+10/-1) smart/commands/download.py (+8/-0) smart/commands/flag.py (+4/-1) smart/commands/info.py (+4/-0) smart/commands/install.py (+4/-0) smart/commands/mirror.py (+4/-1) smart/commands/priority.py (+4/-1) smart/commands/query.py (+51/-0) smart/commands/reinstall.py (+5/-1) smart/commands/remove.py (+4/-0) smart/commands/search.py (+2/-0) smart/commands/upgrade.py (+3/-0) smart/control.py (+2/-2) smart/plugins/detectsys.py (+2/-1) smart/searcher.py (+11/-3) smart/transaction.py (+21/-7) smart/util/optparse.py (+56/-0) |
To merge this branch: | bzr merge lp:~paul-eggleton/smart/yocto-smart-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Smart Package Manager Team | Pending | ||
Review via email: mp+147946@code.launchpad.net |
Commit message
Description of the change
Included are most of the patches for Smart developed within the Yocto Project and being carried in OE-core which are now being carried in OpenEmbedded-Core. Each patch has a commit message explaining what it does; if further clarification or adjustments are needed please let me know.
Unmerged revisions
- 1096. By Paul-eggleton
-
Print a more friendly error if YAML output is requested without PyYAML
Signed-off-by: Paul Eggleton <email address hidden>
- 1095. By Bogdan Marinescu <email address hidden>
-
To fix some multilib issues, change the way the RPM backend decides
if two packages can coexist: if they have a different architecture,
automatically assume that they can coexist (which is fundamental for
multilib).Signed-off-by: Bogdan Marinescu <email address hidden>
- 1094. By Bogdan Marinescu <email address hidden>
-
Improve error reporting in smart
Add code to check proper command line arguments for various
smart commands. Exit with error if erroneous/additional arguments
are given in the command line.Signed-off-by: Bogdan Marinescu <email address hidden>
- 1093. By Mark Hatle <email address hidden>
-
backends/rpm: Fix incorrect call to the match function
The match function should take three parameters, name, comparison, version...
The original code was passing it a reference to the object holding the data
instead, which caused the comparison in match to always fail.Signed-off-by: Mark Hatle <email address hidden>
- 1092. By Paul-eggleton
-
backends/rpm: remove creation of /var/tmp
This doesn't appear to be needed, and breaks installation of base-files
in OpenEmbedded (since that is a symlink installed as part of the
package).Signed-off-by: Paul Eggleton <email address hidden>
- 1091. By Paul-eggleton
-
backends/rpm: fix parsing of rpm-md metadata
If assertions are disabled then the queue.pop() wasn't being executed,
leading to requires, recommends etc. not being read properly.Signed-off-by: Paul Eggleton <email address hidden>
- 1090. By Paul-eggleton
-
backends/rpm: add support for setting dependency flags
This is useful for OpenEmbedded so that we can do the equivalent of
the --nolinktos and --noparentdirs rpm command line options.Signed-off-by: Paul Eggleton <email address hidden>
- 1089. By Paul-eggleton
-
backends/rpm: implement rpm-extra-macros option
Allow defining extra macros in the smart configuration to be passed
to rpm before opening the database.Signed-off-by: Paul Eggleton <email address hidden>
- 1088. By Paul-eggleton
-
Handle recommended packages in core and rpm backends
Identify and store recommended packages in the cache, add a query option
to read them and ignore them if they are not present when installing.Initial identification code from Mark Hatle <email address hidden>.
Signed-off-by: Paul Eggleton <email address hidden>
- 1087. By Paul-eggleton
-
Fix smart RPM backend to handle rpm-dbpath/rpm-root properly
Don't assume that if the dbpath starts with / that it is an absolute
path. This matches the behaviour of rpm itself. (If the root path is
specified and does not start with /, rpm will prepend the root path
twice and fail).Signed-off-by: Paul Eggleton <email address hidden>
Preview Diff
1 | === modified file 'smart/backends/rpm/base.py' | |||
2 | --- smart/backends/rpm/base.py 2011-10-06 07:10:20 +0000 | |||
3 | +++ smart/backends/rpm/base.py 2013-02-12 14:46:20 +0000 | |||
4 | @@ -46,7 +46,17 @@ | |||
5 | 46 | "rpm", "getTS", "getArchScore", "getArchColor", "system_provides", | 46 | "rpm", "getTS", "getArchScore", "getArchColor", "system_provides", |
6 | 47 | "collapse_libc_requires"] | 47 | "collapse_libc_requires"] |
7 | 48 | 48 | ||
8 | 49 | def rpm_join_dbpath(root, dbpath): | ||
9 | 50 | if dbpath.startswith('/') and root: | ||
10 | 51 | return os.path.join(root, dbpath[1:]) | ||
11 | 52 | else: | ||
12 | 53 | return os.path.join(root, dbpath) | ||
13 | 54 | |||
14 | 49 | def getTS(new=False): | 55 | def getTS(new=False): |
15 | 56 | if sysconf.get("rpm-extra-macros"): | ||
16 | 57 | for key, value in sysconf.get("rpm-extra-macros").items(): | ||
17 | 58 | rpm.addMacro(key, str(value)) | ||
18 | 59 | |||
19 | 50 | rpm_root = os.path.abspath(sysconf.get("rpm-root", "/")) | 60 | rpm_root = os.path.abspath(sysconf.get("rpm-root", "/")) |
20 | 51 | if not hasattr(getTS, "ts") or getTS.root != rpm_root: | 61 | if not hasattr(getTS, "ts") or getTS.root != rpm_root: |
21 | 52 | getTS.root = rpm_root | 62 | getTS.root = rpm_root |
22 | @@ -56,7 +66,7 @@ | |||
23 | 56 | if not sysconf.get("rpm-check-signatures", False): | 66 | if not sysconf.get("rpm-check-signatures", False): |
24 | 57 | getTS.ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES) | 67 | getTS.ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES) |
25 | 58 | rpm_dbpath = sysconf.get("rpm-dbpath", "var/lib/rpm") | 68 | rpm_dbpath = sysconf.get("rpm-dbpath", "var/lib/rpm") |
27 | 59 | dbdir = os.path.join(getTS.root, rpm_dbpath) | 69 | dbdir = rpm_join_dbpath(getTS.root, rpm_dbpath) |
28 | 60 | if not os.path.isdir(dbdir): | 70 | if not os.path.isdir(dbdir): |
29 | 61 | try: | 71 | try: |
30 | 62 | os.makedirs(dbdir) | 72 | os.makedirs(dbdir) |
31 | @@ -72,12 +82,6 @@ | |||
32 | 72 | else: | 82 | else: |
33 | 73 | iface.warning(_("Initialized new rpm database at %s") | 83 | iface.warning(_("Initialized new rpm database at %s") |
34 | 74 | % getTS.root) | 84 | % getTS.root) |
35 | 75 | tmpdir = os.path.join(getTS.root, "var/tmp") | ||
36 | 76 | if not os.path.isdir(tmpdir): | ||
37 | 77 | try: | ||
38 | 78 | os.makedirs(tmpdir) | ||
39 | 79 | except OSError: | ||
40 | 80 | pass | ||
41 | 81 | if new: | 85 | if new: |
42 | 82 | if sysconf.get("rpm-dbpath"): | 86 | if sysconf.get("rpm-dbpath"): |
43 | 83 | rpm.addMacro('_dbpath', "/" + sysconf.get("rpm-dbpath")) | 87 | rpm.addMacro('_dbpath', "/" + sysconf.get("rpm-dbpath")) |
44 | @@ -192,6 +196,29 @@ | |||
45 | 192 | break | 196 | break |
46 | 193 | else: | 197 | else: |
47 | 194 | return False | 198 | return False |
48 | 199 | srecs = fk(self.recommends) | ||
49 | 200 | orecs = fk(other.recommends) | ||
50 | 201 | if srecs != orecs: | ||
51 | 202 | for srec in srecs: | ||
52 | 203 | if srec.name[0] == "/" or srec in orecs: | ||
53 | 204 | continue | ||
54 | 205 | for orec in orecs: | ||
55 | 206 | if (srec.name == orec.name and | ||
56 | 207 | srec.relation == orec.relation and | ||
57 | 208 | checkver(srec.version, orec.version)): | ||
58 | 209 | break | ||
59 | 210 | else: | ||
60 | 211 | return False | ||
61 | 212 | for orec in orecs: | ||
62 | 213 | if orec.name[0] == "/" or orec in srecs: | ||
63 | 214 | continue | ||
64 | 215 | for srec in srecs: | ||
65 | 216 | if (srec.name == orec.name and | ||
66 | 217 | srec.relation == orec.relation and | ||
67 | 218 | checkver(srec.version, orec.version)): | ||
68 | 219 | break | ||
69 | 220 | else: | ||
70 | 221 | return False | ||
71 | 195 | return True | 222 | return True |
72 | 196 | 223 | ||
73 | 197 | def coexists(self, other): | 224 | def coexists(self, other): |
74 | @@ -201,6 +228,8 @@ | |||
75 | 201 | return False | 228 | return False |
76 | 202 | selfver, selfarch = splitarch(self.version) | 229 | selfver, selfarch = splitarch(self.version) |
77 | 203 | otherver, otherarch = splitarch(other.version) | 230 | otherver, otherarch = splitarch(other.version) |
78 | 231 | if selfarch != otherarch: | ||
79 | 232 | return True | ||
80 | 204 | selfcolor = getArchColor(selfarch) | 233 | selfcolor = getArchColor(selfarch) |
81 | 205 | othercolor = getArchColor(otherarch) | 234 | othercolor = getArchColor(otherarch) |
82 | 206 | if (selfcolor and othercolor and selfcolor != othercolor and | 235 | if (selfcolor and othercolor and selfcolor != othercolor and |
83 | 207 | 236 | ||
84 | === modified file 'smart/backends/rpm/header.py' | |||
85 | --- smart/backends/rpm/header.py 2011-10-05 15:09:41 +0000 | |||
86 | +++ smart/backends/rpm/header.py 2013-02-12 14:46:20 +0000 | |||
87 | @@ -292,6 +292,7 @@ | |||
88 | 292 | f = [0] | 292 | f = [0] |
89 | 293 | elif type(f) != list: | 293 | elif type(f) != list: |
90 | 294 | f = [f] | 294 | f = [f] |
91 | 295 | recdict = {} | ||
92 | 295 | reqdict = {} | 296 | reqdict = {} |
93 | 296 | for i in range(len(n)): | 297 | for i in range(len(n)): |
94 | 297 | ni = n[i] | 298 | ni = n[i] |
95 | @@ -308,10 +309,16 @@ | |||
96 | 308 | # RPMSENSE_SCRIPT_PREUN | | 309 | # RPMSENSE_SCRIPT_PREUN | |
97 | 309 | # RPMSENSE_SCRIPT_POST | | 310 | # RPMSENSE_SCRIPT_POST | |
98 | 310 | # RPMSENSE_SCRIPT_POSTUN == 7744 | 311 | # RPMSENSE_SCRIPT_POSTUN == 7744 |
101 | 311 | reqdict[(f[i]&7744 and PreReq or Req, | 312 | if (f[i]&rpm.RPMSENSE_MISSINGOK): |
102 | 312 | intern(ni), r, vi)] = True | 313 | recdict[(f[i]&7744 and PreReq or Req, |
103 | 314 | intern(ni), r, vi)] = True | ||
104 | 315 | else: | ||
105 | 316 | reqdict[(f[i]&7744 and PreReq or Req, | ||
106 | 317 | intern(ni), r, vi)] = True | ||
107 | 318 | recargs = collapse_libc_requires(recdict.keys()) | ||
108 | 313 | reqargs = collapse_libc_requires(reqdict.keys()) | 319 | reqargs = collapse_libc_requires(reqdict.keys()) |
109 | 314 | else: | 320 | else: |
110 | 321 | recargs = None | ||
111 | 315 | reqargs = None | 322 | reqargs = None |
112 | 316 | 323 | ||
113 | 317 | n = h[1054] # RPMTAG_CONFLICTNAME | 324 | n = h[1054] # RPMTAG_CONFLICTNAME |
114 | @@ -365,7 +372,7 @@ | |||
115 | 365 | versionarch = "%s@%s" % (distversion, arch) | 372 | versionarch = "%s@%s" % (distversion, arch) |
116 | 366 | 373 | ||
117 | 367 | pkg = self.buildPackage((Pkg, name, versionarch), | 374 | pkg = self.buildPackage((Pkg, name, versionarch), |
119 | 368 | prvargs, reqargs, upgargs, cnfargs) | 375 | prvargs, reqargs, upgargs, cnfargs, recargs) |
120 | 369 | pkg.loaders[self] = offset | 376 | pkg.loaders[self] = offset |
121 | 370 | self._offsets[offset] = pkg | 377 | self._offsets[offset] = pkg |
122 | 371 | self._groups[pkg] = intern(h[rpm.RPMTAG_GROUP]) | 378 | self._groups[pkg] = intern(h[rpm.RPMTAG_GROUP]) |
123 | @@ -583,8 +590,8 @@ | |||
124 | 583 | def setErrataFlags(self, flagdict): | 590 | def setErrataFlags(self, flagdict): |
125 | 584 | self._flagdict = flagdict | 591 | self._flagdict = flagdict |
126 | 585 | 592 | ||
129 | 586 | def buildPackage(self, pkgargs, prvargs, reqargs, upgargs, cnfargs): | 593 | def buildPackage(self, pkgargs, prvargs, reqargs, upgargs, cnfargs, recargs): |
130 | 587 | pkg = Loader.buildPackage(self, pkgargs, prvargs, reqargs, upgargs, cnfargs) | 594 | pkg = Loader.buildPackage(self, pkgargs, prvargs, reqargs, upgargs, cnfargs, recargs) |
131 | 588 | name = pkgargs[1] | 595 | name = pkgargs[1] |
132 | 589 | if hasattr(self, '_flagdict') and self._flagdict and name in self._flagdict: | 596 | if hasattr(self, '_flagdict') and self._flagdict and name in self._flagdict: |
133 | 590 | if sysconf.getReadOnly(): | 597 | if sysconf.getReadOnly(): |
134 | 591 | 598 | ||
135 | === modified file 'smart/backends/rpm/metadata.py' | |||
136 | --- smart/backends/rpm/metadata.py 2011-10-05 15:09:41 +0000 | |||
137 | +++ smart/backends/rpm/metadata.py 2013-02-12 14:46:20 +0000 | |||
138 | @@ -165,6 +165,7 @@ | |||
139 | 165 | distepoch = None | 165 | distepoch = None |
140 | 166 | info = {} | 166 | info = {} |
141 | 167 | reqdict = {} | 167 | reqdict = {} |
142 | 168 | recdict = {} | ||
143 | 168 | prvdict = {} | 169 | prvdict = {} |
144 | 169 | upgdict = {} | 170 | upgdict = {} |
145 | 170 | cnfdict = {} | 171 | cnfdict = {} |
146 | @@ -188,7 +189,8 @@ | |||
147 | 188 | 189 | ||
148 | 189 | elif event == "end": | 190 | elif event == "end": |
149 | 190 | 191 | ||
151 | 191 | assert queue.pop() is elem | 192 | popped = queue.pop() |
152 | 193 | assert popped is elem | ||
153 | 192 | 194 | ||
154 | 193 | if skip: | 195 | if skip: |
155 | 194 | if tag == skip: | 196 | if tag == skip: |
156 | @@ -287,12 +289,16 @@ | |||
157 | 287 | 289 | ||
158 | 288 | lasttag = queue[-1].tag | 290 | lasttag = queue[-1].tag |
159 | 289 | if lasttag == REQUIRES: | 291 | if lasttag == REQUIRES: |
163 | 290 | if elem.get("pre") == "1": | 292 | if elem.get("missingok") == "1": |
164 | 291 | reqdict[(RPMPreRequires, | 293 | recdict[(RPMRequires, |
165 | 292 | ename, erelation, eversion)] = True | 294 | ename, erelation, eversion)] = True |
166 | 293 | else: | 295 | else: |
169 | 294 | reqdict[(RPMRequires, | 296 | if elem.get("pre") == "1": |
170 | 295 | ename, erelation, eversion)] = True | 297 | reqdict[(RPMPreRequires, |
171 | 298 | ename, erelation, eversion)] = True | ||
172 | 299 | else: | ||
173 | 300 | reqdict[(RPMRequires, | ||
174 | 301 | ename, erelation, eversion)] = True | ||
175 | 296 | 302 | ||
176 | 297 | elif lasttag == PROVIDES: | 303 | elif lasttag == PROVIDES: |
177 | 298 | if ename[0] == "/": | 304 | if ename[0] == "/": |
178 | @@ -326,8 +332,14 @@ | |||
179 | 326 | reqargs = [x for x in reqdict | 332 | reqargs = [x for x in reqdict |
180 | 327 | if not ((x[2] is None or "=" in x[2]) and | 333 | if not ((x[2] is None or "=" in x[2]) and |
181 | 328 | (RPMProvides, x[1], x[3]) in prvdict or | 334 | (RPMProvides, x[1], x[3]) in prvdict or |
183 | 329 | system_provides.match(*x[:3]))] | 335 | system_provides.match(x[1], x[2], x[3]))] |
184 | 330 | reqargs = collapse_libc_requires(reqargs) | 336 | reqargs = collapse_libc_requires(reqargs) |
185 | 337 | |||
186 | 338 | recargs = [x for x in recdict | ||
187 | 339 | if not ((x[2] is None or "=" in x[2]) and | ||
188 | 340 | (RPMProvides, x[1], x[3]) in prvdict or | ||
189 | 341 | system_provides.match(x[1], x[2], x[3]))] | ||
190 | 342 | |||
191 | 331 | prvargs = prvdict.keys() | 343 | prvargs = prvdict.keys() |
192 | 332 | cnfargs = cnfdict.keys() | 344 | cnfargs = cnfdict.keys() |
193 | 333 | upgargs = upgdict.keys() | 345 | upgargs = upgdict.keys() |
194 | @@ -339,7 +351,7 @@ | |||
195 | 339 | versionarch = "%s@%s" % (distversion, arch) | 351 | versionarch = "%s@%s" % (distversion, arch) |
196 | 340 | 352 | ||
197 | 341 | pkg = self.buildPackage((RPMPackage, name, versionarch), | 353 | pkg = self.buildPackage((RPMPackage, name, versionarch), |
199 | 342 | prvargs, reqargs, upgargs, cnfargs) | 354 | prvargs, reqargs, upgargs, cnfargs, recargs) |
200 | 343 | pkg.loaders[self] = info | 355 | pkg.loaders[self] = info |
201 | 344 | 356 | ||
202 | 345 | # Store the provided files for future usage. | 357 | # Store the provided files for future usage. |
203 | @@ -362,6 +374,7 @@ | |||
204 | 362 | distepoch = None | 374 | distepoch = None |
205 | 363 | pkgid = None | 375 | pkgid = None |
206 | 364 | reqdict.clear() | 376 | reqdict.clear() |
207 | 377 | recdict.clear() | ||
208 | 365 | prvdict.clear() | 378 | prvdict.clear() |
209 | 366 | upgdict.clear() | 379 | upgdict.clear() |
210 | 367 | cnfdict.clear() | 380 | cnfdict.clear() |
211 | 368 | 381 | ||
212 | === modified file 'smart/backends/rpm/pm.py' | |||
213 | --- smart/backends/rpm/pm.py 2010-12-17 11:26:28 +0000 | |||
214 | +++ smart/backends/rpm/pm.py 2013-02-12 14:46:20 +0000 | |||
215 | @@ -106,6 +106,23 @@ | |||
216 | 106 | flags |= rpm.RPMTRANS_FLAG_TEST | 106 | flags |= rpm.RPMTRANS_FLAG_TEST |
217 | 107 | ts.setFlags(flags) | 107 | ts.setFlags(flags) |
218 | 108 | 108 | ||
219 | 109 | dflags = ts.setDFlags(0) | ||
220 | 110 | if sysconf.get("rpm-noupgrade", False): | ||
221 | 111 | dflags |= rpm.RPMDEPS_FLAG_NOUPGRADE | ||
222 | 112 | if sysconf.get("rpm-norequires", False): | ||
223 | 113 | dflags |= rpm.RPMDEPS_FLAG_NOREQUIRES | ||
224 | 114 | if sysconf.get("rpm-noconflicts", False): | ||
225 | 115 | dflags |= rpm.RPMDEPS_FLAG_NOCONFLICTS | ||
226 | 116 | if sysconf.get("rpm-noobsoletes", False): | ||
227 | 117 | dflags |= rpm.RPMDEPS_FLAG_NOOBSOLETES | ||
228 | 118 | if sysconf.get("rpm-noparentdirs", False): | ||
229 | 119 | dflags |= rpm.RPMDEPS_FLAG_NOPARENTDIRS | ||
230 | 120 | if sysconf.get("rpm-nolinktos", False): | ||
231 | 121 | dflags |= rpm.RPMDEPS_FLAG_NOLINKTOS | ||
232 | 122 | if sysconf.get("rpm-nosuggest", False): | ||
233 | 123 | dflags |= rpm.RPMDEPS_FLAG_NOSUGGEST | ||
234 | 124 | ts.setDFlags(dflags) | ||
235 | 125 | |||
236 | 109 | # Set rpm verbosity level. | 126 | # Set rpm verbosity level. |
237 | 110 | levelname = sysconf.get('rpm-log-level') | 127 | levelname = sysconf.get('rpm-log-level') |
238 | 111 | level = { | 128 | level = { |
239 | 112 | 129 | ||
240 | === modified file 'smart/cache.py' | |||
241 | --- smart/cache.py 2010-08-24 08:15:35 +0000 | |||
242 | +++ smart/cache.py 2013-02-12 14:46:20 +0000 | |||
243 | @@ -32,7 +32,8 @@ | |||
244 | 32 | self.name = name | 32 | self.name = name |
245 | 33 | self.version = version | 33 | self.version = version |
246 | 34 | self.provides = () | 34 | self.provides = () |
248 | 35 | self.requires = () | 35 | self.requires = [] |
249 | 36 | self.recommends = [] | ||
250 | 36 | self.upgrades = () | 37 | self.upgrades = () |
251 | 37 | self.conflicts = () | 38 | self.conflicts = () |
252 | 38 | self.installed = False | 39 | self.installed = False |
253 | @@ -55,7 +56,9 @@ | |||
254 | 55 | fk([x for x in self.provides if x.name[0] != "/"]) != | 56 | fk([x for x in self.provides if x.name[0] != "/"]) != |
255 | 56 | fk([x for x in other.provides if x.name[0] != "/"]) or | 57 | fk([x for x in other.provides if x.name[0] != "/"]) or |
256 | 57 | fk([x for x in self.requires if x.name[0] != "/"]) != | 58 | fk([x for x in self.requires if x.name[0] != "/"]) != |
258 | 58 | fk([x for x in other.requires if x.name[0] != "/"])): | 59 | fk([x for x in other.requires if x.name[0] != "/"]) or |
259 | 60 | fk([x for x in self.recommends if x.name[0] != "/"]) != | ||
260 | 61 | fk([x for x in other.recommends if x.name[0] != "/"])): | ||
261 | 59 | return False | 62 | return False |
262 | 60 | return True | 63 | return True |
263 | 61 | 64 | ||
264 | @@ -110,6 +113,7 @@ | |||
265 | 110 | self.version, | 113 | self.version, |
266 | 111 | self.provides, | 114 | self.provides, |
267 | 112 | self.requires, | 115 | self.requires, |
268 | 116 | self.recommends, | ||
269 | 113 | self.upgrades, | 117 | self.upgrades, |
270 | 114 | self.conflicts, | 118 | self.conflicts, |
271 | 115 | self.installed, | 119 | self.installed, |
272 | @@ -122,6 +126,7 @@ | |||
273 | 122 | self.version, | 126 | self.version, |
274 | 123 | self.provides, | 127 | self.provides, |
275 | 124 | self.requires, | 128 | self.requires, |
276 | 129 | self.recommends, | ||
277 | 125 | self.upgrades, | 130 | self.upgrades, |
278 | 126 | self.conflicts, | 131 | self.conflicts, |
279 | 127 | self.installed, | 132 | self.installed, |
280 | @@ -274,6 +279,7 @@ | |||
281 | 274 | self.version = version | 279 | self.version = version |
282 | 275 | self.packages = [] | 280 | self.packages = [] |
283 | 276 | self.requiredby = () | 281 | self.requiredby = () |
284 | 282 | self.recommendedby = () | ||
285 | 277 | self.upgradedby = () | 283 | self.upgradedby = () |
286 | 278 | self.conflictedby = () | 284 | self.conflictedby = () |
287 | 279 | 285 | ||
288 | @@ -401,7 +407,7 @@ | |||
289 | 401 | def loadFileProvides(self, fndict): | 407 | def loadFileProvides(self, fndict): |
290 | 402 | pass | 408 | pass |
291 | 403 | 409 | ||
293 | 404 | def buildPackage(self, pkgargs, prvargs, reqargs, upgargs, cnfargs): | 410 | def buildPackage(self, pkgargs, prvargs, reqargs, upgargs, cnfargs, recargs = None): |
294 | 405 | cache = self._cache | 411 | cache = self._cache |
295 | 406 | pkg = pkgargs[0](*pkgargs[1:]) | 412 | pkg = pkgargs[0](*pkgargs[1:]) |
296 | 407 | relpkgs = [] | 413 | relpkgs = [] |
297 | @@ -427,6 +433,17 @@ | |||
298 | 427 | relpkgs.append(req.packages) | 433 | relpkgs.append(req.packages) |
299 | 428 | pkg.requires.append(req) | 434 | pkg.requires.append(req) |
300 | 429 | 435 | ||
301 | 436 | if recargs: | ||
302 | 437 | pkg.recommends = [] | ||
303 | 438 | for args in recargs: | ||
304 | 439 | rec = cache._objmap.get(args) | ||
305 | 440 | if not rec: | ||
306 | 441 | rec = args[0](*args[1:]) | ||
307 | 442 | cache._objmap[args] = rec | ||
308 | 443 | cache._recommends.append(rec) | ||
309 | 444 | relpkgs.append(rec.packages) | ||
310 | 445 | pkg.recommends.append(rec) | ||
311 | 446 | |||
312 | 430 | if upgargs: | 447 | if upgargs: |
313 | 431 | pkg.upgrades = [] | 448 | pkg.upgrades = [] |
314 | 432 | for args in upgargs: | 449 | for args in upgargs: |
315 | @@ -572,6 +589,7 @@ | |||
316 | 572 | self._packages = [] | 589 | self._packages = [] |
317 | 573 | self._provides = [] | 590 | self._provides = [] |
318 | 574 | self._requires = [] | 591 | self._requires = [] |
319 | 592 | self._recommends = [] | ||
320 | 575 | self._upgrades = [] | 593 | self._upgrades = [] |
321 | 576 | self._conflicts = [] | 594 | self._conflicts = [] |
322 | 577 | self._objmap = {} | 595 | self._objmap = {} |
323 | @@ -581,6 +599,8 @@ | |||
324 | 581 | del prv.packages[:] | 599 | del prv.packages[:] |
325 | 582 | if prv.requiredby: | 600 | if prv.requiredby: |
326 | 583 | del prv.requiredby[:] | 601 | del prv.requiredby[:] |
327 | 602 | if prv.recommendedby: | ||
328 | 603 | del prv.recommendedby[:] | ||
329 | 584 | if prv.upgradedby: | 604 | if prv.upgradedby: |
330 | 585 | del prv.upgradedby[:] | 605 | del prv.upgradedby[:] |
331 | 586 | if prv.conflictedby: | 606 | if prv.conflictedby: |
332 | @@ -589,6 +609,10 @@ | |||
333 | 589 | del req.packages[:] | 609 | del req.packages[:] |
334 | 590 | if req.providedby: | 610 | if req.providedby: |
335 | 591 | del req.providedby[:] | 611 | del req.providedby[:] |
336 | 612 | for rec in self._recommends: | ||
337 | 613 | del rec.packages[:] | ||
338 | 614 | if rec.providedby: | ||
339 | 615 | del rec.providedby[:] | ||
340 | 592 | for upg in self._upgrades: | 616 | for upg in self._upgrades: |
341 | 593 | del upg.packages[:] | 617 | del upg.packages[:] |
342 | 594 | if upg.providedby: | 618 | if upg.providedby: |
343 | @@ -600,6 +624,7 @@ | |||
344 | 600 | del self._packages[:] | 624 | del self._packages[:] |
345 | 601 | del self._provides[:] | 625 | del self._provides[:] |
346 | 602 | del self._requires[:] | 626 | del self._requires[:] |
347 | 627 | del self._recommends[:] | ||
348 | 603 | del self._upgrades[:] | 628 | del self._upgrades[:] |
349 | 604 | del self._conflicts[:] | 629 | del self._conflicts[:] |
350 | 605 | self._objmap.clear() | 630 | self._objmap.clear() |
351 | @@ -621,6 +646,7 @@ | |||
352 | 621 | packages = {} | 646 | packages = {} |
353 | 622 | provides = {} | 647 | provides = {} |
354 | 623 | requires = {} | 648 | requires = {} |
355 | 649 | recommends = {} | ||
356 | 624 | upgrades = {} | 650 | upgrades = {} |
357 | 625 | conflicts = {} | 651 | conflicts = {} |
358 | 626 | objmap = self._objmap | 652 | objmap = self._objmap |
359 | @@ -646,6 +672,11 @@ | |||
360 | 646 | if req not in requires: | 672 | if req not in requires: |
361 | 647 | objmap[req.getInitArgs()] = req | 673 | objmap[req.getInitArgs()] = req |
362 | 648 | requires[req] = True | 674 | requires[req] = True |
363 | 675 | for rec in pkg.recommends[:]: | ||
364 | 676 | rec.packages.append(pkg) | ||
365 | 677 | if rec not in recommends: | ||
366 | 678 | objmap[rec.getInitArgs()] = rec | ||
367 | 679 | recommends[rec] = True | ||
368 | 649 | for upg in pkg.upgrades: | 680 | for upg in pkg.upgrades: |
369 | 650 | upg.packages.append(pkg) | 681 | upg.packages.append(pkg) |
370 | 651 | if upg not in upgrades: | 682 | if upg not in upgrades: |
371 | @@ -659,6 +690,7 @@ | |||
372 | 659 | self._packages[:] = packages.keys() | 690 | self._packages[:] = packages.keys() |
373 | 660 | self._provides[:] = provides.keys() | 691 | self._provides[:] = provides.keys() |
374 | 661 | self._requires[:] = requires.keys() | 692 | self._requires[:] = requires.keys() |
375 | 693 | self._recommends[:] = recommends.keys() | ||
376 | 662 | self._upgrades[:] = upgrades.keys() | 694 | self._upgrades[:] = upgrades.keys() |
377 | 663 | self._conflicts[:] = conflicts.keys() | 695 | self._conflicts[:] = conflicts.keys() |
378 | 664 | 696 | ||
379 | @@ -710,6 +742,14 @@ | |||
380 | 710 | lst.append(req) | 742 | lst.append(req) |
381 | 711 | else: | 743 | else: |
382 | 712 | reqnames[name] = [req] | 744 | reqnames[name] = [req] |
383 | 745 | recnames = {} | ||
384 | 746 | for rec in self._recommends: | ||
385 | 747 | for name in rec.getMatchNames(): | ||
386 | 748 | lst = recnames.get(name) | ||
387 | 749 | if lst: | ||
388 | 750 | lst.append(rec) | ||
389 | 751 | else: | ||
390 | 752 | recnames[name] = [rec] | ||
391 | 713 | upgnames = {} | 753 | upgnames = {} |
392 | 714 | for upg in self._upgrades: | 754 | for upg in self._upgrades: |
393 | 715 | for name in upg.getMatchNames(): | 755 | for name in upg.getMatchNames(): |
394 | @@ -739,6 +779,18 @@ | |||
395 | 739 | prv.requiredby.append(req) | 779 | prv.requiredby.append(req) |
396 | 740 | else: | 780 | else: |
397 | 741 | prv.requiredby = [req] | 781 | prv.requiredby = [req] |
398 | 782 | lst = recnames.get(prv.name) | ||
399 | 783 | if lst: | ||
400 | 784 | for rec in lst: | ||
401 | 785 | if rec.matches(prv): | ||
402 | 786 | if rec.providedby: | ||
403 | 787 | rec.providedby.append(prv) | ||
404 | 788 | else: | ||
405 | 789 | rec.providedby = [prv] | ||
406 | 790 | if prv.recommendedby: | ||
407 | 791 | prv.recommendedby.append(rec) | ||
408 | 792 | else: | ||
409 | 793 | prv.recommendedby = [rec] | ||
410 | 742 | lst = upgnames.get(prv.name) | 794 | lst = upgnames.get(prv.name) |
411 | 743 | if lst: | 795 | if lst: |
412 | 744 | for upg in lst: | 796 | for upg in lst: |
413 | @@ -782,6 +834,12 @@ | |||
414 | 782 | else: | 834 | else: |
415 | 783 | return [x for x in self._requires if x.name == name] | 835 | return [x for x in self._requires if x.name == name] |
416 | 784 | 836 | ||
417 | 837 | def getRecommends(self, name=None): | ||
418 | 838 | if not name: | ||
419 | 839 | return self._recommends | ||
420 | 840 | else: | ||
421 | 841 | return [x for x in self._recommends if x.name == name] | ||
422 | 842 | |||
423 | 785 | def getUpgrades(self, name=None): | 843 | def getUpgrades(self, name=None): |
424 | 786 | if not name: | 844 | if not name: |
425 | 787 | return self._upgrades | 845 | return self._upgrades |
426 | @@ -807,6 +865,12 @@ | |||
427 | 807 | for req in self._requires: | 865 | for req in self._requires: |
428 | 808 | if prvname in req.getMatchNames() and req.matches(prv): | 866 | if prvname in req.getMatchNames() and req.matches(prv): |
429 | 809 | searcher.addResult(req) | 867 | searcher.addResult(req) |
430 | 868 | if searcher.recommends: | ||
431 | 869 | for prv in searcher.recommends: | ||
432 | 870 | prvname = prv.name | ||
433 | 871 | for req in self._recommends: | ||
434 | 872 | if prvname in req.getMatchNames() and req.matches(prv): | ||
435 | 873 | searcher.addResult(req) | ||
436 | 810 | if searcher.upgrades: | 874 | if searcher.upgrades: |
437 | 811 | for prv in searcher.upgrades: | 875 | for prv in searcher.upgrades: |
438 | 812 | prvname = prv.name | 876 | prvname = prv.name |
439 | @@ -839,6 +903,7 @@ | |||
440 | 839 | self._packages = state["_packages"] | 903 | self._packages = state["_packages"] |
441 | 840 | provides = {} | 904 | provides = {} |
442 | 841 | requires = {} | 905 | requires = {} |
443 | 906 | recommends = {} | ||
444 | 842 | upgrades = {} | 907 | upgrades = {} |
445 | 843 | conflicts = {} | 908 | conflicts = {} |
446 | 844 | for pkg in self._packages: | 909 | for pkg in self._packages: |
447 | @@ -848,6 +913,9 @@ | |||
448 | 848 | for req in pkg.requires: | 913 | for req in pkg.requires: |
449 | 849 | req.packages.append(pkg) | 914 | req.packages.append(pkg) |
450 | 850 | requires[req] = True | 915 | requires[req] = True |
451 | 916 | for rec in pkg.recommends: | ||
452 | 917 | rec.packages.append(pkg) | ||
453 | 918 | recommends[rec] = True | ||
454 | 851 | for upg in pkg.upgrades: | 919 | for upg in pkg.upgrades: |
455 | 852 | upg.packages.append(pkg) | 920 | upg.packages.append(pkg) |
456 | 853 | upgrades[upg] = True | 921 | upgrades[upg] = True |
457 | @@ -856,6 +924,7 @@ | |||
458 | 856 | conflicts[cnf] = True | 924 | conflicts[cnf] = True |
459 | 857 | self._provides = provides.keys() | 925 | self._provides = provides.keys() |
460 | 858 | self._requires = requires.keys() | 926 | self._requires = requires.keys() |
461 | 927 | self._recommends = recommends.keys() | ||
462 | 859 | self._upgrades = upgrades.keys() | 928 | self._upgrades = upgrades.keys() |
463 | 860 | self._conflicts = conflicts.keys() | 929 | self._conflicts = conflicts.keys() |
464 | 861 | self._objmap = {} | 930 | self._objmap = {} |
465 | 862 | 931 | ||
466 | === modified file 'smart/ccache.c' | |||
467 | --- smart/ccache.c 2009-03-02 12:56:54 +0000 | |||
468 | +++ smart/ccache.c 2013-02-12 14:46:20 +0000 | |||
469 | @@ -82,6 +82,7 @@ | |||
470 | 82 | PyObject *version; | 82 | PyObject *version; |
471 | 83 | PyObject *provides; | 83 | PyObject *provides; |
472 | 84 | PyObject *requires; | 84 | PyObject *requires; |
473 | 85 | PyObject *recommends; | ||
474 | 85 | PyObject *upgrades; | 86 | PyObject *upgrades; |
475 | 86 | PyObject *conflicts; | 87 | PyObject *conflicts; |
476 | 87 | PyObject *installed; | 88 | PyObject *installed; |
477 | @@ -96,6 +97,7 @@ | |||
478 | 96 | PyObject *version; | 97 | PyObject *version; |
479 | 97 | PyObject *packages; | 98 | PyObject *packages; |
480 | 98 | PyObject *requiredby; | 99 | PyObject *requiredby; |
481 | 100 | PyObject *recommendedby; | ||
482 | 99 | PyObject *upgradedby; | 101 | PyObject *upgradedby; |
483 | 100 | PyObject *conflictedby; | 102 | PyObject *conflictedby; |
484 | 101 | } ProvidesObject; | 103 | } ProvidesObject; |
485 | @@ -123,6 +125,7 @@ | |||
486 | 123 | PyObject *_packages; | 125 | PyObject *_packages; |
487 | 124 | PyObject *_provides; | 126 | PyObject *_provides; |
488 | 125 | PyObject *_requires; | 127 | PyObject *_requires; |
489 | 128 | PyObject *_recommends; | ||
490 | 126 | PyObject *_upgrades; | 129 | PyObject *_upgrades; |
491 | 127 | PyObject *_conflicts; | 130 | PyObject *_conflicts; |
492 | 128 | PyObject *_objmap; | 131 | PyObject *_objmap; |
493 | @@ -211,7 +214,8 @@ | |||
494 | 211 | Py_INCREF(self->name); | 214 | Py_INCREF(self->name); |
495 | 212 | Py_INCREF(self->version); | 215 | Py_INCREF(self->version); |
496 | 213 | self->provides = PyTuple_New(0); | 216 | self->provides = PyTuple_New(0); |
498 | 214 | self->requires = PyTuple_New(0); | 217 | self->requires = PyList_New(0); |
499 | 218 | self->recommends = PyList_New(0); | ||
500 | 215 | self->upgrades = PyTuple_New(0); | 219 | self->upgrades = PyTuple_New(0); |
501 | 216 | self->conflicts = PyTuple_New(0); | 220 | self->conflicts = PyTuple_New(0); |
502 | 217 | Py_INCREF(Py_False); | 221 | Py_INCREF(Py_False); |
503 | @@ -228,6 +232,7 @@ | |||
504 | 228 | { | 232 | { |
505 | 229 | Py_VISIT(self->provides); | 233 | Py_VISIT(self->provides); |
506 | 230 | Py_VISIT(self->requires); | 234 | Py_VISIT(self->requires); |
507 | 235 | Py_VISIT(self->recommends); | ||
508 | 231 | Py_VISIT(self->upgrades); | 236 | Py_VISIT(self->upgrades); |
509 | 232 | Py_VISIT(self->conflicts); | 237 | Py_VISIT(self->conflicts); |
510 | 233 | Py_VISIT(self->loaders); | 238 | Py_VISIT(self->loaders); |
511 | @@ -239,6 +244,7 @@ | |||
512 | 239 | { | 244 | { |
513 | 240 | Py_CLEAR(self->provides); | 245 | Py_CLEAR(self->provides); |
514 | 241 | Py_CLEAR(self->requires); | 246 | Py_CLEAR(self->requires); |
515 | 247 | Py_CLEAR(self->recommends); | ||
516 | 242 | Py_CLEAR(self->upgrades); | 248 | Py_CLEAR(self->upgrades); |
517 | 243 | Py_CLEAR(self->conflicts); | 249 | Py_CLEAR(self->conflicts); |
518 | 244 | Py_CLEAR(self->loaders); | 250 | Py_CLEAR(self->loaders); |
519 | @@ -252,6 +258,7 @@ | |||
520 | 252 | Py_XDECREF(self->version); | 258 | Py_XDECREF(self->version); |
521 | 253 | Py_XDECREF(self->provides); | 259 | Py_XDECREF(self->provides); |
522 | 254 | Py_XDECREF(self->requires); | 260 | Py_XDECREF(self->requires); |
523 | 261 | Py_XDECREF(self->recommends); | ||
524 | 255 | Py_XDECREF(self->upgrades); | 262 | Py_XDECREF(self->upgrades); |
525 | 256 | Py_XDECREF(self->conflicts); | 263 | Py_XDECREF(self->conflicts); |
526 | 257 | Py_XDECREF(self->installed); | 264 | Py_XDECREF(self->installed); |
527 | @@ -453,6 +460,46 @@ | |||
528 | 453 | } | 460 | } |
529 | 454 | } | 461 | } |
530 | 455 | 462 | ||
531 | 463 | ilen = 0; | ||
532 | 464 | jlen = 0; | ||
533 | 465 | for (i = 0; i != PyList_GET_SIZE(self->recommends); i++) { | ||
534 | 466 | PyObject *item = PyList_GET_ITEM(self->recommends, i); | ||
535 | 467 | if (!PyObject_IsInstance(item, (PyObject *)&Depends_Type)) { | ||
536 | 468 | PyErr_SetString(PyExc_TypeError, "Depends instance expected"); | ||
537 | 469 | return NULL; | ||
538 | 470 | } | ||
539 | 471 | if (STR(((DependsObject *)item)->name)[0] != '/') | ||
540 | 472 | ilen += 1; | ||
541 | 473 | } | ||
542 | 474 | for (j = 0; j != PyList_GET_SIZE(other->recommends); j++) { | ||
543 | 475 | PyObject *item = PyList_GET_ITEM(other->recommends, j); | ||
544 | 476 | if (!PyObject_IsInstance(item, (PyObject *)&Depends_Type)) { | ||
545 | 477 | PyErr_SetString(PyExc_TypeError, "Depends instance expected"); | ||
546 | 478 | return NULL; | ||
547 | 479 | } | ||
548 | 480 | if (STR(((DependsObject *)item)->name)[0] != '/') | ||
549 | 481 | jlen += 1; | ||
550 | 482 | } | ||
551 | 483 | if (ilen != jlen) { | ||
552 | 484 | ret = Py_False; | ||
553 | 485 | goto exit; | ||
554 | 486 | } | ||
555 | 487 | |||
556 | 488 | ilen = PyList_GET_SIZE(self->recommends); | ||
557 | 489 | jlen = PyList_GET_SIZE(other->recommends); | ||
558 | 490 | for (i = 0; i != ilen; i++) { | ||
559 | 491 | PyObject *item = PyList_GET_ITEM(self->recommends, i); | ||
560 | 492 | if (STR(((DependsObject *)item)->name)[0] != '/') { | ||
561 | 493 | for (j = 0; j != jlen; j++) | ||
562 | 494 | if (item == PyList_GET_ITEM(other->recommends, j)) | ||
563 | 495 | break; | ||
564 | 496 | if (j == jlen) { | ||
565 | 497 | ret = Py_False; | ||
566 | 498 | goto exit; | ||
567 | 499 | } | ||
568 | 500 | } | ||
569 | 501 | } | ||
570 | 502 | |||
571 | 456 | exit: | 503 | exit: |
572 | 457 | Py_INCREF(ret); | 504 | Py_INCREF(ret); |
573 | 458 | return ret; | 505 | return ret; |
574 | @@ -606,13 +653,14 @@ | |||
575 | 606 | static PyObject * | 653 | static PyObject * |
576 | 607 | Package__getstate__(PackageObject *self, PyObject *args) | 654 | Package__getstate__(PackageObject *self, PyObject *args) |
577 | 608 | { | 655 | { |
579 | 609 | PyObject *state = PyTuple_New(10); | 656 | PyObject *state = PyTuple_New(11); |
580 | 610 | if (!state) return NULL; | 657 | if (!state) return NULL; |
581 | 611 | 658 | ||
582 | 612 | Py_INCREF(self->name); | 659 | Py_INCREF(self->name); |
583 | 613 | Py_INCREF(self->version); | 660 | Py_INCREF(self->version); |
584 | 614 | Py_INCREF(self->provides); | 661 | Py_INCREF(self->provides); |
585 | 615 | Py_INCREF(self->requires); | 662 | Py_INCREF(self->requires); |
586 | 663 | Py_INCREF(self->recommends); | ||
587 | 616 | Py_INCREF(self->upgrades); | 664 | Py_INCREF(self->upgrades); |
588 | 617 | Py_INCREF(self->conflicts); | 665 | Py_INCREF(self->conflicts); |
589 | 618 | Py_INCREF(self->installed); | 666 | Py_INCREF(self->installed); |
590 | @@ -620,16 +668,17 @@ | |||
591 | 620 | Py_INCREF(self->priority); | 668 | Py_INCREF(self->priority); |
592 | 621 | Py_INCREF(self->loaders); | 669 | Py_INCREF(self->loaders); |
593 | 622 | 670 | ||
604 | 623 | PyTuple_SET_ITEM(state, 0, self->name); | 671 | PyTuple_SET_ITEM(state, 0, self->name); |
605 | 624 | PyTuple_SET_ITEM(state, 1, self->version); | 672 | PyTuple_SET_ITEM(state, 1, self->version); |
606 | 625 | PyTuple_SET_ITEM(state, 2, self->provides); | 673 | PyTuple_SET_ITEM(state, 2, self->provides); |
607 | 626 | PyTuple_SET_ITEM(state, 3, self->requires); | 674 | PyTuple_SET_ITEM(state, 3, self->requires); |
608 | 627 | PyTuple_SET_ITEM(state, 4, self->upgrades); | 675 | PyTuple_SET_ITEM(state, 4, self->recommends); |
609 | 628 | PyTuple_SET_ITEM(state, 5, self->conflicts); | 676 | PyTuple_SET_ITEM(state, 5, self->upgrades); |
610 | 629 | PyTuple_SET_ITEM(state, 6, self->installed); | 677 | PyTuple_SET_ITEM(state, 6, self->conflicts); |
611 | 630 | PyTuple_SET_ITEM(state, 7, self->essential); | 678 | PyTuple_SET_ITEM(state, 7, self->installed); |
612 | 631 | PyTuple_SET_ITEM(state, 8, self->priority); | 679 | PyTuple_SET_ITEM(state, 8, self->essential); |
613 | 632 | PyTuple_SET_ITEM(state, 9, self->loaders); | 680 | PyTuple_SET_ITEM(state, 9, self->priority); |
614 | 681 | PyTuple_SET_ITEM(state, 10, self->loaders); | ||
615 | 633 | 682 | ||
616 | 634 | return state; | 683 | return state; |
617 | 635 | } | 684 | } |
618 | @@ -637,7 +686,7 @@ | |||
619 | 637 | static PyObject * | 686 | static PyObject * |
620 | 638 | Package__setstate__(PackageObject *self, PyObject *state) | 687 | Package__setstate__(PackageObject *self, PyObject *state) |
621 | 639 | { | 688 | { |
623 | 640 | if (!PyTuple_Check(state) || PyTuple_GET_SIZE(state) != 10) { | 689 | if (!PyTuple_Check(state) || PyTuple_GET_SIZE(state) != 11) { |
624 | 641 | PyErr_SetString(StateVersionError, ""); | 690 | PyErr_SetString(StateVersionError, ""); |
625 | 642 | return NULL; | 691 | return NULL; |
626 | 643 | } | 692 | } |
627 | @@ -645,18 +694,20 @@ | |||
628 | 645 | self->version = PyTuple_GET_ITEM(state, 1); | 694 | self->version = PyTuple_GET_ITEM(state, 1); |
629 | 646 | self->provides = PyTuple_GET_ITEM(state, 2); | 695 | self->provides = PyTuple_GET_ITEM(state, 2); |
630 | 647 | self->requires = PyTuple_GET_ITEM(state, 3); | 696 | self->requires = PyTuple_GET_ITEM(state, 3); |
637 | 648 | self->upgrades = PyTuple_GET_ITEM(state, 4); | 697 | self->recommends = PyTuple_GET_ITEM(state, 4); |
638 | 649 | self->conflicts = PyTuple_GET_ITEM(state, 5); | 698 | self->upgrades = PyTuple_GET_ITEM(state, 5); |
639 | 650 | self->installed = PyTuple_GET_ITEM(state, 6); | 699 | self->conflicts = PyTuple_GET_ITEM(state, 6); |
640 | 651 | self->essential = PyTuple_GET_ITEM(state, 7); | 700 | self->installed = PyTuple_GET_ITEM(state, 7); |
641 | 652 | self->priority = PyTuple_GET_ITEM(state, 8); | 701 | self->essential = PyTuple_GET_ITEM(state, 8); |
642 | 653 | self->loaders = PyTuple_GET_ITEM(state, 9); | 702 | self->priority = PyTuple_GET_ITEM(state, 9); |
643 | 703 | self->loaders = PyTuple_GET_ITEM(state, 10); | ||
644 | 654 | 704 | ||
645 | 655 | 705 | ||
646 | 656 | Py_INCREF(self->name); | 706 | Py_INCREF(self->name); |
647 | 657 | Py_INCREF(self->version); | 707 | Py_INCREF(self->version); |
648 | 658 | Py_INCREF(self->provides); | 708 | Py_INCREF(self->provides); |
649 | 659 | Py_INCREF(self->requires); | 709 | Py_INCREF(self->requires); |
650 | 710 | Py_INCREF(self->recommends); | ||
651 | 660 | Py_INCREF(self->upgrades); | 711 | Py_INCREF(self->upgrades); |
652 | 661 | Py_INCREF(self->conflicts); | 712 | Py_INCREF(self->conflicts); |
653 | 662 | Py_INCREF(self->installed); | 713 | Py_INCREF(self->installed); |
654 | @@ -686,6 +737,7 @@ | |||
655 | 686 | {"version", T_OBJECT, OFF(version), 0, 0}, | 737 | {"version", T_OBJECT, OFF(version), 0, 0}, |
656 | 687 | {"provides", T_OBJECT, OFF(provides), 0, 0}, | 738 | {"provides", T_OBJECT, OFF(provides), 0, 0}, |
657 | 688 | {"requires", T_OBJECT, OFF(requires), 0, 0}, | 739 | {"requires", T_OBJECT, OFF(requires), 0, 0}, |
658 | 740 | {"recommends", T_OBJECT, OFF(recommends), 0, 0}, | ||
659 | 689 | {"upgrades", T_OBJECT, OFF(upgrades), 0, 0}, | 741 | {"upgrades", T_OBJECT, OFF(upgrades), 0, 0}, |
660 | 690 | {"conflicts", T_OBJECT, OFF(conflicts), 0, 0}, | 742 | {"conflicts", T_OBJECT, OFF(conflicts), 0, 0}, |
661 | 691 | {"installed", T_OBJECT, OFF(installed), 0, 0}, | 743 | {"installed", T_OBJECT, OFF(installed), 0, 0}, |
662 | @@ -750,6 +802,7 @@ | |||
663 | 750 | Py_INCREF(self->version); | 802 | Py_INCREF(self->version); |
664 | 751 | self->packages = PyList_New(0); | 803 | self->packages = PyList_New(0); |
665 | 752 | self->requiredby = PyTuple_New(0); | 804 | self->requiredby = PyTuple_New(0); |
666 | 805 | self->recommendedby = PyTuple_New(0); | ||
667 | 753 | self->upgradedby = PyTuple_New(0); | 806 | self->upgradedby = PyTuple_New(0); |
668 | 754 | self->conflictedby = PyTuple_New(0); | 807 | self->conflictedby = PyTuple_New(0); |
669 | 755 | return 0; | 808 | return 0; |
670 | @@ -760,6 +813,7 @@ | |||
671 | 760 | { | 813 | { |
672 | 761 | Py_VISIT(self->packages); | 814 | Py_VISIT(self->packages); |
673 | 762 | Py_VISIT(self->requiredby); | 815 | Py_VISIT(self->requiredby); |
674 | 816 | Py_VISIT(self->recommendedby); | ||
675 | 763 | Py_VISIT(self->upgradedby); | 817 | Py_VISIT(self->upgradedby); |
676 | 764 | Py_VISIT(self->conflictedby); | 818 | Py_VISIT(self->conflictedby); |
677 | 765 | return 0; | 819 | return 0; |
678 | @@ -770,6 +824,7 @@ | |||
679 | 770 | { | 824 | { |
680 | 771 | Py_CLEAR(self->packages); | 825 | Py_CLEAR(self->packages); |
681 | 772 | Py_CLEAR(self->requiredby); | 826 | Py_CLEAR(self->requiredby); |
682 | 827 | Py_CLEAR(self->recommendedby); | ||
683 | 773 | Py_CLEAR(self->upgradedby); | 828 | Py_CLEAR(self->upgradedby); |
684 | 774 | Py_CLEAR(self->conflictedby); | 829 | Py_CLEAR(self->conflictedby); |
685 | 775 | return 0; | 830 | return 0; |
686 | @@ -782,6 +837,7 @@ | |||
687 | 782 | Py_XDECREF(self->version); | 837 | Py_XDECREF(self->version); |
688 | 783 | Py_XDECREF(self->packages); | 838 | Py_XDECREF(self->packages); |
689 | 784 | Py_XDECREF(self->requiredby); | 839 | Py_XDECREF(self->requiredby); |
690 | 840 | Py_XDECREF(self->recommendedby); | ||
691 | 785 | Py_XDECREF(self->upgradedby); | 841 | Py_XDECREF(self->upgradedby); |
692 | 786 | Py_XDECREF(self->conflictedby); | 842 | Py_XDECREF(self->conflictedby); |
693 | 787 | self->ob_type->tp_free((PyObject *)self); | 843 | self->ob_type->tp_free((PyObject *)self); |
694 | @@ -960,6 +1016,7 @@ | |||
695 | 960 | {"version", T_OBJECT, OFF(version), 0, 0}, | 1016 | {"version", T_OBJECT, OFF(version), 0, 0}, |
696 | 961 | {"packages", T_OBJECT, OFF(packages), 0, 0}, | 1017 | {"packages", T_OBJECT, OFF(packages), 0, 0}, |
697 | 962 | {"requiredby", T_OBJECT, OFF(requiredby), 0, 0}, | 1018 | {"requiredby", T_OBJECT, OFF(requiredby), 0, 0}, |
698 | 1019 | {"recommendedby", T_OBJECT, OFF(recommendedby), 0, 0}, | ||
699 | 963 | {"upgradedby", T_OBJECT, OFF(upgradedby), 0, 0}, | 1020 | {"upgradedby", T_OBJECT, OFF(upgradedby), 0, 0}, |
700 | 964 | {"conflictedby", T_OBJECT, OFF(conflictedby), 0, 0}, | 1021 | {"conflictedby", T_OBJECT, OFF(conflictedby), 0, 0}, |
701 | 965 | {NULL} | 1022 | {NULL} |
702 | @@ -1555,6 +1612,7 @@ | |||
703 | 1555 | PyObject *reqargs; | 1612 | PyObject *reqargs; |
704 | 1556 | PyObject *upgargs; | 1613 | PyObject *upgargs; |
705 | 1557 | PyObject *cnfargs; | 1614 | PyObject *cnfargs; |
706 | 1615 | PyObject *recargs = NULL; | ||
707 | 1558 | PyObject *callargs; | 1616 | PyObject *callargs; |
708 | 1559 | 1617 | ||
709 | 1560 | PyObject *pkg; | 1618 | PyObject *pkg; |
710 | @@ -1574,9 +1632,10 @@ | |||
711 | 1574 | 1632 | ||
712 | 1575 | cache = (CacheObject *)self->_cache; | 1633 | cache = (CacheObject *)self->_cache; |
713 | 1576 | 1634 | ||
715 | 1577 | if (!PyArg_ParseTuple(args, "O!O&O&O&O&", &PyTuple_Type, &pkgargs, | 1635 | if (!PyArg_ParseTuple(args, "O!O&O&O&O&|O&", &PyTuple_Type, &pkgargs, |
716 | 1578 | mylist, &prvargs, mylist, &reqargs, | 1636 | mylist, &prvargs, mylist, &reqargs, |
718 | 1579 | mylist, &upgargs, mylist, &cnfargs)) | 1637 | mylist, &upgargs, mylist, &cnfargs, |
719 | 1638 | mylist, &recargs)) | ||
720 | 1580 | return NULL; | 1639 | return NULL; |
721 | 1581 | 1640 | ||
722 | 1582 | if (PyTuple_GET_SIZE(pkgargs) < 2) { | 1641 | if (PyTuple_GET_SIZE(pkgargs) < 2) { |
723 | @@ -1701,6 +1760,59 @@ | |||
724 | 1701 | } | 1760 | } |
725 | 1702 | } | 1761 | } |
726 | 1703 | 1762 | ||
727 | 1763 | /* if recargs: */ | ||
728 | 1764 | if (recargs) { | ||
729 | 1765 | int i = 0; | ||
730 | 1766 | int len = PyList_GET_SIZE(recargs); | ||
731 | 1767 | /* pkg.recommends = [] */ | ||
732 | 1768 | Py_DECREF(pkgobj->recommends); | ||
733 | 1769 | pkgobj->recommends = PyList_New(len); | ||
734 | 1770 | /* for args in recargs: */ | ||
735 | 1771 | for (; i != len; i++) { | ||
736 | 1772 | PyObject *args = PyList_GET_ITEM(recargs, i); | ||
737 | 1773 | DependsObject *recobj; | ||
738 | 1774 | PyObject *rec; | ||
739 | 1775 | |||
740 | 1776 | if (!PyTuple_Check(args)) { | ||
741 | 1777 | PyErr_SetString(PyExc_TypeError, | ||
742 | 1778 | "Item in recargs is not a tuple"); | ||
743 | 1779 | return NULL; | ||
744 | 1780 | } | ||
745 | 1781 | |||
746 | 1782 | /* rec = cache._objmap.get(args) */ | ||
747 | 1783 | rec = PyDict_GetItem(cache->_objmap, args); | ||
748 | 1784 | recobj = (DependsObject *)rec; | ||
749 | 1785 | |||
750 | 1786 | /* if not rec: */ | ||
751 | 1787 | if (!rec) { | ||
752 | 1788 | if (!PyTuple_Check(args) || PyTuple_GET_SIZE(args) < 2) { | ||
753 | 1789 | PyErr_SetString(PyExc_ValueError, "Invalid recargs tuple"); | ||
754 | 1790 | return NULL; | ||
755 | 1791 | } | ||
756 | 1792 | /* rec = args[0](*args[1:]) */ | ||
757 | 1793 | callargs = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args)); | ||
758 | 1794 | rec = PyObject_CallObject(PyTuple_GET_ITEM(args, 0), callargs); | ||
759 | 1795 | Py_DECREF(callargs); | ||
760 | 1796 | if (!rec) return NULL; | ||
761 | 1797 | recobj = (DependsObject *)rec; | ||
762 | 1798 | |||
763 | 1799 | /* cache._objmap[args] = rec */ | ||
764 | 1800 | PyDict_SetItem(cache->_objmap, args, rec); | ||
765 | 1801 | Py_DECREF(rec); | ||
766 | 1802 | |||
767 | 1803 | /* cache._recommends.append(rec) */ | ||
768 | 1804 | PyList_Append(cache->_recommends, rec); | ||
769 | 1805 | } | ||
770 | 1806 | |||
771 | 1807 | /* relpkgs.append(rec.packages) */ | ||
772 | 1808 | PyList_Append(relpkgs, recobj->packages); | ||
773 | 1809 | |||
774 | 1810 | /* pkg.recommends.append(rec) */ | ||
775 | 1811 | Py_INCREF(rec); | ||
776 | 1812 | PyList_SET_ITEM(pkgobj->recommends, i, rec); | ||
777 | 1813 | } | ||
778 | 1814 | } | ||
779 | 1815 | |||
780 | 1704 | /* if upgargs: */ | 1816 | /* if upgargs: */ |
781 | 1705 | if (upgargs) { | 1817 | if (upgargs) { |
782 | 1706 | int i = 0; | 1818 | int i = 0; |
783 | @@ -2391,6 +2503,7 @@ | |||
784 | 2391 | self->_packages = PyList_New(0); | 2503 | self->_packages = PyList_New(0); |
785 | 2392 | self->_provides = PyList_New(0); | 2504 | self->_provides = PyList_New(0); |
786 | 2393 | self->_requires = PyList_New(0); | 2505 | self->_requires = PyList_New(0); |
787 | 2506 | self->_recommends = PyList_New(0); | ||
788 | 2394 | self->_upgrades = PyList_New(0); | 2507 | self->_upgrades = PyList_New(0); |
789 | 2395 | self->_conflicts = PyList_New(0); | 2508 | self->_conflicts = PyList_New(0); |
790 | 2396 | self->_objmap = PyDict_New(); | 2509 | self->_objmap = PyDict_New(); |
791 | @@ -2404,6 +2517,7 @@ | |||
792 | 2404 | Py_VISIT(self->_packages); | 2517 | Py_VISIT(self->_packages); |
793 | 2405 | Py_VISIT(self->_provides); | 2518 | Py_VISIT(self->_provides); |
794 | 2406 | Py_VISIT(self->_requires); | 2519 | Py_VISIT(self->_requires); |
795 | 2520 | Py_VISIT(self->_recommends); | ||
796 | 2407 | Py_VISIT(self->_upgrades); | 2521 | Py_VISIT(self->_upgrades); |
797 | 2408 | Py_VISIT(self->_conflicts); | 2522 | Py_VISIT(self->_conflicts); |
798 | 2409 | Py_VISIT(self->_objmap); | 2523 | Py_VISIT(self->_objmap); |
799 | @@ -2417,6 +2531,7 @@ | |||
800 | 2417 | Py_CLEAR(self->_packages); | 2531 | Py_CLEAR(self->_packages); |
801 | 2418 | Py_CLEAR(self->_provides); | 2532 | Py_CLEAR(self->_provides); |
802 | 2419 | Py_CLEAR(self->_requires); | 2533 | Py_CLEAR(self->_requires); |
803 | 2534 | Py_CLEAR(self->_recommends); | ||
804 | 2420 | Py_CLEAR(self->_upgrades); | 2535 | Py_CLEAR(self->_upgrades); |
805 | 2421 | Py_CLEAR(self->_conflicts); | 2536 | Py_CLEAR(self->_conflicts); |
806 | 2422 | Py_CLEAR(self->_objmap); | 2537 | Py_CLEAR(self->_objmap); |
807 | @@ -2430,6 +2545,7 @@ | |||
808 | 2430 | Py_XDECREF(self->_packages); | 2545 | Py_XDECREF(self->_packages); |
809 | 2431 | Py_XDECREF(self->_provides); | 2546 | Py_XDECREF(self->_provides); |
810 | 2432 | Py_XDECREF(self->_requires); | 2547 | Py_XDECREF(self->_requires); |
811 | 2548 | Py_XDECREF(self->_recommends); | ||
812 | 2433 | Py_XDECREF(self->_upgrades); | 2549 | Py_XDECREF(self->_upgrades); |
813 | 2434 | Py_XDECREF(self->_conflicts); | 2550 | Py_XDECREF(self->_conflicts); |
814 | 2435 | Py_XDECREF(self->_objmap); | 2551 | Py_XDECREF(self->_objmap); |
815 | @@ -2449,6 +2565,8 @@ | |||
816 | 2449 | LIST_CLEAR(prvobj->packages); | 2565 | LIST_CLEAR(prvobj->packages); |
817 | 2450 | if (PyList_Check(prvobj->requiredby)) | 2566 | if (PyList_Check(prvobj->requiredby)) |
818 | 2451 | LIST_CLEAR(prvobj->requiredby); | 2567 | LIST_CLEAR(prvobj->requiredby); |
819 | 2568 | if (PyList_Check(prvobj->recommendedby)) | ||
820 | 2569 | LIST_CLEAR(prvobj->recommendedby); | ||
821 | 2452 | if (PyList_Check(prvobj->upgradedby)) | 2570 | if (PyList_Check(prvobj->upgradedby)) |
822 | 2453 | LIST_CLEAR(prvobj->upgradedby); | 2571 | LIST_CLEAR(prvobj->upgradedby); |
823 | 2454 | if (PyList_Check(prvobj->conflictedby)) | 2572 | if (PyList_Check(prvobj->conflictedby)) |
824 | @@ -2464,6 +2582,16 @@ | |||
825 | 2464 | if (PyList_Check(reqobj->providedby)) | 2582 | if (PyList_Check(reqobj->providedby)) |
826 | 2465 | LIST_CLEAR(reqobj->providedby); | 2583 | LIST_CLEAR(reqobj->providedby); |
827 | 2466 | } | 2584 | } |
828 | 2585 | len = PyList_GET_SIZE(self->_recommends); | ||
829 | 2586 | for (i = 0; i != len; i++) { | ||
830 | 2587 | DependsObject *reqobj; | ||
831 | 2588 | PyObject *req; | ||
832 | 2589 | req = PyList_GET_ITEM(self->_recommends, i); | ||
833 | 2590 | reqobj = (DependsObject *)req; | ||
834 | 2591 | LIST_CLEAR(reqobj->packages); | ||
835 | 2592 | if (PyList_Check(reqobj->providedby)) | ||
836 | 2593 | LIST_CLEAR(reqobj->providedby); | ||
837 | 2594 | } | ||
838 | 2467 | len = PyList_GET_SIZE(self->_upgrades); | 2595 | len = PyList_GET_SIZE(self->_upgrades); |
839 | 2468 | for (i = 0; i != len; i++) { | 2596 | for (i = 0; i != len; i++) { |
840 | 2469 | DependsObject *upgobj; | 2597 | DependsObject *upgobj; |
841 | @@ -2487,6 +2615,7 @@ | |||
842 | 2487 | LIST_CLEAR(self->_packages); | 2615 | LIST_CLEAR(self->_packages); |
843 | 2488 | LIST_CLEAR(self->_provides); | 2616 | LIST_CLEAR(self->_provides); |
844 | 2489 | LIST_CLEAR(self->_requires); | 2617 | LIST_CLEAR(self->_requires); |
845 | 2618 | LIST_CLEAR(self->_recommends); | ||
846 | 2490 | LIST_CLEAR(self->_upgrades); | 2619 | LIST_CLEAR(self->_upgrades); |
847 | 2491 | LIST_CLEAR(self->_conflicts); | 2620 | LIST_CLEAR(self->_conflicts); |
848 | 2492 | PyDict_Clear(self->_objmap); | 2621 | PyDict_Clear(self->_objmap); |
849 | @@ -2534,6 +2663,7 @@ | |||
850 | 2534 | packages = {} | 2663 | packages = {} |
851 | 2535 | provides = {} | 2664 | provides = {} |
852 | 2536 | requires = {} | 2665 | requires = {} |
853 | 2666 | recommends = {} | ||
854 | 2537 | upgrades = {} | 2667 | upgrades = {} |
855 | 2538 | conflicts = {} | 2668 | conflicts = {} |
856 | 2539 | objmap = self._objmap | 2669 | objmap = self._objmap |
857 | @@ -2541,11 +2671,12 @@ | |||
858 | 2541 | PyObject *packages = PyDict_New(); | 2671 | PyObject *packages = PyDict_New(); |
859 | 2542 | PyObject *provides = PyDict_New(); | 2672 | PyObject *provides = PyDict_New(); |
860 | 2543 | PyObject *requires = PyDict_New(); | 2673 | PyObject *requires = PyDict_New(); |
861 | 2674 | PyObject *recommends = PyDict_New(); | ||
862 | 2544 | PyObject *upgrades = PyDict_New(); | 2675 | PyObject *upgrades = PyDict_New(); |
863 | 2545 | PyObject *conflicts = PyDict_New(); | 2676 | PyObject *conflicts = PyDict_New(); |
864 | 2546 | PyObject *objmap = self->_objmap; | 2677 | PyObject *objmap = self->_objmap; |
865 | 2547 | int i, ilen; | 2678 | int i, ilen; |
867 | 2548 | if (!packages || !provides || !requires || !conflicts) | 2679 | if (!packages || !provides || !requires || !recommends || !conflicts ) |
868 | 2549 | return NULL; | 2680 | return NULL; |
869 | 2550 | 2681 | ||
870 | 2551 | /* for loader in loaders: */ | 2682 | /* for loader in loaders: */ |
871 | @@ -2679,6 +2810,30 @@ | |||
872 | 2679 | } | 2810 | } |
873 | 2680 | 2811 | ||
874 | 2681 | /* | 2812 | /* |
875 | 2813 | for rec in pkg.recommends: | ||
876 | 2814 | rec.packages.append(pkg) | ||
877 | 2815 | if rec not in recommends: | ||
878 | 2816 | recommends[rec] = True | ||
879 | 2817 | objmap[rec.getInitArgs()] = rec | ||
880 | 2818 | */ | ||
881 | 2819 | if (PyList_Check(pkg->recommends)) { | ||
882 | 2820 | klen = PyList_GET_SIZE(pkg->recommends); | ||
883 | 2821 | for (k = 0; k != klen; k++) { | ||
884 | 2822 | PyObject *rec = PyList_GET_ITEM(pkg->recommends, k); | ||
885 | 2823 | PyList_Append(((DependsObject *)rec)->packages, | ||
886 | 2824 | (PyObject *)pkg); | ||
887 | 2825 | if (!PyDict_GetItem(recommends, rec)) { | ||
888 | 2826 | PyDict_SetItem(recommends, rec, Py_True); | ||
889 | 2827 | args = PyObject_CallMethod(rec, "getInitArgs", | ||
890 | 2828 | NULL); | ||
891 | 2829 | if (!args) return NULL; | ||
892 | 2830 | PyDict_SetItem(objmap, args, rec); | ||
893 | 2831 | Py_DECREF(args); | ||
894 | 2832 | } | ||
895 | 2833 | } | ||
896 | 2834 | } | ||
897 | 2835 | |||
898 | 2836 | /* | ||
899 | 2682 | for upg in pkg.upgrades: | 2837 | for upg in pkg.upgrades: |
900 | 2683 | upg.packages.append(pkg) | 2838 | upg.packages.append(pkg) |
901 | 2684 | if upg not in upgrades: | 2839 | if upg not in upgrades: |
902 | @@ -2747,6 +2902,11 @@ | |||
903 | 2747 | self->_requires = PyDict_Keys(requires); | 2902 | self->_requires = PyDict_Keys(requires); |
904 | 2748 | Py_DECREF(requires); | 2903 | Py_DECREF(requires); |
905 | 2749 | 2904 | ||
906 | 2905 | /* self._recommends[:] = recommends.keys() */ | ||
907 | 2906 | Py_DECREF(self->_recommends); | ||
908 | 2907 | self->_recommends = PyDict_Keys(recommends); | ||
909 | 2908 | Py_DECREF(recommends); | ||
910 | 2909 | |||
911 | 2750 | /* self._upgrades[:] = upgrades.keys() */ | 2910 | /* self._upgrades[:] = upgrades.keys() */ |
912 | 2751 | Py_DECREF(self->_upgrades); | 2911 | Py_DECREF(self->_upgrades); |
913 | 2752 | self->_upgrades = PyDict_Keys(upgrades); | 2912 | self->_upgrades = PyDict_Keys(upgrades); |
914 | @@ -2852,7 +3012,7 @@ | |||
915 | 2852 | Cache_linkDeps(CacheObject *self, PyObject *args) | 3012 | Cache_linkDeps(CacheObject *self, PyObject *args) |
916 | 2853 | { | 3013 | { |
917 | 2854 | int i, j, len; | 3014 | int i, j, len; |
919 | 2855 | PyObject *reqnames, *upgnames, *cnfnames; | 3015 | PyObject *reqnames, *recnames, *upgnames, *cnfnames; |
920 | 2856 | PyObject *lst; | 3016 | PyObject *lst; |
921 | 2857 | 3017 | ||
922 | 2858 | /* reqnames = {} */ | 3018 | /* reqnames = {} */ |
923 | @@ -2896,6 +3056,47 @@ | |||
924 | 2896 | Py_DECREF(seq); | 3056 | Py_DECREF(seq); |
925 | 2897 | } | 3057 | } |
926 | 2898 | 3058 | ||
927 | 3059 | /* recnames = {} */ | ||
928 | 3060 | recnames = PyDict_New(); | ||
929 | 3061 | /* for rec in self._recommends: */ | ||
930 | 3062 | len = PyList_GET_SIZE(self->_recommends); | ||
931 | 3063 | for (i = 0; i != len; i++) { | ||
932 | 3064 | PyObject *rec = PyList_GET_ITEM(self->_recommends, i); | ||
933 | 3065 | |||
934 | 3066 | /* for name in rec.getMatchNames(): */ | ||
935 | 3067 | PyObject *names = PyObject_CallMethod(rec, "getMatchNames", NULL); | ||
936 | 3068 | PyObject *seq = PySequence_Fast(names, "getMatchNames() returned " | ||
937 | 3069 | "non-sequence object"); | ||
938 | 3070 | int nameslen; | ||
939 | 3071 | if (!seq) return NULL; | ||
940 | 3072 | nameslen = PySequence_Fast_GET_SIZE(seq); | ||
941 | 3073 | for (j = 0; j != nameslen; j++) { | ||
942 | 3074 | PyObject *name = PySequence_Fast_GET_ITEM(seq, j); | ||
943 | 3075 | |||
944 | 3076 | /* lst = recnames.get(name) */ | ||
945 | 3077 | lst = PyDict_GetItem(recnames, name); | ||
946 | 3078 | |||
947 | 3079 | /* | ||
948 | 3080 | if lst: | ||
949 | 3081 | lst.append(rec) | ||
950 | 3082 | else: | ||
951 | 3083 | recnames[name] = [rec] | ||
952 | 3084 | */ | ||
953 | 3085 | if (lst) { | ||
954 | 3086 | PyList_Append(lst, rec); | ||
955 | 3087 | } else { | ||
956 | 3088 | lst = PyList_New(1); | ||
957 | 3089 | Py_INCREF(rec); | ||
958 | 3090 | PyList_SET_ITEM(lst, 0, rec); | ||
959 | 3091 | PyDict_SetItem(recnames, name, lst); | ||
960 | 3092 | Py_DECREF(lst); | ||
961 | 3093 | } | ||
962 | 3094 | } | ||
963 | 3095 | |||
964 | 3096 | Py_DECREF(names); | ||
965 | 3097 | Py_DECREF(seq); | ||
966 | 3098 | } | ||
967 | 3099 | |||
968 | 2899 | /* upgnames = {} */ | 3100 | /* upgnames = {} */ |
969 | 2900 | upgnames = PyDict_New(); | 3101 | upgnames = PyDict_New(); |
970 | 2901 | /* for upg in self._upgrades: */ | 3102 | /* for upg in self._upgrades: */ |
971 | @@ -3035,6 +3236,56 @@ | |||
972 | 3035 | } | 3236 | } |
973 | 3036 | } | 3237 | } |
974 | 3037 | 3238 | ||
975 | 3239 | /* lst = recnames.get(prv.name) */ | ||
976 | 3240 | lst = PyDict_GetItem(recnames, prv->name); | ||
977 | 3241 | |||
978 | 3242 | /* if lst: */ | ||
979 | 3243 | if (lst) { | ||
980 | 3244 | /* for rec in lst: */ | ||
981 | 3245 | int reclen = PyList_GET_SIZE(lst); | ||
982 | 3246 | for (j = 0; j != reclen; j++) { | ||
983 | 3247 | DependsObject *rec = (DependsObject *)PyList_GET_ITEM(lst, j); | ||
984 | 3248 | /* if rec.matches(prv): */ | ||
985 | 3249 | PyObject *ret = PyObject_CallMethod((PyObject *)rec, "matches", | ||
986 | 3250 | "O", (PyObject *)prv); | ||
987 | 3251 | if (!ret) return NULL; | ||
988 | 3252 | if (PyObject_IsTrue(ret)) { | ||
989 | 3253 | /* | ||
990 | 3254 | if rec.providedby: | ||
991 | 3255 | rec.providedby.append(prv) | ||
992 | 3256 | else: | ||
993 | 3257 | rec.providedby = [prv] | ||
994 | 3258 | */ | ||
995 | 3259 | if (PyList_Check(rec->providedby)) { | ||
996 | 3260 | PyList_Append(rec->providedby, (PyObject *)prv); | ||
997 | 3261 | } else { | ||
998 | 3262 | PyObject *_lst = PyList_New(1); | ||
999 | 3263 | Py_INCREF(prv); | ||
1000 | 3264 | PyList_SET_ITEM(_lst, 0, (PyObject *)prv); | ||
1001 | 3265 | Py_DECREF(rec->providedby); | ||
1002 | 3266 | rec->providedby = _lst; | ||
1003 | 3267 | } | ||
1004 | 3268 | |||
1005 | 3269 | /* | ||
1006 | 3270 | if prv.recommendedby: | ||
1007 | 3271 | prv.recommendedby.append(prv) | ||
1008 | 3272 | else: | ||
1009 | 3273 | prv.recommendedby = [prv] | ||
1010 | 3274 | */ | ||
1011 | 3275 | if (PyList_Check(prv->recommendedby)) { | ||
1012 | 3276 | PyList_Append(prv->recommendedby, (PyObject *)rec); | ||
1013 | 3277 | } else { | ||
1014 | 3278 | PyObject *_lst = PyList_New(1); | ||
1015 | 3279 | Py_INCREF(rec); | ||
1016 | 3280 | PyList_SET_ITEM(_lst, 0, (PyObject *)rec); | ||
1017 | 3281 | Py_DECREF(prv->recommendedby); | ||
1018 | 3282 | prv->recommendedby = _lst; | ||
1019 | 3283 | } | ||
1020 | 3284 | } | ||
1021 | 3285 | Py_DECREF(ret); | ||
1022 | 3286 | } | ||
1023 | 3287 | } | ||
1024 | 3288 | |||
1025 | 3038 | /* lst = upgnames.get(prv.name) */ | 3289 | /* lst = upgnames.get(prv.name) */ |
1026 | 3039 | lst = PyDict_GetItem(upgnames, prv->name); | 3290 | lst = PyDict_GetItem(upgnames, prv->name); |
1027 | 3040 | 3291 | ||
1028 | @@ -3139,6 +3390,7 @@ | |||
1029 | 3139 | } | 3390 | } |
1030 | 3140 | 3391 | ||
1031 | 3141 | Py_DECREF(reqnames); | 3392 | Py_DECREF(reqnames); |
1032 | 3393 | Py_DECREF(recnames); | ||
1033 | 3142 | Py_DECREF(upgnames); | 3394 | Py_DECREF(upgnames); |
1034 | 3143 | Py_DECREF(cnfnames); | 3395 | Py_DECREF(cnfnames); |
1035 | 3144 | 3396 | ||
1036 | @@ -3215,6 +3467,29 @@ | |||
1037 | 3215 | } | 3467 | } |
1038 | 3216 | 3468 | ||
1039 | 3217 | PyObject * | 3469 | PyObject * |
1040 | 3470 | Cache_getRecommends(CacheObject *self, PyObject *args) | ||
1041 | 3471 | { | ||
1042 | 3472 | const char *name = NULL; | ||
1043 | 3473 | PyObject *lst; | ||
1044 | 3474 | int i, len; | ||
1045 | 3475 | if (!PyArg_ParseTuple(args, "|s", &name)) | ||
1046 | 3476 | return NULL; | ||
1047 | 3477 | if (!name) { | ||
1048 | 3478 | Py_INCREF(self->_recommends); | ||
1049 | 3479 | return self->_recommends; | ||
1050 | 3480 | } | ||
1051 | 3481 | lst = PyList_New(0); | ||
1052 | 3482 | len = PyList_GET_SIZE(self->_recommends); | ||
1053 | 3483 | for (i = 0; i != len; i++) { | ||
1054 | 3484 | DependsObject *rec = | ||
1055 | 3485 | (DependsObject*)PyList_GET_ITEM(self->_recommends, i); | ||
1056 | 3486 | if (strcmp(STR(rec->name), name) == 0) | ||
1057 | 3487 | PyList_Append(lst, (PyObject *)rec); | ||
1058 | 3488 | } | ||
1059 | 3489 | return lst; | ||
1060 | 3490 | } | ||
1061 | 3491 | |||
1062 | 3492 | PyObject * | ||
1063 | 3218 | Cache_getUpgrades(CacheObject *self, PyObject *args) | 3493 | Cache_getUpgrades(CacheObject *self, PyObject *args) |
1064 | 3219 | { | 3494 | { |
1065 | 3220 | const char *name = NULL; | 3495 | const char *name = NULL; |
1066 | @@ -3324,6 +3599,38 @@ | |||
1067 | 3324 | } | 3599 | } |
1068 | 3325 | Py_DECREF(lst); | 3600 | Py_DECREF(lst); |
1069 | 3326 | 3601 | ||
1070 | 3602 | lst = PyObject_GetAttrString(searcher, "recommends"); | ||
1071 | 3603 | if (lst == NULL || !PyList_Check(lst)) { | ||
1072 | 3604 | PyErr_SetString(PyExc_TypeError, "Invalid recommends attribute"); | ||
1073 | 3605 | return NULL; | ||
1074 | 3606 | } | ||
1075 | 3607 | for (i = 0; i != PyList_GET_SIZE(lst); i++) { | ||
1076 | 3608 | ProvidesObject *prv = (ProvidesObject *)PyList_GET_ITEM(lst, i); | ||
1077 | 3609 | for (j = 0; j != PyList_GET_SIZE(self->_recommends); j++) { | ||
1078 | 3610 | PyObject *rec = PyList_GET_ITEM(self->_recommends, j); | ||
1079 | 3611 | PyObject *names = PyObject_CallMethod(rec, "getMatchNames", NULL); | ||
1080 | 3612 | PyObject *seq = PySequence_Fast(names, "getMatchNames() returned " | ||
1081 | 3613 | "non-sequence object"); | ||
1082 | 3614 | if (seq == NULL) return NULL; | ||
1083 | 3615 | for (k = 0; k != PySequence_Fast_GET_SIZE(seq); k++) { | ||
1084 | 3616 | if (strcmp(PyString_AS_STRING(PySequence_Fast_GET_ITEM(seq, k)), | ||
1085 | 3617 | PyString_AS_STRING(prv->name)) == 0) { | ||
1086 | 3618 | res = PyObject_CallMethod(rec, "matches", "O", prv); | ||
1087 | 3619 | if (res == NULL) | ||
1088 | 3620 | return NULL; | ||
1089 | 3621 | if (PyObject_IsTrue(res)) | ||
1090 | 3622 | CALLMETHOD(searcher, "addResult", "O", rec); | ||
1091 | 3623 | Py_DECREF(res); | ||
1092 | 3624 | break; | ||
1093 | 3625 | } | ||
1094 | 3626 | } | ||
1095 | 3627 | |||
1096 | 3628 | Py_DECREF(names); | ||
1097 | 3629 | Py_DECREF(seq); | ||
1098 | 3630 | } | ||
1099 | 3631 | } | ||
1100 | 3632 | Py_DECREF(lst); | ||
1101 | 3633 | |||
1102 | 3327 | lst = PyObject_GetAttrString(searcher, "upgrades"); | 3634 | lst = PyObject_GetAttrString(searcher, "upgrades"); |
1103 | 3328 | if (lst == NULL || !PyList_Check(lst)) { | 3635 | if (lst == NULL || !PyList_Check(lst)) { |
1104 | 3329 | PyErr_SetString(PyExc_TypeError, "Invalid upgrades attribute"); | 3636 | PyErr_SetString(PyExc_TypeError, "Invalid upgrades attribute"); |
1105 | @@ -3420,7 +3727,7 @@ | |||
1106 | 3420 | static PyObject * | 3727 | static PyObject * |
1107 | 3421 | Cache__setstate__(CacheObject *self, PyObject *state) | 3728 | Cache__setstate__(CacheObject *self, PyObject *state) |
1108 | 3422 | { | 3729 | { |
1110 | 3423 | PyObject *provides, *requires, *upgrades, *conflicts; | 3730 | PyObject *provides, *requires, *recommends, *upgrades, *conflicts; |
1111 | 3424 | int i, ilen; | 3731 | int i, ilen; |
1112 | 3425 | int j, jlen; | 3732 | int j, jlen; |
1113 | 3426 | 3733 | ||
1114 | @@ -3452,11 +3759,13 @@ | |||
1115 | 3452 | /* | 3759 | /* |
1116 | 3453 | provides = {} | 3760 | provides = {} |
1117 | 3454 | requires = {} | 3761 | requires = {} |
1118 | 3762 | recommends = {} | ||
1119 | 3455 | upgrades = {} | 3763 | upgrades = {} |
1120 | 3456 | conflicts = {} | 3764 | conflicts = {} |
1121 | 3457 | */ | 3765 | */ |
1122 | 3458 | provides = PyDict_New(); | 3766 | provides = PyDict_New(); |
1123 | 3459 | requires = PyDict_New(); | 3767 | requires = PyDict_New(); |
1124 | 3768 | recommends = PyDict_New(); | ||
1125 | 3460 | upgrades = PyDict_New(); | 3769 | upgrades = PyDict_New(); |
1126 | 3461 | conflicts = PyDict_New(); | 3770 | conflicts = PyDict_New(); |
1127 | 3462 | 3771 | ||
1128 | @@ -3497,6 +3806,21 @@ | |||
1129 | 3497 | } | 3806 | } |
1130 | 3498 | 3807 | ||
1131 | 3499 | /* | 3808 | /* |
1132 | 3809 | for rec in pkg.recommends: | ||
1133 | 3810 | rec.packages.append(pkg) | ||
1134 | 3811 | recommends[rec] = True | ||
1135 | 3812 | */ | ||
1136 | 3813 | if (PyList_Check(pkgobj->recommends)) { | ||
1137 | 3814 | jlen = PyList_GET_SIZE(pkgobj->recommends); | ||
1138 | 3815 | for (j = 0; j != jlen; j++) { | ||
1139 | 3816 | PyObject *rec = PyList_GET_ITEM(pkgobj->recommends, j); | ||
1140 | 3817 | DependsObject *recobj = (DependsObject *)rec; | ||
1141 | 3818 | PyList_Append(recobj->packages, pkg); | ||
1142 | 3819 | PyDict_SetItem(recommends, rec, Py_True); | ||
1143 | 3820 | } | ||
1144 | 3821 | } | ||
1145 | 3822 | |||
1146 | 3823 | /* | ||
1147 | 3500 | for upg in pkg.upgrades: | 3824 | for upg in pkg.upgrades: |
1148 | 3501 | upg.packages.append(pkg) | 3825 | upg.packages.append(pkg) |
1149 | 3502 | upgrades[upg] = True | 3826 | upgrades[upg] = True |
1150 | @@ -3525,6 +3849,7 @@ | |||
1151 | 3525 | PyDict_SetItem(conflicts, cnf, Py_True); | 3849 | PyDict_SetItem(conflicts, cnf, Py_True); |
1152 | 3526 | } | 3850 | } |
1153 | 3527 | } | 3851 | } |
1154 | 3852 | |||
1155 | 3528 | } | 3853 | } |
1156 | 3529 | 3854 | ||
1157 | 3530 | /* self._provides = provides.keys() */ | 3855 | /* self._provides = provides.keys() */ |
1158 | @@ -3535,6 +3860,10 @@ | |||
1159 | 3535 | self->_requires = PyDict_Keys(requires); | 3860 | self->_requires = PyDict_Keys(requires); |
1160 | 3536 | Py_DECREF(requires); | 3861 | Py_DECREF(requires); |
1161 | 3537 | 3862 | ||
1162 | 3863 | /* self._recommends = recommends.keys() */ | ||
1163 | 3864 | self->_recommends = PyDict_Keys(recommends); | ||
1164 | 3865 | Py_DECREF(recommends); | ||
1165 | 3866 | |||
1166 | 3538 | /* self._upgrades = upgrades.keys() */ | 3867 | /* self._upgrades = upgrades.keys() */ |
1167 | 3539 | self->_upgrades = PyDict_Keys(upgrades); | 3868 | self->_upgrades = PyDict_Keys(upgrades); |
1168 | 3540 | Py_DECREF(upgrades); | 3869 | Py_DECREF(upgrades); |
1169 | @@ -3562,6 +3891,7 @@ | |||
1170 | 3562 | {"getPackages", (PyCFunction)Cache_getPackages, METH_VARARGS, NULL}, | 3891 | {"getPackages", (PyCFunction)Cache_getPackages, METH_VARARGS, NULL}, |
1171 | 3563 | {"getProvides", (PyCFunction)Cache_getProvides, METH_VARARGS, NULL}, | 3892 | {"getProvides", (PyCFunction)Cache_getProvides, METH_VARARGS, NULL}, |
1172 | 3564 | {"getRequires", (PyCFunction)Cache_getRequires, METH_VARARGS, NULL}, | 3893 | {"getRequires", (PyCFunction)Cache_getRequires, METH_VARARGS, NULL}, |
1173 | 3894 | {"getRecommends", (PyCFunction)Cache_getRecommends, METH_VARARGS, NULL}, | ||
1174 | 3565 | {"getUpgrades", (PyCFunction)Cache_getUpgrades, METH_VARARGS, NULL}, | 3895 | {"getUpgrades", (PyCFunction)Cache_getUpgrades, METH_VARARGS, NULL}, |
1175 | 3566 | {"getConflicts", (PyCFunction)Cache_getConflicts, METH_VARARGS, NULL}, | 3896 | {"getConflicts", (PyCFunction)Cache_getConflicts, METH_VARARGS, NULL}, |
1176 | 3567 | {"search", (PyCFunction)Cache_search, METH_O, NULL}, | 3897 | {"search", (PyCFunction)Cache_search, METH_O, NULL}, |
1177 | @@ -3576,6 +3906,7 @@ | |||
1178 | 3576 | {"_packages", T_OBJECT, OFF(_packages), RO, 0}, | 3906 | {"_packages", T_OBJECT, OFF(_packages), RO, 0}, |
1179 | 3577 | {"_provides", T_OBJECT, OFF(_provides), RO, 0}, | 3907 | {"_provides", T_OBJECT, OFF(_provides), RO, 0}, |
1180 | 3578 | {"_requires", T_OBJECT, OFF(_requires), RO, 0}, | 3908 | {"_requires", T_OBJECT, OFF(_requires), RO, 0}, |
1181 | 3909 | {"_recommends", T_OBJECT, OFF(_recommends), RO, 0}, | ||
1182 | 3579 | {"_upgrades", T_OBJECT, OFF(_upgrades), RO, 0}, | 3910 | {"_upgrades", T_OBJECT, OFF(_upgrades), RO, 0}, |
1183 | 3580 | {"_conflicts", T_OBJECT, OFF(_conflicts), RO, 0}, | 3911 | {"_conflicts", T_OBJECT, OFF(_conflicts), RO, 0}, |
1184 | 3581 | {"_objmap", T_OBJECT, OFF(_objmap), RO, 0}, | 3912 | {"_objmap", T_OBJECT, OFF(_objmap), RO, 0}, |
1185 | 3582 | 3913 | ||
1186 | === modified file 'smart/channels/rpm_sys.py' | |||
1187 | --- smart/channels/rpm_sys.py 2009-12-18 14:50:03 +0000 | |||
1188 | +++ smart/channels/rpm_sys.py 2013-02-12 14:46:20 +0000 | |||
1189 | @@ -20,7 +20,7 @@ | |||
1190 | 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1191 | 21 | # | 21 | # |
1192 | 22 | from smart.backends.rpm.header import RPMDBLoader | 22 | from smart.backends.rpm.header import RPMDBLoader |
1194 | 23 | from smart.backends.rpm.base import getTS | 23 | from smart.backends.rpm.base import getTS, rpm_join_dbpath |
1195 | 24 | from smart.channel import PackageChannel | 24 | from smart.channel import PackageChannel |
1196 | 25 | from smart import * | 25 | from smart import * |
1197 | 26 | import os | 26 | import os |
1198 | @@ -32,9 +32,9 @@ | |||
1199 | 32 | 32 | ||
1200 | 33 | def fetch(self, fetcher, progress): | 33 | def fetch(self, fetcher, progress): |
1201 | 34 | getTS() # Make sure the db exists. | 34 | getTS() # Make sure the db exists. |
1205 | 35 | path = os.path.join(sysconf.get("rpm-root", "/"), | 35 | dbdir = rpm_join_dbpath(sysconf.get("rpm-root", "/"), |
1206 | 36 | sysconf.get("rpm-dbpath", "var/lib/rpm"), | 36 | sysconf.get("rpm-dbpath", "var/lib/rpm")) |
1207 | 37 | "Packages") | 37 | path = os.path.join(dbdir, "Packages") |
1208 | 38 | digest = os.path.getmtime(path) | 38 | digest = os.path.getmtime(path) |
1209 | 39 | if digest == self._digest: | 39 | if digest == self._digest: |
1210 | 40 | return True | 40 | return True |
1211 | 41 | 41 | ||
1212 | === modified file 'smart/commands/channel.py' | |||
1213 | --- smart/commands/channel.py 2010-12-06 07:35:59 +0000 | |||
1214 | +++ smart/commands/channel.py 2013-02-12 14:46:20 +0000 | |||
1215 | @@ -157,7 +157,17 @@ | |||
1216 | 157 | opts.show is None and opts.yaml is None): | 157 | opts.show is None and opts.yaml is None): |
1217 | 158 | iface.warning(_("Can't edit channels information.")) | 158 | iface.warning(_("Can't edit channels information.")) |
1218 | 159 | raise Error, _("Configuration is in readonly mode.") | 159 | raise Error, _("Configuration is in readonly mode.") |
1220 | 160 | 160 | ||
1221 | 161 | # Argument check | ||
1222 | 162 | opts.check_args_of_option("set", -1) | ||
1223 | 163 | opts.check_args_of_option("remove", -1) | ||
1224 | 164 | opts.check_args_of_option("edit", 0) | ||
1225 | 165 | opts.check_args_of_option("enable", -1) | ||
1226 | 166 | opts.check_args_of_option("disable", -1) | ||
1227 | 167 | opts.ensure_action("channel", ["add", "set", "remove", "remove-all", | ||
1228 | 168 | "list", "show", "yaml", "enable", "disable"]) | ||
1229 | 169 | opts.check_remaining_args() | ||
1230 | 170 | |||
1231 | 161 | if opts.add is not None: | 171 | if opts.add is not None: |
1232 | 162 | if not opts.add and opts.args == ["-"]: | 172 | if not opts.add and opts.args == ["-"]: |
1233 | 163 | newchannels = [] | 173 | newchannels = [] |
1234 | @@ -329,7 +339,10 @@ | |||
1235 | 329 | 339 | ||
1236 | 330 | 340 | ||
1237 | 331 | if opts.yaml is not None: | 341 | if opts.yaml is not None: |
1239 | 332 | import yaml | 342 | try: |
1240 | 343 | import yaml | ||
1241 | 344 | except ImportError: | ||
1242 | 345 | raise Error, _("Please install PyYAML in order to use this function") | ||
1243 | 333 | yamlchannels = {} | 346 | yamlchannels = {} |
1244 | 334 | for alias in (opts.yaml or sysconf.get("channels", ())): | 347 | for alias in (opts.yaml or sysconf.get("channels", ())): |
1245 | 335 | channel = sysconf.get(("channels", alias)) | 348 | channel = sysconf.get(("channels", alias)) |
1246 | 336 | 349 | ||
1247 | === modified file 'smart/commands/check.py' | |||
1248 | --- smart/commands/check.py 2010-06-22 20:51:32 +0000 | |||
1249 | +++ smart/commands/check.py 2013-02-12 14:46:20 +0000 | |||
1250 | @@ -72,6 +72,9 @@ | |||
1251 | 72 | 72 | ||
1252 | 73 | def main(ctrl, opts, reloadchannels=True): | 73 | def main(ctrl, opts, reloadchannels=True): |
1253 | 74 | 74 | ||
1254 | 75 | # Argument check | ||
1255 | 76 | opts.check_args_of_option("channels", 1) | ||
1256 | 77 | |||
1257 | 75 | if sysconf.get("auto-update"): | 78 | if sysconf.get("auto-update"): |
1258 | 76 | from smart.commands import update | 79 | from smart.commands import update |
1259 | 77 | updateopts = update.parse_options([]) | 80 | updateopts = update.parse_options([]) |
1260 | 78 | 81 | ||
1261 | === modified file 'smart/commands/config.py' | |||
1262 | --- smart/commands/config.py 2010-07-02 13:55:04 +0000 | |||
1263 | +++ smart/commands/config.py 2013-02-12 14:46:20 +0000 | |||
1264 | @@ -80,6 +80,12 @@ | |||
1265 | 80 | globals["false"] = False | 80 | globals["false"] = False |
1266 | 81 | globals["no"] = False | 81 | globals["no"] = False |
1267 | 82 | 82 | ||
1268 | 83 | # Check arguments | ||
1269 | 84 | opts.check_args_of_option("set", -1) | ||
1270 | 85 | opts.check_args_of_option("remove", -1) | ||
1271 | 86 | opts.ensure_action("config", ["set", "show", "yaml", "remove"]) | ||
1272 | 87 | opts.check_remaining_args() | ||
1273 | 88 | |||
1274 | 83 | if opts.set: | 89 | if opts.set: |
1275 | 84 | for opt in opts.set: | 90 | for opt in opts.set: |
1276 | 85 | m = SETRE.match(opt) | 91 | m = SETRE.match(opt) |
1277 | @@ -131,7 +137,10 @@ | |||
1278 | 131 | pprint.pprint(sysconf.get((), hard=True)) | 137 | pprint.pprint(sysconf.get((), hard=True)) |
1279 | 132 | 138 | ||
1280 | 133 | if opts.yaml is not None: | 139 | if opts.yaml is not None: |
1282 | 134 | import yaml | 140 | try: |
1283 | 141 | import yaml | ||
1284 | 142 | except ImportError: | ||
1285 | 143 | raise Error, _("Please install PyYAML in order to use this function") | ||
1286 | 135 | if opts.yaml: | 144 | if opts.yaml: |
1287 | 136 | marker = object() | 145 | marker = object() |
1288 | 137 | for opt in opts.yaml: | 146 | for opt in opts.yaml: |
1289 | 138 | 147 | ||
1290 | === modified file 'smart/commands/download.py' | |||
1291 | --- smart/commands/download.py 2010-06-22 20:51:32 +0000 | |||
1292 | +++ smart/commands/download.py 2013-02-12 14:46:20 +0000 | |||
1293 | @@ -81,6 +81,14 @@ | |||
1294 | 81 | 81 | ||
1295 | 82 | def main(ctrl, opts): | 82 | def main(ctrl, opts): |
1296 | 83 | 83 | ||
1297 | 84 | # Argument check | ||
1298 | 85 | opts.check_args_of_option("target", 1) | ||
1299 | 86 | opts.check_args_of_option("output", 1) | ||
1300 | 87 | opts.check_args_of_option("from_urls", -1) | ||
1301 | 88 | opts.check_args_of_option("from_metalink", -1) | ||
1302 | 89 | if not opts.args and not opts.from_metalink and not opts.from_urls: | ||
1303 | 90 | raise Error, _("no package(s) given") | ||
1304 | 91 | |||
1305 | 84 | packages = [] | 92 | packages = [] |
1306 | 85 | if opts.args: | 93 | if opts.args: |
1307 | 86 | if sysconf.get("auto-update"): | 94 | if sysconf.get("auto-update"): |
1308 | 87 | 95 | ||
1309 | === modified file 'smart/commands/flag.py' | |||
1310 | --- smart/commands/flag.py 2010-12-05 15:14:50 +0000 | |||
1311 | +++ smart/commands/flag.py 2013-02-12 14:46:20 +0000 | |||
1312 | @@ -138,7 +138,10 @@ | |||
1313 | 138 | 138 | ||
1314 | 139 | 139 | ||
1315 | 140 | if opts.yaml is not None: | 140 | if opts.yaml is not None: |
1317 | 141 | import yaml | 141 | try: |
1318 | 142 | import yaml | ||
1319 | 143 | except ImportError: | ||
1320 | 144 | raise Error, _("Please install PyYAML in order to use this function") | ||
1321 | 142 | yamlflags = {} | 145 | yamlflags = {} |
1322 | 143 | for flag in opts.yaml or pkgconf.getFlagNames(): | 146 | for flag in opts.yaml or pkgconf.getFlagNames(): |
1323 | 144 | flag = flag.strip() | 147 | flag = flag.strip() |
1324 | 145 | 148 | ||
1325 | === modified file 'smart/commands/info.py' | |||
1326 | --- smart/commands/info.py 2010-06-22 20:51:32 +0000 | |||
1327 | +++ smart/commands/info.py 2013-02-12 14:46:20 +0000 | |||
1328 | @@ -58,6 +58,10 @@ | |||
1329 | 58 | 58 | ||
1330 | 59 | def main(ctrl, opts, reloadchannels=True): | 59 | def main(ctrl, opts, reloadchannels=True): |
1331 | 60 | 60 | ||
1332 | 61 | # Argument check | ||
1333 | 62 | if not opts.args: | ||
1334 | 63 | raise Error, _("No package(s) given") | ||
1335 | 64 | |||
1336 | 61 | if sysconf.get("auto-update"): | 65 | if sysconf.get("auto-update"): |
1337 | 62 | from smart.commands import update | 66 | from smart.commands import update |
1338 | 63 | updateopts = update.parse_options([]) | 67 | updateopts = update.parse_options([]) |
1339 | 64 | 68 | ||
1340 | === modified file 'smart/commands/install.py' | |||
1341 | --- smart/commands/install.py 2011-01-30 21:55:29 +0000 | |||
1342 | +++ smart/commands/install.py 2013-02-12 14:46:20 +0000 | |||
1343 | @@ -76,6 +76,10 @@ | |||
1344 | 76 | 76 | ||
1345 | 77 | def main(ctrl, opts): | 77 | def main(ctrl, opts): |
1346 | 78 | 78 | ||
1347 | 79 | # Argument check | ||
1348 | 80 | if not opts.args: | ||
1349 | 81 | raise Error, _("no package(s) given") | ||
1350 | 82 | |||
1351 | 79 | if opts.explain: | 83 | if opts.explain: |
1352 | 80 | sysconf.set("explain-changesets", True, soft=True) | 84 | sysconf.set("explain-changesets", True, soft=True) |
1353 | 81 | 85 | ||
1354 | 82 | 86 | ||
1355 | === modified file 'smart/commands/mirror.py' | |||
1356 | --- smart/commands/mirror.py 2010-07-02 13:55:04 +0000 | |||
1357 | +++ smart/commands/mirror.py 2013-02-12 14:46:20 +0000 | |||
1358 | @@ -218,7 +218,10 @@ | |||
1359 | 218 | 218 | ||
1360 | 219 | 219 | ||
1361 | 220 | if opts.yaml: | 220 | if opts.yaml: |
1363 | 221 | import yaml | 221 | try: |
1364 | 222 | import yaml | ||
1365 | 223 | except ImportError: | ||
1366 | 224 | raise Error, _("Please install PyYAML in order to use this function") | ||
1367 | 222 | yamlmirrors = {} | 225 | yamlmirrors = {} |
1368 | 223 | mirrors = sysconf.get("mirrors", ()) | 226 | mirrors = sysconf.get("mirrors", ()) |
1369 | 224 | for origin in mirrors: | 227 | for origin in mirrors: |
1370 | 225 | 228 | ||
1371 | === modified file 'smart/commands/priority.py' | |||
1372 | --- smart/commands/priority.py 2010-07-02 13:55:04 +0000 | |||
1373 | +++ smart/commands/priority.py 2013-02-12 14:46:20 +0000 | |||
1374 | @@ -117,7 +117,10 @@ | |||
1375 | 117 | 117 | ||
1376 | 118 | 118 | ||
1377 | 119 | elif opts.yaml: | 119 | elif opts.yaml: |
1379 | 120 | import yaml | 120 | try: |
1380 | 121 | import yaml | ||
1381 | 122 | except ImportError: | ||
1382 | 123 | raise Error, _("Please install PyYAML in order to use this function") | ||
1383 | 121 | yamlpriorities = {} | 124 | yamlpriorities = {} |
1384 | 122 | priorities = sysconf.get("package-priorities", {}) | 125 | priorities = sysconf.get("package-priorities", {}) |
1385 | 123 | for name in opts.args or priorities: | 126 | for name in opts.args or priorities: |
1386 | 124 | 127 | ||
1387 | === modified file 'smart/commands/query.py' | |||
1388 | --- smart/commands/query.py 2010-12-05 15:11:14 +0000 | |||
1389 | +++ smart/commands/query.py 2013-02-12 14:46:20 +0000 | |||
1390 | @@ -107,6 +107,8 @@ | |||
1391 | 107 | help=_("show requires for the given packages")) | 107 | help=_("show requires for the given packages")) |
1392 | 108 | parser.add_option("--show-prerequires", action="store_true", | 108 | parser.add_option("--show-prerequires", action="store_true", |
1393 | 109 | help=_("show requires selecting only pre-dependencies")) | 109 | help=_("show requires selecting only pre-dependencies")) |
1394 | 110 | parser.add_option("--show-recommends", action="store_true", | ||
1395 | 111 | help=_("show recommends for the given packages")) | ||
1396 | 110 | parser.add_option("--show-upgrades", action="store_true", | 112 | parser.add_option("--show-upgrades", action="store_true", |
1397 | 111 | help=_("show upgrades for the given packages")) | 113 | help=_("show upgrades for the given packages")) |
1398 | 112 | parser.add_option("--show-conflicts", action="store_true", | 114 | parser.add_option("--show-conflicts", action="store_true", |
1399 | @@ -488,6 +490,19 @@ | |||
1400 | 488 | continue | 490 | continue |
1401 | 489 | output.showRequiresProvidedBy(pkg, req, | 491 | output.showRequiresProvidedBy(pkg, req, |
1402 | 490 | prv, prvpkg) | 492 | prv, prvpkg) |
1403 | 493 | if pkg.recommends and (opts.show_recommends): | ||
1404 | 494 | pkg.recommends.sort() | ||
1405 | 495 | first = True | ||
1406 | 496 | for req in pkg.recommends: | ||
1407 | 497 | output.showRecommends(pkg, req) | ||
1408 | 498 | if opts.show_providedby and req.providedby: | ||
1409 | 499 | for prv in req.providedby: | ||
1410 | 500 | prv.packages.sort() | ||
1411 | 501 | for prvpkg in prv.packages: | ||
1412 | 502 | if opts.installed and not prvpkg.installed: | ||
1413 | 503 | continue | ||
1414 | 504 | output.showRecommendsProvidedBy(pkg, req, | ||
1415 | 505 | prv, prvpkg) | ||
1416 | 491 | if pkg.upgrades and (opts.show_upgrades or whoupgrades): | 506 | if pkg.upgrades and (opts.show_upgrades or whoupgrades): |
1417 | 492 | pkg.upgrades.sort() | 507 | pkg.upgrades.sort() |
1418 | 493 | first = True | 508 | first = True |
1419 | @@ -594,6 +609,12 @@ | |||
1420 | 594 | def showRequiresProvidedBy(self, pkg, req, prv, prvpkg): | 609 | def showRequiresProvidedBy(self, pkg, req, prv, prvpkg): |
1421 | 595 | pass | 610 | pass |
1422 | 596 | 611 | ||
1423 | 612 | def showRecommends(self, pkg, req): | ||
1424 | 613 | pass | ||
1425 | 614 | |||
1426 | 615 | def showRecommendsProvidedBy(self, pkg, req, prv, prvpkg): | ||
1427 | 616 | pass | ||
1428 | 617 | |||
1429 | 597 | def showUpgrades(self, pkg, upg): | 618 | def showUpgrades(self, pkg, upg): |
1430 | 598 | pass | 619 | pass |
1431 | 599 | 620 | ||
1432 | @@ -619,6 +640,8 @@ | |||
1433 | 619 | self._firstconflictedby = True | 640 | self._firstconflictedby = True |
1434 | 620 | self._firstrequires = True | 641 | self._firstrequires = True |
1435 | 621 | self._firstrequiresprovidedby = True | 642 | self._firstrequiresprovidedby = True |
1436 | 643 | self._firstrecommends = True | ||
1437 | 644 | self._firstrecommendsprovidedby = True | ||
1438 | 622 | self._firstupgrades = True | 645 | self._firstupgrades = True |
1439 | 623 | self._firstupgradesprovidedby = True | 646 | self._firstupgradesprovidedby = True |
1440 | 624 | self._firstconflicts = True | 647 | self._firstconflicts = True |
1441 | @@ -711,6 +734,22 @@ | |||
1442 | 711 | name = str(prvpkg) | 734 | name = str(prvpkg) |
1443 | 712 | print " ", "%s (%s)" % (name, prv) | 735 | print " ", "%s (%s)" % (name, prv) |
1444 | 713 | 736 | ||
1445 | 737 | def showRecommends(self, pkg, rec): | ||
1446 | 738 | if self._firstrecommends: | ||
1447 | 739 | self._firstrecommends = False | ||
1448 | 740 | print " ", _("Recommends:") | ||
1449 | 741 | print " ", rec | ||
1450 | 742 | |||
1451 | 743 | def showRecommendsProvidedBy(self, pkg, req, prv, prvpkg): | ||
1452 | 744 | if self._firstrecommendsprovidedby: | ||
1453 | 745 | self._firstrecommendsprovidedby = False | ||
1454 | 746 | print " ", _("Provided By:") | ||
1455 | 747 | if self.opts.hide_version: | ||
1456 | 748 | name = prvpkg.name | ||
1457 | 749 | else: | ||
1458 | 750 | name = str(prvpkg) | ||
1459 | 751 | print " ", "%s (%s)" % (name, prv) | ||
1460 | 752 | |||
1461 | 714 | def showUpgrades(self, pkg, upg): | 753 | def showUpgrades(self, pkg, upg): |
1462 | 715 | if self._firstupgrades: | 754 | if self._firstupgrades: |
1463 | 716 | self._firstupgrades = False | 755 | self._firstupgrades = False |
1464 | @@ -797,6 +836,18 @@ | |||
1465 | 797 | self._shown[req, prv] = True | 836 | self._shown[req, prv] = True |
1466 | 798 | print ' "Requires: %s" -> "Provides: %s";' % (req, prv) | 837 | print ' "Requires: %s" -> "Provides: %s";' % (req, prv) |
1467 | 799 | 838 | ||
1468 | 839 | def showRecommends(self, pkg, req): | ||
1469 | 840 | if (pkg, req) not in self._shown: | ||
1470 | 841 | self._shown[pkg, req] = True | ||
1471 | 842 | print ' "%s" -> "Recommends: %s";' % (pkg, req) | ||
1472 | 843 | |||
1473 | 844 | def showRecommendsProvidedBy(self, pkg, req, prv, prvpkg): | ||
1474 | 845 | self.showPackage(prvpkg) | ||
1475 | 846 | self.showProvides(prvpkg, prv) | ||
1476 | 847 | if (req, prv) not in self._shown: | ||
1477 | 848 | self._shown[req, prv] = True | ||
1478 | 849 | print ' "Recommends: %s" -> "Provides: %s";' % (req, prv) | ||
1479 | 850 | |||
1480 | 800 | def showUpgrades(self, pkg, upg): | 851 | def showUpgrades(self, pkg, upg): |
1481 | 801 | if (pkg, upg) not in self._shown: | 852 | if (pkg, upg) not in self._shown: |
1482 | 802 | self._shown[pkg, upg] = True | 853 | self._shown[pkg, upg] = True |
1483 | 803 | 854 | ||
1484 | === modified file 'smart/commands/reinstall.py' | |||
1485 | --- smart/commands/reinstall.py 2010-06-22 20:51:32 +0000 | |||
1486 | +++ smart/commands/reinstall.py 2013-02-12 14:46:20 +0000 | |||
1487 | @@ -68,7 +68,11 @@ | |||
1488 | 68 | return opts | 68 | return opts |
1489 | 69 | 69 | ||
1490 | 70 | def main(ctrl, opts): | 70 | def main(ctrl, opts): |
1492 | 71 | 71 | ||
1493 | 72 | # Argument check | ||
1494 | 73 | if not opts.args: | ||
1495 | 74 | raise Error, _("no package(s) given") | ||
1496 | 75 | |||
1497 | 72 | if opts.explain: | 76 | if opts.explain: |
1498 | 73 | sysconf.set("explain-changesets", True, soft=True) | 77 | sysconf.set("explain-changesets", True, soft=True) |
1499 | 74 | 78 | ||
1500 | 75 | 79 | ||
1501 | === modified file 'smart/commands/remove.py' | |||
1502 | --- smart/commands/remove.py 2010-06-22 20:51:32 +0000 | |||
1503 | +++ smart/commands/remove.py 2013-02-12 14:46:20 +0000 | |||
1504 | @@ -74,6 +74,10 @@ | |||
1505 | 74 | 74 | ||
1506 | 75 | def main(ctrl, opts): | 75 | def main(ctrl, opts): |
1507 | 76 | 76 | ||
1508 | 77 | # Argument check | ||
1509 | 78 | if not opts.args: | ||
1510 | 79 | raise Error, _("no package(s) given") | ||
1511 | 80 | |||
1512 | 77 | if opts.explain: | 81 | if opts.explain: |
1513 | 78 | sysconf.set("explain-changesets", True, soft=True) | 82 | sysconf.set("explain-changesets", True, soft=True) |
1514 | 79 | 83 | ||
1515 | 80 | 84 | ||
1516 | === modified file 'smart/commands/search.py' | |||
1517 | --- smart/commands/search.py 2010-11-28 13:12:37 +0000 | |||
1518 | +++ smart/commands/search.py 2013-02-12 14:46:20 +0000 | |||
1519 | @@ -44,6 +44,8 @@ | |||
1520 | 44 | def parse_options(argv): | 44 | def parse_options(argv): |
1521 | 45 | opts = query.parse_options(argv, usage=USAGE, \ | 45 | opts = query.parse_options(argv, usage=USAGE, \ |
1522 | 46 | description=DESCRIPTION, examples=EXAMPLES) | 46 | description=DESCRIPTION, examples=EXAMPLES) |
1523 | 47 | if not argv: | ||
1524 | 48 | raise Error, _("Search expression not specified") | ||
1525 | 47 | opts.name = opts.args | 49 | opts.name = opts.args |
1526 | 48 | opts.summary = opts.args | 50 | opts.summary = opts.args |
1527 | 49 | opts.description = opts.args | 51 | opts.description = opts.args |
1528 | 50 | 52 | ||
1529 | === modified file 'smart/commands/upgrade.py' | |||
1530 | --- smart/commands/upgrade.py 2010-12-05 15:11:14 +0000 | |||
1531 | +++ smart/commands/upgrade.py 2013-02-12 14:46:20 +0000 | |||
1532 | @@ -91,6 +91,9 @@ | |||
1533 | 91 | 91 | ||
1534 | 92 | def main(ctrl, opts): | 92 | def main(ctrl, opts): |
1535 | 93 | 93 | ||
1536 | 94 | # Argument check | ||
1537 | 95 | opts.check_args_of_option("flag", 1) | ||
1538 | 96 | |||
1539 | 94 | if opts.explain: | 97 | if opts.explain: |
1540 | 95 | sysconf.set("explain-changesets", True, soft=True) | 98 | sysconf.set("explain-changesets", True, soft=True) |
1541 | 96 | 99 | ||
1542 | 97 | 100 | ||
1543 | === modified file 'smart/control.py' | |||
1544 | --- smart/control.py 2011-10-05 22:02:21 +0000 | |||
1545 | +++ smart/control.py 2013-02-12 14:46:20 +0000 | |||
1546 | @@ -447,7 +447,7 @@ | |||
1547 | 447 | queue = marked.keys() | 447 | queue = marked.keys() |
1548 | 448 | while queue: | 448 | while queue: |
1549 | 449 | pkg = queue.pop(0) | 449 | pkg = queue.pop(0) |
1551 | 450 | for req in pkg.requires: | 450 | for req in pkg.requires + pkg.recommends: |
1552 | 451 | for prv in req.providedby: | 451 | for prv in req.providedby: |
1553 | 452 | for prvpkg in prv.packages: | 452 | for prvpkg in prv.packages: |
1554 | 453 | if (prvpkg.installed and | 453 | if (prvpkg.installed and |
1555 | @@ -794,7 +794,7 @@ | |||
1556 | 794 | pkglst = [] | 794 | pkglst = [] |
1557 | 795 | for pkg in changeset: | 795 | for pkg in changeset: |
1558 | 796 | n = 0 | 796 | n = 0 |
1560 | 797 | for req in pkg.requires: | 797 | for req in pkg.requires + pkg.recommends: |
1561 | 798 | for prv in req.providedby: | 798 | for prv in req.providedby: |
1562 | 799 | for prvpkg in prv.packages: | 799 | for prvpkg in prv.packages: |
1563 | 800 | if changeset.get(prvpkg) is INSTALL: | 800 | if changeset.get(prvpkg) is INSTALL: |
1564 | 801 | 801 | ||
1565 | === modified file 'smart/plugins/detectsys.py' | |||
1566 | --- smart/plugins/detectsys.py 2011-09-22 20:06:16 +0000 | |||
1567 | +++ smart/plugins/detectsys.py 2013-02-12 14:46:20 +0000 | |||
1568 | @@ -20,10 +20,11 @@ | |||
1569 | 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1570 | 21 | # | 21 | # |
1571 | 22 | from smart import * | 22 | from smart import * |
1572 | 23 | from smart.backends.rpm.base import rpm_join_dbpath | ||
1573 | 23 | import os | 24 | import os |
1574 | 24 | 25 | ||
1575 | 25 | def detectRPMSystem(): | 26 | def detectRPMSystem(): |
1577 | 26 | dir = os.path.join(sysconf.get("rpm-root", "/"), | 27 | dir = rpm_join_dbpath(sysconf.get("rpm-root", "/"), |
1578 | 27 | sysconf.get("rpm-dbpath", "var/lib/rpm")) | 28 | sysconf.get("rpm-dbpath", "var/lib/rpm")) |
1579 | 28 | file = os.path.join(dir, "Packages") | 29 | file = os.path.join(dir, "Packages") |
1580 | 29 | if os.path.exists(file): | 30 | if os.path.exists(file): |
1581 | 30 | 31 | ||
1582 | === modified file 'smart/searcher.py' | |||
1583 | --- smart/searcher.py 2010-06-22 10:41:16 +0000 | |||
1584 | +++ smart/searcher.py 2013-02-12 14:46:20 +0000 | |||
1585 | @@ -45,9 +45,9 @@ | |||
1586 | 45 | 45 | ||
1587 | 46 | - provides is matched in Provides.search(), for the same reason. | 46 | - provides is matched in Provides.search(), for the same reason. |
1588 | 47 | 47 | ||
1592 | 48 | - requires, upgrades, and conflicts don't have special searching | 48 | - requires, recommends, upgrades, and conflicts don't have special |
1593 | 49 | methods. Instead, their usual match() method is given an instance | 49 | searching methods. Instead, their usual match() method is given |
1594 | 50 | of the Provides type. | 50 | an instance of the Provides type. |
1595 | 51 | 51 | ||
1596 | 52 | - group, path, url, and other information which is found by | 52 | - group, path, url, and other information which is found by |
1597 | 53 | PackageInfo, is searched by the Loader.search() method and | 53 | PackageInfo, is searched by the Loader.search() method and |
1598 | @@ -62,6 +62,7 @@ | |||
1599 | 62 | self.nameversion = [] | 62 | self.nameversion = [] |
1600 | 63 | self.provides = [] | 63 | self.provides = [] |
1601 | 64 | self.requires = [] | 64 | self.requires = [] |
1602 | 65 | self.recommends = [] | ||
1603 | 65 | self.upgrades = [] | 66 | self.upgrades = [] |
1604 | 66 | self.conflicts = [] | 67 | self.conflicts = [] |
1605 | 67 | self.path = [] | 68 | self.path = [] |
1606 | @@ -76,6 +77,7 @@ | |||
1607 | 76 | del self.nameversion[:] | 77 | del self.nameversion[:] |
1608 | 77 | del self.provides[:] | 78 | del self.provides[:] |
1609 | 78 | del self.requires[:] | 79 | del self.requires[:] |
1610 | 80 | del self.recommends[:] | ||
1611 | 79 | del self.upgrades[:] | 81 | del self.upgrades[:] |
1612 | 80 | del self.conflicts[:] | 82 | del self.conflicts[:] |
1613 | 81 | del self.path[:] | 83 | del self.path[:] |
1614 | @@ -122,6 +124,8 @@ | |||
1615 | 122 | self.addProvides(s[9:], cutoff) | 124 | self.addProvides(s[9:], cutoff) |
1616 | 123 | elif s.startswith("requires:"): | 125 | elif s.startswith("requires:"): |
1617 | 124 | self.addRequires(s[9:]) | 126 | self.addRequires(s[9:]) |
1618 | 127 | elif s.startswith("recommends:"): | ||
1619 | 128 | self.addRecommends(s[11:]) | ||
1620 | 125 | elif s.startswith("upgrades:"): | 129 | elif s.startswith("upgrades:"): |
1621 | 126 | self.addUpgrades(s[9:]) | 130 | self.addUpgrades(s[9:]) |
1622 | 127 | elif s.startswith("conflicts:"): | 131 | elif s.startswith("conflicts:"): |
1623 | @@ -151,6 +155,7 @@ | |||
1624 | 151 | return s and ( | 155 | return s and ( |
1625 | 152 | s.startswith("provides:") or | 156 | s.startswith("provides:") or |
1626 | 153 | s.startswith("requires:") or | 157 | s.startswith("requires:") or |
1627 | 158 | s.startswith("recommends:") or | ||
1628 | 154 | s.startswith("upgrades:") or | 159 | s.startswith("upgrades:") or |
1629 | 155 | s.startswith("conflicts:") or | 160 | s.startswith("conflicts:") or |
1630 | 156 | s.startswith("url:") or | 161 | s.startswith("url:") or |
1631 | @@ -182,6 +187,9 @@ | |||
1632 | 182 | def addRequires(self, s): | 187 | def addRequires(self, s): |
1633 | 183 | self.requires.append(self._buildProvides(s)) | 188 | self.requires.append(self._buildProvides(s)) |
1634 | 184 | 189 | ||
1635 | 190 | def addRecommends(self, s): | ||
1636 | 191 | self.recommends.append(self._buildProvides(s)) | ||
1637 | 192 | |||
1638 | 185 | def addUpgrades(self, s): | 193 | def addUpgrades(self, s): |
1639 | 186 | self.upgrades.append(self._buildProvides(s)) | 194 | self.upgrades.append(self._buildProvides(s)) |
1640 | 187 | 195 | ||
1641 | 188 | 196 | ||
1642 | === modified file 'smart/transaction.py' | |||
1643 | --- smart/transaction.py 2010-06-22 17:01:09 +0000 | |||
1644 | +++ smart/transaction.py 2013-02-12 14:46:20 +0000 | |||
1645 | @@ -573,7 +573,7 @@ | |||
1646 | 573 | self._remove(namepkg, changeset, locked, pending, depth) | 573 | self._remove(namepkg, changeset, locked, pending, depth) |
1647 | 574 | 574 | ||
1648 | 575 | # Install packages required by this one. | 575 | # Install packages required by this one. |
1650 | 576 | for req in pkg.requires: | 576 | for req in pkg.requires + pkg.recommends: |
1651 | 577 | 577 | ||
1652 | 578 | # Check if someone is already providing it. | 578 | # Check if someone is already providing it. |
1653 | 579 | prvpkgs = {} | 579 | prvpkgs = {} |
1654 | @@ -596,8 +596,12 @@ | |||
1655 | 596 | 596 | ||
1656 | 597 | if not prvpkgs: | 597 | if not prvpkgs: |
1657 | 598 | # No packages provide it at all. Give up. | 598 | # No packages provide it at all. Give up. |
1660 | 599 | raise Failed, _("Can't install %s: no package provides %s") % \ | 599 | if req in pkg.requires: |
1661 | 600 | (pkg, req) | 600 | raise Failed, _("Can't install %s: no package provides %s") % \ |
1662 | 601 | (pkg, req) | ||
1663 | 602 | else: | ||
1664 | 603 | # It's only a recommend, skip | ||
1665 | 604 | continue | ||
1666 | 601 | 605 | ||
1667 | 602 | if len(prvpkgs) == 1: | 606 | if len(prvpkgs) == 1: |
1668 | 603 | # Don't check locked here. prvpkgs was | 607 | # Don't check locked here. prvpkgs was |
1669 | @@ -1359,7 +1363,7 @@ | |||
1670 | 1359 | set = self._changeset | 1363 | set = self._changeset |
1671 | 1360 | 1364 | ||
1672 | 1361 | # Check all dependencies needed by this package. | 1365 | # Check all dependencies needed by this package. |
1674 | 1362 | for req in pkg.requires: | 1366 | for req in pkg.requires + pkg.recommends: |
1675 | 1363 | 1367 | ||
1676 | 1364 | # Check if any already installed or to be installed | 1368 | # Check if any already installed or to be installed |
1677 | 1365 | # package will solve the problem. | 1369 | # package will solve the problem. |
1678 | @@ -1424,8 +1428,9 @@ | |||
1679 | 1424 | 1428 | ||
1680 | 1425 | # There are no solutions for the problem. | 1429 | # There are no solutions for the problem. |
1681 | 1426 | # Should we really care about it? | 1430 | # Should we really care about it? |
1684 | 1427 | if (self._forcerequires or | 1431 | if ((self._forcerequires or |
1685 | 1428 | isinstance(req, PreRequires)): | 1432 | isinstance(req, PreRequires)) |
1686 | 1433 | and req in pkg.requires): | ||
1687 | 1429 | raise Error, _("No providers for '%s', " | 1434 | raise Error, _("No providers for '%s', " |
1688 | 1430 | "required by '%s'") % (req, pkg) | 1435 | "required by '%s'") % (req, pkg) |
1689 | 1431 | 1436 | ||
1690 | @@ -1625,7 +1630,7 @@ | |||
1691 | 1625 | return n | 1630 | return n |
1692 | 1626 | 1631 | ||
1693 | 1627 | def forwardRequires(pkg, map): | 1632 | def forwardRequires(pkg, map): |
1695 | 1628 | for req in pkg.requires: | 1633 | for req in pkg.requires + pkg.recommends: |
1696 | 1629 | if req not in map: | 1634 | if req not in map: |
1697 | 1630 | map[req] = True | 1635 | map[req] = True |
1698 | 1631 | for prv in req.providedby: | 1636 | for prv in req.providedby: |
1699 | @@ -1794,6 +1799,15 @@ | |||
1700 | 1794 | iface.info(_("Unsatisfied dependency: %s requires %s") % | 1799 | iface.info(_("Unsatisfied dependency: %s requires %s") % |
1701 | 1795 | (pkg, req)) | 1800 | (pkg, req)) |
1702 | 1796 | 1801 | ||
1703 | 1802 | for req in pkg.recommends: | ||
1704 | 1803 | for prv in req.providedby: | ||
1705 | 1804 | for prvpkg in prv.packages: | ||
1706 | 1805 | if prvpkg in relateset: | ||
1707 | 1806 | break | ||
1708 | 1807 | else: | ||
1709 | 1808 | continue | ||
1710 | 1809 | break | ||
1711 | 1810 | |||
1712 | 1797 | if not pkg.installed: | 1811 | if not pkg.installed: |
1713 | 1798 | continue | 1812 | continue |
1714 | 1799 | 1813 | ||
1715 | 1800 | 1814 | ||
1716 | === modified file 'smart/util/optparse.py' | |||
1717 | --- smart/util/optparse.py 2005-06-14 17:41:24 +0000 | |||
1718 | +++ smart/util/optparse.py 2013-02-12 14:46:20 +0000 | |||
1719 | @@ -70,6 +70,8 @@ | |||
1720 | 70 | import types | 70 | import types |
1721 | 71 | import textwrap | 71 | import textwrap |
1722 | 72 | from gettext import gettext as _ | 72 | from gettext import gettext as _ |
1723 | 73 | from smart import Error | ||
1724 | 74 | import re | ||
1725 | 73 | 75 | ||
1726 | 74 | def _repr(self): | 76 | def _repr(self): |
1727 | 75 | return "<%s at 0x%x: %s>" % (self.__class__.__name__, id(self), self) | 77 | return "<%s at 0x%x: %s>" % (self.__class__.__name__, id(self), self) |
1728 | @@ -708,6 +710,12 @@ | |||
1729 | 708 | self.action, self.dest, opt, value, values, parser) | 710 | self.action, self.dest, opt, value, values, parser) |
1730 | 709 | 711 | ||
1731 | 710 | def take_action(self, action, dest, opt, value, values, parser): | 712 | def take_action(self, action, dest, opt, value, values, parser): |
1732 | 713 | # Keep all the options in the command line in the '_given_opts' array | ||
1733 | 714 | # This will be used later to validate the command line | ||
1734 | 715 | given_opts = getattr(parser.values, "_given_opts", []) | ||
1735 | 716 | user_opt = re.sub(r"^\-*", "", opt).replace("-", "_") | ||
1736 | 717 | given_opts.append(user_opt) | ||
1737 | 718 | setattr(parser.values, "_given_opts", given_opts) | ||
1738 | 711 | if action == "store": | 719 | if action == "store": |
1739 | 712 | setattr(values, dest, value) | 720 | setattr(values, dest, value) |
1740 | 713 | elif action == "store_const": | 721 | elif action == "store_const": |
1741 | @@ -819,6 +827,54 @@ | |||
1742 | 819 | setattr(self, attr, value) | 827 | setattr(self, attr, value) |
1743 | 820 | return getattr(self, attr) | 828 | return getattr(self, attr) |
1744 | 821 | 829 | ||
1745 | 830 | # Check if the given option has the specified number of arguments | ||
1746 | 831 | # Raise an error if the option has an invalid number of arguments | ||
1747 | 832 | # A negative number for 'nargs' means "at least |nargs| arguments are needed" | ||
1748 | 833 | def check_args_of_option(self, opt, nargs, err=None): | ||
1749 | 834 | given_opts = getattr(self, "_given_opts", []) | ||
1750 | 835 | if not opt in given_opts: | ||
1751 | 836 | return | ||
1752 | 837 | values = getattr(self, opt, []) | ||
1753 | 838 | if type(values) != type([]): | ||
1754 | 839 | return | ||
1755 | 840 | if nargs < 0: | ||
1756 | 841 | nargs = -nargs | ||
1757 | 842 | if len(values) >= nargs: | ||
1758 | 843 | return | ||
1759 | 844 | if not err: | ||
1760 | 845 | if nargs == 1: | ||
1761 | 846 | err = _("Option '%s' requires at least one argument") % opt | ||
1762 | 847 | else: | ||
1763 | 848 | err = _("Option '%s' requires at least %d arguments") % (opt, nargs) | ||
1764 | 849 | raise Error, err | ||
1765 | 850 | elif nargs == 0: | ||
1766 | 851 | if len( values ) == 0: | ||
1767 | 852 | return | ||
1768 | 853 | raise Error, err | ||
1769 | 854 | else: | ||
1770 | 855 | if len(values) == nargs: | ||
1771 | 856 | return | ||
1772 | 857 | if not err: | ||
1773 | 858 | if nargs == 1: | ||
1774 | 859 | err = _("Option '%s' requires one argument") % opt | ||
1775 | 860 | else: | ||
1776 | 861 | err = _("Option '%s' requires %d arguments") % (opt, nargs) | ||
1777 | 862 | raise Error, err | ||
1778 | 863 | |||
1779 | 864 | # Check that at least one of the options in 'actlist' was given as an argument | ||
1780 | 865 | # to the command 'cmdname' | ||
1781 | 866 | def ensure_action(self, cmdname, actlist): | ||
1782 | 867 | given_opts = getattr(self, "_given_opts", []) | ||
1783 | 868 | for action in actlist: | ||
1784 | 869 | if action in given_opts: | ||
1785 | 870 | return | ||
1786 | 871 | raise Error, _("No action specified for command '%s'") % cmdname | ||
1787 | 872 | |||
1788 | 873 | # Check if there are any other arguments left after parsing the command line and | ||
1789 | 874 | # raise an error if such arguments are found | ||
1790 | 875 | def check_remaining_args(self): | ||
1791 | 876 | if self.args: | ||
1792 | 877 | raise Error, _("Invalid argument(s) '%s'" % str(self.args)) | ||
1793 | 822 | 878 | ||
1794 | 823 | class OptionContainer: | 879 | class OptionContainer: |
1795 | 824 | 880 |