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