packagemanager.cc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: packagemanager.cc,v 1.26 2001/02/20 07:03:17 jgg 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. #ifdef __GNUG__
  13. #pragma implementation "apt-pkg/packagemanager.h"
  14. #endif
  15. #include <apt-pkg/packagemanager.h>
  16. #include <apt-pkg/orderlist.h>
  17. #include <apt-pkg/depcache.h>
  18. #include <apt-pkg/error.h>
  19. #include <apt-pkg/version.h>
  20. #include <apt-pkg/acquire-item.h>
  21. #include <apt-pkg/algorithms.h>
  22. #include <apt-pkg/configuration.h>
  23. #include <apt-pkg/sptr.h>
  24. #include <apti18n.h>
  25. /*}}}*/
  26. // PM::PackageManager - Constructor /*{{{*/
  27. // ---------------------------------------------------------------------
  28. /* */
  29. pkgPackageManager::pkgPackageManager(pkgDepCache *pCache) : Cache(*pCache)
  30. {
  31. FileNames = new string[Cache.Head().PackageCount];
  32. List = 0;
  33. Debug = _config->FindB("Debug::pkgPackageManager",false);
  34. }
  35. /*}}}*/
  36. // PM::PackageManager - Destructor /*{{{*/
  37. // ---------------------------------------------------------------------
  38. /* */
  39. pkgPackageManager::~pkgPackageManager()
  40. {
  41. delete List;
  42. delete [] FileNames;
  43. }
  44. /*}}}*/
  45. // PM::GetArchives - Queue the archives for download /*{{{*/
  46. // ---------------------------------------------------------------------
  47. /* */
  48. bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
  49. pkgRecords *Recs)
  50. {
  51. if (CreateOrderList() == false)
  52. return false;
  53. if (List->OrderUnpack() == false)
  54. return _error->Error("Internal ordering error");
  55. for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
  56. {
  57. PkgIterator Pkg(Cache,*I);
  58. FileNames[Pkg->ID] = string();
  59. // Skip packages to erase
  60. if (Cache[Pkg].Delete() == true)
  61. continue;
  62. // Skip Packages that need configure only.
  63. if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
  64. Cache[Pkg].Keep() == true)
  65. continue;
  66. // Skip already processed packages
  67. if (List->IsNow(Pkg) == false)
  68. continue;
  69. new pkgAcqArchive(Owner,Sources,Recs,Cache[Pkg].InstVerIter(Cache),
  70. FileNames[Pkg->ID]);
  71. }
  72. return true;
  73. }
  74. /*}}}*/
  75. // PM::FixMissing - Keep all missing packages /*{{{*/
  76. // ---------------------------------------------------------------------
  77. /* This is called to correct the installation when packages could not
  78. be downloaded. */
  79. bool pkgPackageManager::FixMissing()
  80. {
  81. pkgProblemResolver Resolve(&Cache);
  82. List->SetFileList(FileNames);
  83. bool Bad = false;
  84. for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
  85. {
  86. if (List->IsMissing(I) == false)
  87. continue;
  88. // Okay, this file is missing and we need it. Mark it for keep
  89. Bad = true;
  90. Cache.MarkKeep(I);
  91. }
  92. // We have to empty the list otherwise it will not have the new changes
  93. delete List;
  94. List = 0;
  95. if (Bad == false)
  96. return true;
  97. // Now downgrade everything that is broken
  98. return Resolve.ResolveByKeep() == true && Cache.BrokenCount() == 0;
  99. }
  100. /*}}}*/
  101. // PM::CreateOrderList - Create the ordering class /*{{{*/
  102. // ---------------------------------------------------------------------
  103. /* This populates the ordering list with all the packages that are
  104. going to change. */
  105. bool pkgPackageManager::CreateOrderList()
  106. {
  107. if (List != 0)
  108. return true;
  109. delete List;
  110. List = new pkgOrderList(&Cache);
  111. bool NoImmConfigure = _config->FindB("APT::Immediate-Configure",false);
  112. // Generate the list of affected packages and sort it
  113. for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
  114. {
  115. // Mark the package and its dependends for immediate configuration
  116. if (((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential ||
  117. (I->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important) &&
  118. NoImmConfigure == false)
  119. {
  120. List->Flag(I,pkgOrderList::Immediate);
  121. // Look for other packages to make immediate configurea
  122. if (Cache[I].InstallVer != 0)
  123. for (DepIterator D = Cache[I].InstVerIter(Cache).DependsList();
  124. D.end() == false; D++)
  125. if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends)
  126. List->Flag(D.TargetPkg(),pkgOrderList::Immediate);
  127. // And again with the current version.
  128. if (I->CurrentVer != 0)
  129. for (DepIterator D = I.CurrentVer().DependsList();
  130. D.end() == false; D++)
  131. if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends)
  132. List->Flag(D.TargetPkg(),pkgOrderList::Immediate);
  133. }
  134. // Not interesting
  135. if ((Cache[I].Keep() == true ||
  136. Cache[I].InstVerIter(Cache) == I.CurrentVer()) &&
  137. I.State() == pkgCache::PkgIterator::NeedsNothing &&
  138. (Cache[I].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall &&
  139. (I.Purge() != false || Cache[I].Mode != pkgDepCache::ModeDelete ||
  140. (Cache[I].iFlags & pkgDepCache::Purge) != pkgDepCache::Purge))
  141. continue;
  142. // Append it to the list
  143. List->push_back(I);
  144. }
  145. return true;
  146. }
  147. /*}}}*/
  148. // PM::DepAlwaysTrue - Returns true if this dep is irrelevent /*{{{*/
  149. // ---------------------------------------------------------------------
  150. /* The restriction on provides is to eliminate the case when provides
  151. are transitioning between valid states [ie exim to smail] */
  152. bool pkgPackageManager::DepAlwaysTrue(DepIterator D)
  153. {
  154. if (D.TargetPkg()->ProvidesList != 0)
  155. return false;
  156. if ((Cache[D] & pkgDepCache::DepInstall) != 0 &&
  157. (Cache[D] & pkgDepCache::DepNow) != 0)
  158. return true;
  159. return false;
  160. }
  161. /*}}}*/
  162. // PM::CheckRConflicts - Look for reverse conflicts /*{{{*/
  163. // ---------------------------------------------------------------------
  164. /* This looks over the reverses for a conflicts line that needs early
  165. removal. */
  166. bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D,
  167. const char *Ver)
  168. {
  169. for (;D.end() == false; D++)
  170. {
  171. if (D->Type != pkgCache::Dep::Conflicts &&
  172. D->Type != pkgCache::Dep::Obsoletes)
  173. continue;
  174. // The package hasnt been changed
  175. if (List->IsNow(Pkg) == false)
  176. continue;
  177. // Ignore self conflicts, ignore conflicts from irrelevent versions
  178. if (D.ParentPkg() == Pkg || D.ParentVer() != D.ParentPkg().CurrentVer())
  179. continue;
  180. if (Cache.VS().CheckDep(Ver,D->CompareOp,D.TargetVer()) == false)
  181. continue;
  182. if (EarlyRemove(D.ParentPkg()) == false)
  183. return _error->Error("Reverse conflicts early remove for package '%s' failed",
  184. Pkg.Name());
  185. }
  186. return true;
  187. }
  188. /*}}}*/
  189. // PM::ConfigureAll - Run the all out configuration /*{{{*/
  190. // ---------------------------------------------------------------------
  191. /* This configures every package. It is assumed they are all unpacked and
  192. that the final configuration is valid. */
  193. bool pkgPackageManager::ConfigureAll()
  194. {
  195. pkgOrderList OList(&Cache);
  196. // Populate the order list
  197. for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
  198. if (List->IsFlag(pkgCache::PkgIterator(Cache,*I),
  199. pkgOrderList::UnPacked) == true)
  200. OList.push_back(*I);
  201. if (OList.OrderConfigure() == false)
  202. return false;
  203. // Perform the configuring
  204. for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++)
  205. {
  206. PkgIterator Pkg(Cache,*I);
  207. if (Configure(Pkg) == false)
  208. return false;
  209. List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States);
  210. }
  211. return true;
  212. }
  213. /*}}}*/
  214. // PM::SmartConfigure - Perform immediate configuration of the pkg /*{{{*/
  215. // ---------------------------------------------------------------------
  216. /* This routine scheduals the configuration of the given package and all
  217. of it's dependents. */
  218. bool pkgPackageManager::SmartConfigure(PkgIterator Pkg)
  219. {
  220. pkgOrderList OList(&Cache);
  221. if (DepAdd(OList,Pkg) == false)
  222. return false;
  223. if (OList.OrderConfigure() == false)
  224. return false;
  225. // Perform the configuring
  226. for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++)
  227. {
  228. PkgIterator Pkg(Cache,*I);
  229. if (Configure(Pkg) == false)
  230. return false;
  231. List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States);
  232. }
  233. // Sanity Check
  234. if (List->IsFlag(Pkg,pkgOrderList::Configured) == false)
  235. return _error->Error("Internal error, could not immediate configure %s",Pkg.Name());
  236. return true;
  237. }
  238. /*}}}*/
  239. // PM::DepAdd - Add all dependents to the oder list /*{{{*/
  240. // ---------------------------------------------------------------------
  241. /* This recursively adds all dependents to the order list */
  242. bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth)
  243. {
  244. if (OList.IsFlag(Pkg,pkgOrderList::Added) == true)
  245. return true;
  246. if (List->IsFlag(Pkg,pkgOrderList::Configured) == true)
  247. return true;
  248. if (List->IsFlag(Pkg,pkgOrderList::UnPacked) == false)
  249. return false;
  250. // Put the package on the list
  251. OList.push_back(Pkg);
  252. OList.Flag(Pkg,pkgOrderList::Added);
  253. Depth++;
  254. // Check the dependencies to see if they are all satisfied.
  255. bool Bad = false;
  256. for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); D.end() == false;)
  257. {
  258. if (D->Type != pkgCache::Dep::Depends && D->Type != pkgCache::Dep::PreDepends)
  259. {
  260. D++;
  261. continue;
  262. }
  263. // Grok or groups
  264. Bad = true;
  265. for (bool LastOR = true; D.end() == false && LastOR == true; D++)
  266. {
  267. LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
  268. if (Bad == false)
  269. continue;
  270. SPtrArray<Version *> VList = D.AllTargets();
  271. for (Version **I = VList; *I != 0 && Bad == true; I++)
  272. {
  273. VerIterator Ver(Cache,*I);
  274. PkgIterator Pkg = Ver.ParentPkg();
  275. // See if the current version is ok
  276. if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true &&
  277. Pkg.State() == PkgIterator::NeedsNothing)
  278. {
  279. Bad = false;
  280. continue;
  281. }
  282. // Not the install version
  283. if (Cache[Pkg].InstallVer != *I ||
  284. (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing))
  285. continue;
  286. if (List->IsFlag(Pkg,pkgOrderList::UnPacked) == true)
  287. Bad = !DepAdd(OList,Pkg,Depth);
  288. if (List->IsFlag(Pkg,pkgOrderList::Configured) == true)
  289. Bad = false;
  290. }
  291. }
  292. if (Bad == true)
  293. {
  294. OList.Flag(Pkg,0,pkgOrderList::Added);
  295. OList.pop_back();
  296. Depth--;
  297. return false;
  298. }
  299. }
  300. Depth--;
  301. return true;
  302. }
  303. /*}}}*/
  304. // PM::EarlyRemove - Perform removal of packages before their time /*{{{*/
  305. // ---------------------------------------------------------------------
  306. /* This is called to deal with conflicts arising from unpacking */
  307. bool pkgPackageManager::EarlyRemove(PkgIterator Pkg)
  308. {
  309. if (List->IsNow(Pkg) == false)
  310. return true;
  311. // Already removed it
  312. if (List->IsFlag(Pkg,pkgOrderList::Removed) == true)
  313. return true;
  314. // Woops, it will not be re-installed!
  315. if (List->IsFlag(Pkg,pkgOrderList::InList) == false)
  316. return false;
  317. // Essential packages get special treatment
  318. bool IsEssential = false;
  319. if ((Pkg->Flags & pkgCache::Flag::Essential) != 0)
  320. IsEssential = true;
  321. /* Check for packages that are the dependents of essential packages and
  322. promote them too */
  323. if (Pkg->CurrentVer != 0)
  324. {
  325. for (DepIterator D = Pkg.RevDependsList(); D.end() == false &&
  326. IsEssential == false; D++)
  327. if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends)
  328. if ((D.ParentPkg()->Flags & pkgCache::Flag::Essential) != 0)
  329. IsEssential = true;
  330. }
  331. if (IsEssential == true)
  332. {
  333. if (_config->FindB("APT::Force-LoopBreak",false) == false)
  334. return _error->Error(_("This installation run will require temporarily "
  335. "removing the essential package %s due to a "
  336. "Conflicts/Pre-Depends loop. This is often bad, "
  337. "but if you really want to do it, activate the "
  338. "APT::Force-LoopBreak option."),Pkg.Name());
  339. }
  340. bool Res = SmartRemove(Pkg);
  341. if (Cache[Pkg].Delete() == false)
  342. List->Flag(Pkg,pkgOrderList::Removed,pkgOrderList::States);
  343. return Res;
  344. }
  345. /*}}}*/
  346. // PM::SmartRemove - Removal Helper /*{{{*/
  347. // ---------------------------------------------------------------------
  348. /* */
  349. bool pkgPackageManager::SmartRemove(PkgIterator Pkg)
  350. {
  351. if (List->IsNow(Pkg) == false)
  352. return true;
  353. List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States);
  354. return Remove(Pkg,(Cache[Pkg].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge);
  355. }
  356. /*}}}*/
  357. // PM::SmartUnPack - Install helper /*{{{*/
  358. // ---------------------------------------------------------------------
  359. /* This performs the task of handling pre-depends. */
  360. bool pkgPackageManager::SmartUnPack(PkgIterator Pkg)
  361. {
  362. // Check if it is already unpacked
  363. if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
  364. Cache[Pkg].Keep() == true)
  365. {
  366. List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States);
  367. if (List->IsFlag(Pkg,pkgOrderList::Immediate) == true)
  368. if (SmartConfigure(Pkg) == false)
  369. return _error->Error("Internal Error, Could not perform immediate configuration (1) on %s",Pkg.Name());
  370. return true;
  371. }
  372. /* See if this packages install version has any predependencies
  373. that are not met by 'now' packages. */
  374. for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList();
  375. D.end() == false; )
  376. {
  377. // Compute a single dependency element (glob or)
  378. pkgCache::DepIterator Start;
  379. pkgCache::DepIterator End;
  380. D.GlobOr(Start,End);
  381. while (End->Type == pkgCache::Dep::PreDepends)
  382. {
  383. // Look for possible ok targets.
  384. SPtrArray<Version *> VList = Start.AllTargets();
  385. bool Bad = true;
  386. for (Version **I = VList; *I != 0 && Bad == true; I++)
  387. {
  388. VerIterator Ver(Cache,*I);
  389. PkgIterator Pkg = Ver.ParentPkg();
  390. // See if the current version is ok
  391. if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true &&
  392. Pkg.State() == PkgIterator::NeedsNothing)
  393. {
  394. Bad = false;
  395. continue;
  396. }
  397. }
  398. // Look for something that could be configured.
  399. for (Version **I = VList; *I != 0 && Bad == true; I++)
  400. {
  401. VerIterator Ver(Cache,*I);
  402. PkgIterator Pkg = Ver.ParentPkg();
  403. // Not the install version
  404. if (Cache[Pkg].InstallVer != *I ||
  405. (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing))
  406. continue;
  407. Bad = !SmartConfigure(Pkg);
  408. }
  409. /* If this or element did not match then continue on to the
  410. next or element until a matching element is found*/
  411. if (Bad == true)
  412. {
  413. if (Start == End)
  414. return _error->Error("Internal Error, Couldn't configure a pre-depend");
  415. Start++;
  416. }
  417. else
  418. break;
  419. }
  420. if (End->Type == pkgCache::Dep::Conflicts ||
  421. End->Type == pkgCache::Dep::Obsoletes)
  422. {
  423. /* Look for conflicts. Two packages that are both in the install
  424. state cannot conflict so we don't check.. */
  425. SPtrArray<Version *> VList = End.AllTargets();
  426. for (Version **I = VList; *I != 0; I++)
  427. {
  428. VerIterator Ver(Cache,*I);
  429. PkgIterator Pkg = Ver.ParentPkg();
  430. // See if the current version is conflicting
  431. if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true)
  432. {
  433. if (EarlyRemove(Pkg) == false)
  434. return _error->Error("Internal Error, Could not early remove %s",Pkg.Name());
  435. }
  436. }
  437. }
  438. }
  439. // Check for reverse conflicts.
  440. if (CheckRConflicts(Pkg,Pkg.RevDependsList(),
  441. Cache[Pkg].InstVerIter(Cache).VerStr()) == false)
  442. return false;
  443. for (PrvIterator P = Cache[Pkg].InstVerIter(Cache).ProvidesList();
  444. P.end() == false; P++)
  445. CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion());
  446. if (Install(Pkg,FileNames[Pkg->ID]) == false)
  447. return false;
  448. List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States);
  449. // Perform immedate configuration of the package.
  450. if (List->IsFlag(Pkg,pkgOrderList::Immediate) == true)
  451. if (SmartConfigure(Pkg) == false)
  452. return _error->Error("Internal Error, Could not perform immediate configuration (2) on %s",Pkg.Name());
  453. return true;
  454. }
  455. /*}}}*/
  456. // PM::OrderInstall - Installation ordering routine /*{{{*/
  457. // ---------------------------------------------------------------------
  458. /* */
  459. pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
  460. {
  461. if (CreateOrderList() == false)
  462. return Failed;
  463. Reset();
  464. if (Debug == true)
  465. clog << "Begining to order" << endl;
  466. if (List->OrderUnpack(FileNames) == false)
  467. {
  468. _error->Error("Internal ordering error");
  469. return Failed;
  470. }
  471. if (Debug == true)
  472. clog << "Done ordering" << endl;
  473. bool DoneSomething = false;
  474. for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
  475. {
  476. PkgIterator Pkg(Cache,*I);
  477. if (List->IsNow(Pkg) == false)
  478. {
  479. if (Debug == true)
  480. clog << "Skipping already done " << Pkg.Name() << endl;
  481. continue;
  482. }
  483. if (List->IsMissing(Pkg) == true)
  484. {
  485. if (Debug == true)
  486. clog << "Sequence completed at " << Pkg.Name() << endl;
  487. if (DoneSomething == false)
  488. {
  489. _error->Error("Internal Error, ordering was unable to handle the media swap");
  490. return Failed;
  491. }
  492. return Incomplete;
  493. }
  494. // Sanity check
  495. if (Cache[Pkg].Keep() == true &&
  496. Pkg.State() == pkgCache::PkgIterator::NeedsNothing &&
  497. (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)
  498. {
  499. _error->Error("Internal Error, trying to manipulate a kept package");
  500. return Failed;
  501. }
  502. // Perform a delete or an install
  503. if (Cache[Pkg].Delete() == true)
  504. {
  505. if (SmartRemove(Pkg) == false)
  506. return Failed;
  507. }
  508. else
  509. if (SmartUnPack(Pkg) == false)
  510. return Failed;
  511. DoneSomething = true;
  512. }
  513. // Final run through the configure phase
  514. if (ConfigureAll() == false)
  515. return Failed;
  516. // Sanity check
  517. for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
  518. {
  519. if (List->IsFlag(*I,pkgOrderList::Configured) == false)
  520. {
  521. _error->Error("Internal error, packages left unconfigured. %s",
  522. PkgIterator(Cache,*I).Name());
  523. return Failed;
  524. }
  525. }
  526. return Completed;
  527. }
  528. /*}}}*/
  529. // PM::DoInstall - Does the installation /*{{{*/
  530. // ---------------------------------------------------------------------
  531. /* This uses the filenames in FileNames and the information in the
  532. DepCache to perform the installation of packages.*/
  533. pkgPackageManager::OrderResult pkgPackageManager::DoInstall()
  534. {
  535. OrderResult Res = OrderInstall();
  536. if (Res != Failed)
  537. if (Go() == false)
  538. return Failed;
  539. return Res;
  540. }
  541. /*}}}*/