packagemanager.cc 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: packagemanager.cc,v 1.30 2003/04/27 03:04:15 doogie Exp $
  4. /* ######################################################################
  5. Package Manager - Abstacts the package manager
  6. More work is needed in the area of transitioning provides, ie exim
  7. replacing smail. This can cause interesing side effects.
  8. Other cases involving conflicts+replaces should be tested.
  9. ##################################################################### */
  10. /*}}}*/
  11. // Include Files /*{{{*/
  12. #include <config.h>
  13. #include <apt-pkg/packagemanager.h>
  14. #include <apt-pkg/orderlist.h>
  15. #include <apt-pkg/depcache.h>
  16. #include <apt-pkg/error.h>
  17. #include <apt-pkg/version.h>
  18. #include <apt-pkg/acquire-item.h>
  19. #include <apt-pkg/algorithms.h>
  20. #include <apt-pkg/configuration.h>
  21. #include <apt-pkg/macros.h>
  22. #include <apt-pkg/pkgcache.h>
  23. #include <apt-pkg/cacheiterators.h>
  24. #include <apt-pkg/strutl.h>
  25. #include <apt-pkg/install-progress.h>
  26. #include <stddef.h>
  27. #include <list>
  28. #include <string>
  29. #include <iostream>
  30. #include <apti18n.h>
  31. /*}}}*/
  32. using namespace std;
  33. bool pkgPackageManager::SigINTStop = false;
  34. // PM::PackageManager - Constructor /*{{{*/
  35. // ---------------------------------------------------------------------
  36. /* */
  37. pkgPackageManager::pkgPackageManager(pkgDepCache *pCache) : Cache(*pCache),
  38. List(NULL), Res(Incomplete), d(NULL)
  39. {
  40. FileNames = new string[Cache.Head().PackageCount];
  41. Debug = _config->FindB("Debug::pkgPackageManager",false);
  42. NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true);
  43. ImmConfigureAll = _config->FindB("APT::Immediate-Configure-All",false);
  44. }
  45. /*}}}*/
  46. // PM::PackageManager - Destructor /*{{{*/
  47. // ---------------------------------------------------------------------
  48. /* */
  49. pkgPackageManager::~pkgPackageManager()
  50. {
  51. delete List;
  52. delete [] FileNames;
  53. }
  54. /*}}}*/
  55. // PM::GetArchives - Queue the archives for download /*{{{*/
  56. // ---------------------------------------------------------------------
  57. /* */
  58. bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  59. pkgRecords *Recs)
  60. {
  61. if (CreateOrderList() == false)
  62. return false;
  63. bool const ordering =
  64. _config->FindB("PackageManager::UnpackAll",true) ?
  65. List->OrderUnpack() : List->OrderCritical();
  66. if (ordering == false)
  67. return _error->Error("Internal ordering error");
  68. for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
  69. {
  70. PkgIterator Pkg(Cache,*I);
  71. FileNames[Pkg->ID] = string();
  72. // Skip packages to erase
  73. if (Cache[Pkg].Delete() == true)
  74. continue;
  75. // Skip Packages that need configure only.
  76. if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
  77. Cache[Pkg].Keep() == true)
  78. continue;
  79. // Skip already processed packages
  80. if (List->IsNow(Pkg) == false)
  81. continue;
  82. new pkgAcqArchive(Owner,Sources,Recs,Cache[Pkg].InstVerIter(Cache),
  83. FileNames[Pkg->ID]);
  84. }
  85. return true;
  86. }
  87. /*}}}*/
  88. // PM::FixMissing - Keep all missing packages /*{{{*/
  89. // ---------------------------------------------------------------------
  90. /* This is called to correct the installation when packages could not
  91. be downloaded. */
  92. bool pkgPackageManager::FixMissing()
  93. {
  94. pkgDepCache::ActionGroup group(Cache);
  95. pkgProblemResolver Resolve(&Cache);
  96. List->SetFileList(FileNames);
  97. bool Bad = false;
  98. for (PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
  99. {
  100. if (List->IsMissing(I) == false)
  101. continue;
  102. // Okay, this file is missing and we need it. Mark it for keep
  103. Bad = true;
  104. Cache.MarkKeep(I, false, false);
  105. }
  106. // We have to empty the list otherwise it will not have the new changes
  107. delete List;
  108. List = 0;
  109. if (Bad == false)
  110. return true;
  111. // Now downgrade everything that is broken
  112. return Resolve.ResolveByKeep() == true && Cache.BrokenCount() == 0;
  113. }
  114. /*}}}*/
  115. // PM::ImmediateAdd - Add the immediate flag recursivly /*{{{*/
  116. // ---------------------------------------------------------------------
  117. /* This adds the immediate flag to the pkg and recursively to the
  118. dependendies
  119. */
  120. void pkgPackageManager::ImmediateAdd(PkgIterator I, bool UseInstallVer, unsigned const int &Depth)
  121. {
  122. DepIterator D;
  123. if(UseInstallVer)
  124. {
  125. if(Cache[I].InstallVer == 0)
  126. return;
  127. D = Cache[I].InstVerIter(Cache).DependsList();
  128. } else {
  129. if (I->CurrentVer == 0)
  130. return;
  131. D = I.CurrentVer().DependsList();
  132. }
  133. for ( /* nothing */ ; D.end() == false; ++D)
  134. if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends)
  135. {
  136. if(!List->IsFlag(D.TargetPkg(), pkgOrderList::Immediate))
  137. {
  138. if(Debug)
  139. clog << OutputInDepth(Depth) << "ImmediateAdd(): Adding Immediate flag to " << D.TargetPkg() << " cause of " << D.DepType() << " " << I.FullName() << endl;
  140. List->Flag(D.TargetPkg(),pkgOrderList::Immediate);
  141. ImmediateAdd(D.TargetPkg(), UseInstallVer, Depth + 1);
  142. }
  143. }
  144. return;
  145. }
  146. /*}}}*/
  147. // PM::CreateOrderList - Create the ordering class /*{{{*/
  148. // ---------------------------------------------------------------------
  149. /* This populates the ordering list with all the packages that are
  150. going to change. */
  151. bool pkgPackageManager::CreateOrderList()
  152. {
  153. if (List != 0)
  154. return true;
  155. delete List;
  156. List = new pkgOrderList(&Cache);
  157. if (Debug && ImmConfigureAll)
  158. clog << "CreateOrderList(): Adding Immediate flag for all packages because of APT::Immediate-Configure-All" << endl;
  159. // Generate the list of affected packages and sort it
  160. for (PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
  161. {
  162. // Ignore no-version packages
  163. if (I->VersionList == 0)
  164. continue;
  165. // Mark the package and its dependends for immediate configuration
  166. if ((((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) &&
  167. NoImmConfigure == false) || ImmConfigureAll)
  168. {
  169. if(Debug && !ImmConfigureAll)
  170. clog << "CreateOrderList(): Adding Immediate flag for " << I.FullName() << endl;
  171. List->Flag(I,pkgOrderList::Immediate);
  172. if (!ImmConfigureAll) {
  173. // Look for other install packages to make immediate configurea
  174. ImmediateAdd(I, true);
  175. // And again with the current version.
  176. ImmediateAdd(I, false);
  177. }
  178. }
  179. // Not interesting
  180. if ((Cache[I].Keep() == true ||
  181. Cache[I].InstVerIter(Cache) == I.CurrentVer()) &&
  182. I.State() == pkgCache::PkgIterator::NeedsNothing &&
  183. (Cache[I].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall &&
  184. (I.Purge() != false || Cache[I].Mode != pkgDepCache::ModeDelete ||
  185. (Cache[I].iFlags & pkgDepCache::Purge) != pkgDepCache::Purge))
  186. continue;
  187. // Append it to the list
  188. List->push_back(I);
  189. }
  190. return true;
  191. }
  192. /*}}}*/
  193. // PM::DepAlwaysTrue - Returns true if this dep is irrelevant /*{{{*/
  194. // ---------------------------------------------------------------------
  195. /* The restriction on provides is to eliminate the case when provides
  196. are transitioning between valid states [ie exim to smail] */
  197. bool pkgPackageManager::DepAlwaysTrue(DepIterator D)
  198. {
  199. if (D.TargetPkg()->ProvidesList != 0)
  200. return false;
  201. if ((Cache[D] & pkgDepCache::DepInstall) != 0 &&
  202. (Cache[D] & pkgDepCache::DepNow) != 0)
  203. return true;
  204. return false;
  205. }
  206. /*}}}*/
  207. // PM::CheckRConflicts - Look for reverse conflicts /*{{{*/
  208. // ---------------------------------------------------------------------
  209. /* This looks over the reverses for a conflicts line that needs early
  210. removal. */
  211. bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D,
  212. const char *Ver)
  213. {
  214. for (;D.end() == false; ++D)
  215. {
  216. if (D->Type != pkgCache::Dep::Conflicts &&
  217. D->Type != pkgCache::Dep::Obsoletes)
  218. continue;
  219. // The package hasn't been changed
  220. if (List->IsNow(Pkg) == false)
  221. continue;
  222. // Ignore self conflicts, ignore conflicts from irrelevant versions
  223. if (D.IsIgnorable(Pkg) || D.ParentVer() != D.ParentPkg().CurrentVer())
  224. continue;
  225. if (Cache.VS().CheckDep(Ver,D->CompareOp,D.TargetVer()) == false)
  226. continue;
  227. if (EarlyRemove(D.ParentPkg(), &D) == false)
  228. return _error->Error("Reverse conflicts early remove for package '%s' failed",
  229. Pkg.FullName().c_str());
  230. }
  231. return true;
  232. }
  233. /*}}}*/
  234. // PM::CheckRBreaks - Look for reverse breaks /*{{{*/
  235. bool pkgPackageManager::CheckRBreaks(PkgIterator const &Pkg, DepIterator D,
  236. const char * const Ver)
  237. {
  238. for (;D.end() == false; ++D)
  239. {
  240. if (D->Type != pkgCache::Dep::DpkgBreaks)
  241. continue;
  242. PkgIterator const DP = D.ParentPkg();
  243. if (Cache[DP].Delete() == false)
  244. continue;
  245. // Ignore self conflicts, ignore conflicts from irrelevant versions
  246. if (D.IsIgnorable(Pkg) || D.ParentVer() != DP.CurrentVer())
  247. continue;
  248. if (Cache.VS().CheckDep(Ver, D->CompareOp, D.TargetVer()) == false)
  249. continue;
  250. // no earlyremove() here as user has already agreed to the permanent removal
  251. if (SmartRemove(DP) == false)
  252. return _error->Error("Internal Error, Could not early remove %s (%d)",DP.FullName().c_str(), 4);
  253. }
  254. return true;
  255. }
  256. /*}}}*/
  257. // PM::ConfigureAll - Run the all out configuration /*{{{*/
  258. // ---------------------------------------------------------------------
  259. /* This configures every package. It is assumed they are all unpacked and
  260. that the final configuration is valid. This is also used to catch packages
  261. that have not been configured when using ImmConfigureAll */
  262. bool pkgPackageManager::ConfigureAll()
  263. {
  264. pkgOrderList OList(&Cache);
  265. // Populate the order list
  266. for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
  267. if (List->IsFlag(pkgCache::PkgIterator(Cache,*I),
  268. pkgOrderList::UnPacked) == true)
  269. OList.push_back(*I);
  270. if (OList.OrderConfigure() == false)
  271. return false;
  272. std::string const conf = _config->Find("PackageManager::Configure","all");
  273. bool const ConfigurePkgs = (conf == "all");
  274. // Perform the configuring
  275. for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I)
  276. {
  277. PkgIterator Pkg(Cache,*I);
  278. /* Check if the package has been configured, this can happen if SmartConfigure
  279. calls its self */
  280. if (List->IsFlag(Pkg,pkgOrderList::Configured)) continue;
  281. if (ConfigurePkgs == true && SmartConfigure(Pkg, 0) == false) {
  282. if (ImmConfigureAll)
  283. _error->Error(_("Could not perform immediate configuration on '%s'. "
  284. "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.FullName().c_str(),1);
  285. else
  286. _error->Error("Internal error, packages left unconfigured. %s",Pkg.FullName().c_str());
  287. return false;
  288. }
  289. List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States);
  290. }
  291. return true;
  292. }
  293. /*}}}*/
  294. // PM::NonLoopingSmart - helper to avoid loops while calling Smart methods /*{{{*/
  295. // -----------------------------------------------------------------------
  296. /* ensures that a loop of the form A depends B, B depends A (and similar)
  297. is not leading us down into infinite recursion segfault land */
  298. bool pkgPackageManager::NonLoopingSmart(SmartAction const action, pkgCache::PkgIterator &Pkg,
  299. pkgCache::PkgIterator DepPkg, int const Depth, bool const PkgLoop,
  300. bool * const Bad, bool * const Changed)
  301. {
  302. if (PkgLoop == false)
  303. List->Flag(Pkg,pkgOrderList::Loop);
  304. bool success = false;
  305. switch(action)
  306. {
  307. case UNPACK_IMMEDIATE: success = SmartUnPack(DepPkg, true, Depth + 1); break;
  308. case UNPACK: success = SmartUnPack(DepPkg, false, Depth + 1); break;
  309. case CONFIGURE: success = SmartConfigure(DepPkg, Depth + 1); break;
  310. }
  311. if (PkgLoop == false)
  312. List->RmFlag(Pkg,pkgOrderList::Loop);
  313. if (success == false)
  314. return false;
  315. if (Bad != NULL)
  316. *Bad = false;
  317. if (Changed != NULL && List->IsFlag(DepPkg,pkgOrderList::Loop) == false)
  318. *Changed = true;
  319. return true;
  320. }
  321. /*}}}*/
  322. // PM::SmartConfigure - Perform immediate configuration of the pkg /*{{{*/
  323. // ---------------------------------------------------------------------
  324. /* This function tries to put the system in a state where Pkg can be configured.
  325. This involves checking each of Pkg's dependencies and unpacking and
  326. configuring packages where needed. */
  327. bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
  328. {
  329. // If this is true, only check and correct and dependencies without the Loop flag
  330. bool const PkgLoop = List->IsFlag(Pkg,pkgOrderList::Loop);
  331. if (Debug) {
  332. VerIterator InstallVer = VerIterator(Cache,Cache[Pkg].InstallVer);
  333. clog << OutputInDepth(Depth) << "SmartConfigure " << Pkg.FullName() << " (" << InstallVer.VerStr() << ")";
  334. if (PkgLoop)
  335. clog << " (Only Correct Dependencies)";
  336. clog << endl;
  337. }
  338. VerIterator const instVer = Cache[Pkg].InstVerIter(Cache);
  339. /* Because of the ordered list, most dependencies should be unpacked,
  340. however if there is a loop (A depends on B, B depends on A) this will not
  341. be the case, so check for dependencies before configuring. */
  342. bool Bad = false, Changed = false;
  343. const unsigned int max_loops = _config->FindI("APT::pkgPackageManager::MaxLoopCount", 5000);
  344. unsigned int i=0;
  345. std::list<DepIterator> needConfigure;
  346. do
  347. {
  348. // Check each dependency and see if anything needs to be done
  349. // so that it can be configured
  350. Changed = false;
  351. for (DepIterator D = instVer.DependsList(); D.end() == false; )
  352. {
  353. // Compute a single dependency element (glob or)
  354. pkgCache::DepIterator Start, End;
  355. D.GlobOr(Start,End);
  356. if (End->Type != pkgCache::Dep::Depends)
  357. continue;
  358. Bad = true;
  359. // the first pass checks if we its all good, i.e. if we have
  360. // to do anything at all
  361. for (DepIterator Cur = Start; true; ++Cur)
  362. {
  363. std::unique_ptr<Version *> VList(Cur.AllTargets());
  364. for (Version **I = VList.get(); *I != 0; ++I)
  365. {
  366. VerIterator Ver(Cache,*I);
  367. PkgIterator DepPkg = Ver.ParentPkg();
  368. // Check if the current version of the package is available and will satisfy this dependency
  369. if (DepPkg.CurrentVer() == Ver && List->IsNow(DepPkg) == true &&
  370. List->IsFlag(DepPkg,pkgOrderList::Removed) == false &&
  371. DepPkg.State() == PkgIterator::NeedsNothing &&
  372. (Cache[DepPkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)
  373. {
  374. Bad = false;
  375. break;
  376. }
  377. // Check if the version that is going to be installed will satisfy the dependency
  378. if (Cache[DepPkg].InstallVer != *I || List->IsNow(DepPkg) == false)
  379. continue;
  380. if (PkgLoop == true)
  381. {
  382. if (Debug)
  383. std::clog << OutputInDepth(Depth) << "Package " << Pkg << " loops in SmartConfigure";
  384. if (List->IsFlag(DepPkg,pkgOrderList::UnPacked))
  385. Bad = false;
  386. else if (Debug)
  387. std::clog << ", but it isn't unpacked yet";
  388. if (Debug)
  389. std::clog << std::endl;
  390. }
  391. }
  392. if (Cur == End || Bad == false)
  393. break;
  394. }
  395. // this dependency is in a good state, so we can stop
  396. if (Bad == false)
  397. {
  398. if (Debug)
  399. std::clog << OutputInDepth(Depth) << "Found ok dep " << Start.TargetPkg() << std::endl;
  400. continue;
  401. }
  402. // Check for dependencies that have not been unpacked,
  403. // probably due to loops.
  404. for (DepIterator Cur = Start; true; ++Cur)
  405. {
  406. std::unique_ptr<Version *> VList(Cur.AllTargets());
  407. for (Version **I = VList.get(); *I != 0; ++I)
  408. {
  409. VerIterator Ver(Cache,*I);
  410. PkgIterator DepPkg = Ver.ParentPkg();
  411. // Check if the current version of the package is available and will satisfy this dependency
  412. if (DepPkg.CurrentVer() == Ver && List->IsNow(DepPkg) == true &&
  413. List->IsFlag(DepPkg,pkgOrderList::Removed) == false &&
  414. DepPkg.State() == PkgIterator::NeedsNothing &&
  415. (Cache[DepPkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)
  416. continue;
  417. // Check if the version that is going to be installed will satisfy the dependency
  418. if (Cache[DepPkg].InstallVer != *I || List->IsNow(DepPkg) == false)
  419. continue;
  420. if (PkgLoop == true)
  421. {
  422. if (Debug)
  423. std::clog << OutputInDepth(Depth) << "Package " << Pkg << " loops in SmartConfigure";
  424. if (List->IsFlag(DepPkg,pkgOrderList::UnPacked))
  425. Bad = false;
  426. else if (Debug)
  427. std::clog << ", but it isn't unpacked yet";
  428. if (Debug)
  429. std::clog << std::endl;
  430. }
  431. else
  432. {
  433. if (Debug)
  434. clog << OutputInDepth(Depth) << "Unpacking " << DepPkg.FullName() << " to avoid loop " << Cur << endl;
  435. if (NonLoopingSmart(UNPACK_IMMEDIATE, Pkg, DepPkg, Depth, PkgLoop, &Bad, &Changed) == false)
  436. return false;
  437. }
  438. // at this point we either unpacked a Dep or we are in a loop,
  439. // no need to unpack a second one
  440. break;
  441. }
  442. if (Cur == End || Bad == false)
  443. break;
  444. }
  445. if (Bad == false)
  446. continue;
  447. needConfigure.push_back(Start);
  448. }
  449. if (i++ > max_loops)
  450. return _error->Error("Internal error: MaxLoopCount reached in SmartUnPack (1) for %s, aborting", Pkg.FullName().c_str());
  451. } while (Changed == true);
  452. // now go over anything that needs configuring
  453. Bad = false, Changed = false, i = 0;
  454. do
  455. {
  456. Changed = false;
  457. for (std::list<DepIterator>::const_iterator D = needConfigure.begin(); D != needConfigure.end(); ++D)
  458. {
  459. // Compute a single dependency element (glob or) without modifying D
  460. pkgCache::DepIterator Start, End;
  461. {
  462. pkgCache::DepIterator Discard = *D;
  463. Discard.GlobOr(Start,End);
  464. }
  465. if (End->Type != pkgCache::Dep::Depends)
  466. continue;
  467. Bad = true;
  468. // Search for dependencies which are unpacked but aren't configured yet (maybe loops)
  469. for (DepIterator Cur = Start; true; ++Cur)
  470. {
  471. std::unique_ptr<Version *> VList(Cur.AllTargets());
  472. for (Version **I = VList.get(); *I != 0; ++I)
  473. {
  474. VerIterator Ver(Cache,*I);
  475. PkgIterator DepPkg = Ver.ParentPkg();
  476. // Check if the version that is going to be installed will satisfy the dependency
  477. if (Cache[DepPkg].InstallVer != *I)
  478. continue;
  479. if (List->IsFlag(DepPkg,pkgOrderList::UnPacked))
  480. {
  481. if (List->IsFlag(DepPkg,pkgOrderList::Loop) && PkgLoop)
  482. {
  483. // This dependency has already been dealt with by another SmartConfigure on Pkg
  484. Bad = false;
  485. break;
  486. }
  487. if (Debug)
  488. std::clog << OutputInDepth(Depth) << "Configure already unpacked " << DepPkg << std::endl;
  489. if (NonLoopingSmart(CONFIGURE, Pkg, DepPkg, Depth, PkgLoop, &Bad, &Changed) == false)
  490. return false;
  491. break;
  492. }
  493. else if (List->IsFlag(DepPkg,pkgOrderList::Configured))
  494. {
  495. Bad = false;
  496. break;
  497. }
  498. }
  499. if (Cur == End || Bad == false)
  500. break;
  501. }
  502. if (Bad == true && Changed == false && Debug == true)
  503. std::clog << OutputInDepth(Depth) << "Could not satisfy " << *D << std::endl;
  504. }
  505. if (i++ > max_loops)
  506. return _error->Error("Internal error: MaxLoopCount reached in SmartUnPack (2) for %s, aborting", Pkg.FullName().c_str());
  507. } while (Changed == true);
  508. if (Bad == true)
  509. return _error->Error(_("Could not configure '%s'. "),Pkg.FullName().c_str());
  510. // Check for reverse conflicts.
  511. if (CheckRBreaks(Pkg,Pkg.RevDependsList(), instVer.VerStr()) == false)
  512. return false;
  513. for (PrvIterator P = instVer.ProvidesList(); P.end() == false; ++P)
  514. if (Pkg->Group != P.OwnerPkg()->Group)
  515. CheckRBreaks(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion());
  516. if (PkgLoop) return true;
  517. static std::string const conf = _config->Find("PackageManager::Configure","all");
  518. static bool const ConfigurePkgs = (conf == "all" || conf == "smart");
  519. if (List->IsFlag(Pkg,pkgOrderList::Configured))
  520. return _error->Error("Internal configure error on '%s'.", Pkg.FullName().c_str());
  521. if (ConfigurePkgs == true && Configure(Pkg) == false)
  522. return false;
  523. List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States);
  524. if ((Cache[Pkg].InstVerIter(Cache)->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same)
  525. for (PkgIterator P = Pkg.Group().PackageList();
  526. P.end() == false; P = Pkg.Group().NextPkg(P))
  527. {
  528. if (Pkg == P || List->IsFlag(P,pkgOrderList::Configured) == true ||
  529. List->IsFlag(P,pkgOrderList::UnPacked) == false ||
  530. Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer &&
  531. (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall))
  532. continue;
  533. if (SmartConfigure(P, (Depth +1)) == false)
  534. return false;
  535. }
  536. // Sanity Check
  537. if (List->IsFlag(Pkg,pkgOrderList::Configured) == false)
  538. return _error->Error(_("Could not configure '%s'. "),Pkg.FullName().c_str());
  539. return true;
  540. }
  541. /*}}}*/
  542. // PM::EarlyRemove - Perform removal of packages before their time /*{{{*/
  543. // ---------------------------------------------------------------------
  544. /* This is called to deal with conflicts arising from unpacking */
  545. bool pkgPackageManager::EarlyRemove(PkgIterator Pkg)
  546. {
  547. return EarlyRemove(Pkg, NULL);
  548. }
  549. bool pkgPackageManager::EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep)
  550. {
  551. if (List->IsNow(Pkg) == false)
  552. return true;
  553. // Already removed it
  554. if (List->IsFlag(Pkg,pkgOrderList::Removed) == true)
  555. return true;
  556. // Woops, it will not be re-installed!
  557. if (List->IsFlag(Pkg,pkgOrderList::InList) == false)
  558. return false;
  559. // these breaks on M-A:same packages can be dealt with. They 'loop' by design
  560. if (Dep != NULL && (*Dep)->Type == pkgCache::Dep::DpkgBreaks && Dep->IsMultiArchImplicit() == true)
  561. return true;
  562. // Essential packages get special treatment
  563. bool IsEssential = false;
  564. if ((Pkg->Flags & pkgCache::Flag::Essential) != 0 ||
  565. (Pkg->Flags & pkgCache::Flag::Important) != 0)
  566. IsEssential = true;
  567. /* Check for packages that are the dependents of essential packages and
  568. promote them too */
  569. if (Pkg->CurrentVer != 0)
  570. {
  571. for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false &&
  572. IsEssential == false; ++D)
  573. if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends)
  574. if ((D.ParentPkg()->Flags & pkgCache::Flag::Essential) != 0 ||
  575. (D.ParentPkg()->Flags & pkgCache::Flag::Important) != 0)
  576. IsEssential = true;
  577. }
  578. if (IsEssential == true)
  579. {
  580. if (_config->FindB("APT::Force-LoopBreak",false) == false)
  581. return _error->Error(_("This installation run will require temporarily "
  582. "removing the essential package %s due to a "
  583. "Conflicts/Pre-Depends loop. This is often bad, "
  584. "but if you really want to do it, activate the "
  585. "APT::Force-LoopBreak option."),Pkg.FullName().c_str());
  586. }
  587. // dpkg will auto-deconfigure it, no need for the big remove hammer
  588. else if (Dep != NULL && (*Dep)->Type == pkgCache::Dep::DpkgBreaks)
  589. return true;
  590. bool Res = SmartRemove(Pkg);
  591. if (Cache[Pkg].Delete() == false)
  592. List->Flag(Pkg,pkgOrderList::Removed,pkgOrderList::States);
  593. return Res;
  594. }
  595. /*}}}*/
  596. // PM::SmartRemove - Removal Helper /*{{{*/
  597. // ---------------------------------------------------------------------
  598. /* */
  599. bool pkgPackageManager::SmartRemove(PkgIterator Pkg)
  600. {
  601. if (List->IsNow(Pkg) == false)
  602. return true;
  603. List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States);
  604. return Remove(Pkg,(Cache[Pkg].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge);
  605. }
  606. /*}}}*/
  607. // PM::SmartUnPack - Install helper /*{{{*/
  608. // ---------------------------------------------------------------------
  609. /* This puts the system in a state where it can Unpack Pkg, if Pkg is already
  610. unpacked, or when it has been unpacked, if Immediate==true it configures it. */
  611. bool pkgPackageManager::SmartUnPack(PkgIterator Pkg)
  612. {
  613. return SmartUnPack(Pkg, true, 0);
  614. }
  615. bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth)
  616. {
  617. bool PkgLoop = List->IsFlag(Pkg,pkgOrderList::Loop);
  618. if (Debug) {
  619. clog << OutputInDepth(Depth) << "SmartUnPack " << Pkg.FullName();
  620. VerIterator InstallVer = VerIterator(Cache,Cache[Pkg].InstallVer);
  621. if (Pkg.CurrentVer() == 0)
  622. clog << " (install version " << InstallVer.VerStr() << ")";
  623. else
  624. clog << " (replace version " << Pkg.CurrentVer().VerStr() << " with " << InstallVer.VerStr() << ")";
  625. if (PkgLoop)
  626. clog << " (Only Perform PreUnpack Checks)";
  627. if (Immediate)
  628. clog << " immediately";
  629. clog << endl;
  630. }
  631. VerIterator const instVer = Cache[Pkg].InstVerIter(Cache);
  632. /* PreUnpack Checks: This loop checks and attempts to rectify any problems that would prevent the package being unpacked.
  633. It addresses: PreDepends, Conflicts, Obsoletes and Breaks (DpkgBreaks). Any resolutions that do not require it should
  634. avoid configuration (calling SmartUnpack with Immediate=true), this is because when unpacking some packages with
  635. complex dependency structures, trying to configure some packages while breaking the loops can complicate things.
  636. This will be either dealt with if the package is configured as a dependency of Pkg (if and when Pkg is configured),
  637. or by the ConfigureAll call at the end of the for loop in OrderInstall. */
  638. bool SomethingBad = false, Changed = false;
  639. bool couldBeTemporaryRemoved = Depth != 0 && List->IsFlag(Pkg,pkgOrderList::Removed) == false;
  640. const unsigned int max_loops = _config->FindI("APT::pkgPackageManager::MaxLoopCount", 5000);
  641. unsigned int i = 0;
  642. do
  643. {
  644. Changed = false;
  645. for (DepIterator D = instVer.DependsList(); D.end() == false; )
  646. {
  647. // Compute a single dependency element (glob or)
  648. pkgCache::DepIterator Start, End;
  649. D.GlobOr(Start,End);
  650. if (End->Type == pkgCache::Dep::PreDepends)
  651. {
  652. bool Bad = true;
  653. if (Debug)
  654. clog << OutputInDepth(Depth) << "PreDepends order for " << Pkg.FullName() << std::endl;
  655. // Look for easy targets: packages that are already okay
  656. for (DepIterator Cur = Start; Bad == true; ++Cur)
  657. {
  658. std::unique_ptr<Version *> VList(Cur.AllTargets());
  659. for (Version **I = VList.get(); *I != 0; ++I)
  660. {
  661. VerIterator Ver(Cache,*I);
  662. PkgIterator Pkg = Ver.ParentPkg();
  663. // See if the current version is ok
  664. if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true &&
  665. Pkg.State() == PkgIterator::NeedsNothing &&
  666. (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)
  667. {
  668. Bad = false;
  669. if (Debug)
  670. clog << OutputInDepth(Depth) << "Found ok package " << Pkg.FullName() << endl;
  671. break;
  672. }
  673. }
  674. if (Cur == End)
  675. break;
  676. }
  677. // Look for something that could be configured.
  678. for (DepIterator Cur = Start; Bad == true && Cur.end() == false; ++Cur)
  679. {
  680. std::unique_ptr<Version *[]> VList(Cur.AllTargets());
  681. for (Version **I = VList.get(); *I != 0; ++I)
  682. {
  683. VerIterator Ver(Cache,*I);
  684. PkgIterator DepPkg = Ver.ParentPkg();
  685. // Not the install version
  686. if (Cache[DepPkg].InstallVer != *I)
  687. continue;
  688. if (Cache[DepPkg].Keep() == true && DepPkg.State() == PkgIterator::NeedsNothing &&
  689. (Cache[DepPkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)
  690. continue;
  691. if (List->IsFlag(DepPkg,pkgOrderList::Configured))
  692. {
  693. Bad = false;
  694. break;
  695. }
  696. // check if it needs unpack or if if configure is enough
  697. if (List->IsFlag(DepPkg,pkgOrderList::UnPacked) == false)
  698. {
  699. // two packages pre-depending on each other can't be handled sanely
  700. if (List->IsFlag(DepPkg,pkgOrderList::Loop) && PkgLoop)
  701. {
  702. // this isn't an error as there is potential for something else to satisfy it
  703. // (like a provides or an or-group member)
  704. if (Debug)
  705. clog << OutputInDepth(Depth) << "Unpack loop detected between " << DepPkg.FullName() << " and " << Pkg.FullName() << endl;
  706. continue;
  707. }
  708. if (Debug)
  709. clog << OutputInDepth(Depth) << "Trying to SmartUnpack " << DepPkg.FullName() << endl;
  710. if (NonLoopingSmart(UNPACK_IMMEDIATE, Pkg, DepPkg, Depth, PkgLoop, &Bad, &Changed) == false)
  711. return false;
  712. }
  713. else
  714. {
  715. if (Debug)
  716. clog << OutputInDepth(Depth) << "Trying to SmartConfigure " << DepPkg.FullName() << endl;
  717. if (NonLoopingSmart(CONFIGURE, Pkg, DepPkg, Depth, PkgLoop, &Bad, &Changed) == false)
  718. return false;
  719. }
  720. break;
  721. }
  722. }
  723. if (Bad == true)
  724. SomethingBad = true;
  725. }
  726. else if (End->Type == pkgCache::Dep::Conflicts ||
  727. End->Type == pkgCache::Dep::Obsoletes ||
  728. End->Type == pkgCache::Dep::DpkgBreaks)
  729. {
  730. std::unique_ptr<Version *[]> VList(End.AllTargets());
  731. for (Version **I = VList.get(); *I != 0; ++I)
  732. {
  733. VerIterator Ver(Cache,*I);
  734. PkgIterator ConflictPkg = Ver.ParentPkg();
  735. if (ConflictPkg.CurrentVer() != Ver)
  736. {
  737. if (Debug)
  738. std::clog << OutputInDepth(Depth) << "Ignore not-installed version " << Ver.VerStr() << " of " << ConflictPkg.FullName() << " for " << End << std::endl;
  739. continue;
  740. }
  741. if (List->IsNow(ConflictPkg) == false)
  742. {
  743. if (Debug)
  744. std::clog << OutputInDepth(Depth) << "Ignore already dealt-with version " << Ver.VerStr() << " of " << ConflictPkg.FullName() << " for " << End << std::endl;
  745. continue;
  746. }
  747. if (List->IsFlag(ConflictPkg,pkgOrderList::Removed) == true)
  748. {
  749. if (Debug)
  750. clog << OutputInDepth(Depth) << "Ignoring " << End << " as " << ConflictPkg.FullName() << "was temporarily removed" << endl;
  751. continue;
  752. }
  753. if (List->IsFlag(ConflictPkg,pkgOrderList::Loop) && PkgLoop)
  754. {
  755. if (End->Type == pkgCache::Dep::DpkgBreaks && End.IsMultiArchImplicit() == true)
  756. {
  757. if (Debug)
  758. clog << OutputInDepth(Depth) << "Because dependency is MultiArchImplicit we ignored looping on: " << ConflictPkg << endl;
  759. continue;
  760. }
  761. if (Debug)
  762. {
  763. if (End->Type == pkgCache::Dep::DpkgBreaks)
  764. clog << OutputInDepth(Depth) << "Because of breaks knot, deconfigure " << ConflictPkg.FullName() << " temporarily" << endl;
  765. else
  766. clog << OutputInDepth(Depth) << "Because of conflict knot, removing " << ConflictPkg.FullName() << " temporarily" << endl;
  767. }
  768. if (EarlyRemove(ConflictPkg, &End) == false)
  769. return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 3);
  770. SomethingBad = true;
  771. continue;
  772. }
  773. if (Cache[ConflictPkg].Delete() == false)
  774. {
  775. if (Debug)
  776. {
  777. clog << OutputInDepth(Depth) << "Unpacking " << ConflictPkg.FullName() << " to avoid " << End;
  778. if (PkgLoop == true)
  779. clog << " (Looping)";
  780. clog << std::endl;
  781. }
  782. // we would like to avoid temporary removals and all that at best via a simple unpack
  783. _error->PushToStack();
  784. if (NonLoopingSmart(UNPACK, Pkg, ConflictPkg, Depth, PkgLoop, NULL, &Changed) == false)
  785. {
  786. // but if it fails ignore this failure and look for alternative ways of solving
  787. if (Debug)
  788. {
  789. clog << OutputInDepth(Depth) << "Avoidance unpack of " << ConflictPkg.FullName() << " failed for " << End << " ignoring:" << std::endl;
  790. _error->DumpErrors(std::clog, GlobalError::DEBUG, false);
  791. }
  792. _error->RevertToStack();
  793. // ignorance can only happen if a) one of the offenders is already gone
  794. if (List->IsFlag(ConflictPkg,pkgOrderList::Removed) == true)
  795. {
  796. if (Debug)
  797. clog << OutputInDepth(Depth) << "But " << ConflictPkg.FullName() << " was temporarily removed in the meantime to satisfy " << End << endl;
  798. }
  799. else if (List->IsFlag(Pkg,pkgOrderList::Removed) == true)
  800. {
  801. if (Debug)
  802. clog << OutputInDepth(Depth) << "But " << Pkg.FullName() << " was temporarily removed in the meantime to satisfy " << End << endl;
  803. }
  804. // or b) we can make one go (removal or dpkg auto-deconfigure)
  805. else
  806. {
  807. if (Debug)
  808. clog << OutputInDepth(Depth) << "So temprorary remove/deconfigure " << ConflictPkg.FullName() << " to satisfy " << End << endl;
  809. if (EarlyRemove(ConflictPkg, &End) == false)
  810. return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 2);
  811. }
  812. }
  813. else
  814. _error->MergeWithStack();
  815. }
  816. else
  817. {
  818. if (Debug)
  819. clog << OutputInDepth(Depth) << "Removing " << ConflictPkg.FullName() << " now to avoid " << End << endl;
  820. // no earlyremove() here as user has already agreed to the permanent removal
  821. if (SmartRemove(Pkg) == false)
  822. return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 1);
  823. }
  824. }
  825. }
  826. }
  827. if (i++ > max_loops)
  828. return _error->Error("Internal error: APT::pkgPackageManager::MaxLoopCount reached in SmartConfigure for %s, aborting", Pkg.FullName().c_str());
  829. } while (Changed == true);
  830. if (SomethingBad == true)
  831. return _error->Error("Couldn't configure %s, probably a dependency cycle.", Pkg.FullName().c_str());
  832. if (couldBeTemporaryRemoved == true && List->IsFlag(Pkg,pkgOrderList::Removed) == true)
  833. {
  834. if (Debug)
  835. std::clog << OutputInDepth(Depth) << "Prevent unpack as " << Pkg << " is currently temporarily removed" << std::endl;
  836. return true;
  837. }
  838. // Check for reverse conflicts.
  839. if (CheckRConflicts(Pkg,Pkg.RevDependsList(),
  840. instVer.VerStr()) == false)
  841. return false;
  842. for (PrvIterator P = instVer.ProvidesList();
  843. P.end() == false; ++P)
  844. if (Pkg->Group != P.OwnerPkg()->Group)
  845. CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion());
  846. if (PkgLoop)
  847. return true;
  848. List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States);
  849. if (Immediate == true && (instVer->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same)
  850. {
  851. /* Do lockstep M-A:same unpacking in two phases:
  852. First unpack all installed architectures, then the not installed.
  853. This way we avoid that M-A: enabled packages are installed before
  854. their older non-M-A enabled packages are replaced by newer versions */
  855. bool const installed = Pkg->CurrentVer != 0;
  856. if (installed == true &&
  857. (instVer != Pkg.CurrentVer() ||
  858. ((Cache[Pkg].iFlags & pkgDepCache::ReInstall) == pkgDepCache::ReInstall)) &&
  859. Install(Pkg,FileNames[Pkg->ID]) == false)
  860. return false;
  861. for (PkgIterator P = Pkg.Group().PackageList();
  862. P.end() == false; P = Pkg.Group().NextPkg(P))
  863. {
  864. if (P->CurrentVer == 0 || P == Pkg || List->IsFlag(P,pkgOrderList::UnPacked) == true ||
  865. Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer &&
  866. (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall))
  867. continue;
  868. if (SmartUnPack(P, false, Depth + 1) == false)
  869. return false;
  870. }
  871. if (installed == false && Install(Pkg,FileNames[Pkg->ID]) == false)
  872. return false;
  873. for (PkgIterator P = Pkg.Group().PackageList();
  874. P.end() == false; P = Pkg.Group().NextPkg(P))
  875. {
  876. if (P->CurrentVer != 0 || P == Pkg || List->IsFlag(P,pkgOrderList::UnPacked) == true ||
  877. List->IsFlag(P,pkgOrderList::Configured) == true ||
  878. Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer &&
  879. (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall))
  880. continue;
  881. if (SmartUnPack(P, false, Depth + 1) == false)
  882. return false;
  883. }
  884. }
  885. // packages which are already unpacked don't need to be unpacked again
  886. else if ((instVer != Pkg.CurrentVer() ||
  887. ((Cache[Pkg].iFlags & pkgDepCache::ReInstall) == pkgDepCache::ReInstall)) &&
  888. Install(Pkg,FileNames[Pkg->ID]) == false)
  889. return false;
  890. if (Immediate == true) {
  891. // Perform immedate configuration of the package.
  892. if (SmartConfigure(Pkg, Depth + 1) == false)
  893. _error->Error(_("Could not perform immediate configuration on '%s'. "
  894. "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.FullName().c_str(),2);
  895. }
  896. return true;
  897. }
  898. /*}}}*/
  899. // PM::OrderInstall - Installation ordering routine /*{{{*/
  900. // ---------------------------------------------------------------------
  901. /* */
  902. pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
  903. {
  904. if (CreateOrderList() == false)
  905. return Failed;
  906. Reset();
  907. if (Debug == true)
  908. clog << "Beginning to order" << endl;
  909. bool const ordering =
  910. _config->FindB("PackageManager::UnpackAll",true) ?
  911. List->OrderUnpack(FileNames) : List->OrderCritical();
  912. if (ordering == false)
  913. {
  914. _error->Error("Internal ordering error");
  915. return Failed;
  916. }
  917. if (Debug == true)
  918. clog << "Done ordering" << endl;
  919. bool DoneSomething = false;
  920. for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
  921. {
  922. PkgIterator Pkg(Cache,*I);
  923. if (List->IsNow(Pkg) == false)
  924. {
  925. if (Debug == true)
  926. clog << "Skipping already done " << Pkg.FullName() << endl;
  927. continue;
  928. }
  929. if (List->IsMissing(Pkg) == true)
  930. {
  931. if (Debug == true)
  932. clog << "Sequence completed at " << Pkg.FullName() << endl;
  933. if (DoneSomething == false)
  934. {
  935. _error->Error("Internal Error, ordering was unable to handle the media swap");
  936. return Failed;
  937. }
  938. return Incomplete;
  939. }
  940. // Sanity check
  941. if (Cache[Pkg].Keep() == true &&
  942. Pkg.State() == pkgCache::PkgIterator::NeedsNothing &&
  943. (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)
  944. {
  945. _error->Error("Internal Error, trying to manipulate a kept package (%s)",Pkg.FullName().c_str());
  946. return Failed;
  947. }
  948. // Perform a delete or an install
  949. if (Cache[Pkg].Delete() == true)
  950. {
  951. if (SmartRemove(Pkg) == false)
  952. return Failed;
  953. }
  954. else
  955. if (SmartUnPack(Pkg,List->IsFlag(Pkg,pkgOrderList::Immediate),0) == false)
  956. return Failed;
  957. DoneSomething = true;
  958. if (ImmConfigureAll) {
  959. /* ConfigureAll here to pick up and packages left unconfigured because they were unpacked in the
  960. "PreUnpack Checks" section */
  961. if (!ConfigureAll())
  962. return Failed;
  963. }
  964. }
  965. // Final run through the configure phase
  966. if (ConfigureAll() == false)
  967. return Failed;
  968. // Sanity check
  969. for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
  970. {
  971. if (List->IsFlag(*I,pkgOrderList::Configured) == false)
  972. {
  973. _error->Error("Internal error, packages left unconfigured. %s",
  974. PkgIterator(Cache,*I).FullName().c_str());
  975. return Failed;
  976. }
  977. }
  978. return Completed;
  979. }
  980. // PM::DoInstallPostFork - compat /*{{{*/
  981. // ---------------------------------------------------------------------
  982. /*}}}*/
  983. pkgPackageManager::OrderResult
  984. pkgPackageManager::DoInstallPostFork(int statusFd)
  985. {
  986. APT::Progress::PackageManager *progress = new
  987. APT::Progress::PackageManagerProgressFd(statusFd);
  988. pkgPackageManager::OrderResult res = DoInstallPostFork(progress);
  989. delete progress;
  990. return res;
  991. }
  992. /*}}}*/
  993. // PM::DoInstallPostFork - Does install part that happens after the fork /*{{{*/
  994. // ---------------------------------------------------------------------
  995. pkgPackageManager::OrderResult
  996. pkgPackageManager::DoInstallPostFork(APT::Progress::PackageManager *progress)
  997. {
  998. bool goResult = Go(progress);
  999. if(goResult == false)
  1000. return Failed;
  1001. return Res;
  1002. }
  1003. /*}}}*/
  1004. // PM::DoInstall - Does the installation /*{{{*/
  1005. // ---------------------------------------------------------------------
  1006. /* compat */
  1007. pkgPackageManager::OrderResult
  1008. pkgPackageManager::DoInstall(int statusFd)
  1009. {
  1010. APT::Progress::PackageManager *progress = new
  1011. APT::Progress::PackageManagerProgressFd(statusFd);
  1012. OrderResult res = DoInstall(progress);
  1013. delete progress;
  1014. return res;
  1015. }
  1016. /*}}}*/
  1017. // PM::DoInstall - Does the installation /*{{{*/
  1018. // ---------------------------------------------------------------------
  1019. /* This uses the filenames in FileNames and the information in the
  1020. DepCache to perform the installation of packages.*/
  1021. pkgPackageManager::OrderResult
  1022. pkgPackageManager::DoInstall(APT::Progress::PackageManager *progress)
  1023. {
  1024. if(DoInstallPreFork() == Failed)
  1025. return Failed;
  1026. return DoInstallPostFork(progress);
  1027. }
  1028. /*}}}*/