]>
Commit | Line | Data |
---|---|---|
6c139d6e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
6fc33863 | 3 | // $Id: algorithms.h,v 1.3 1998/07/19 21:24:11 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. | |
6fc33863 AL |
17 | |
18 | pkgFixBroken corrects a broken system so that it is in a sane state. | |
6c139d6e AL |
19 | |
20 | ##################################################################### */ | |
21 | /*}}}*/ | |
22 | // Header section: pkglib | |
23 | #ifndef PKGLIB_ALGORITHMS_H | |
24 | #define PKGLIB_ALGORITHMS_H | |
25 | ||
26 | #ifdef __GNUG__ | |
094a497d | 27 | #pragma interface "apt-pkg/algorithms.h" |
6c139d6e AL |
28 | #endif |
29 | ||
094a497d AL |
30 | #include <apt-pkg/packagemanager.h> |
31 | #include <apt-pkg/depcache.h> | |
6c139d6e AL |
32 | |
33 | class pkgSimulate : public pkgPackageManager | |
34 | { | |
35 | protected: | |
36 | ||
37 | unsigned char *Flags; | |
38 | ||
39 | pkgDepCache Sim; | |
40 | ||
41 | // The Actuall installation implementation | |
42 | virtual bool Install(PkgIterator Pkg,string File); | |
43 | virtual bool Configure(PkgIterator Pkg); | |
44 | virtual bool Remove(PkgIterator Pkg); | |
45 | void ShortBreaks(); | |
46 | ||
47 | public: | |
48 | ||
49 | pkgSimulate(pkgDepCache &Cache); | |
50 | }; | |
51 | ||
52 | class pkgProblemResolver | |
53 | { | |
54 | pkgDepCache &Cache; | |
55 | typedef pkgCache::PkgIterator PkgIterator; | |
56 | typedef pkgCache::VerIterator VerIterator; | |
57 | typedef pkgCache::DepIterator DepIterator; | |
58 | typedef pkgCache::PrvIterator PrvIterator; | |
59 | typedef pkgCache::Version Version; | |
60 | typedef pkgCache::Package Package; | |
61 | ||
62 | enum Flags {Protected = (1 << 0), PreInstalled = (1 << 1), | |
63 | Upgradable = (1 << 2)}; | |
64 | signed short *Scores; | |
65 | unsigned char *Flags; | |
66 | bool Debug; | |
67 | ||
68 | // Sort stuff | |
69 | static pkgProblemResolver *This; | |
70 | static int ScoreSort(const void *a,const void *b); | |
71 | ||
72 | struct PackageKill | |
73 | { | |
74 | PkgIterator Pkg; | |
75 | DepIterator Dep; | |
76 | }; | |
77 | ||
78 | void MakeScores(); | |
79 | bool DoUpgrade(pkgCache::PkgIterator Pkg); | |
80 | ||
81 | public: | |
82 | ||
83 | inline void Protect(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] |= Protected;}; | |
84 | bool Resolve(bool BrokenFix = false); | |
85 | ||
86 | pkgProblemResolver(pkgDepCache &Cache); | |
87 | }; | |
88 | ||
89 | bool pkgDistUpgrade(pkgDepCache &Cache); | |
90 | bool pkgApplyStatus(pkgDepCache &Cache); | |
91 | bool pkgFixBroken(pkgDepCache &Cache); | |
92 | ||
93 | #endif |