]> git.saurik.com Git - apt.git/blob - apt-pkg/packagemanager.h
* Install-Reason -> Auto-Installed in pkgstates
[apt.git] / apt-pkg / packagemanager.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: packagemanager.h,v 1.14 2001/05/07 04:24:08 jgg Exp $
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
11 - Invokation of package manager
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 /*}}}*/
23 #ifndef PKGLIB_PACKAGEMANAGER_H
24 #define PKGLIB_PACKAGEMANAGER_H
25
26 #ifdef __GNUG__
27 #pragma interface "apt-pkg/packagemanager.h"
28 #endif
29
30 #include <string>
31 #include <iostream>
32 #include <apt-pkg/pkgcache.h>
33 #include <apt-pkg/depcache.h>
34
35 using std::string;
36
37 class pkgAcquire;
38 class pkgDepCache;
39 class pkgSourceList;
40 class pkgOrderList;
41 class pkgRecords;
42 class pkgPackageManager : protected pkgCache::Namespace
43 {
44 public:
45
46 enum OrderResult {Completed,Failed,Incomplete};
47
48 protected:
49 string *FileNames;
50 pkgDepCache &Cache;
51 pkgOrderList *List;
52 bool Debug;
53
54 bool DepAdd(pkgOrderList &Order,PkgIterator P,int Depth = 0);
55 virtual OrderResult OrderInstall();
56 bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
57 bool CreateOrderList();
58
59 // Analysis helpers
60 bool DepAlwaysTrue(DepIterator D);
61
62 // Install helpers
63 bool ConfigureAll();
64 bool SmartConfigure(PkgIterator Pkg);
65 bool SmartUnPack(PkgIterator Pkg);
66 bool SmartRemove(PkgIterator Pkg);
67 bool EarlyRemove(PkgIterator Pkg);
68
69 // The Actual installation implementation
70 virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;};
71 virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
72 virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
73 virtual bool Go(int statusFd=-1) {return true;};
74 virtual void Reset() {};
75
76 // the result of the operation
77 OrderResult Res;
78
79 public:
80
81 // Main action members
82 bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
83 pkgRecords *Recs);
84
85 // Do the installation
86 OrderResult DoInstall() {
87 if(DoInstallPreFork() == Failed)
88 return Failed;
89
90 return DoInstallPostFork();
91 }
92
93 // stuff that needs to be done before the fork() of a library that
94 // uses apt
95 OrderResult DoInstallPreFork() {
96 Res = OrderInstall();
97 return Res;
98 };
99
100 // stuff that needs to be done after the fork
101 OrderResult DoInstallPostFork(int statusFd=-1) {
102 bool goResult = Go(statusFd);
103 if(goResult == false)
104 return Failed;
105
106 // if all was fine update the state file
107 if(Res == Completed) {
108 Cache.writeStateFile(NULL);
109 }
110 return Res;
111 };
112
113 bool FixMissing();
114
115 pkgPackageManager(pkgDepCache *Cache);
116 virtual ~pkgPackageManager();
117 };
118
119 #endif