apt @VERSION@
|
00001 // -*- mode: cpp; mode: fold -*- 00002 // Description /*{{{*/ 00003 // $Id: dpkgpm.h,v 1.8 2001/05/07 05:05:13 jgg Exp $ 00004 /* ###################################################################### 00005 00006 DPKG Package Manager - Provide an interface to dpkg 00007 00008 ##################################################################### */ 00009 /*}}}*/ 00010 #ifndef PKGLIB_DPKGPM_H 00011 #define PKGLIB_DPKGPM_H 00012 00013 #include <apt-pkg/packagemanager.h> 00014 #include <vector> 00015 #include <map> 00016 #include <stdio.h> 00017 00018 using std::vector; 00019 using std::map; 00020 00021 class pkgDPkgPMPrivate; 00022 00023 class pkgDPkgPM : public pkgPackageManager 00024 { 00025 private: 00026 pkgDPkgPMPrivate *d; 00027 00041 void handleDisappearAction(string const &pkgname); 00042 00043 protected: 00044 int pkgFailures; 00045 00046 // progress reporting 00047 struct DpkgState 00048 { 00049 const char *state; // the dpkg state (e.g. "unpack") 00050 const char *str; // the human readable translation of the state 00051 }; 00052 00053 // the dpkg states that the pkg will run through, the string is 00054 // the package, the vector contains the dpkg states that the package 00055 // will go through 00056 map<string,vector<struct DpkgState> > PackageOps; 00057 // the dpkg states that are already done; the string is the package 00058 // the int is the state that is already done (e.g. a package that is 00059 // going to be install is already in state "half-installed") 00060 map<string,unsigned int> PackageOpsDone; 00061 00062 // progress reporting 00063 unsigned int PackagesDone; 00064 unsigned int PackagesTotal; 00065 00066 struct Item 00067 { 00068 enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op; 00069 string File; 00070 PkgIterator Pkg; 00071 Item(Ops Op,PkgIterator Pkg,string File = "") : Op(Op), 00072 File(File), Pkg(Pkg) {}; 00073 Item() {}; 00074 00075 }; 00076 vector<Item> List; 00077 00078 // Helpers 00079 bool RunScriptsWithPkgs(const char *Cnf); 00080 bool SendV2Pkgs(FILE *F); 00081 void WriteHistoryTag(string const &tag, string value); 00082 00083 // apport integration 00084 void WriteApportReport(const char *pkgpath, const char *errormsg); 00085 00086 // dpkg log 00087 bool OpenLog(); 00088 bool CloseLog(); 00089 00090 // input processing 00091 void DoStdin(int master); 00092 void DoTerminalPty(int master); 00093 void DoDpkgStatusFd(int statusfd, int OutStatusFd); 00094 void ProcessDpkgStatusLine(int OutStatusFd, char *line); 00095 00096 // The Actuall installation implementation 00097 virtual bool Install(PkgIterator Pkg,string File); 00098 virtual bool Configure(PkgIterator Pkg); 00099 virtual bool Remove(PkgIterator Pkg,bool Purge = false); 00100 virtual bool Go(int StatusFd=-1); 00101 virtual void Reset(); 00102 00103 public: 00104 00105 pkgDPkgPM(pkgDepCache *Cache); 00106 virtual ~pkgDPkgPM(); 00107 }; 00108 00109 #endif