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