update changelog for upload
[ntk/apt.git] / apt-pkg / cacheset.cc
CommitLineData
ffee1c2b
DK
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Simple wrapper around a std::set to provide a similar interface to
7959c5ed
DK
6 a set of cache structures as to the complete set of all structures
7 in the pkgCache. Currently only Package is supported.
ffee1c2b
DK
8
9 ##################################################################### */
10 /*}}}*/
11// Include Files /*{{{*/
ea542140
DK
12#include <config.h>
13
78c32596 14#include <apt-pkg/aptconfiguration.h>
472ff00e 15#include <apt-pkg/cachefile.h>
9ba5aa3b 16#include <apt-pkg/cachefilter.h>
8fde7239 17#include <apt-pkg/cacheset.h>
ffee1c2b 18#include <apt-pkg/error.h>
ffee1c2b 19#include <apt-pkg/strutl.h>
856d3b06 20#include <apt-pkg/versionmatch.h>
472ff00e
DK
21#include <apt-pkg/pkgrecords.h>
22#include <apt-pkg/policy.h>
ffee1c2b 23
78c32596
DK
24#include <vector>
25
ffee1c2b 26#include <regex.h>
ea542140
DK
27
28#include <apti18n.h>
ffee1c2b
DK
29 /*}}}*/
30namespace APT {
dc0f01f7 31// FromTask - Return all packages in the cache from a specific task /*{{{*/
15fc8636 32bool PackageContainerInterface::FromTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) {
bd631595 33 size_t const archfound = pattern.find_last_of(':');
dc0f01f7
DK
34 std::string arch = "native";
35 if (archfound != std::string::npos) {
36 arch = pattern.substr(archfound+1);
37 pattern.erase(archfound);
38 }
39
40 if (pattern[pattern.length() -1] != '^')
15fc8636 41 return false;
dc0f01f7
DK
42 pattern.erase(pattern.length()-1);
43
bd631595 44 if (unlikely(Cache.GetPkgCache() == 0 || Cache.GetDepCache() == 0))
15fc8636
DK
45 return false;
46
47 bool const wasEmpty = pci->empty();
48 if (wasEmpty == true)
49 pci->setConstructor(TASK);
bd631595 50
dc0f01f7
DK
51 // get the records
52 pkgRecords Recs(Cache);
53
54 // build regexp for the task
55 regex_t Pattern;
56 char S[300];
57 snprintf(S, sizeof(S), "^Task:.*[, ]%s([, ]|$)", pattern.c_str());
58 if(regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE) != 0) {
59 _error->Error("Failed to compile task regexp");
15fc8636 60 return false;
dc0f01f7
DK
61 }
62
15fc8636 63 bool found = false;
dc0f01f7
DK
64 for (pkgCache::GrpIterator Grp = Cache->GrpBegin(); Grp.end() == false; ++Grp) {
65 pkgCache::PkgIterator Pkg = Grp.FindPkg(arch);
66 if (Pkg.end() == true)
67 continue;
68 pkgCache::VerIterator ver = Cache[Pkg].CandidateVerIter(Cache);
69 if(ver.end() == true)
70 continue;
71
72 pkgRecords::Parser &parser = Recs.Lookup(ver.FileList());
73 const char *start, *end;
74 parser.GetRec(start,end);
75 unsigned int const length = end - start;
76 char buf[length];
77 strncpy(buf, start, length);
78 buf[length-1] = '\0';
70e706ad
DK
79 if (regexec(&Pattern, buf, 0, 0, 0) != 0)
80 continue;
81
15fc8636
DK
82 pci->insert(Pkg);
83 helper.showTaskSelection(Pkg, pattern);
84 found = true;
dc0f01f7 85 }
70e706ad 86 regfree(&Pattern);
dc0f01f7 87
15fc8636
DK
88 if (found == false) {
89 helper.canNotFindTask(pci, Cache, pattern);
90 pci->setConstructor(UNKNOWN);
91 return false;
92 }
93
94 if (wasEmpty == false && pci->getConstructor() != UNKNOWN)
95 pci->setConstructor(UNKNOWN);
dc0f01f7 96
15fc8636 97 return true;
dc0f01f7
DK
98}
99 /*}}}*/
ffee1c2b 100// FromRegEx - Return all packages in the cache matching a pattern /*{{{*/
15fc8636 101bool PackageContainerInterface::FromRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) {
6e235c66 102 static const char * const isregex = ".?+*|[^$";
6e235c66 103 if (pattern.find_first_of(isregex) == std::string::npos)
15fc8636
DK
104 return false;
105
106 bool const wasEmpty = pci->empty();
107 if (wasEmpty == true)
108 pci->setConstructor(REGEX);
ffee1c2b 109
6e235c66 110 size_t archfound = pattern.find_last_of(':');
dc0f01f7 111 std::string arch = "native";
6e235c66
DK
112 if (archfound != std::string::npos) {
113 arch = pattern.substr(archfound+1);
114 if (arch.find_first_of(isregex) == std::string::npos)
115 pattern.erase(archfound);
116 else
117 arch = "native";
118 }
119
bd631595 120 if (unlikely(Cache.GetPkgCache() == 0))
15fc8636 121 return false;
bd631595 122
9ba5aa3b
DK
123 APT::CacheFilter::PackageNameMatchesRegEx regexfilter(pattern);
124
15fc8636 125 bool found = false;
9ba5aa3b
DK
126 for (pkgCache::GrpIterator Grp = Cache.GetPkgCache()->GrpBegin(); Grp.end() == false; ++Grp) {
127 if (regexfilter(Grp) == false)
ffee1c2b 128 continue;
6e235c66 129 pkgCache::PkgIterator Pkg = Grp.FindPkg(arch);
78c32596 130 if (Pkg.end() == true) {
6e235c66
DK
131 if (archfound == std::string::npos) {
132 std::vector<std::string> archs = APT::Configuration::getArchitectures();
133 for (std::vector<std::string>::const_iterator a = archs.begin();
134 a != archs.end() && Pkg.end() != true; ++a)
135 Pkg = Grp.FindPkg(*a);
78c32596
DK
136 }
137 if (Pkg.end() == true)
138 continue;
139 }
ffee1c2b 140
15fc8636
DK
141 pci->insert(Pkg);
142 helper.showRegExSelection(Pkg, pattern);
143 found = true;
ffee1c2b 144 }
ffee1c2b 145
15fc8636
DK
146 if (found == false) {
147 helper.canNotFindRegEx(pci, Cache, pattern);
148 pci->setConstructor(UNKNOWN);
149 return false;
150 }
151
152 if (wasEmpty == false && pci->getConstructor() != UNKNOWN)
153 pci->setConstructor(UNKNOWN);
70e706ad 154
15fc8636 155 return true;
78c32596
DK
156}
157 /*}}}*/
bd631595 158// FromName - Returns the package defined by this string /*{{{*/
15fc8636 159pkgCache::PkgIterator PackageContainerInterface::FromName(pkgCacheFile &Cache,
bd631595
DK
160 std::string const &str, CacheSetHelper &helper) {
161 std::string pkg = str;
162 size_t archfound = pkg.find_last_of(':');
163 std::string arch;
164 if (archfound != std::string::npos) {
165 arch = pkg.substr(archfound+1);
166 pkg.erase(archfound);
167 }
168
169 if (Cache.GetPkgCache() == 0)
170 return pkgCache::PkgIterator(Cache, 0);
171
172 pkgCache::PkgIterator Pkg(Cache, 0);
173 if (arch.empty() == true) {
174 pkgCache::GrpIterator Grp = Cache.GetPkgCache()->FindGrp(pkg);
175 if (Grp.end() == false)
176 Pkg = Grp.FindPreferredPkg();
177 } else
178 Pkg = Cache.GetPkgCache()->FindPkg(pkg, arch);
179
180 if (Pkg.end() == true)
181 return helper.canNotFindPkgName(Cache, str);
182 return Pkg;
183}
184 /*}}}*/
2f0d4029
DK
185// FromGroup - Returns the package defined by this string /*{{{*/
186bool PackageContainerInterface::FromGroup(PackageContainerInterface * const pci, pkgCacheFile &Cache,
187 std::string pkg, CacheSetHelper &helper) {
188 if (unlikely(Cache.GetPkgCache() == 0))
189 return false;
190
191 size_t const archfound = pkg.find_last_of(':');
192 std::string arch;
193 if (archfound != std::string::npos) {
194 arch = pkg.substr(archfound+1);
195 pkg.erase(archfound);
f1d86c0e
DK
196 if (arch == "all" || arch == "native")
197 arch = _config->Find("APT::Architecture");
2f0d4029
DK
198 }
199
200 pkgCache::GrpIterator Grp = Cache.GetPkgCache()->FindGrp(pkg);
201 if (Grp.end() == false) {
202 if (arch.empty() == true) {
203 pkgCache::PkgIterator Pkg = Grp.FindPreferredPkg();
204 if (Pkg.end() == false)
205 {
206 pci->insert(Pkg);
207 return true;
208 }
209 } else {
210 bool found = false;
211 // for 'linux-any' return the first package matching, for 'linux-*' return all matches
212 bool const isGlobal = arch.find('*') != std::string::npos;
213 APT::CacheFilter::PackageArchitectureMatchesSpecification pams(arch);
214 for (pkgCache::PkgIterator Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg)) {
215 if (pams(Pkg) == false)
216 continue;
217 pci->insert(Pkg);
218 found = true;
219 if (isGlobal == false)
220 break;
221 }
222 if (found == true)
223 return true;
224 }
225 }
226
227 pkgCache::PkgIterator Pkg = helper.canNotFindPkgName(Cache, pkg);
228 if (Pkg.end() == true)
229 return false;
230
231 pci->insert(Pkg);
232 return true;
233}
234 /*}}}*/
856d3b06 235// FromString - Return all packages matching a specific string /*{{{*/
15fc8636
DK
236bool PackageContainerInterface::FromString(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str, CacheSetHelper &helper) {
237 bool found = true;
48c39e32
DK
238 _error->PushToStack();
239
2f0d4029
DK
240 if (FromGroup(pci, Cache, str, helper) == false &&
241 FromTask(pci, Cache, str, helper) == false &&
15fc8636
DK
242 FromRegEx(pci, Cache, str, helper) == false)
243 {
244 helper.canNotFindPackage(pci, Cache, str);
245 found = false;
48c39e32 246 }
dc0f01f7 247
15fc8636 248 if (found == true)
48c39e32
DK
249 _error->RevertToStack();
250 else
251 _error->MergeWithStack();
15fc8636 252 return found;
856d3b06
DK
253}
254 /*}}}*/
15fc8636
DK
255// FromCommandLine - Return all packages specified on commandline /*{{{*/
256bool PackageContainerInterface::FromCommandLine(PackageContainerInterface * const pci, pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper) {
257 bool found = false;
258 for (const char **I = cmdline; *I != 0; ++I)
259 found |= PackageContainerInterface::FromString(pci, Cache, *I, helper);
260 return found;
261}
262 /*}}}*/
263// FromModifierCommandLine - helper doing the work for PKG:GroupedFromCommandLine /*{{{*/
264bool PackageContainerInterface::FromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci,
265 pkgCacheFile &Cache, const char * cmdline,
266 std::list<Modifier> const &mods, CacheSetHelper &helper) {
267 std::string str = cmdline;
e6a12579 268 unsigned short fallback = modID;
15fc8636
DK
269 bool modifierPresent = false;
270 for (std::list<Modifier>::const_iterator mod = mods.begin();
271 mod != mods.end(); ++mod) {
272 size_t const alength = strlen(mod->Alias);
273 switch(mod->Pos) {
274 case Modifier::POSTFIX:
275 if (str.compare(str.length() - alength, alength,
276 mod->Alias, 0, alength) != 0)
55c59998 277 continue;
15fc8636
DK
278 str.erase(str.length() - alength);
279 modID = mod->ID;
55c59998 280 break;
15fc8636
DK
281 case Modifier::PREFIX:
282 continue;
283 case Modifier::NONE:
284 continue;
55c59998 285 }
15fc8636
DK
286 modifierPresent = true;
287 break;
288 }
289 if (modifierPresent == true) {
290 bool const errors = helper.showErrors(false);
291 pkgCache::PkgIterator Pkg = FromName(Cache, cmdline, helper);
292 helper.showErrors(errors);
293 if (Pkg.end() == false) {
294 pci->insert(Pkg);
e6a12579 295 modID = fallback;
15fc8636
DK
296 return true;
297 }
298 }
299 return FromString(pci, Cache, str, helper);
300}
301 /*}}}*/
302// FromModifierCommandLine - helper doing the work for VER:GroupedFromCommandLine /*{{{*/
303bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID,
304 VersionContainerInterface * const vci,
305 pkgCacheFile &Cache, const char * cmdline,
306 std::list<Modifier> const &mods,
307 CacheSetHelper &helper) {
308 Version select = NEWEST;
309 std::string str = cmdline;
310 bool modifierPresent = false;
311 unsigned short fallback = modID;
312 for (std::list<Modifier>::const_iterator mod = mods.begin();
313 mod != mods.end(); ++mod) {
314 if (modID == fallback && mod->ID == fallback)
315 select = mod->SelectVersion;
316 size_t const alength = strlen(mod->Alias);
317 switch(mod->Pos) {
318 case Modifier::POSTFIX:
319 if (str.compare(str.length() - alength, alength,
320 mod->Alias, 0, alength) != 0)
bd631595 321 continue;
15fc8636
DK
322 str.erase(str.length() - alength);
323 modID = mod->ID;
324 select = mod->SelectVersion;
325 break;
326 case Modifier::PREFIX:
327 continue;
328 case Modifier::NONE:
329 continue;
bd631595 330 }
15fc8636
DK
331 modifierPresent = true;
332 break;
55c59998 333 }
15fc8636
DK
334 if (modifierPresent == true) {
335 bool const errors = helper.showErrors(false);
336 bool const found = VersionContainerInterface::FromString(vci, Cache, cmdline, select, helper, true);
337 helper.showErrors(errors);
e6a12579
DK
338 if (found == true) {
339 modID = fallback;
15fc8636 340 return true;
e6a12579 341 }
15fc8636
DK
342 }
343 return FromString(vci, Cache, str, select, helper);
55c59998
DK
344}
345 /*}}}*/
856d3b06 346// FromCommandLine - Return all versions specified on commandline /*{{{*/
15fc8636
DK
347bool VersionContainerInterface::FromCommandLine(VersionContainerInterface * const vci,
348 pkgCacheFile &Cache, const char **cmdline,
349 Version const &fallback, CacheSetHelper &helper) {
350 bool found = false;
bd631595 351 for (const char **I = cmdline; *I != 0; ++I)
15fc8636
DK
352 found |= VersionContainerInterface::FromString(vci, Cache, *I, fallback, helper);
353 return found;
55c59998
DK
354}
355 /*}}}*/
356// FromString - Returns all versions spedcified by a string /*{{{*/
15fc8636
DK
357bool VersionContainerInterface::FromString(VersionContainerInterface * const vci,
358 pkgCacheFile &Cache, std::string pkg,
359 Version const &fallback, CacheSetHelper &helper,
360 bool const onlyFromName) {
55c59998
DK
361 std::string ver;
362 bool verIsRel = false;
363 size_t const vertag = pkg.find_last_of("/=");
472ff00e 364 if (vertag != std::string::npos) {
55c59998
DK
365 ver = pkg.substr(vertag+1);
366 verIsRel = (pkg[vertag] == '/');
367 pkg.erase(vertag);
368 }
bd631595
DK
369 PackageSet pkgset;
370 if (onlyFromName == false)
15fc8636 371 PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
bd631595 372 else {
15fc8636 373 pkgset.insert(PackageContainerInterface::FromName(Cache, pkg, helper));
bd631595
DK
374 }
375
c8db3fff
DK
376 bool errors = true;
377 if (pkgset.getConstructor() != PackageSet::UNKNOWN)
378 errors = helper.showErrors(false);
15fc8636
DK
379
380 bool found = false;
55c59998
DK
381 for (PackageSet::const_iterator P = pkgset.begin();
382 P != pkgset.end(); ++P) {
472ff00e 383 if (vertag == std::string::npos) {
15fc8636 384 found |= VersionContainerInterface::FromPackage(vci, Cache, P, fallback, helper);
55c59998 385 continue;
856d3b06 386 }
55c59998
DK
387 pkgCache::VerIterator V;
388 if (ver == "installed")
70e706ad 389 V = getInstalledVer(Cache, P, helper);
55c59998 390 else if (ver == "candidate")
70e706ad 391 V = getCandidateVer(Cache, P, helper);
f1a58ff8
DK
392 else if (ver == "newest") {
393 if (P->VersionList != 0)
394 V = P.VersionList();
395 else
396 V = helper.canNotFindNewestVer(Cache, P);
397 } else {
55c59998
DK
398 pkgVersionMatch Match(ver, (verIsRel == true ? pkgVersionMatch::Release :
399 pkgVersionMatch::Version));
400 V = Match.Find(P);
401 if (V.end() == true) {
402 if (verIsRel == true)
403 _error->Error(_("Release '%s' for '%s' was not found"),
404 ver.c_str(), P.FullName(true).c_str());
405 else
406 _error->Error(_("Version '%s' for '%s' was not found"),
407 ver.c_str(), P.FullName(true).c_str());
84910ad5
DK
408 continue;
409 }
78c32596 410 }
55c59998
DK
411 if (V.end() == true)
412 continue;
70e706ad 413 helper.showSelectedVersion(P, V, ver, verIsRel);
15fc8636
DK
414 vci->insert(V);
415 found = true;
78c32596 416 }
c8db3fff
DK
417 if (pkgset.getConstructor() != PackageSet::UNKNOWN)
418 helper.showErrors(errors);
15fc8636 419 return found;
856d3b06
DK
420}
421 /*}}}*/
fb83c1d0 422// FromPackage - versions from package based on fallback /*{{{*/
15fc8636
DK
423bool VersionContainerInterface::FromPackage(VersionContainerInterface * const vci,
424 pkgCacheFile &Cache,
425 pkgCache::PkgIterator const &P,
426 Version const &fallback,
427 CacheSetHelper &helper) {
84910ad5 428 pkgCache::VerIterator V;
70e706ad 429 bool showErrors;
15fc8636 430 bool found = false;
84910ad5 431 switch(fallback) {
15fc8636 432 case ALL:
84910ad5
DK
433 if (P->VersionList != 0)
434 for (V = P.VersionList(); V.end() != true; ++V)
15fc8636 435 found |= vci->insert(V);
84910ad5 436 else
15fc8636 437 helper.canNotFindAllVer(vci, Cache, P);
84910ad5 438 break;
15fc8636
DK
439 case CANDANDINST:
440 found |= vci->insert(getInstalledVer(Cache, P, helper));
441 found |= vci->insert(getCandidateVer(Cache, P, helper));
84910ad5 442 break;
15fc8636
DK
443 case CANDIDATE:
444 found |= vci->insert(getCandidateVer(Cache, P, helper));
84910ad5 445 break;
15fc8636
DK
446 case INSTALLED:
447 found |= vci->insert(getInstalledVer(Cache, P, helper));
84910ad5 448 break;
15fc8636 449 case CANDINST:
70e706ad
DK
450 showErrors = helper.showErrors(false);
451 V = getCandidateVer(Cache, P, helper);
84910ad5 452 if (V.end() == true)
70e706ad
DK
453 V = getInstalledVer(Cache, P, helper);
454 helper.showErrors(showErrors);
84910ad5 455 if (V.end() == false)
15fc8636 456 found |= vci->insert(V);
84910ad5 457 else
15fc8636 458 helper.canNotFindInstCandVer(vci, Cache, P);
84910ad5 459 break;
15fc8636 460 case INSTCAND:
70e706ad
DK
461 showErrors = helper.showErrors(false);
462 V = getInstalledVer(Cache, P, helper);
84910ad5 463 if (V.end() == true)
70e706ad
DK
464 V = getCandidateVer(Cache, P, helper);
465 helper.showErrors(showErrors);
84910ad5 466 if (V.end() == false)
15fc8636 467 found |= vci->insert(V);
84910ad5 468 else
15fc8636 469 helper.canNotFindInstCandVer(vci, Cache, P);
84910ad5 470 break;
15fc8636 471 case NEWEST:
84910ad5 472 if (P->VersionList != 0)
15fc8636 473 found |= vci->insert(P.VersionList());
84910ad5 474 else
15fc8636 475 helper.canNotFindNewestVer(Cache, P);
84910ad5
DK
476 break;
477 }
15fc8636 478 return found;
84910ad5
DK
479}
480 /*}}}*/
856d3b06 481// getCandidateVer - Returns the candidate version of the given package /*{{{*/
15fc8636 482pkgCache::VerIterator VersionContainerInterface::getCandidateVer(pkgCacheFile &Cache,
70e706ad 483 pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
a8ef7efd 484 pkgCache::VerIterator Cand;
15fc8636 485 if (Cache.IsPolicyBuilt() == true || Cache.IsDepCacheBuilt() == false) {
bd631595
DK
486 if (unlikely(Cache.GetPolicy() == 0))
487 return pkgCache::VerIterator(Cache);
a8ef7efd 488 Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
2fbfb111
DK
489 } else {
490 Cand = Cache[Pkg].CandidateVerIter(Cache);
a8ef7efd 491 }
70e706ad
DK
492 if (Cand.end() == true)
493 return helper.canNotFindCandidateVer(Cache, Pkg);
856d3b06
DK
494 return Cand;
495}
496 /*}}}*/
497// getInstalledVer - Returns the installed version of the given package /*{{{*/
15fc8636 498pkgCache::VerIterator VersionContainerInterface::getInstalledVer(pkgCacheFile &Cache,
70e706ad
DK
499 pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
500 if (Pkg->CurrentVer == 0)
501 return helper.canNotFindInstalledVer(Cache, Pkg);
856d3b06 502 return Pkg.CurrentVer();
ffee1c2b
DK
503}
504 /*}}}*/
15fc8636 505
bd631595
DK
506// canNotFindPkgName - handle the case no package has this name /*{{{*/
507pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache,
508 std::string const &str) {
509 if (ShowError == true)
cd7bbc47 510 _error->Insert(ErrorType, _("Unable to locate package %s"), str.c_str());
bd631595
DK
511 return pkgCache::PkgIterator(Cache, 0);
512}
513 /*}}}*/
70e706ad 514// canNotFindTask - handle the case no package is found for a task /*{{{*/
15fc8636 515void CacheSetHelper::canNotFindTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
70e706ad 516 if (ShowError == true)
cd7bbc47 517 _error->Insert(ErrorType, _("Couldn't find task '%s'"), pattern.c_str());
70e706ad
DK
518}
519 /*}}}*/
520// canNotFindRegEx - handle the case no package is found by a regex /*{{{*/
15fc8636 521void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
70e706ad 522 if (ShowError == true)
cd7bbc47 523 _error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str());
70e706ad
DK
524}
525 /*}}}*/
526// canNotFindPackage - handle the case no package is found from a string/*{{{*/
15fc8636 527void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str) {
70e706ad
DK
528}
529 /*}}}*/
530// canNotFindAllVer /*{{{*/
15fc8636 531void CacheSetHelper::canNotFindAllVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
70e706ad
DK
532 pkgCache::PkgIterator const &Pkg) {
533 if (ShowError == true)
edc0ef10 534 _error->Insert(ErrorType, _("Can't select versions from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str());
70e706ad
DK
535}
536 /*}}}*/
537// canNotFindInstCandVer /*{{{*/
15fc8636 538void CacheSetHelper::canNotFindInstCandVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
70e706ad
DK
539 pkgCache::PkgIterator const &Pkg) {
540 if (ShowError == true)
cd7bbc47 541 _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
70e706ad
DK
542}
543 /*}}}*/
cf28bcad 544// canNotFindInstCandVer /*{{{*/
15fc8636 545void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
cf28bcad
DK
546 pkgCache::PkgIterator const &Pkg) {
547 if (ShowError == true)
cd7bbc47 548 _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
cf28bcad
DK
549}
550 /*}}}*/
70e706ad
DK
551// canNotFindNewestVer /*{{{*/
552pkgCache::VerIterator CacheSetHelper::canNotFindNewestVer(pkgCacheFile &Cache,
553 pkgCache::PkgIterator const &Pkg) {
554 if (ShowError == true)
cd7bbc47 555 _error->Insert(ErrorType, _("Can't select newest version from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str());
c8db3fff 556 return pkgCache::VerIterator(Cache, 0);
70e706ad
DK
557}
558 /*}}}*/
559// canNotFindCandidateVer /*{{{*/
560pkgCache::VerIterator CacheSetHelper::canNotFindCandidateVer(pkgCacheFile &Cache,
561 pkgCache::PkgIterator const &Pkg) {
562 if (ShowError == true)
cd7bbc47 563 _error->Insert(ErrorType, _("Can't select candidate version from package %s as it has no candidate"), Pkg.FullName(true).c_str());
c8db3fff 564 return pkgCache::VerIterator(Cache, 0);
70e706ad
DK
565}
566 /*}}}*/
567// canNotFindInstalledVer /*{{{*/
568pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache,
569 pkgCache::PkgIterator const &Pkg) {
570 if (ShowError == true)
cd7bbc47 571 _error->Insert(ErrorType, _("Can't select installed version from package %s as it is not installed"), Pkg.FullName(true).c_str());
c8db3fff 572 return pkgCache::VerIterator(Cache, 0);
70e706ad
DK
573}
574 /*}}}*/
15fc8636
DK
575// showTaskSelection /*{{{*/
576void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &pkg,
577 std::string const &pattern) {
578}
579 /*}}}*/
580// showRegExSelection /*{{{*/
581void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &pkg,
582 std::string const &pattern) {
583}
584 /*}}}*/
585// showSelectedVersion /*{{{*/
586void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &Pkg,
587 pkgCache::VerIterator const Ver,
588 std::string const &ver,
589 bool const verIsRel) {
590}
591 /*}}}*/
ffee1c2b 592}