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