]> git.saurik.com Git - apt.git/blame - apt-pkg/packagemanager.h
* fix missing SetExecClose() call when the status-fd is used
[apt.git] / apt-pkg / packagemanager.h
CommitLineData
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
6c139d6e
AL
26
27#include <string>
e23e6733 28#include <iostream>
094a497d 29#include <apt-pkg/pkgcache.h>
3c9b111f 30#include <apt-pkg/depcache.h>
6c139d6e 31
0a843901
AL
32using std::string;
33
03e39e59 34class pkgAcquire;
6c139d6e
AL
35class pkgDepCache;
36class pkgSourceList;
37class pkgOrderList;
03e39e59 38class pkgRecords;
b2e465d6 39class pkgPackageManager : protected pkgCache::Namespace
6c139d6e 40{
281daf46
AL
41 public:
42
43 enum OrderResult {Completed,Failed,Incomplete};
44
6c139d6e
AL
45 protected:
46 string *FileNames;
47 pkgDepCache &Cache;
48 pkgOrderList *List;
30e1eab5 49 bool Debug;
b2e465d6 50
6c139d6e 51 bool DepAdd(pkgOrderList &Order,PkgIterator P,int Depth = 0);
756458fb 52 virtual OrderResult OrderInstall();
6c139d6e 53 bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
7a1b1f8b 54 bool CreateOrderList();
6c139d6e
AL
55
56 // Analysis helpers
57 bool DepAlwaysTrue(DepIterator D);
58
59 // Install helpers
60 bool ConfigureAll();
61 bool SmartConfigure(PkgIterator Pkg);
62 bool SmartUnPack(PkgIterator Pkg);
63 bool SmartRemove(PkgIterator Pkg);
64 bool EarlyRemove(PkgIterator Pkg);
65
b2e465d6 66 // The Actual installation implementation
db5c1b54
AL
67 virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;};
68 virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
69 virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
007dc9e0 70 virtual bool Go(int statusFd=-1) {return true;};
281daf46 71 virtual void Reset() {};
3c9b111f
MV
72
73 // the result of the operation
74 OrderResult Res;
75
6c139d6e 76 public:
281daf46 77
b50b2c97 78 // Main action members
03e39e59
AL
79 bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
80 pkgRecords *Recs);
3c9b111f
MV
81
82 // Do the installation
2a7e07c7 83 OrderResult DoInstall(int statusFd=-1);
3c9b111f
MV
84
85 // stuff that needs to be done before the fork() of a library that
86 // uses apt
87 OrderResult DoInstallPreFork() {
88 Res = OrderInstall();
89 return Res;
90 };
91
92 // stuff that needs to be done after the fork
93 OrderResult DoInstallPostFork(int statusFd=-1) {
faebb699
MV
94 if(statusFd > 0)
95 SetCloseExec(statusFd, true);
3c9b111f
MV
96 bool goResult = Go(statusFd);
97 if(goResult == false)
98 return Failed;
e23e6733 99
3c9b111f 100 // if all was fine update the state file
e23e6733 101 if(Res == Completed) {
3c9b111f 102 Cache.writeStateFile(NULL);
e23e6733 103 }
3c9b111f
MV
104 return Res;
105 };
106
6c139d6e
AL
107 bool FixMissing();
108
b2e465d6 109 pkgPackageManager(pkgDepCache *Cache);
6c139d6e
AL
110 virtual ~pkgPackageManager();
111};
112
113#endif