00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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>
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>
00050
00051 #include <y2pm/RpmDb.h>
00052 #include <y2pm/InstTargetProdDBPtr.h>
00053 #include <y2pm/InstSrcDescrPtr.h>
00054 #include <y2pm/InstTargetSelDBPtr.h>
00055 #include <y2pm/PkgDu.h>
00056
00058
00059
00063 class InstTarget: public CountedRep, public InstData {
00064 REP_BODY(InstTarget);
00065
00066 public:
00067
00071 typedef class InstTargetError Error;
00072
00074
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
00103
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
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
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
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
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
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
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
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
00453
00455 public:
00456
00482 std::set<PkgDuMaster::MountPoint> getMountPoints() const;
00483 };
00484
00486
00487 #endif // InstTarget_h