cacheset.cc 21 KB

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