00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PMYouPatch_h
00023 #define PMYouPatch_h
00024
00025 #include <iosfwd>
00026 #include <string>
00027
00028 #include <y2util/Pathname.h>
00029 #include <y2util/FSize.h>
00030
00031 #include <y2pm/PMYouPatchPtr.h>
00032
00033 #include <y2pm/PMObject.h>
00034 #include <y2pm/PMPackagePtr.h>
00035 #include <y2pm/PMYouProductPtr.h>
00036
00040 class PMYouFile
00041 {
00042 public:
00043 PMYouFile( const std::string &name, const FSize &size )
00044 : _name( name ), _size( size ) {}
00045
00046 std::string name() const { return _name; }
00047 FSize size() const { return _size; }
00048
00049 private:
00050 std::string _name;
00051 FSize _size;
00052 };
00053
00057 class PMYouPatch : public PMObject
00058 {
00059 REP_BODY(PMYouPatch);
00060
00061 public:
00062
00066 enum Kind {
00067 kind_invalid = 0,
00068 kind_yast = 1,
00069 kind_security = 2,
00070 kind_recommended = 4,
00071 kind_optional = 8,
00072 kind_document = 16,
00073 kind_patchlevel = 32,
00074 kind_all = 63
00075 };
00079 void setKind( Kind kind ) { _kind = kind; }
00083 Kind kind() const { return _kind; }
00087 std::string kindLabel() { return kindLabel( _kind ); }
00091 static std::string kindLabel( Kind kind );
00092
00096 void setShortDescription( const std::string &str ) { _shortDescription = str; }
00100 std::string shortDescription() const { return _shortDescription; }
00101
00105 void setLongDescription( const std::string &str ) { _longDescription = str; }
00109 std::string longDescription() const { return _longDescription; }
00110
00114 void setPreInformation( const std::string &str ) { _preInformation = str; }
00118 std::string preInformation() const { return _preInformation; }
00119
00123 void setPostInformation( const std::string &str ) { _postInformation = str; }
00127 std::string postInformation() const { return _postInformation; }
00128
00132 void setUpdateOnlyInstalled( bool v ) { _updateOnlyInstalled = v; }
00136 bool updateOnlyInstalled() const { return _updateOnlyInstalled; }
00137
00141 void setUpdateOnlyNew( bool v ) { _updateOnlyNew = v; }
00145 bool updateOnlyNew() const { return _updateOnlyNew; }
00146
00150 void setPreScript( const std::string &preScript ) { _preScript = preScript; }
00154 std::string preScript() const { return _preScript; }
00155
00159 void setUpdateScript( const std::string &updateScript );
00160
00164 std::string updateScript() const;
00165
00169 std::string fallbackScript() const;
00170
00174 void setPostScript( const std::string &postScript ) { _postScript = postScript; }
00178 std::string postScript() const { return _postScript; }
00179
00183 void setPackages( const std::list<PMPackagePtr> &p );
00187 std::list<PMPackagePtr> packages() const { return _packages; }
00191 void addPackage( const PMPackagePtr &pkg );
00195 void clearPackages();
00196
00200 void setLocalFile( const Pathname &localFile ) { _localFile = localFile; }
00204 Pathname localFile() const { return _localFile; }
00205
00209 void setPatchSize( const FSize &size );
00210
00214 FSize patchSize() const;
00215
00220 std::string fullName() const;
00221
00226 void setPackagesInstalled( bool installed ) { _packagesInstalled = installed; }
00227
00231 bool packagesInstalled() const { return _packagesInstalled; }
00232
00233
00237 bool installable() const;
00238
00239
00243 void setFiles( const std::list<PMYouFile> &files );
00244
00248 void addFile( const PMYouFile &file );
00249
00253 std::list<PMYouFile> files() const { return _files; }
00254
00258 void setProduct( const PMYouProductPtr & );
00262 PMYouProductPtr product() const;
00263
00267 void setSkipped( bool s ) { _skipped = s; }
00271 bool skipped() const { return _skipped; }
00272
00276 bool isSelected() const;
00277
00281 void setFileName( const std::string &n ) { _fileName = n; }
00285 std::string fileName() const { return _fileName; }
00286
00287 public:
00288
00293 virtual std::string summary() const { return shortDescription(); }
00294 virtual std::list<std::string> description() const;
00295 virtual std::list<std::string> insnotify() const;
00296 virtual std::list<std::string> delnotify() const { return PMObject::delnotify(); }
00297 virtual FSize size() const { return patchSize(); }
00298 virtual bool providesSources() const { return PMObject::providesSources(); }
00299
00300 virtual std::string instSrcLabel() const { return PMObject::instSrcLabel(); }
00301 virtual Vendor instSrcVendor() const { return PMObject::instSrcVendor(); }
00302 virtual unsigned instSrcRank() const { return PMObject::instSrcRank(); }
00303
00304 private:
00305
00306 std::string _shortDescription, _longDescription;
00307 std::string _preInformation, _postInformation;
00308 Kind _kind;
00309 bool _updateOnlyInstalled;
00310 bool _updateOnlyNew;
00311 std::string _preScript, _postScript;
00312 FSize _patchSize;
00313
00314 std::list<PMPackagePtr> _packages;
00315
00316 Pathname _localFile;
00317 std::string _fileName;
00318
00319 bool _packagesInstalled;
00320
00321 std::list<PMYouFile> _files;
00322
00323 PMYouProductPtr _product;
00324
00325 bool _skipped;
00326
00327 public:
00328
00329 PMYouPatch( const PkgName & name_r,
00330 const PkgEdition & edition_r,
00331 const PkgArch & arch_r );
00332
00333 virtual ~PMYouPatch();
00334
00335 public:
00336
00337 virtual std::ostream & dumpOn( std::ostream & str ) const;
00338 };
00339
00341
00342 #endif // PMYouPatch_h