apt  @VERSION@
dpkgpm.h
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 #ifndef APT_8_CLEANER_HEADERS
00019 using std::vector;
00020 using std::map;
00021 #endif
00022 
00023 class pkgDPkgPMPrivate;
00024 
00025 class pkgDPkgPM : public pkgPackageManager
00026 {
00027    private:
00028    pkgDPkgPMPrivate *d;
00029 
00043    void handleDisappearAction(std::string const &pkgname);
00044 
00045    protected:
00046    int pkgFailures;
00047 
00048    // progress reporting
00049    struct DpkgState 
00050    {
00051       const char *state;     // the dpkg state (e.g. "unpack")
00052       const char *str;       // the human readable translation of the state
00053    };
00054 
00055    // the dpkg states that the pkg will run through, the string is 
00056    // the package, the vector contains the dpkg states that the package
00057    // will go through
00058    std::map<std::string,std::vector<struct DpkgState> > PackageOps;
00059    // the dpkg states that are already done; the string is the package
00060    // the int is the state that is already done (e.g. a package that is
00061    // going to be install is already in state "half-installed")
00062    std::map<std::string,unsigned int> PackageOpsDone;
00063 
00064    // progress reporting
00065    unsigned int PackagesDone;
00066    unsigned int PackagesTotal;
00067   
00068    struct Item
00069    {
00070       enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op;
00071       std::string File;
00072       PkgIterator Pkg;
00073       Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op),
00074             File(File), Pkg(Pkg) {};
00075       Item() {};
00076       
00077    };
00078    std::vector<Item> List;
00079 
00080    // Helpers
00081    bool RunScriptsWithPkgs(const char *Cnf);
00082    bool SendV2Pkgs(FILE *F);
00083    void WriteHistoryTag(std::string const &tag, std::string value);
00084 
00085    // apport integration
00086    void WriteApportReport(const char *pkgpath, const char *errormsg);
00087 
00088    // dpkg log
00089    bool OpenLog();
00090    bool CloseLog();
00091    
00092    // input processing
00093    void DoStdin(int master);
00094    void DoTerminalPty(int master);
00095    void DoDpkgStatusFd(int statusfd, int OutStatusFd);
00096    void ProcessDpkgStatusLine(int OutStatusFd, char *line);
00097 
00098    // The Actuall installation implementation
00099    virtual bool Install(PkgIterator Pkg,std::string File);
00100    virtual bool Configure(PkgIterator Pkg);
00101    virtual bool Remove(PkgIterator Pkg,bool Purge = false);
00102    virtual bool Go(int StatusFd=-1);
00103    virtual void Reset();
00104    
00105    public:
00106 
00107    pkgDPkgPM(pkgDepCache *Cache);
00108    virtual ~pkgDPkgPM();
00109 };
00110 
00111 void SigINT(int sig);
00112 
00113 #endif