summaryrefslogtreecommitdiff
path: root/src/installtransaction.h
blob: 4c740c20674d621f59e2e3332712b4c4c5574f8d (plain)
    1 ////////////////////////////////////////////////////////////////////////
    2 // FILE:        installtransaction.h
    3 // AUTHOR:      Johannes Winkelmann, jw@tks6.net
    4 // COPYRIGHT:   (c) 2002 by Johannes Winkelmann
    5 // ---------------------------------------------------------------------
    6 //  This program is free software; you can redistribute it and/or modify
    7 //  it under the terms of the GNU General Public License as published by
    8 //  the Free Software Foundation; either version 2 of the License, or
    9 //  (at your option) any later version.
   10 ////////////////////////////////////////////////////////////////////////
   11 
   12 #ifndef _INSTALLTRANSACTION_H_
   13 #define _INSTALLTRANSACTION_H_
   14 
   15 #include <string>
   16 #include <list>
   17 #include <map>
   18 #include <vector>
   19 #include <utility>
   20 using namespace std;
   21 
   22 #include "depresolver.h"
   23 
   24 class Repository;
   25 class PkgDB;
   26 class Package;
   27 class ArgParser;
   28 class Configuration;
   29 /*!
   30   \class InstallTransaction
   31   \brief Transaction for installing/updating a list of packages
   32 */
   33 class InstallTransaction
   34 {
   35 public:
   36     InstallTransaction( const list<char*>& names,
   37                         const Repository* repo,
   38                         PkgDB* pkgDB,
   39                         const Configuration* config );
   40     InstallTransaction( const list<string>& names,
   41                         const Repository* repo,
   42                         PkgDB* pkgDB,
   43                         const Configuration* config );
   44 
   45     static const std::string PKGMK_DEFAULT_COMMAND;
   46     static const std::string PKGADD_DEFAULT_COMMAND;
   47     static const std::string PKGRM_DEFAULT_COMMAND;
   48 
   49 
   50     /*! Result of an installation */
   51     enum InstallResult {
   52         SUCCESS,             /*!< yeah, success */
   53         NO_PACKAGE_GIVEN,    /*!< no package give to install */
   54         PACKAGE_NOT_FOUND,   /*!< package not found */
   55         PKGMK_EXEC_ERROR,    /*!< can't execute pkgmk */
   56         PKGMK_FAILURE,       /*!< error while pkgmk */
   57         PKGADD_EXEC_ERROR,   /*!< can't execute pkgadd */
   58         PKGDEST_ERROR,             /*!< can't change to PKGDEST */
   59         PKGADD_FAILURE,      /*!< error while pkgadd */
   60         CYCLIC_DEPEND,       /*!< cyclic dependencies found */
   61         LOG_DIR_FAILURE,     /*!< couldn't create log directory */
   62         LOG_FILE_FAILURE,    /*!< couldn't create log file */
   63         NO_LOG_FILE,         /*!< no log file specified */
   64         CANT_LOCK_LOG_FILE   /*!< can't create lock for log file */
   65     };
   66 
   67     enum State {
   68         EXEC_SUCCESS,
   69         FAILED,
   70         NONEXISTENT
   71     };
   72     struct InstallInfo {
   73         InstallInfo(bool hasReadme_) {
   74             hasReadme = hasReadme_;
   75             preState = NONEXISTENT;
   76             postState = NONEXISTENT;
   77         }
   78         State preState;
   79         State postState;
   80         bool hasReadme;
   81     };
   82 
   83     InstallResult install( const ArgParser* parser,
   84                            bool update,
   85                            bool group );
   86     InstallResult  calcDependencies();
   87 
   88     const list< pair<string, InstallInfo> >& installedPackages() const;
   89     const list<string>& alreadyInstalledPackages() const;
   90     const list<string>& ignoredPackages() const;
   91 
   92 
   93     const list<string>& dependencies() const;
   94     const list< pair<string,string> >& missing() const;
   95     const list< pair<string, InstallInfo> >& installError() const;
   96 
   97 private:
   98     bool calculateDependencies();
   99     void checkDependecies( const Package* package, int depends=-1 );
  100 
  101     InstallResult installPackage( const Package* package,
  102                                   const ArgParser* parser,
  103                                   bool update,
  104                                   InstallInfo& info ) const;
  105 
  106     static string getPkgDest(const string& installRoot);
  107 
  108     PkgDB* m_pkgDB;
  109     DepResolver m_resolver;
  110     const Repository* m_repo;
  111 
  112     // packages to be installed
  113     list< pair<string, const Package*> > m_packages;
  114 
  115     // boolean used to implement lazy initialization
  116     bool m_depCalced;
  117 
  118     // packages< pair<name, hasReadme> > installed by this transaction
  119     list< pair<string, InstallInfo> > m_installedPackages;
  120 
  121     // packages which were requested to be installed which where already
  122     list<string> m_alreadyInstalledPackages;
  123 
  124     // packages which are required by the transaction, but ignored by
  125     // the user
  126     list<string> m_ignoredPackages;
  127 
  128     list<string> m_depNameList;
  129     vector<string> m_depList;
  130 
  131     // packages requested to be installed not found in the ports tree
  132     list< pair<string, string> > m_missingPackages;
  133 
  134     // packages where build/installed failed
  135     list< pair<string, InstallInfo> > m_installErrors;
  136 
  137     /// prt-get itself
  138     const Configuration* m_config;
  139 
  140 };
  141 
  142 #endif /* _INSTALLTRANSACTION_H_ */

Generated by cgit