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