algorithms.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: algorithms.h,v 1.3 1998/07/19 21:24:11 jgg Exp $
  4. /* ######################################################################
  5. Algorithms - A set of misc algorithms
  6. This simulate class displays what the ordering code has done and
  7. analyses it with a fresh new dependency cache. In this way we can
  8. see all of the effects of an upgrade run.
  9. pkgDistUpgrade computes an upgrade that causes as many packages as
  10. possible to move to the newest verison.
  11. pkgApplyStatus sets the target state based on the content of the status
  12. field in the status file. It is important to get proper crash recovery.
  13. pkgFixBroken corrects a broken system so that it is in a sane state.
  14. ##################################################################### */
  15. /*}}}*/
  16. // Header section: pkglib
  17. #ifndef PKGLIB_ALGORITHMS_H
  18. #define PKGLIB_ALGORITHMS_H
  19. #ifdef __GNUG__
  20. #pragma interface "apt-pkg/algorithms.h"
  21. #endif
  22. #include <apt-pkg/packagemanager.h>
  23. #include <apt-pkg/depcache.h>
  24. class pkgSimulate : public pkgPackageManager
  25. {
  26. protected:
  27. unsigned char *Flags;
  28. pkgDepCache Sim;
  29. // The Actuall installation implementation
  30. virtual bool Install(PkgIterator Pkg,string File);
  31. virtual bool Configure(PkgIterator Pkg);
  32. virtual bool Remove(PkgIterator Pkg);
  33. void ShortBreaks();
  34. public:
  35. pkgSimulate(pkgDepCache &Cache);
  36. };
  37. class pkgProblemResolver
  38. {
  39. pkgDepCache &Cache;
  40. typedef pkgCache::PkgIterator PkgIterator;
  41. typedef pkgCache::VerIterator VerIterator;
  42. typedef pkgCache::DepIterator DepIterator;
  43. typedef pkgCache::PrvIterator PrvIterator;
  44. typedef pkgCache::Version Version;
  45. typedef pkgCache::Package Package;
  46. enum Flags {Protected = (1 << 0), PreInstalled = (1 << 1),
  47. Upgradable = (1 << 2)};
  48. signed short *Scores;
  49. unsigned char *Flags;
  50. bool Debug;
  51. // Sort stuff
  52. static pkgProblemResolver *This;
  53. static int ScoreSort(const void *a,const void *b);
  54. struct PackageKill
  55. {
  56. PkgIterator Pkg;
  57. DepIterator Dep;
  58. };
  59. void MakeScores();
  60. bool DoUpgrade(pkgCache::PkgIterator Pkg);
  61. public:
  62. inline void Protect(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] |= Protected;};
  63. bool Resolve(bool BrokenFix = false);
  64. pkgProblemResolver(pkgDepCache &Cache);
  65. };
  66. bool pkgDistUpgrade(pkgDepCache &Cache);
  67. bool pkgApplyStatus(pkgDepCache &Cache);
  68. bool pkgFixBroken(pkgDepCache &Cache);
  69. #endif