Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

InstTarget.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013    File:       InstTarget.h
00014 
00015    Author:     Michael Andres <ma@suse.de>
00016    Maintainer: Michael Andres <ma@suse.de>
00017 
00018    Purpose:     Class for installation target
00019                 It provides access to the installation target
00020                 and shares some API calls with InstSrc, esp.
00021                 - selection information
00022                 - package information
00023                 - patch information
00024                 but does not report about installable but installed
00025                 selections, packages, or patches.
00026 
00027                 Additionally, the InstTarget can also change packages,
00028                 selections, and patches, by installing or removing them.
00029 
00030 /-*/
00031 #ifndef InstTarget_h
00032 #define InstTarget_h
00033 
00034 #include <iosfwd>
00035 #include <list>
00036 #include <set>
00037 #include <string>
00038 
00039 #include <y2util/Pathname.h>
00040 #include <y2util/FSize.h>
00041 
00042 #include <y2pm/PMError.h>
00043 
00044 #include <y2pm/MediaAccessPtr.h>        // physical media access class
00045 #include <y2pm/PkgArch.h>
00046 #include <y2pm/PMPackagePtr.h>
00047 #include <y2pm/PMSelectionPtr.h>
00048 #include <y2pm/PMYouPatchPtr.h>
00049 #include <y2pm/InstData.h>       // InstTarget implements InstData
00050 
00051 #include <y2pm/RpmDb.h>               // InstTarget is tied to RpmDb atm
00052 #include <y2pm/InstTargetProdDBPtr.h> // Installed Products
00053 #include <y2pm/InstSrcDescrPtr.h>
00054 #include <y2pm/InstTargetSelDBPtr.h>  // Installed Selections
00055 #include <y2pm/PkgDu.h>
00056 
00058 //
00059 //      CLASS NAME : InstTarget
00063 class InstTarget: public CountedRep, public InstData {
00064     REP_BODY(InstTarget);
00065 
00066   public:
00067 
00071     typedef class InstTargetError Error;
00072 
00074     // General interface
00076 
00077   private:
00078 
00082     Pathname _rootdir;
00083 
00087     RpmDbPtr _rpmdb;
00088 
00092     InstTargetProdDBPtr _proddb;
00093 
00097     InstTargetSelDBPtr _seldb;
00098 
00099   private:
00100 
00101     friend class Y2PM;
00102     // no parameters here since Y2PM creates it on first access
00103     // and there's no way to pass parameters -> see init()
00104     InstTarget();
00105     ~InstTarget();
00106 
00117     PMError init( const Pathname & rootpath );
00118 
00119   public:
00120 
00124     static PkgArch baseArch();
00125 
00130     const Pathname & rootdir() const { return _rootdir; }
00131 
00135     bool initialized() const { return( ! _rootdir.empty() ); }
00136 
00142     bool needsUpdate() const;
00143 
00147     PMError bringIntoCleanState();
00148 
00153     virtual const std::list<PMPackagePtr> & getPackages() const;
00154 
00159     virtual const std::vector<PMYouPatchPtr> & getPatches() const;
00160 
00162     // Package related interface
00164 
00165   private:
00166 
00169     unsigned _rpminstflags;
00170 
00173     unsigned _rpmremoveflags;
00174 
00175   public:
00176 
00183     typedef enum RpmDb::RpmInstFlag InstFlag;
00184 
00191     typedef enum RpmDb::checkPackageResult checkPackageResult;
00192 
00193     //-----------------------------
00194     // package install / remove
00195 
00201     bool setInstallationLogfile(const std::string& logfile);
00202 
00208     void setBackupPath (const Pathname& path);
00209 
00216     void createPackageBackups(bool yes);
00217 
00222     Pathname getBackupPath (void);
00223 
00229     void setPkgInstFlags(unsigned flags);
00230 
00235     unsigned getPkgInstFlags() const;
00236 
00242     void setPkgRemoveFlags(unsigned flags);
00243 
00248     unsigned getPkgRemoveFlags() const;
00249 
00256     PMError installPackage (const Pathname& filename, unsigned flags = 0);
00257 
00264     PMError installPackages (const std::list<Pathname>& filenames, unsigned flags = 0);
00265 
00272     PMError removePackage(const std::string & name_r, unsigned flags = 0);
00273     PMError removePackage(constPMPackagePtr package, unsigned flags = 0);
00274 
00280     PMError removePackages(const std::list<std::string>& names_r, unsigned flags = 0);
00281     PMError removePackages(const std::list<PMPackagePtr>& packages, unsigned flags = 0);
00282 
00283   public:
00285     //
00286     // RPM database public keys
00287     //
00289 
00293     PMError importPubkey( const Pathname & pubkey_r ) { return _rpmdb->importPubkey( pubkey_r ); }
00294 
00298     PMError importPubkey( const Pathname & keyring_r, const std::string & keyname_r ) { return _rpmdb->importPubkey( keyring_r, keyname_r ); }
00299 
00303     std::set<PkgEdition> pubkeys() const { return _rpmdb->pubkeys(); }
00304 
00305   public:
00307     //
00308     // Direct RPM database retrieval forwarded to RpmDb
00309     //
00311 
00315     bool hasFile( const std::string & file_r ) const { return _rpmdb->hasFile( file_r ); }
00316 
00320     bool hasProvides( const std::string & tag_r ) const { return _rpmdb->hasProvides( tag_r ); }
00321 
00325     bool hasRequiredBy( const std::string & tag_r ) const { return _rpmdb->hasRequiredBy( tag_r ); }
00326 
00330     bool hasConflicts( const std::string & tag_r ) const { return _rpmdb->hasConflicts( tag_r ); }
00331 
00335     bool hasPackage( const PkgName & name_r ) const { return _rpmdb->hasPackage( name_r ); }
00336 
00340     void traceFileRel( const PkgRelation & rel_r ) { _rpmdb->traceFileRel( rel_r ); }
00341 
00343 
00347     bool isProvided (const std::string& tag) { return hasProvides(tag); }
00351     bool isInstalled (const std::string& name) { return hasPackage(PkgName(name)); }
00352 
00354     // Patch related interface
00356   private:
00357 
00358       mutable std::vector<PMYouPatchPtr> _patches;
00359       mutable bool _patchesInitialized;
00360 
00361   public:
00362 
00369     PMError installPatch( const Pathname &filename );
00370 
00374     PMError executeScript( const Pathname &scriptname );
00375     PMError executeScript( const Pathname &scriptname, const std::list<std::string> arguments );
00376 
00378     // Product related interface
00380   public:
00381 
00385     bool mayAccessProducts() const;
00386 
00391     const std::list<constInstSrcDescrPtr> & getProducts() const;
00392 
00398     bool isInstalledProduct( const constInstSrcDescrPtr & isd_r ) const;
00399 
00405     PMError installProduct( const constInstSrcDescrPtr & isd_r );
00406 
00411     PMError removeProduct( const constInstSrcDescrPtr & isd_r );
00412 
00413 
00415     // Selection related interface
00417   public:
00418 
00422     bool mayAccessSelections() const;
00423 
00428     virtual const std::list<PMSelectionPtr> & getSelections() const;
00429 
00435     bool isInstalledSelection( const Pathname & selfile_r ) const;
00436 
00441     PMError installSelection( const Pathname & selfile_r );
00442 
00447     PMError removeSelection( const Pathname & selfile_r );
00448 
00449 
00451     //
00452     // Disk usage calculation.
00453     //
00455   public:
00456 
00482     std::set<PkgDuMaster::MountPoint> getMountPoints() const;
00483 };
00484 
00486 
00487 #endif // InstTarget_h

Generated on Fri Nov 9 14:30:31 2007 for yast2-packagemanager by doxygen 1.3.6