apt @VERSION@
packagemanager.h
00001 // -*- mode: cpp; mode: fold -*-
00002 // Description                                                          /*{{{*/
00003 // $Id: packagemanager.h,v 1.14 2001/05/07 04:24:08 jgg Exp $
00004 /* ######################################################################
00005 
00006    Package Manager - Abstacts the package manager
00007 
00008    Three steps are 
00009      - Aquiration of archives (stores the list of final file names)
00010      - Sorting of operations
00011      - Invokation of package manager
00012    
00013    This is the final stage when the package cache entities get converted
00014    into file names and the state stored in a DepCache is transformed
00015    into a series of operations.
00016 
00017    In the final scheme of things this may serve as a director class to
00018    access the actual install methods based on the file type being
00019    installed.
00020    
00021    ##################################################################### */
00022                                                                         /*}}}*/
00023 #ifndef PKGLIB_PACKAGEMANAGER_H
00024 #define PKGLIB_PACKAGEMANAGER_H
00025 
00026 
00027 #include <string>
00028 #include <iostream>
00029 #include <apt-pkg/pkgcache.h>
00030 #include <apt-pkg/depcache.h>
00031 #include <set>
00032 
00033 using std::string;
00034 
00035 class pkgAcquire;
00036 class pkgDepCache;
00037 class pkgSourceList;
00038 class pkgOrderList;
00039 class pkgRecords;
00040 class pkgPackageManager : protected pkgCache::Namespace
00041 {
00042    public:
00043    
00044    enum OrderResult {Completed,Failed,Incomplete};
00045    static bool SigINTStop;
00046    
00047    protected:
00048    string *FileNames;
00049    pkgDepCache &Cache;
00050    pkgOrderList *List;
00051    bool Debug;
00052    bool NoImmConfigure;
00053    bool ImmConfigureAll;
00054 
00061    std::set<std::string> disappearedPkgs;
00062 
00063    void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
00064    virtual OrderResult OrderInstall();
00065    bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
00066    bool CreateOrderList();
00067    
00068    // Analysis helpers
00069    bool DepAlwaysTrue(DepIterator D);
00070    
00071    // Install helpers
00072    bool ConfigureAll();
00073    bool SmartConfigure(PkgIterator Pkg, int const Depth);
00074    //FIXME: merge on abi break
00075    bool SmartUnPack(PkgIterator Pkg);
00076    bool SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth);
00077    bool SmartRemove(PkgIterator Pkg);
00078    bool EarlyRemove(PkgIterator Pkg);  
00079    
00080    // The Actual installation implementation
00081    virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;};
00082    virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
00083    virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
00084    virtual bool Go(int statusFd=-1) {return true;};
00085    virtual void Reset() {};
00086 
00087    // the result of the operation
00088    OrderResult Res;
00089 
00090    public:
00091       
00092    // Main action members
00093    bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
00094                     pkgRecords *Recs);
00095 
00096    // Do the installation 
00097    OrderResult DoInstall(int statusFd=-1);
00098 
00099    // stuff that needs to be done before the fork() of a library that
00100    // uses apt
00101    OrderResult DoInstallPreFork() {
00102       Res = OrderInstall();
00103       return Res;
00104    };
00105 
00106    // stuff that needs to be done after the fork
00107    OrderResult DoInstallPostFork(int statusFd=-1);
00108    bool FixMissing();
00109 
00111    inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
00112 
00113    pkgPackageManager(pkgDepCache *Cache);
00114    virtual ~pkgPackageManager();
00115 };
00116 
00117 #endif