00001
00002
00003
00004
00005
00006
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
00022 class pkgDPkgPM : public pkgPackageManager
00023 {
00024 private:
00025
00026 bool stdin_is_dev_null;
00027
00028
00029 char dpkgbuf[1024];
00030 int dpkgbuf_pos;
00031 FILE *term_out;
00032 FILE *history_out;
00033 string dpkg_error;
00034
00048 void handleDisappearAction(string const &pkgname);
00049
00050 protected:
00051 int pkgFailures;
00052
00053
00054 struct DpkgState
00055 {
00056 const char *state;
00057 const char *str;
00058 };
00059
00060
00061
00062
00063 map<string,vector<struct DpkgState> > PackageOps;
00064
00065
00066
00067 map<string,unsigned int> PackageOpsDone;
00068
00069
00070 unsigned int PackagesDone;
00071 unsigned int PackagesTotal;
00072
00073 struct Item
00074 {
00075 enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op;
00076 string File;
00077 PkgIterator Pkg;
00078 Item(Ops Op,PkgIterator Pkg,string File = "") : Op(Op),
00079 File(File), Pkg(Pkg) {};
00080 Item() {};
00081
00082 };
00083 vector<Item> List;
00084
00085
00086 bool RunScriptsWithPkgs(const char *Cnf);
00087 bool SendV2Pkgs(FILE *F);
00088 void WriteHistoryTag(string const &tag, string value);
00089
00090
00091 void WriteApportReport(const char *pkgpath, const char *errormsg);
00092
00093
00094 bool OpenLog();
00095 bool CloseLog();
00096
00097
00098 void DoStdin(int master);
00099 void DoTerminalPty(int master);
00100 void DoDpkgStatusFd(int statusfd, int OutStatusFd);
00101 void ProcessDpkgStatusLine(int OutStatusFd, char *line);
00102
00103
00104 virtual bool Install(PkgIterator Pkg,string File);
00105 virtual bool Configure(PkgIterator Pkg);
00106 virtual bool Remove(PkgIterator Pkg,bool Purge = false);
00107 virtual bool Go(int StatusFd=-1);
00108 virtual void Reset();
00109
00110 public:
00111
00112 pkgDPkgPM(pkgDepCache *Cache);
00113 virtual ~pkgDPkgPM();
00114 };
00115
00116 #endif