apt-get.cc 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: apt-get.cc,v 1.156 2004/08/28 01:05:16 mdz Exp $
  4. /* ######################################################################
  5. apt-get - Cover for dpkg
  6. This is an allout cover for dpkg implementing a safer front end. It is
  7. based largely on libapt-pkg.
  8. The syntax is different,
  9. apt-get [opt] command [things]
  10. Where command is:
  11. update - Resyncronize the package files from their sources
  12. upgrade - Smart-Download the newest versions of all packages
  13. dselect-upgrade - Follows dselect's changes to the Status: field
  14. and installes new and removes old packages
  15. dist-upgrade - Powerful upgrader designed to handle the issues with
  16. a new distribution.
  17. install - Download and install a given package (by name, not by .deb)
  18. check - Update the package cache and check for broken packages
  19. clean - Erase the .debs downloaded to /var/cache/apt/archives and
  20. the partial dir too
  21. ##################################################################### */
  22. /*}}}*/
  23. // Include Files /*{{{*/
  24. #include <config.h>
  25. #include <apt-pkg/acquire-item.h>
  26. #include <apt-pkg/algorithms.h>
  27. #include <apt-pkg/aptconfiguration.h>
  28. #include <apt-pkg/cachefile.h>
  29. #include <apt-pkg/cacheset.h>
  30. #include <apt-pkg/clean.h>
  31. #include <apt-pkg/cmndline.h>
  32. #include <apt-pkg/debmetaindex.h>
  33. #include <apt-pkg/depcache.h>
  34. #include <apt-pkg/error.h>
  35. #include <apt-pkg/fileutl.h>
  36. #include <apt-pkg/indexfile.h>
  37. #include <apt-pkg/init.h>
  38. #include <apt-pkg/md5.h>
  39. #include <apt-pkg/metaindex.h>
  40. #include <apt-pkg/pkgrecords.h>
  41. #include <apt-pkg/pkgsystem.h>
  42. #include <apt-pkg/progress.h>
  43. #include <apt-pkg/sourcelist.h>
  44. #include <apt-pkg/srcrecords.h>
  45. #include <apt-pkg/strutl.h>
  46. #include <apt-pkg/version.h>
  47. #include <apt-pkg/acquire.h>
  48. #include <apt-pkg/configuration.h>
  49. #include <apt-pkg/macros.h>
  50. #include <apt-pkg/pkgcache.h>
  51. #include <apt-pkg/cacheiterators.h>
  52. #include <apt-pkg/upgrade.h>
  53. #include <apt-pkg/sptr.h>
  54. #include <apt-private/acqprogress.h>
  55. #include <apt-private/private-cacheset.h>
  56. #include <apt-private/private-cachefile.h>
  57. #include <apt-private/private-cmndline.h>
  58. #include <apt-private/private-download.h>
  59. #include <apt-private/private-install.h>
  60. #include <apt-private/private-main.h>
  61. #include <apt-private/private-moo.h>
  62. #include <apt-private/private-output.h>
  63. #include <apt-private/private-update.h>
  64. #include <apt-private/private-upgrade.h>
  65. #include <apt-private/private-utils.h>
  66. #include <errno.h>
  67. #include <signal.h>
  68. #include <stddef.h>
  69. #include <stdio.h>
  70. #include <stdlib.h>
  71. #include <string.h>
  72. #include <sys/ioctl.h>
  73. #include <sys/stat.h>
  74. #include <sys/wait.h>
  75. #include <unistd.h>
  76. #include <pwd.h>
  77. #include <grp.h>
  78. #include <algorithm>
  79. #include <fstream>
  80. #include <iostream>
  81. #include <sstream>
  82. #include <set>
  83. #include <string>
  84. #include <vector>
  85. #include <apti18n.h>
  86. /*}}}*/
  87. using namespace std;
  88. // TryToInstallBuildDep - Try to install a single package /*{{{*/
  89. // ---------------------------------------------------------------------
  90. /* This used to be inlined in DoInstall, but with the advent of regex package
  91. name matching it was split out.. */
  92. static bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache,
  93. pkgProblemResolver &Fix,bool Remove,bool BrokenFix,
  94. bool AllowFail = true)
  95. {
  96. if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0)
  97. {
  98. CacheSetHelperAPTGet helper(c1out);
  99. helper.showErrors(false);
  100. pkgCache::VerIterator Ver = helper.canNotFindNewestVer(Cache, Pkg);
  101. if (Ver.end() == false)
  102. Pkg = Ver.ParentPkg();
  103. else if (helper.showVirtualPackageErrors(Cache) == false)
  104. return AllowFail;
  105. }
  106. if (_config->FindB("Debug::BuildDeps",false) == true)
  107. {
  108. if (Remove == true)
  109. cout << " Trying to remove " << Pkg << endl;
  110. else
  111. cout << " Trying to install " << Pkg << endl;
  112. }
  113. if (Remove == true)
  114. {
  115. TryToRemove RemoveAction(Cache, &Fix);
  116. RemoveAction(Pkg.VersionList());
  117. } else if (Cache[Pkg].CandidateVer != 0) {
  118. TryToInstall InstallAction(Cache, &Fix, BrokenFix);
  119. InstallAction(Cache[Pkg].CandidateVerIter(Cache));
  120. InstallAction.doAutoInstall();
  121. } else
  122. return AllowFail;
  123. return true;
  124. }
  125. /*}}}*/
  126. // GetReleaseFileForSourceRecord - Return Suite for the given srcrecord /*{{{*/
  127. static pkgCache::RlsFileIterator GetReleaseFileForSourceRecord(CacheFile &CacheFile,
  128. pkgSourceList *SrcList, pkgSrcRecords::Parser *Parse)
  129. {
  130. // try to find release
  131. const pkgIndexFile& CurrentIndexFile = Parse->Index();
  132. for (pkgSourceList::const_iterator S = SrcList->begin();
  133. S != SrcList->end(); ++S)
  134. {
  135. vector<pkgIndexFile *> *Indexes = (*S)->GetIndexFiles();
  136. for (vector<pkgIndexFile *>::const_iterator IF = Indexes->begin();
  137. IF != Indexes->end(); ++IF)
  138. {
  139. if (&CurrentIndexFile == (*IF))
  140. return (*S)->FindInCache(CacheFile, false);
  141. }
  142. }
  143. return pkgCache::RlsFileIterator(CacheFile);
  144. }
  145. /*}}}*/
  146. // FindSrc - Find a source record /*{{{*/
  147. // ---------------------------------------------------------------------
  148. /* */
  149. static pkgSrcRecords::Parser *FindSrc(const char *Name,
  150. pkgSrcRecords &SrcRecs,string &Src,
  151. CacheFile &CacheFile)
  152. {
  153. string VerTag, UserRequestedVerTag;
  154. string ArchTag = "";
  155. string RelTag = _config->Find("APT::Default-Release");
  156. string TmpSrc = Name;
  157. pkgDepCache *Cache = CacheFile.GetDepCache();
  158. // extract release
  159. size_t found = TmpSrc.find_last_of("/");
  160. if (found != string::npos)
  161. {
  162. RelTag = TmpSrc.substr(found+1);
  163. TmpSrc = TmpSrc.substr(0,found);
  164. }
  165. // extract the version
  166. found = TmpSrc.find_last_of("=");
  167. if (found != string::npos)
  168. {
  169. VerTag = UserRequestedVerTag = TmpSrc.substr(found+1);
  170. TmpSrc = TmpSrc.substr(0,found);
  171. }
  172. // extract arch
  173. found = TmpSrc.find_last_of(":");
  174. if (found != string::npos)
  175. {
  176. ArchTag = TmpSrc.substr(found+1);
  177. TmpSrc = TmpSrc.substr(0,found);
  178. }
  179. /* Lookup the version of the package we would install if we were to
  180. install a version and determine the source package name, then look
  181. in the archive for a source package of the same name. */
  182. bool MatchSrcOnly = _config->FindB("APT::Get::Only-Source");
  183. pkgCache::PkgIterator Pkg;
  184. if (ArchTag != "")
  185. Pkg = Cache->FindPkg(TmpSrc, ArchTag);
  186. else
  187. Pkg = Cache->FindPkg(TmpSrc);
  188. // if we can't find a package but the user qualified with a arch,
  189. // error out here
  190. if (Pkg.end() && ArchTag != "")
  191. {
  192. Src = Name;
  193. _error->Error(_("Can not find a package for architecture '%s'"),
  194. ArchTag.c_str());
  195. return 0;
  196. }
  197. if (MatchSrcOnly == false && Pkg.end() == false)
  198. {
  199. if(VerTag != "" || RelTag != "" || ArchTag != "")
  200. {
  201. bool fuzzy = false;
  202. // we have a default release, try to locate the pkg. we do it like
  203. // this because GetCandidateVer() will not "downgrade", that means
  204. // "apt-get source -t stable apt" won't work on a unstable system
  205. for (pkgCache::VerIterator Ver = Pkg.VersionList();; ++Ver)
  206. {
  207. // try first only exact matches, later fuzzy matches
  208. if (Ver.end() == true)
  209. {
  210. if (fuzzy == true)
  211. break;
  212. fuzzy = true;
  213. Ver = Pkg.VersionList();
  214. // exit right away from the Pkg.VersionList() loop if we
  215. // don't have any versions
  216. if (Ver.end() == true)
  217. break;
  218. }
  219. // ignore arches that are not for us
  220. if (ArchTag != "" && Ver.Arch() != ArchTag)
  221. continue;
  222. // pick highest version for the arch unless the user wants
  223. // something else
  224. if (ArchTag != "" && VerTag == "" && RelTag == "")
  225. if(Cache->VS().CmpVersion(VerTag, Ver.VerStr()) < 0)
  226. VerTag = Ver.VerStr();
  227. // We match against a concrete version (or a part of this version)
  228. if (VerTag.empty() == false &&
  229. (fuzzy == true || Cache->VS().CmpVersion(VerTag, Ver.VerStr()) != 0) && // exact match
  230. (fuzzy == false || strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0)) // fuzzy match
  231. continue;
  232. for (pkgCache::VerFileIterator VF = Ver.FileList();
  233. VF.end() == false; ++VF)
  234. {
  235. /* If this is the status file, and the current version is not the
  236. version in the status file (ie it is not installed, or somesuch)
  237. then it is not a candidate for installation, ever. This weeds
  238. out bogus entries that may be due to config-file states, or
  239. other. */
  240. if ((VF.File()->Flags & pkgCache::Flag::NotSource) ==
  241. pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver)
  242. continue;
  243. // or we match against a release
  244. if(VerTag.empty() == false ||
  245. (VF.File().Archive() != 0 && VF.File().Archive() == RelTag) ||
  246. (VF.File().Codename() != 0 && VF.File().Codename() == RelTag))
  247. {
  248. // the Version we have is possibly fuzzy or includes binUploads,
  249. // so we use the Version of the SourcePkg (empty if same as package)
  250. Src = Ver.SourcePkgName();
  251. VerTag = Ver.SourceVerStr();
  252. break;
  253. }
  254. }
  255. if (Src.empty() == false)
  256. break;
  257. }
  258. }
  259. if (Src == "" && ArchTag != "")
  260. {
  261. if (VerTag != "")
  262. _error->Error(_("Can not find a package '%s' with version '%s'"),
  263. Pkg.FullName().c_str(), VerTag.c_str());
  264. if (RelTag != "")
  265. _error->Error(_("Can not find a package '%s' with release '%s'"),
  266. Pkg.FullName().c_str(), RelTag.c_str());
  267. Src = Name;
  268. return 0;
  269. }
  270. if (Src.empty() == true)
  271. {
  272. // if we don't have found a fitting package yet so we will
  273. // choose a good candidate and proceed with that.
  274. // Maybe we will find a source later on with the right VerTag
  275. // or RelTag
  276. pkgCache::VerIterator Ver = Cache->GetCandidateVer(Pkg);
  277. if (Ver.end() == false)
  278. {
  279. if (strcmp(Ver.SourcePkgName(),Ver.ParentPkg().Name()) != 0)
  280. Src = Ver.SourcePkgName();
  281. if (VerTag.empty() == true && strcmp(Ver.SourceVerStr(),Ver.VerStr()) != 0)
  282. VerTag = Ver.SourceVerStr();
  283. }
  284. }
  285. }
  286. if (Src.empty() == true)
  287. {
  288. Src = TmpSrc;
  289. }
  290. else
  291. {
  292. /* if we have a source pkg name, make sure to only search
  293. for srcpkg names, otherwise apt gets confused if there
  294. is a binary package "pkg1" and a source package "pkg1"
  295. with the same name but that comes from different packages */
  296. MatchSrcOnly = true;
  297. if (Src != TmpSrc)
  298. {
  299. ioprintf(c1out, _("Picking '%s' as source package instead of '%s'\n"), Src.c_str(), TmpSrc.c_str());
  300. }
  301. }
  302. // The best hit
  303. pkgSrcRecords::Parser *Last = 0;
  304. unsigned long Offset = 0;
  305. string Version;
  306. pkgSourceList *SrcList = CacheFile.GetSourceList();
  307. /* Iterate over all of the hits, which includes the resulting
  308. binary packages in the search */
  309. pkgSrcRecords::Parser *Parse;
  310. while (true)
  311. {
  312. SrcRecs.Restart();
  313. while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0)
  314. {
  315. const string Ver = Parse->Version();
  316. // See if we need to look for a specific release tag
  317. if (RelTag != "" && UserRequestedVerTag == "")
  318. {
  319. pkgCache::RlsFileIterator const Rls = GetReleaseFileForSourceRecord(CacheFile, SrcList, Parse);
  320. if (Rls.end() == false)
  321. {
  322. if ((Rls->Archive != 0 && RelTag == Rls.Archive()) ||
  323. (Rls->Codename != 0 && RelTag == Rls.Codename()))
  324. {
  325. Last = Parse;
  326. Offset = Parse->Offset();
  327. Version = Ver;
  328. }
  329. }
  330. }
  331. // Ignore all versions which doesn't fit
  332. if (VerTag.empty() == false &&
  333. Cache->VS().CmpVersion(VerTag, Ver) != 0) // exact match
  334. continue;
  335. // Newer version or an exact match? Save the hit
  336. if (Last == 0 || Cache->VS().CmpVersion(Version,Ver) < 0) {
  337. Last = Parse;
  338. Offset = Parse->Offset();
  339. Version = Ver;
  340. }
  341. // was the version check above an exact match?
  342. // If so, we don't need to look further
  343. if (VerTag.empty() == false && (VerTag == Ver))
  344. break;
  345. }
  346. if (UserRequestedVerTag == "" && Version != "" && RelTag != "")
  347. ioprintf(c1out, "Selected version '%s' (%s) for %s\n",
  348. Version.c_str(), RelTag.c_str(), Src.c_str());
  349. if (Last != 0 || VerTag.empty() == true)
  350. break;
  351. _error->Error(_("Can not find version '%s' of package '%s'"), VerTag.c_str(), TmpSrc.c_str());
  352. return 0;
  353. }
  354. if (Last == 0 || Last->Jump(Offset) == false)
  355. return 0;
  356. return Last;
  357. }
  358. /*}}}*/
  359. /* mark packages as automatically/manually installed. {{{*/
  360. static bool DoMarkAuto(CommandLine &CmdL)
  361. {
  362. bool Action = true;
  363. int AutoMarkChanged = 0;
  364. OpTextProgress progress;
  365. CacheFile Cache;
  366. if (Cache.Open() == false)
  367. return false;
  368. if (strcasecmp(CmdL.FileList[0],"markauto") == 0)
  369. Action = true;
  370. else if (strcasecmp(CmdL.FileList[0],"unmarkauto") == 0)
  371. Action = false;
  372. for (const char **I = CmdL.FileList + 1; *I != 0; I++)
  373. {
  374. const char *S = *I;
  375. // Locate the package
  376. pkgCache::PkgIterator Pkg = Cache->FindPkg(S);
  377. if (Pkg.end() == true) {
  378. return _error->Error(_("Couldn't find package %s"),S);
  379. }
  380. else
  381. {
  382. if (!Action)
  383. ioprintf(c1out,_("%s set to manually installed.\n"), Pkg.Name());
  384. else
  385. ioprintf(c1out,_("%s set to automatically installed.\n"),
  386. Pkg.Name());
  387. Cache->MarkAuto(Pkg,Action);
  388. AutoMarkChanged++;
  389. }
  390. }
  391. _error->Notice(_("This command is deprecated. Please use 'apt-mark auto' and 'apt-mark manual' instead."));
  392. if (AutoMarkChanged && ! _config->FindB("APT::Get::Simulate",false))
  393. return Cache->writeStateFile(NULL);
  394. return false;
  395. }
  396. /*}}}*/
  397. // DoDSelectUpgrade - Do an upgrade by following dselects selections /*{{{*/
  398. // ---------------------------------------------------------------------
  399. /* Follows dselect's selections */
  400. static bool DoDSelectUpgrade(CommandLine &)
  401. {
  402. CacheFile Cache;
  403. if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
  404. return false;
  405. pkgDepCache::ActionGroup group(Cache);
  406. // Install everything with the install flag set
  407. pkgCache::PkgIterator I = Cache->PkgBegin();
  408. for (;I.end() != true; ++I)
  409. {
  410. /* Install the package only if it is a new install, the autoupgrader
  411. will deal with the rest */
  412. if (I->SelectedState == pkgCache::State::Install)
  413. Cache->MarkInstall(I,false);
  414. }
  415. /* Now install their deps too, if we do this above then order of
  416. the status file is significant for | groups */
  417. for (I = Cache->PkgBegin();I.end() != true; ++I)
  418. {
  419. /* Install the package only if it is a new install, the autoupgrader
  420. will deal with the rest */
  421. if (I->SelectedState == pkgCache::State::Install)
  422. Cache->MarkInstall(I,true);
  423. }
  424. // Apply erasures now, they override everything else.
  425. for (I = Cache->PkgBegin();I.end() != true; ++I)
  426. {
  427. // Remove packages
  428. if (I->SelectedState == pkgCache::State::DeInstall ||
  429. I->SelectedState == pkgCache::State::Purge)
  430. Cache->MarkDelete(I,I->SelectedState == pkgCache::State::Purge);
  431. }
  432. /* Resolve any problems that dselect created, allupgrade cannot handle
  433. such things. We do so quite aggressively too.. */
  434. if (Cache->BrokenCount() != 0)
  435. {
  436. pkgProblemResolver Fix(Cache);
  437. // Hold back held packages.
  438. if (_config->FindB("APT::Ignore-Hold",false) == false)
  439. {
  440. for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; ++I)
  441. {
  442. if (I->SelectedState == pkgCache::State::Hold)
  443. {
  444. Fix.Protect(I);
  445. Cache->MarkKeep(I);
  446. }
  447. }
  448. }
  449. if (Fix.Resolve() == false)
  450. {
  451. ShowBroken(c1out,Cache,false);
  452. return _error->Error(_("Internal error, problem resolver broke stuff"));
  453. }
  454. }
  455. // Now upgrade everything
  456. if (APT::Upgrade::Upgrade(Cache, APT::Upgrade::FORBID_REMOVE_PACKAGES | APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES) == false)
  457. {
  458. ShowBroken(c1out,Cache,false);
  459. return _error->Error(_("Internal error, problem resolver broke stuff"));
  460. }
  461. return InstallPackages(Cache,false);
  462. }
  463. /*}}}*/
  464. // DoClean - Remove download archives /*{{{*/
  465. // ---------------------------------------------------------------------
  466. /* */
  467. static bool DoClean(CommandLine &)
  468. {
  469. std::string const archivedir = _config->FindDir("Dir::Cache::archives");
  470. std::string const listsdir = _config->FindDir("Dir::state::lists");
  471. if (_config->FindB("APT::Get::Simulate") == true)
  472. {
  473. std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache");
  474. std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
  475. cout << "Del " << archivedir << "* " << archivedir << "partial/*"<< endl
  476. << "Del " << listsdir << "partial/*" << endl
  477. << "Del " << pkgcache << " " << srcpkgcache << endl;
  478. return true;
  479. }
  480. pkgAcquire Fetcher;
  481. Fetcher.GetLock(archivedir);
  482. Fetcher.Clean(archivedir);
  483. Fetcher.Clean(archivedir + "partial/");
  484. Fetcher.GetLock(listsdir);
  485. Fetcher.Clean(listsdir + "partial/");
  486. pkgCacheFile::RemoveCaches();
  487. return true;
  488. }
  489. /*}}}*/
  490. // DoAutoClean - Smartly remove downloaded archives /*{{{*/
  491. // ---------------------------------------------------------------------
  492. /* This is similar to clean but it only purges things that cannot be
  493. downloaded, that is old versions of cached packages. */
  494. class LogCleaner : public pkgArchiveCleaner
  495. {
  496. protected:
  497. virtual void Erase(const char *File,string Pkg,string Ver,struct stat &St) APT_OVERRIDE
  498. {
  499. c1out << "Del " << Pkg << " " << Ver << " [" << SizeToStr(St.st_size) << "B]" << endl;
  500. if (_config->FindB("APT::Get::Simulate") == false)
  501. unlink(File);
  502. };
  503. };
  504. static bool DoAutoClean(CommandLine &)
  505. {
  506. // Lock the archive directory
  507. FileFd Lock;
  508. if (_config->FindB("Debug::NoLocking",false) == false)
  509. {
  510. int lock_fd = GetLock(_config->FindDir("Dir::Cache::Archives") + "lock");
  511. if (lock_fd < 0)
  512. return _error->Error(_("Unable to lock the download directory"));
  513. Lock.Fd(lock_fd);
  514. }
  515. CacheFile Cache;
  516. if (Cache.Open() == false)
  517. return false;
  518. LogCleaner Cleaner;
  519. return Cleaner.Go(_config->FindDir("Dir::Cache::archives"),*Cache) &&
  520. Cleaner.Go(_config->FindDir("Dir::Cache::archives") + "partial/",*Cache);
  521. }
  522. /*}}}*/
  523. // DoDownload - download a binary /*{{{*/
  524. // ---------------------------------------------------------------------
  525. static bool DoDownload(CommandLine &CmdL)
  526. {
  527. CacheFile Cache;
  528. if (Cache.ReadOnlyOpen() == false)
  529. return false;
  530. APT::CacheSetHelper helper;
  531. APT::VersionSet verset = APT::VersionSet::FromCommandLine(Cache,
  532. CmdL.FileList + 1, APT::CacheSetHelper::CANDIDATE, helper);
  533. if (verset.empty() == true)
  534. return false;
  535. AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
  536. pkgAcquire Fetcher(&Stat);
  537. pkgRecords Recs(Cache);
  538. pkgSourceList *SrcList = Cache.GetSourceList();
  539. // reuse the usual acquire methods for deb files, but don't drop them into
  540. // the usual directories - keep everything in the current directory
  541. std::vector<std::string> storefile(verset.size());
  542. std::string const cwd = SafeGetCWD();
  543. _config->Set("Dir::Cache::Archives", cwd);
  544. int i = 0;
  545. for (APT::VersionSet::const_iterator Ver = verset.begin();
  546. Ver != verset.end(); ++Ver, ++i)
  547. {
  548. pkgAcquire::Item *I = new pkgAcqArchive(&Fetcher, SrcList, &Recs, *Ver, storefile[i]);
  549. if (storefile[i].empty())
  550. continue;
  551. std::string const filename = cwd + flNotDir(storefile[i]);
  552. storefile[i].assign(filename);
  553. I->DestFile.assign(filename);
  554. }
  555. // Just print out the uris and exit if the --print-uris flag was used
  556. if (_config->FindB("APT::Get::Print-URIs") == true)
  557. {
  558. pkgAcquire::UriIterator I = Fetcher.UriBegin();
  559. for (; I != Fetcher.UriEnd(); ++I)
  560. cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
  561. I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
  562. return true;
  563. }
  564. // Disable drop-privs if "_apt" can not write to the target dir
  565. CheckDropPrivsMustBeDisabled(Fetcher);
  566. if (_error->PendingError() == true || CheckAuth(Fetcher, false) == false)
  567. return false;
  568. bool Failed = false;
  569. if (AcquireRun(Fetcher, 0, &Failed, NULL) == false)
  570. return false;
  571. // copy files in local sources to the current directory
  572. for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
  573. {
  574. std::string const filename = cwd + flNotDir((*I)->DestFile);
  575. if ((*I)->Local == true &&
  576. filename != (*I)->DestFile &&
  577. (*I)->Status == pkgAcquire::Item::StatDone)
  578. {
  579. std::ifstream src((*I)->DestFile.c_str(), std::ios::binary);
  580. std::ofstream dst(filename.c_str(), std::ios::binary);
  581. dst << src.rdbuf();
  582. }
  583. }
  584. return Failed == false;
  585. }
  586. /*}}}*/
  587. // DoCheck - Perform the check operation /*{{{*/
  588. // ---------------------------------------------------------------------
  589. /* Opening automatically checks the system, this command is mostly used
  590. for debugging */
  591. static bool DoCheck(CommandLine &)
  592. {
  593. CacheFile Cache;
  594. Cache.Open();
  595. Cache.CheckDeps();
  596. return true;
  597. }
  598. /*}}}*/
  599. // DoSource - Fetch a source archive /*{{{*/
  600. // ---------------------------------------------------------------------
  601. /* Fetch souce packages */
  602. struct DscFile
  603. {
  604. string Package;
  605. string Version;
  606. string Dsc;
  607. };
  608. static bool DoSource(CommandLine &CmdL)
  609. {
  610. CacheFile Cache;
  611. if (Cache.Open(false) == false)
  612. return false;
  613. if (CmdL.FileSize() <= 1)
  614. return _error->Error(_("Must specify at least one package to fetch source for"));
  615. // Read the source list
  616. if (Cache.BuildSourceList() == false)
  617. return false;
  618. pkgSourceList *List = Cache.GetSourceList();
  619. // Create the text record parsers
  620. pkgSrcRecords SrcRecs(*List);
  621. if (_error->PendingError() == true)
  622. return false;
  623. // Create the download object
  624. AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
  625. pkgAcquire Fetcher(&Stat);
  626. std::unique_ptr<DscFile[]> Dsc(new DscFile[CmdL.FileSize()]);
  627. // insert all downloaded uris into this set to avoid downloading them
  628. // twice
  629. set<string> queued;
  630. // Diff only mode only fetches .diff files
  631. bool const diffOnly = _config->FindB("APT::Get::Diff-Only", false);
  632. // Tar only mode only fetches .tar files
  633. bool const tarOnly = _config->FindB("APT::Get::Tar-Only", false);
  634. // Dsc only mode only fetches .dsc files
  635. bool const dscOnly = _config->FindB("APT::Get::Dsc-Only", false);
  636. // Load the requestd sources into the fetcher
  637. unsigned J = 0;
  638. std::vector<std::string> UntrustedList;
  639. for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
  640. {
  641. string Src;
  642. pkgSrcRecords::Parser *Last = FindSrc(*I,SrcRecs,Src,Cache);
  643. if (Last == 0) {
  644. return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
  645. }
  646. if (Last->Index().IsTrusted() == false)
  647. UntrustedList.push_back(Src);
  648. string srec = Last->AsStr();
  649. string::size_type pos = srec.find("\nVcs-");
  650. while (pos != string::npos)
  651. {
  652. pos += strlen("\nVcs-");
  653. string vcs = srec.substr(pos,srec.find(":",pos)-pos);
  654. if(vcs == "Browser")
  655. {
  656. pos = srec.find("\nVcs-", pos);
  657. continue;
  658. }
  659. pos += vcs.length()+2;
  660. string::size_type epos = srec.find("\n", pos);
  661. string uri = srec.substr(pos,epos-pos).c_str();
  662. ioprintf(c1out, _("NOTICE: '%s' packaging is maintained in "
  663. "the '%s' version control system at:\n"
  664. "%s\n"),
  665. Src.c_str(), vcs.c_str(), uri.c_str());
  666. if(vcs == "Bzr")
  667. ioprintf(c1out,_("Please use:\n"
  668. "bzr branch %s\n"
  669. "to retrieve the latest (possibly unreleased) "
  670. "updates to the package.\n"),
  671. uri.c_str());
  672. break;
  673. }
  674. // Back track
  675. vector<pkgSrcRecords::File2> Lst;
  676. if (Last->Files2(Lst) == false) {
  677. return false;
  678. }
  679. // Load them into the fetcher
  680. for (vector<pkgSrcRecords::File2>::const_iterator I = Lst.begin();
  681. I != Lst.end(); ++I)
  682. {
  683. // Try to guess what sort of file it is we are getting.
  684. if (I->Type == "dsc")
  685. {
  686. Dsc[J].Package = Last->Package();
  687. Dsc[J].Version = Last->Version();
  688. Dsc[J].Dsc = flNotDir(I->Path);
  689. }
  690. // Handle the only options so that multiple can be used at once
  691. if (diffOnly == true || tarOnly == true || dscOnly == true)
  692. {
  693. if ((diffOnly == true && I->Type == "diff") ||
  694. (tarOnly == true && I->Type == "tar") ||
  695. (dscOnly == true && I->Type == "dsc"))
  696. ; // Fine, we want this file downloaded
  697. else
  698. continue;
  699. }
  700. // don't download the same uri twice (should this be moved to
  701. // the fetcher interface itself?)
  702. if(queued.find(Last->Index().ArchiveURI(I->Path)) != queued.end())
  703. continue;
  704. queued.insert(Last->Index().ArchiveURI(I->Path));
  705. // check if we have a file with that md5 sum already localy
  706. std::string localFile = flNotDir(I->Path);
  707. if (FileExists(localFile) == true)
  708. if(I->Hashes.VerifyFile(localFile) == true)
  709. {
  710. ioprintf(c1out,_("Skipping already downloaded file '%s'\n"),
  711. localFile.c_str());
  712. continue;
  713. }
  714. // see if we have a hash (Acquire::ForceHash is the only way to have none)
  715. if (I->Hashes.usable() == false && _config->FindB("APT::Get::AllowUnauthenticated",false) == false)
  716. {
  717. ioprintf(c1out, "Skipping download of file '%s' as requested hashsum is not available for authentication\n",
  718. localFile.c_str());
  719. continue;
  720. }
  721. new pkgAcqFile(&Fetcher,Last->Index().ArchiveURI(I->Path),
  722. I->Hashes, I->FileSize, Last->Index().SourceInfo(*Last,*I), Src);
  723. }
  724. }
  725. // Display statistics
  726. unsigned long long FetchBytes = Fetcher.FetchNeeded();
  727. unsigned long long FetchPBytes = Fetcher.PartialPresent();
  728. unsigned long long DebBytes = Fetcher.TotalNeeded();
  729. if (CheckFreeSpaceBeforeDownload(".", (FetchBytes - FetchPBytes)) == false)
  730. return false;
  731. // Number of bytes
  732. if (DebBytes != FetchBytes)
  733. //TRANSLATOR: The required space between number and unit is already included
  734. // in the replacement strings, so %sB will be correctly translate in e.g. 1,5 MB
  735. ioprintf(c1out,_("Need to get %sB/%sB of source archives.\n"),
  736. SizeToStr(FetchBytes).c_str(),SizeToStr(DebBytes).c_str());
  737. else
  738. //TRANSLATOR: The required space between number and unit is already included
  739. // in the replacement string, so %sB will be correctly translate in e.g. 1,5 MB
  740. ioprintf(c1out,_("Need to get %sB of source archives.\n"),
  741. SizeToStr(DebBytes).c_str());
  742. if (_config->FindB("APT::Get::Simulate",false) == true)
  743. {
  744. for (unsigned I = 0; I != J; I++)
  745. ioprintf(cout,_("Fetch source %s\n"),Dsc[I].Package.c_str());
  746. return true;
  747. }
  748. // Just print out the uris an exit if the --print-uris flag was used
  749. if (_config->FindB("APT::Get::Print-URIs") == true)
  750. {
  751. pkgAcquire::UriIterator I = Fetcher.UriBegin();
  752. for (; I != Fetcher.UriEnd(); ++I)
  753. cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
  754. I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
  755. return true;
  756. }
  757. // Disable drop-privs if "_apt" can not write to the target dir
  758. CheckDropPrivsMustBeDisabled(Fetcher);
  759. // check authentication status of the source as well
  760. if (UntrustedList.empty() == false && AuthPrompt(UntrustedList, false) == false)
  761. return false;
  762. // Run it
  763. bool Failed = false;
  764. if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true)
  765. {
  766. return _error->Error(_("Failed to fetch some archives."));
  767. }
  768. if (_config->FindB("APT::Get::Download-only",false) == true)
  769. {
  770. c1out << _("Download complete and in download only mode") << endl;
  771. return true;
  772. }
  773. // Unpack the sources
  774. pid_t Process = ExecFork();
  775. if (Process == 0)
  776. {
  777. bool const fixBroken = _config->FindB("APT::Get::Fix-Broken", false);
  778. for (unsigned I = 0; I != J; ++I)
  779. {
  780. string Dir = Dsc[I].Package + '-' + Cache->VS().UpstreamVersion(Dsc[I].Version.c_str());
  781. // Diff only mode only fetches .diff files
  782. if (_config->FindB("APT::Get::Diff-Only",false) == true ||
  783. _config->FindB("APT::Get::Tar-Only",false) == true ||
  784. Dsc[I].Dsc.empty() == true)
  785. continue;
  786. // See if the package is already unpacked
  787. struct stat Stat;
  788. if (fixBroken == false && stat(Dir.c_str(),&Stat) == 0 &&
  789. S_ISDIR(Stat.st_mode) != 0)
  790. {
  791. ioprintf(c0out ,_("Skipping unpack of already unpacked source in %s\n"),
  792. Dir.c_str());
  793. }
  794. else
  795. {
  796. // Call dpkg-source
  797. std::string const sourceopts = _config->Find("DPkg::Source-Options", "-x");
  798. std::string S;
  799. strprintf(S, "%s %s %s",
  800. _config->Find("Dir::Bin::dpkg-source","dpkg-source").c_str(),
  801. sourceopts.c_str(), Dsc[I].Dsc.c_str());
  802. if (system(S.c_str()) != 0)
  803. {
  804. fprintf(stderr, _("Unpack command '%s' failed.\n"), S.c_str());
  805. fprintf(stderr, _("Check if the 'dpkg-dev' package is installed.\n"));
  806. _exit(1);
  807. }
  808. }
  809. // Try to compile it with dpkg-buildpackage
  810. if (_config->FindB("APT::Get::Compile",false) == true)
  811. {
  812. string buildopts = _config->Find("APT::Get::Host-Architecture");
  813. if (buildopts.empty() == false)
  814. buildopts = "-a" + buildopts + " ";
  815. // get all active build profiles
  816. std::string const profiles = APT::Configuration::getBuildProfilesString();
  817. if (profiles.empty() == false)
  818. buildopts.append(" -P").append(profiles).append(" ");
  819. buildopts.append(_config->Find("DPkg::Build-Options","-b -uc"));
  820. // Call dpkg-buildpackage
  821. std::string S;
  822. strprintf(S, "cd %s && %s %s",
  823. Dir.c_str(),
  824. _config->Find("Dir::Bin::dpkg-buildpackage","dpkg-buildpackage").c_str(),
  825. buildopts.c_str());
  826. if (system(S.c_str()) != 0)
  827. {
  828. fprintf(stderr, _("Build command '%s' failed.\n"), S.c_str());
  829. _exit(1);
  830. }
  831. }
  832. }
  833. _exit(0);
  834. }
  835. // Wait for the subprocess
  836. int Status = 0;
  837. while (waitpid(Process,&Status,0) != Process)
  838. {
  839. if (errno == EINTR)
  840. continue;
  841. return _error->Errno("waitpid","Couldn't wait for subprocess");
  842. }
  843. if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
  844. return _error->Error(_("Child process failed"));
  845. return true;
  846. }
  847. /*}}}*/
  848. // DoBuildDep - Install/removes packages to satisfy build dependencies /*{{{*/
  849. // ---------------------------------------------------------------------
  850. /* This function will look at the build depends list of the given source
  851. package and install the necessary packages to make it true, or fail. */
  852. static bool DoBuildDep(CommandLine &CmdL)
  853. {
  854. CacheFile Cache;
  855. _config->Set("APT::Install-Recommends", false);
  856. bool WantLock = _config->FindB("APT::Get::Print-URIs", false) == false;
  857. if (Cache.Open(WantLock) == false)
  858. return false;
  859. if (CmdL.FileSize() <= 1)
  860. return _error->Error(_("Must specify at least one package to check builddeps for"));
  861. // Read the source list
  862. if (Cache.BuildSourceList() == false)
  863. return false;
  864. pkgSourceList *List = Cache.GetSourceList();
  865. // Create the text record parsers
  866. pkgSrcRecords SrcRecs(*List);
  867. if (_error->PendingError() == true)
  868. return false;
  869. bool StripMultiArch;
  870. string hostArch = _config->Find("APT::Get::Host-Architecture");
  871. if (hostArch.empty() == false)
  872. {
  873. std::vector<std::string> archs = APT::Configuration::getArchitectures();
  874. if (std::find(archs.begin(), archs.end(), hostArch) == archs.end())
  875. return _error->Error(_("No architecture information available for %s. See apt.conf(5) APT::Architectures for setup"), hostArch.c_str());
  876. StripMultiArch = false;
  877. }
  878. else
  879. StripMultiArch = true;
  880. unsigned J = 0;
  881. for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
  882. {
  883. string Src;
  884. pkgSrcRecords::Parser *Last = 0;
  885. std::unique_ptr<pkgSrcRecords::Parser> LastOwner;
  886. // an unpacked debian source tree
  887. using APT::String::Startswith;
  888. if ((Startswith(*I, "./") || Startswith(*I, "/")) &&
  889. DirectoryExists(*I))
  890. {
  891. ioprintf(c1out, _("Note, using directory '%s' to get the build dependencies\n"), *I);
  892. // FIXME: how can we make this more elegant?
  893. std::string TypeName = "Debian control file";
  894. pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
  895. if(Type != NULL)
  896. LastOwner.reset(Last = Type->CreateSrcPkgParser(*I));
  897. }
  898. // if its a local file (e.g. .dsc) use this
  899. else if (FileExists(*I))
  900. {
  901. ioprintf(c1out, _("Note, using file '%s' to get the build dependencies\n"), *I);
  902. // see if we can get a parser for this pkgIndexFile type
  903. string TypeName = "Debian " + flExtension(*I) + " file";
  904. pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
  905. if(Type != NULL)
  906. LastOwner.reset(Last = Type->CreateSrcPkgParser(*I));
  907. } else {
  908. // normal case, search the cache for the source file
  909. Last = FindSrc(*I,SrcRecs,Src,Cache);
  910. }
  911. if (Last == 0)
  912. return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
  913. // Process the build-dependencies
  914. vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
  915. // FIXME: Can't specify architecture to use for [wildcard] matching, so switch default arch temporary
  916. if (hostArch.empty() == false)
  917. {
  918. std::string nativeArch = _config->Find("APT::Architecture");
  919. _config->Set("APT::Architecture", hostArch);
  920. bool Success = Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch);
  921. _config->Set("APT::Architecture", nativeArch);
  922. if (Success == false)
  923. return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
  924. }
  925. else if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch) == false)
  926. return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
  927. // Also ensure that build-essential packages are present
  928. Configuration::Item const *Opts = _config->Tree("APT::Build-Essential");
  929. if (Opts)
  930. Opts = Opts->Child;
  931. for (; Opts; Opts = Opts->Next)
  932. {
  933. if (Opts->Value.empty() == true)
  934. continue;
  935. pkgSrcRecords::Parser::BuildDepRec rec;
  936. rec.Package = Opts->Value;
  937. rec.Type = pkgSrcRecords::Parser::BuildDependIndep;
  938. rec.Op = 0;
  939. BuildDeps.push_back(rec);
  940. }
  941. if (BuildDeps.empty() == true)
  942. {
  943. ioprintf(c1out,_("%s has no build depends.\n"),Src.c_str());
  944. continue;
  945. }
  946. // Install the requested packages
  947. vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
  948. pkgProblemResolver Fix(Cache);
  949. bool skipAlternatives = false; // skip remaining alternatives in an or group
  950. for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D)
  951. {
  952. bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or);
  953. if (skipAlternatives == true)
  954. {
  955. /*
  956. * if there are alternatives, we've already picked one, so skip
  957. * the rest
  958. *
  959. * TODO: this means that if there's a build-dep on A|B and B is
  960. * installed, we'll still try to install A; more importantly,
  961. * if A is currently broken, we cannot go back and try B. To fix
  962. * this would require we do a Resolve cycle for each package we
  963. * add to the install list. Ugh
  964. */
  965. if (!hasAlternatives)
  966. skipAlternatives = false; // end of or group
  967. continue;
  968. }
  969. if ((*D).Type == pkgSrcRecords::Parser::BuildConflict ||
  970. (*D).Type == pkgSrcRecords::Parser::BuildConflictIndep)
  971. {
  972. pkgCache::GrpIterator Grp = Cache->FindGrp((*D).Package);
  973. // Build-conflicts on unknown packages are silently ignored
  974. if (Grp.end() == true)
  975. continue;
  976. for (pkgCache::PkgIterator Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg))
  977. {
  978. pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache);
  979. /*
  980. * Remove if we have an installed version that satisfies the
  981. * version criteria
  982. */
  983. if (IV.end() == false &&
  984. Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true)
  985. TryToInstallBuildDep(Pkg,Cache,Fix,true,false);
  986. }
  987. }
  988. else // BuildDep || BuildDepIndep
  989. {
  990. if (_config->FindB("Debug::BuildDeps",false) == true)
  991. cout << "Looking for " << (*D).Package << "...\n";
  992. pkgCache::PkgIterator Pkg;
  993. // Cross-Building?
  994. if (StripMultiArch == false && D->Type != pkgSrcRecords::Parser::BuildDependIndep)
  995. {
  996. size_t const colon = D->Package.find(":");
  997. if (colon != string::npos)
  998. {
  999. if (strcmp(D->Package.c_str() + colon, ":any") == 0 || strcmp(D->Package.c_str() + colon, ":native") == 0)
  1000. Pkg = Cache->FindPkg(D->Package.substr(0,colon));
  1001. else
  1002. Pkg = Cache->FindPkg(D->Package);
  1003. }
  1004. else
  1005. Pkg = Cache->FindPkg(D->Package, hostArch);
  1006. // a bad version either is invalid or doesn't satify dependency
  1007. #define BADVER(Ver) (Ver.end() == true || \
  1008. (D->Version.empty() == false && \
  1009. Cache->VS().CheckDep(Ver.VerStr(),D->Op,D->Version.c_str()) == false))
  1010. APT::VersionList verlist;
  1011. if (Pkg.end() == false)
  1012. {
  1013. pkgCache::VerIterator Ver = (*Cache)[Pkg].InstVerIter(*Cache);
  1014. if (BADVER(Ver) == false)
  1015. verlist.insert(Ver);
  1016. Ver = (*Cache)[Pkg].CandidateVerIter(*Cache);
  1017. if (BADVER(Ver) == false)
  1018. verlist.insert(Ver);
  1019. }
  1020. if (verlist.empty() == true)
  1021. {
  1022. pkgCache::PkgIterator BuildPkg = Cache->FindPkg(D->Package, "native");
  1023. if (BuildPkg.end() == false && Pkg != BuildPkg)
  1024. {
  1025. pkgCache::VerIterator Ver = (*Cache)[BuildPkg].InstVerIter(*Cache);
  1026. if (BADVER(Ver) == false)
  1027. verlist.insert(Ver);
  1028. Ver = (*Cache)[BuildPkg].CandidateVerIter(*Cache);
  1029. if (BADVER(Ver) == false)
  1030. verlist.insert(Ver);
  1031. }
  1032. }
  1033. #undef BADVER
  1034. string forbidden;
  1035. // We need to decide if host or build arch, so find a version we can look at
  1036. APT::VersionList::const_iterator Ver = verlist.begin();
  1037. for (; Ver != verlist.end(); ++Ver)
  1038. {
  1039. forbidden.clear();
  1040. if (Ver->MultiArch == pkgCache::Version::No || Ver->MultiArch == pkgCache::Version::All)
  1041. {
  1042. if (colon == string::npos)
  1043. Pkg = Ver.ParentPkg().Group().FindPkg(hostArch);
  1044. else if (strcmp(D->Package.c_str() + colon, ":any") == 0)
  1045. forbidden = "Multi-Arch: no";
  1046. else if (strcmp(D->Package.c_str() + colon, ":native") == 0)
  1047. Pkg = Ver.ParentPkg().Group().FindPkg("native");
  1048. }
  1049. else if (Ver->MultiArch == pkgCache::Version::Same)
  1050. {
  1051. if (colon == string::npos)
  1052. Pkg = Ver.ParentPkg().Group().FindPkg(hostArch);
  1053. else if (strcmp(D->Package.c_str() + colon, ":any") == 0)
  1054. forbidden = "Multi-Arch: same";
  1055. else if (strcmp(D->Package.c_str() + colon, ":native") == 0)
  1056. Pkg = Ver.ParentPkg().Group().FindPkg("native");
  1057. }
  1058. else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign)
  1059. {
  1060. if (colon == string::npos)
  1061. Pkg = Ver.ParentPkg().Group().FindPkg("native");
  1062. else if (strcmp(D->Package.c_str() + colon, ":any") == 0 ||
  1063. strcmp(D->Package.c_str() + colon, ":native") == 0)
  1064. forbidden = "Multi-Arch: foreign";
  1065. }
  1066. else if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
  1067. {
  1068. if (colon == string::npos)
  1069. Pkg = Ver.ParentPkg().Group().FindPkg(hostArch);
  1070. else if (strcmp(D->Package.c_str() + colon, ":any") == 0)
  1071. {
  1072. // prefer any installed over preferred non-installed architectures
  1073. pkgCache::GrpIterator Grp = Ver.ParentPkg().Group();
  1074. // we don't check for version here as we are better of with upgrading than remove and install
  1075. for (Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg))
  1076. if (Pkg.CurrentVer().end() == false)
  1077. break;
  1078. if (Pkg.end() == true)
  1079. Pkg = Grp.FindPreferredPkg(true);
  1080. }
  1081. else if (strcmp(D->Package.c_str() + colon, ":native") == 0)
  1082. Pkg = Ver.ParentPkg().Group().FindPkg("native");
  1083. }
  1084. if (forbidden.empty() == false)
  1085. {
  1086. if (_config->FindB("Debug::BuildDeps",false) == true)
  1087. cout << D->Package.substr(colon, string::npos) << " is not allowed from " << forbidden << " package " << (*D).Package << " (" << Ver.VerStr() << ")" << endl;
  1088. continue;
  1089. }
  1090. //we found a good version
  1091. break;
  1092. }
  1093. if (Ver == verlist.end())
  1094. {
  1095. if (_config->FindB("Debug::BuildDeps",false) == true)
  1096. cout << " No multiarch info as we have no satisfying installed nor candidate for " << D->Package << " on build or host arch" << endl;
  1097. if (forbidden.empty() == false)
  1098. {
  1099. if (hasAlternatives)
  1100. continue;
  1101. return _error->Error(_("%s dependency for %s can't be satisfied "
  1102. "because %s is not allowed on '%s' packages"),
  1103. Last->BuildDepType(D->Type), Src.c_str(),
  1104. D->Package.c_str(), forbidden.c_str());
  1105. }
  1106. }
  1107. }
  1108. else
  1109. Pkg = Cache->FindPkg(D->Package);
  1110. if (Pkg.end() == true || (Pkg->VersionList == 0 && Pkg->ProvidesList == 0))
  1111. {
  1112. if (_config->FindB("Debug::BuildDeps",false) == true)
  1113. cout << " (not found)" << (*D).Package << endl;
  1114. if (hasAlternatives)
  1115. continue;
  1116. return _error->Error(_("%s dependency for %s cannot be satisfied "
  1117. "because the package %s cannot be found"),
  1118. Last->BuildDepType((*D).Type),Src.c_str(),
  1119. (*D).Package.c_str());
  1120. }
  1121. pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache);
  1122. if (IV.end() == false)
  1123. {
  1124. if (_config->FindB("Debug::BuildDeps",false) == true)
  1125. cout << " Is installed\n";
  1126. if (D->Version.empty() == true ||
  1127. Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true)
  1128. {
  1129. skipAlternatives = hasAlternatives;
  1130. continue;
  1131. }
  1132. if (_config->FindB("Debug::BuildDeps",false) == true)
  1133. cout << " ...but the installed version doesn't meet the version requirement\n";
  1134. if (((*D).Op & pkgCache::Dep::LessEq) == pkgCache::Dep::LessEq)
  1135. return _error->Error(_("Failed to satisfy %s dependency for %s: Installed package %s is too new"),
  1136. Last->BuildDepType((*D).Type), Src.c_str(), Pkg.FullName(true).c_str());
  1137. }
  1138. // Only consider virtual packages if there is no versioned dependency
  1139. if ((*D).Version.empty() == true)
  1140. {
  1141. /*
  1142. * If this is a virtual package, we need to check the list of
  1143. * packages that provide it and see if any of those are
  1144. * installed
  1145. */
  1146. pkgCache::PrvIterator Prv = Pkg.ProvidesList();
  1147. for (; Prv.end() != true; ++Prv)
  1148. {
  1149. if (_config->FindB("Debug::BuildDeps",false) == true)
  1150. cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl;
  1151. if ((*Cache)[Prv.OwnerPkg()].InstVerIter(*Cache).end() == false)
  1152. break;
  1153. }
  1154. if (Prv.end() == false)
  1155. {
  1156. if (_config->FindB("Debug::BuildDeps",false) == true)
  1157. cout << " Is provided by installed package " << Prv.OwnerPkg().FullName() << endl;
  1158. skipAlternatives = hasAlternatives;
  1159. continue;
  1160. }
  1161. }
  1162. else // versioned dependency
  1163. {
  1164. pkgCache::VerIterator CV = (*Cache)[Pkg].CandidateVerIter(*Cache);
  1165. if (CV.end() == true ||
  1166. Cache->VS().CheckDep(CV.VerStr(),(*D).Op,(*D).Version.c_str()) == false)
  1167. {
  1168. if (hasAlternatives)
  1169. continue;
  1170. else if (CV.end() == false)
  1171. return _error->Error(_("%s dependency for %s cannot be satisfied "
  1172. "because candidate version of package %s "
  1173. "can't satisfy version requirements"),
  1174. Last->BuildDepType(D->Type), Src.c_str(),
  1175. D->Package.c_str());
  1176. else
  1177. return _error->Error(_("%s dependency for %s cannot be satisfied "
  1178. "because package %s has no candidate version"),
  1179. Last->BuildDepType(D->Type), Src.c_str(),
  1180. D->Package.c_str());
  1181. }
  1182. }
  1183. if (TryToInstallBuildDep(Pkg,Cache,Fix,false,false,false) == true)
  1184. {
  1185. // We successfully installed something; skip remaining alternatives
  1186. skipAlternatives = hasAlternatives;
  1187. if(_config->FindB("APT::Get::Build-Dep-Automatic", false) == true)
  1188. Cache->MarkAuto(Pkg, true);
  1189. continue;
  1190. }
  1191. else if (hasAlternatives)
  1192. {
  1193. if (_config->FindB("Debug::BuildDeps",false) == true)
  1194. cout << " Unsatisfiable, trying alternatives\n";
  1195. continue;
  1196. }
  1197. else
  1198. {
  1199. return _error->Error(_("Failed to satisfy %s dependency for %s: %s"),
  1200. Last->BuildDepType((*D).Type),
  1201. Src.c_str(),
  1202. (*D).Package.c_str());
  1203. }
  1204. }
  1205. }
  1206. if (Fix.Resolve(true) == false)
  1207. _error->Discard();
  1208. // Now we check the state of the packages,
  1209. if (Cache->BrokenCount() != 0)
  1210. {
  1211. ShowBroken(cout, Cache, false);
  1212. return _error->Error(_("Build-dependencies for %s could not be satisfied."),*I);
  1213. }
  1214. }
  1215. if (InstallPackages(Cache, false, true) == false)
  1216. return _error->Error(_("Failed to process build dependencies"));
  1217. return true;
  1218. }
  1219. /*}}}*/
  1220. // DoChangelog - Get changelog from the command line /*{{{*/
  1221. static bool DoChangelog(CommandLine &CmdL)
  1222. {
  1223. CacheFile Cache;
  1224. if (Cache.ReadOnlyOpen() == false)
  1225. return false;
  1226. APT::CacheSetHelper helper;
  1227. APT::VersionList verset = APT::VersionList::FromCommandLine(Cache,
  1228. CmdL.FileList + 1, APT::CacheSetHelper::CANDIDATE, helper);
  1229. if (verset.empty() == true)
  1230. return false;
  1231. pkgAcquire Fetcher;
  1232. AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
  1233. Fetcher.SetLog(&Stat);
  1234. bool const downOnly = _config->FindB("APT::Get::Download-Only", false);
  1235. bool const printOnly = _config->FindB("APT::Get::Print-URIs", false);
  1236. for (APT::VersionList::const_iterator Ver = verset.begin();
  1237. Ver != verset.end();
  1238. ++Ver)
  1239. {
  1240. if (printOnly)
  1241. new pkgAcqChangelog(&Fetcher, Ver, "/dev/null");
  1242. else if (downOnly)
  1243. new pkgAcqChangelog(&Fetcher, Ver, ".");
  1244. else
  1245. new pkgAcqChangelog(&Fetcher, Ver);
  1246. }
  1247. if (printOnly == false)
  1248. {
  1249. // Disable drop-privs if "_apt" can not write to the target dir
  1250. CheckDropPrivsMustBeDisabled(Fetcher);
  1251. if (_error->PendingError() == true)
  1252. return false;
  1253. bool Failed = false;
  1254. if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true)
  1255. return false;
  1256. }
  1257. if (downOnly == false || printOnly == true)
  1258. {
  1259. bool Failed = false;
  1260. for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
  1261. {
  1262. if (printOnly)
  1263. {
  1264. if ((*I)->ErrorText.empty() == false)
  1265. {
  1266. Failed = true;
  1267. _error->Error("%s", (*I)->ErrorText.c_str());
  1268. }
  1269. else
  1270. cout << '\'' << (*I)->DescURI() << "' " << flNotDir((*I)->DestFile) << std::endl;
  1271. }
  1272. else
  1273. DisplayFileInPager((*I)->DestFile);
  1274. }
  1275. return Failed == false;
  1276. }
  1277. return true;
  1278. }
  1279. /*}}}*/
  1280. // DoIndexTargets - Lists all IndexTargets /*{{{*/
  1281. static std::string format_key(std::string key)
  1282. {
  1283. // deb822 is case-insensitive, but the human eye prefers candy
  1284. std::transform(key.begin(), key.end(), key.begin(), ::tolower);
  1285. key[0] = ::toupper(key[0]);
  1286. size_t found = key.find("_uri");
  1287. if (found != std::string::npos)
  1288. key.replace(found, 4, "-URI");
  1289. while ((found = key.find('_')) != std::string::npos)
  1290. {
  1291. key[found] = '-';
  1292. key[found + 1] = ::toupper(key[found + 1]);
  1293. }
  1294. return key;
  1295. }
  1296. static bool DoIndexTargets(CommandLine &CmdL)
  1297. {
  1298. pkgCacheFile CacheFile;
  1299. pkgSourceList *SrcList = CacheFile.GetSourceList();
  1300. if (SrcList == NULL)
  1301. return false;
  1302. std::string const Format = _config->Find("APT::Get::IndexTargets::Format");
  1303. bool const ReleaseInfo = _config->FindB("APT::Get::IndexTargets::ReleaseInfo", true);
  1304. bool Filtered = CmdL.FileSize() > 1;
  1305. for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); ++S)
  1306. {
  1307. std::vector<IndexTarget> const targets = (*S)->GetIndexTargets();
  1308. std::map<std::string, string> AddOptions;
  1309. if (ReleaseInfo)
  1310. {
  1311. AddOptions.insert(std::make_pair("TRUSTED", ((*S)->IsTrusted() ? "yes" : "no")));
  1312. pkgCache &Cache = *CacheFile.GetPkgCache();
  1313. pkgCache::RlsFileIterator const RlsFile = (*S)->FindInCache(Cache, false);
  1314. if (RlsFile.end())
  1315. continue;
  1316. #define APT_RELEASE(X,Y) if (RlsFile.Y() != NULL) AddOptions.insert(std::make_pair(X, RlsFile.Y()))
  1317. APT_RELEASE("CODENAME", Codename);
  1318. APT_RELEASE("SUITE", Archive);
  1319. APT_RELEASE("VERSION", Version);
  1320. APT_RELEASE("ORIGIN", Origin);
  1321. APT_RELEASE("LABEL", Label);
  1322. #undef APT_RELEASE
  1323. }
  1324. for (std::vector<IndexTarget>::const_iterator T = targets.begin(); T != targets.end(); ++T)
  1325. {
  1326. std::string filename = T->Option(ReleaseInfo ? IndexTarget::EXISTING_FILENAME : IndexTarget::FILENAME);
  1327. if (filename.empty())
  1328. continue;
  1329. std::ostringstream stanza;
  1330. if (Filtered || Format.empty())
  1331. {
  1332. stanza << "MetaKey: " << T->MetaKey << "\n"
  1333. << "ShortDesc: " << T->ShortDesc << "\n"
  1334. << "Description: " << T->Description << "\n"
  1335. << "URI: " << T->URI << "\n"
  1336. << "Filename: " << filename << "\n"
  1337. << "Optional: " << (T->IsOptional ? "yes" : "no") << "\n";
  1338. for (std::map<std::string,std::string>::const_iterator O = AddOptions.begin(); O != AddOptions.end(); ++O)
  1339. stanza << format_key(O->first) << ": " << O->second << "\n";
  1340. for (std::map<std::string,std::string>::const_iterator O = T->Options.begin(); O != T->Options.end(); ++O)
  1341. stanza << format_key(O->first) << ": " << O->second << "\n";
  1342. stanza << "\n";
  1343. if (Filtered)
  1344. {
  1345. // that is a bit crude, but good enough for now
  1346. bool found = true;
  1347. std::string haystack = std::string("\n") + stanza.str() + "\n";
  1348. std::transform(haystack.begin(), haystack.end(), haystack.begin(), ::tolower);
  1349. size_t const filesize = CmdL.FileSize() - 1;
  1350. for (size_t i = 0; i != filesize; ++i)
  1351. {
  1352. std::string needle = std::string("\n") + CmdL.FileList[i + 1] + "\n";
  1353. std::transform(needle.begin(), needle.end(), needle.begin(), ::tolower);
  1354. if (haystack.find(needle) != std::string::npos)
  1355. continue;
  1356. found = false;
  1357. break;
  1358. }
  1359. if (found == false)
  1360. continue;
  1361. }
  1362. }
  1363. if (Format.empty())
  1364. cout << stanza.str();
  1365. else
  1366. {
  1367. std::string out = SubstVar(Format, "$(FILENAME)", filename);
  1368. out = T->Format(out);
  1369. for (std::map<std::string,std::string>::const_iterator O = AddOptions.begin(); O != AddOptions.end(); ++O)
  1370. out = SubstVar(out, std::string("$(") + O->first + ")", O->second);
  1371. cout << out << std::endl;
  1372. }
  1373. }
  1374. }
  1375. return true;
  1376. }
  1377. /*}}}*/
  1378. // ShowHelp - Show a help screen /*{{{*/
  1379. // ---------------------------------------------------------------------
  1380. /* */
  1381. static bool ShowHelp(CommandLine &)
  1382. {
  1383. ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
  1384. if (_config->FindB("version") == true)
  1385. {
  1386. cout << _("Supported modules:") << endl;
  1387. for (unsigned I = 0; I != pkgVersioningSystem::GlobalListLen; I++)
  1388. {
  1389. pkgVersioningSystem *VS = pkgVersioningSystem::GlobalList[I];
  1390. if (_system != 0 && _system->VS == VS)
  1391. cout << '*';
  1392. else
  1393. cout << ' ';
  1394. cout << "Ver: " << VS->Label << endl;
  1395. /* Print out all the packaging systems that will work with
  1396. this VS */
  1397. for (unsigned J = 0; J != pkgSystem::GlobalListLen; J++)
  1398. {
  1399. pkgSystem *Sys = pkgSystem::GlobalList[J];
  1400. if (_system == Sys)
  1401. cout << '*';
  1402. else
  1403. cout << ' ';
  1404. if (Sys->VS->TestCompatibility(*VS) == true)
  1405. cout << "Pkg: " << Sys->Label << " (Priority " << Sys->Score(*_config) << ")" << endl;
  1406. }
  1407. }
  1408. for (unsigned I = 0; I != pkgSourceList::Type::GlobalListLen; I++)
  1409. {
  1410. pkgSourceList::Type *Type = pkgSourceList::Type::GlobalList[I];
  1411. cout << " S.L: '" << Type->Name << "' " << Type->Label << endl;
  1412. }
  1413. for (unsigned I = 0; I != pkgIndexFile::Type::GlobalListLen; I++)
  1414. {
  1415. pkgIndexFile::Type *Type = pkgIndexFile::Type::GlobalList[I];
  1416. cout << " Idx: " << Type->Label << endl;
  1417. }
  1418. return true;
  1419. }
  1420. cout <<
  1421. _("Usage: apt-get [options] command\n"
  1422. " apt-get [options] install|remove pkg1 [pkg2 ...]\n"
  1423. " apt-get [options] source pkg1 [pkg2 ...]\n"
  1424. "\n"
  1425. "apt-get is a simple command line interface for downloading and\n"
  1426. "installing packages. The most frequently used commands are update\n"
  1427. "and install.\n"
  1428. "\n"
  1429. "Commands:\n"
  1430. " update - Retrieve new lists of packages\n"
  1431. " upgrade - Perform an upgrade\n"
  1432. " install - Install new packages (pkg is libc6 not libc6.deb)\n"
  1433. " remove - Remove packages\n"
  1434. " autoremove - Remove automatically all unused packages\n"
  1435. " purge - Remove packages and config files\n"
  1436. " source - Download source archives\n"
  1437. " build-dep - Configure build-dependencies for source packages\n"
  1438. " dist-upgrade - Distribution upgrade, see apt-get(8)\n"
  1439. " dselect-upgrade - Follow dselect selections\n"
  1440. " clean - Erase downloaded archive files\n"
  1441. " autoclean - Erase old downloaded archive files\n"
  1442. " check - Verify that there are no broken dependencies\n"
  1443. " changelog - Download and display the changelog for the given package\n"
  1444. " download - Download the binary package into the current directory\n"
  1445. "\n"
  1446. "Options:\n"
  1447. " -h This help text.\n"
  1448. " -q Loggable output - no progress indicator\n"
  1449. " -qq No output except for errors\n"
  1450. " -d Download only - do NOT install or unpack archives\n"
  1451. " -s No-act. Perform ordering simulation\n"
  1452. " -y Assume Yes to all queries and do not prompt\n"
  1453. " -f Attempt to correct a system with broken dependencies in place\n"
  1454. " -m Attempt to continue if archives are unlocatable\n"
  1455. " -u Show a list of upgraded packages as well\n"
  1456. " -b Build the source package after fetching it\n"
  1457. " -V Show verbose version numbers\n"
  1458. " -c=? Read this configuration file\n"
  1459. " -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n"
  1460. "See the apt-get(8), sources.list(5) and apt.conf(5) manual\n"
  1461. "pages for more information and options.\n"
  1462. " This APT has Super Cow Powers.\n");
  1463. return true;
  1464. }
  1465. /*}}}*/
  1466. int main(int argc,const char *argv[]) /*{{{*/
  1467. {
  1468. CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate},
  1469. {"upgrade",&DoUpgrade},
  1470. {"install",&DoInstall},
  1471. {"remove",&DoInstall},
  1472. {"purge",&DoInstall},
  1473. {"autoremove",&DoInstall},
  1474. {"auto-remove",&DoInstall},
  1475. {"markauto",&DoMarkAuto},
  1476. {"unmarkauto",&DoMarkAuto},
  1477. {"dist-upgrade",&DoDistUpgrade},
  1478. {"full-upgrade",&DoDistUpgrade},
  1479. {"dselect-upgrade",&DoDSelectUpgrade},
  1480. {"build-dep",&DoBuildDep},
  1481. {"clean",&DoClean},
  1482. {"autoclean",&DoAutoClean},
  1483. {"auto-clean",&DoAutoClean},
  1484. {"check",&DoCheck},
  1485. {"source",&DoSource},
  1486. {"download",&DoDownload},
  1487. {"changelog",&DoChangelog},
  1488. {"indextargets",&DoIndexTargets},
  1489. {"moo",&DoMoo},
  1490. {"help",&ShowHelp},
  1491. {0,0}};
  1492. std::vector<CommandLine::Args> Args = getCommandArgs("apt-get", CommandLine::GetCommand(Cmds, argc, argv));
  1493. // Set up gettext support
  1494. setlocale(LC_ALL,"");
  1495. textdomain(PACKAGE);
  1496. // Parse the command line and initialize the package library
  1497. CommandLine CmdL;
  1498. ParseCommandLine(CmdL, Cmds, Args.data(), &_config, &_system, argc, argv, ShowHelp);
  1499. // see if we are in simulate mode
  1500. CheckSimulateMode(CmdL);
  1501. // Init the signals
  1502. InitSignals();
  1503. // Setup the output streams
  1504. InitOutput();
  1505. // Match the operation
  1506. CmdL.DispatchArg(Cmds);
  1507. // Print any errors or warnings found during parsing
  1508. bool const Errors = _error->PendingError();
  1509. if (_config->FindI("quiet",0) > 0)
  1510. _error->DumpErrors();
  1511. else
  1512. _error->DumpErrors(GlobalError::DEBUG);
  1513. return Errors == true ? 100 : 0;
  1514. }
  1515. /*}}}*/