packagemanager.cc 39 KB

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