apt  1.5
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 #include <apt-pkg/pkgcache.h>
00027 
00028 #include <string>
00029 #include <iostream>
00030 #include <set>
00031 
00032 #ifndef APT_8_CLEANER_HEADERS
00033 #include <apt-pkg/depcache.h>
00034 using std::string;
00035 #endif
00036 
00037 class pkgAcquire;
00038 class pkgDepCache;
00039 class pkgSourceList;
00040 class pkgOrderList;
00041 class pkgRecords;
00042 class pkgPackageManager : protected pkgCache::Namespace
00043 {
00044    public:
00045    
00046    enum OrderResult {Completed,Failed,Incomplete};
00047    static bool SigINTStop;
00048    
00049    protected:
00050    std::string *FileNames;
00051    pkgDepCache &Cache;
00052    pkgOrderList *List;
00053    bool Debug;
00054    bool NoImmConfigure;
00055    bool ImmConfigureAll;
00056 
00063    std::set<std::string> disappearedPkgs;
00064 
00065    void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
00066    virtual OrderResult OrderInstall();
00067    bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
00068    bool CreateOrderList();
00069    
00070    // Analysis helpers
00071    bool DepAlwaysTrue(DepIterator D);
00072    
00073    // Install helpers
00074    bool ConfigureAll();
00075    bool SmartConfigure(PkgIterator Pkg, int const Depth);
00076    //FIXME: merge on abi break
00077    bool SmartUnPack(PkgIterator Pkg);
00078    bool SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth);
00079    bool SmartRemove(PkgIterator Pkg);
00080    bool EarlyRemove(PkgIterator Pkg);  
00081    
00082    // The Actual installation implementation
00083    virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;};
00084    virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
00085    virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;};
00086    virtual bool Go(int statusFd=-1) {return true;};
00087    virtual void Reset() {};
00088 
00089    // the result of the operation
00090    OrderResult Res;
00091 
00092    public:
00093       
00094    // Main action members
00095    bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
00096                     pkgRecords *Recs);
00097 
00098    // Do the installation 
00099    OrderResult DoInstall(int statusFd=-1);
00100 
00101    // stuff that needs to be done before the fork() of a library that
00102    // uses apt
00103    OrderResult DoInstallPreFork() {
00104       Res = OrderInstall();
00105       return Res;
00106    };
00107 
00108    // stuff that needs to be done after the fork
00109    OrderResult DoInstallPostFork(int statusFd=-1);
00110    bool FixMissing();
00111 
00113    inline std::set<std::string> GetDisappearedPackages() { return disappearedPkgs; };
00114 
00115    pkgPackageManager(pkgDepCache *Cache);
00116    virtual ~pkgPackageManager();
00117 };
00118 
00119 #endif