Removed obsolete files and classes.
[platform/upstream/libzypp.git] / zypp / target / rpm / RpmHeader.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/rpm/RpmHeader.h
10  *
11 */
12 #ifndef ZYPP_TARGET_RPM_RPMHEADER_H
13 #define ZYPP_TARGET_RPM_RPMHEADER_H
14
15 #include <iosfwd>
16 #include <list>
17
18 #include "zypp/target/rpm/BinHeader.h"
19
20 #include "zypp/Package.h"
21 #include "zypp/Changelog.h"
22 #include "zypp/Pathname.h"
23 #include "zypp/DiskUsage.h"
24
25
26 namespace zypp
27 {
28 namespace target
29 {
30 namespace rpm
31 {
32
33 struct FileInfo
34 {
35   Pathname    filename;
36   ByteCount   size;
37   std::string md5sum;
38   uid_t       uid;
39   gid_t       gid;
40   mode_t      mode;
41   time_t      mtime;
42   bool        ghost;
43   Pathname link_target;
44 };
45
46 ///////////////////////////////////////////////////////////////////
47 //
48 //      CLASS NAME : RpmHeader
49 /**
50  * @short Wrapper class for rpm header struct.
51  *
52  * <code>RpmHeader</code> provides methods to query the content
53  * of a rpm header struct retrieved from the RPM database or by reading
54  * the rpm header of a package on disk.
55  *
56  * The rpm header contains all data associated with a package. So you
57  * probabely do not want to permanently store too many of them.
58  *
59  * <B>NEVER create <code>RpmHeader</code> from a NULL <code>Header</code>! </B>
60  **/
61 class RpmHeader : public BinHeader
62 {
63 public:
64   typedef intrusive_ptr<RpmHeader> Ptr;
65   typedef intrusive_ptr<const RpmHeader> constPtr;
66
67 private:
68
69   CapabilitySet PkgRelList_val( tag tag_r, bool pre, std::set<std::string> * freq_r = 0 ) const;
70
71 public:
72
73   /**
74    *
75    **/
76   RpmHeader( Header h_r = 0 );
77
78   /**
79    * <B>Dangerous!<\B> This one takes the header out of rhs
80    * and leaves rhs empty.
81    **/
82   RpmHeader( BinHeader::Ptr & rhs );
83
84   virtual ~RpmHeader();
85
86   bool isSrc() const;
87
88 public:
89
90   std::string      tag_name()    const;
91   Edition::epoch_t tag_epoch()   const;
92   std::string      tag_version() const;
93   std::string      tag_release() const;
94   Edition          tag_edition() const;
95   Arch             tag_arch()    const;
96
97   Date tag_installtime() const;
98   Date tag_buildtime()   const;
99
100   /**
101    * If <code>freq_r</code> is not NULL, file dependencies found are inserted.
102    **/
103   CapabilitySet tag_provides ( std::set<std::string> * freq_r = 0 ) const;
104   /**
105    * @see #tag_provides
106    **/
107   CapabilitySet tag_requires ( std::set<std::string> * freq_r = 0 ) const;
108   /**
109    * @see #tag_provides
110    **/
111   CapabilitySet tag_prerequires ( std::set<std::string> * freq_r = 0 ) const;
112   /**
113    * @see #tag_provides
114    **/
115   CapabilitySet tag_conflicts( std::set<std::string> * freq_r = 0 ) const;
116   /**
117    * @see #tag_provides
118    **/
119   CapabilitySet tag_obsoletes( std::set<std::string> * freq_r = 0 ) const;
120   /**
121    * @see #tag_provides
122    **/
123   CapabilitySet tag_enhances( std::set<std::string> * freq_r = 0 ) const;
124   /**
125    * @see #tag_provides
126    **/
127   CapabilitySet tag_suggests( std::set<std::string> * freq_r = 0 ) const;
128   /** Unsupported by rpm.
129    * @see #tag_provides
130    **/
131   CapabilitySet tag_supplements( std::set<std::string> * freq_r = 0 ) const
132   { return CapabilitySet(); }
133   /** Unsupported by rpm.
134    * @see #tag_provides
135    **/
136   CapabilitySet tag_freshens( std::set<std::string> * freq_r = 0 ) const
137   { return CapabilitySet(); }
138
139   ByteCount tag_size()        const;
140   ByteCount tag_archivesize() const;
141
142   std::string tag_summary()      const;
143   std::string tag_description()  const;
144   std::string tag_group()        const;
145   std::string tag_vendor()       const;
146   std::string tag_distribution() const;
147   std::string tag_license()      const;
148   std::string tag_buildhost()    const;
149   std::string tag_packager()     const;
150   std::string tag_url()          const;
151   std::string tag_os()           const;
152   std::string tag_prein()        const;
153   std::string tag_postin()       const;
154   std::string tag_preun()        const;
155   std::string tag_postun()       const;
156   std::string tag_sourcerpm()    const;
157
158   /** just the list of names  */
159   std::list<std::string> tag_filenames() const;
160
161   /**
162    * complete information about the files
163    * (extended version of tag_filenames())
164           */
165   std::list<FileInfo> tag_fileinfos() const;
166
167   Changelog tag_changelog() const;
168
169   /**
170    * Returns reference to arg <code>dudata_r</code>.
171    **/
172   DiskUsage & tag_du( DiskUsage & dudata_r ) const;
173
174 public:
175
176   virtual std::ostream & dumpOn( std::ostream & str ) const;
177
178 public:
179
180   /**
181    * Digest and signature verification flags
182    **/
183   enum VERIFICATION
184   {
185     VERIFY       = 0x0000,
186     NODIGEST     = (1<<0),
187     NOSIGNATURE  = (1<<1),
188     NOVERIFY     = 0xffff
189   };
190
191   /**
192    * Get an accessible packages data from disk.
193    * Returns NULL on any error.
194    **/
195   static RpmHeader::constPtr readPackage( const Pathname & path,
196                                           VERIFICATION verification = VERIFY );
197 };
198
199 ///////////////////////////////////////////////////////////////////
200 } // namespace rpm
201 } // namespace target
202 } // namespace zypp
203
204 #endif // ZYPP_TARGET_RPM_RPMHEADER_H
205