algorithms.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: algorithms.h,v 1.2 1998/07/12 23:58:22 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. ##################################################################### */
  14. /*}}}*/
  15. // Header section: pkglib
  16. #ifndef PKGLIB_ALGORITHMS_H
  17. #define PKGLIB_ALGORITHMS_H
  18. #ifdef __GNUG__
  19. #pragma interface "apt-pkg/algorithms.h"
  20. #endif
  21. #include <apt-pkg/packagemanager.h>
  22. #include <apt-pkg/depcache.h>
  23. class pkgSimulate : public pkgPackageManager
  24. {
  25. protected:
  26. unsigned char *Flags;
  27. pkgDepCache Sim;
  28. // The Actuall installation implementation
  29. virtual bool Install(PkgIterator Pkg,string File);
  30. virtual bool Configure(PkgIterator Pkg);
  31. virtual bool Remove(PkgIterator Pkg);
  32. void ShortBreaks();
  33. public:
  34. pkgSimulate(pkgDepCache &Cache);
  35. };
  36. class pkgProblemResolver
  37. {
  38. pkgDepCache &Cache;
  39. typedef pkgCache::PkgIterator PkgIterator;
  40. typedef pkgCache::VerIterator VerIterator;
  41. typedef pkgCache::DepIterator DepIterator;
  42. typedef pkgCache::PrvIterator PrvIterator;
  43. typedef pkgCache::Version Version;
  44. typedef pkgCache::Package Package;
  45. enum Flags {Protected = (1 << 0), PreInstalled = (1 << 1),
  46. Upgradable = (1 << 2)};
  47. signed short *Scores;
  48. unsigned char *Flags;
  49. bool Debug;
  50. // Sort stuff
  51. static pkgProblemResolver *This;
  52. static int ScoreSort(const void *a,const void *b);
  53. struct PackageKill
  54. {
  55. PkgIterator Pkg;
  56. DepIterator Dep;
  57. };
  58. void MakeScores();
  59. bool DoUpgrade(pkgCache::PkgIterator Pkg);
  60. public:
  61. inline void Protect(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] |= Protected;};
  62. bool Resolve(bool BrokenFix = false);
  63. pkgProblemResolver(pkgDepCache &Cache);
  64. };
  65. bool pkgDistUpgrade(pkgDepCache &Cache);
  66. bool pkgApplyStatus(pkgDepCache &Cache);
  67. bool pkgFixBroken(pkgDepCache &Cache);
  68. #endif