cacheset.cc 21 KB

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