]> git.saurik.com Git - apt.git/blame_incremental - apt-pkg/packagemanager.h
* bumped the library version
[apt.git] / apt-pkg / packagemanager.h
... / ...
CommitLineData
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 <apt-pkg/pkgcache.h>
32#include <apt-pkg/depcache.h>
33
34using std::string;
35
36class pkgAcquire;
37class pkgDepCache;
38class pkgSourceList;
39class pkgOrderList;
40class pkgRecords;
41class pkgPackageManager : protected pkgCache::Namespace
42{
43 public:
44
45 enum OrderResult {Completed,Failed,Incomplete};
46
47 protected:
48 string *FileNames;
49 pkgDepCache &Cache;
50 pkgOrderList *List;
51 bool Debug;
52
53 bool DepAdd(pkgOrderList &Order,PkgIterator P,int Depth = 0);
54 virtual OrderResult OrderInstall();
55 bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
56 bool CreateOrderList();
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
68 // The Actual installation implementation
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;};
72 virtual bool Go(int statusFd=-1) {return true;};
73 virtual void Reset() {};
74
75 // the result of the operation
76 OrderResult Res;
77
78 public:
79
80 // Main action members
81 bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
82 pkgRecords *Recs);
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
112 bool FixMissing();
113
114 pkgPackageManager(pkgDepCache *Cache);
115 virtual ~pkgPackageManager();
116};
117
118#endif