]>
Commit | Line | Data |
---|---|---|
6c139d6e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
0a843901 | 3 | // $Id: packagemanager.h,v 1.14 2001/05/07 04:24:08 jgg Exp $ |
6c139d6e AL |
4 | /* ###################################################################### |
5 | ||
6 | Package Manager - Abstacts the package manager | |
7 | ||
8 | Three steps are | |
9 | - Aquiration of archives (stores the list of final file names) | |
10 | - Sorting of operations | |
6fc33863 | 11 | - Invokation of package manager |
6c139d6e AL |
12 | |
13 | This is the final stage when the package cache entities get converted | |
14 | into file names and the state stored in a DepCache is transformed | |
15 | into a series of operations. | |
16 | ||
17 | In the final scheme of things this may serve as a director class to | |
18 | access the actual install methods based on the file type being | |
19 | installed. | |
20 | ||
21 | ##################################################################### */ | |
22 | /*}}}*/ | |
6c139d6e AL |
23 | #ifndef PKGLIB_PACKAGEMANAGER_H |
24 | #define PKGLIB_PACKAGEMANAGER_H | |
25 | ||
26 | #ifdef __GNUG__ | |
094a497d | 27 | #pragma interface "apt-pkg/packagemanager.h" |
6c139d6e AL |
28 | #endif |
29 | ||
30 | #include <string> | |
094a497d | 31 | #include <apt-pkg/pkgcache.h> |
3c9b111f | 32 | #include <apt-pkg/depcache.h> |
6c139d6e | 33 | |
0a843901 AL |
34 | using std::string; |
35 | ||
03e39e59 | 36 | class pkgAcquire; |
6c139d6e AL |
37 | class pkgDepCache; |
38 | class pkgSourceList; | |
39 | class pkgOrderList; | |
03e39e59 | 40 | class pkgRecords; |
b2e465d6 | 41 | class pkgPackageManager : protected pkgCache::Namespace |
6c139d6e | 42 | { |
281daf46 AL |
43 | public: |
44 | ||
45 | enum OrderResult {Completed,Failed,Incomplete}; | |
46 | ||
6c139d6e AL |
47 | protected: |
48 | string *FileNames; | |
49 | pkgDepCache &Cache; | |
50 | pkgOrderList *List; | |
30e1eab5 | 51 | bool Debug; |
b2e465d6 | 52 | |
6c139d6e | 53 | bool DepAdd(pkgOrderList &Order,PkgIterator P,int Depth = 0); |
756458fb | 54 | virtual OrderResult OrderInstall(); |
6c139d6e | 55 | bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver); |
7a1b1f8b | 56 | bool CreateOrderList(); |
6c139d6e AL |
57 | |
58 | // Analysis helpers | |
59 | bool DepAlwaysTrue(DepIterator D); | |
60 | ||
61 | // Install helpers | |
62 | bool ConfigureAll(); | |
63 | bool SmartConfigure(PkgIterator Pkg); | |
64 | bool SmartUnPack(PkgIterator Pkg); | |
65 | bool SmartRemove(PkgIterator Pkg); | |
66 | bool EarlyRemove(PkgIterator Pkg); | |
67 | ||
b2e465d6 | 68 | // The Actual installation implementation |
db5c1b54 AL |
69 | virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;}; |
70 | virtual bool Configure(PkgIterator /*Pkg*/) {return false;}; | |
71 | virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;}; | |
007dc9e0 | 72 | virtual bool Go(int statusFd=-1) {return true;}; |
281daf46 | 73 | virtual void Reset() {}; |
3c9b111f MV |
74 | |
75 | // the result of the operation | |
76 | OrderResult Res; | |
77 | ||
6c139d6e | 78 | public: |
281daf46 | 79 | |
b50b2c97 | 80 | // Main action members |
03e39e59 AL |
81 | bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources, |
82 | pkgRecords *Recs); | |
3c9b111f MV |
83 | |
84 | // Do the installation | |
85 | OrderResult DoInstall() { | |
86 | if(DoInstallPreFork() == Failed) | |
87 | return Failed; | |
88 | ||
89 | return DoInstallPostFork(); | |
90 | } | |
91 | ||
92 | // stuff that needs to be done before the fork() of a library that | |
93 | // uses apt | |
94 | OrderResult DoInstallPreFork() { | |
95 | Res = OrderInstall(); | |
96 | return Res; | |
97 | }; | |
98 | ||
99 | // stuff that needs to be done after the fork | |
100 | OrderResult DoInstallPostFork(int statusFd=-1) { | |
101 | bool goResult = Go(statusFd); | |
102 | if(goResult == false) | |
103 | return Failed; | |
104 | ||
105 | // if all was fine update the state file | |
106 | if(Res == Completed) | |
107 | Cache.writeStateFile(NULL); | |
108 | ||
109 | return Res; | |
110 | }; | |
111 | ||
6c139d6e AL |
112 | bool FixMissing(); |
113 | ||
b2e465d6 | 114 | pkgPackageManager(pkgDepCache *Cache); |
6c139d6e AL |
115 | virtual ~pkgPackageManager(); |
116 | }; | |
117 | ||
118 | #endif |