d33abf6854d227939e6b6b244493889443e28f73
[platform/upstream/libzypp.git] / zypp / source / yum / YUMPackageImpl.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/source/yum/YUMPackageImpl.cc
10  *
11 */
12
13 #include "zypp/source/yum/YUMPackageImpl.h"
14 #include "zypp/base/String.h"
15 #include "zypp/base/Logger.h"
16
17 using namespace std;
18 using namespace zypp::detail;
19 using namespace zypp::parser::yum;
20
21 ///////////////////////////////////////////////////////////////////
22 namespace zypp
23 { /////////////////////////////////////////////////////////////////
24   ///////////////////////////////////////////////////////////////////
25   namespace source
26   { /////////////////////////////////////////////////////////////////
27     namespace yum
28     {
29       ///////////////////////////////////////////////////////////////////
30       //
31       //        CLASS NAME : YUMPackageImpl
32       //
33       ///////////////////////////////////////////////////////////////////
34
35       /** Default ctor
36       */
37       YUMPackageImpl::YUMPackageImpl(
38         const zypp::parser::yum::YUMPrimaryData & parsed,
39         const zypp::parser::yum::YUMFileListData & filelist,
40         const zypp::parser::yum::YUMOtherData & other
41       )
42       : _summary(parsed.summary),
43         _description(),
44         _buildtime(strtol(parsed.timeBuild.c_str(), 0, 10)),
45         _buildhost(parsed.buildhost),
46         _url(parsed.url),
47         _vendor( parsed.vendor),
48         _license( parsed.license),
49         _packager(parsed.packager),
50         _group(parsed.group),
51         _changelog(), // TODO
52         _type(parsed.type),
53         _license_to_confirm(), // TODO add to metadata
54         _authors(parsed.authors),
55         _keywords( parsed.keywords),
56         _mediaid(strtol(parsed.media.c_str(), 0, 10)),
57         _checksum(parsed.checksumType,
58                   parsed.checksum),
59         _filenames(),
60         _location(parsed.location),
61         _delta_rpms(),
62         _patch_rpms(),
63
64         _install_only(parsed.installOnly)
65 #if 0
66       : _size_package(strtol(parsed.sizePackage.c_str(), 0, 10)),
67         _size_archive(strtol(parsed.sizeArchive.c_str(), 0, 10)),
68         _size_installed(strtol(parsed.sizeInstalled.c_str(), 0, 10)),
69         _sourcepkg(parsed.sourcerpm),
70         _dir_sizes(parsed.dirSizes),
71 #endif
72       {
73         _description.push_back(parsed.description);
74         for (std::list<FileData>::const_iterator it = filelist.files.begin();
75              it != filelist.files.end();
76              it++)
77         {
78           _filenames.push_back(it->name);
79         }
80 // TODO changelog
81       }
82
83       YUMPackageImpl::YUMPackageImpl(
84         const zypp::parser::yum::YUMPatchPackage & parsed
85       )
86       : _summary(parsed.summary),
87         _description(),
88         _buildtime(strtol(parsed.timeBuild.c_str(), 0, 10)),
89         _buildhost(parsed.buildhost),
90         _url(parsed.url),
91         _vendor( parsed.vendor),
92         _license( parsed.license),
93         _packager( parsed.packager),
94         _group(parsed.group),
95         _changelog(), // TODO
96         _type(parsed.type),
97         _license_to_confirm(), // TODO add to metadata
98         _authors(parsed.authors),
99         _keywords( parsed.keywords),
100         _mediaid(strtol(parsed.media.c_str(), 0, 10)),
101         _checksum(parsed.checksumType,
102                   parsed.checksum),
103         _filenames(),
104         _location(parsed.plainRpms.begin()->filename),
105         _delta_rpms(),
106         _patch_rpms(),
107
108         _install_only(parsed.installOnly)
109 #if 0
110       : _size_package( strtol(parsed.sizePackage.c_str(), 0, 10)),
111         _size_archive( strtol(parsed.sizeArchive.c_str(), 0, 10)),
112         _size_installed( strtol(parsed.sizeInstalled.c_str(), 0, 10)),
113         _sourcepkg( parsed.sourcerpm),
114         _dir_sizes(parsed.dirSizes),
115 #endif
116       {
117         _description.push_back(parsed.description);
118         for (std::list<FileData>::const_iterator it = parsed.files.begin();
119              it != parsed.files.end();
120              it++)
121         {
122           _filenames.push_back(it->name);
123         }
124         for (std::list<zypp::parser::yum::PatchRpm>::const_iterator it
125                 = parsed.patchRpms.begin();
126              it != parsed.patchRpms.end();
127              it++)
128         {
129           std::list<BaseVersion> base_versions;
130           for (std::list<YUMBaseVersion>::const_iterator bit
131                         = it->baseVersions.begin();
132                bit != it->baseVersions.end();
133                bit++)
134           {
135             Edition base_edition(bit->ver, bit->rel, bit->epoch);
136             BaseVersion base_version(base_edition,
137                                      CheckSum("md5", bit->md5sum),
138                                      strtol(bit->buildtime.c_str(), 0, 10));
139             base_versions.push_back(base_version);
140           }
141           PatchRpm patch(Arch(it->arch),
142                          it->filename,
143                          strtol(it->downloadsize.c_str(), 0, 10),
144                          CheckSum("md5", it->md5sum),
145                          strtol(it->buildtime.c_str(), 0, 10),
146                          base_versions
147           );
148           _patch_rpms.push_back(patch);
149           
150         }
151         for (std::list<zypp::parser::yum::DeltaRpm>::const_iterator it
152                 = parsed.deltaRpms.begin();
153              it != parsed.deltaRpms.end();
154              it++)
155         {
156           Edition base_edition(it->baseVersion.ver,
157                                it->baseVersion.rel,
158                                it->baseVersion.epoch);
159           BaseVersion base_version(base_edition,
160                                    CheckSum("md5", it->baseVersion.md5sum),
161                                    strtol(it->baseVersion.buildtime.c_str(),
162                                         0, 10));
163           DeltaRpm delta(Arch(it->arch),
164                          it->filename,
165                          strtol(it->downloadsize.c_str(), 0, 10),
166                          CheckSum("md5", it->md5sum),
167                          strtol(it->buildtime.c_str(), 0, 10),
168                          base_version
169           );
170           _delta_rpms.push_back(delta);
171         }
172 // TODO changelog
173       }
174
175
176       /** Package summary */
177       Label YUMPackageImpl::summary() const
178       { return _summary; }
179
180       /** Package description */
181       Text YUMPackageImpl::description() const
182       { return _description; }
183
184       Text YUMPackageImpl::insnotify() const
185       // metadata doesn't priovide this attribute
186       { return ResObjectImplIf::insnotify(); }
187
188       Text YUMPackageImpl::delnotify() const
189       // metadata doesn't priovide this attribute
190       { return ResObjectImplIf::delnotify(); }
191
192       FSize YUMPackageImpl::size() const
193       { }
194
195       bool YUMPackageImpl::providesSources() const
196       { return ResObjectImplIf::providesSources(); }
197
198       Label YUMPackageImpl::instSrcLabel() const
199       { return ResObjectImplIf::instSrcLabel(); }
200       
201       Vendor YUMPackageImpl::instSrcVendor() const
202       { return ResObjectImplIf::instSrcVendor(); }
203       
204       /** */
205       Date YUMPackageImpl::buildtime() const
206       { return _buildtime; }
207
208       /** */
209       std::string YUMPackageImpl::buildhost() const
210       { return _buildhost; }
211
212       /** */
213       Date YUMPackageImpl::installtime() const
214       { return PackageImplIf::installtime(); }
215
216       /** */
217       std::string YUMPackageImpl::distribution() const
218       { }
219
220       /** */
221       Vendor YUMPackageImpl::vendor() const
222       { return _vendor; }
223
224       /** */
225       Label YUMPackageImpl::license() const
226       { return _license; }
227
228       /** */
229       std::string YUMPackageImpl::packager() const
230       { return _packager; }
231
232       /** */
233       PackageGroup YUMPackageImpl::group() const
234       { return _group; }
235
236       /** */
237       Text YUMPackageImpl::changelog() const
238       { return _changelog; }
239
240       /** Don't ship it as class Url, because it might be
241        * in fact anything but a legal Url. */
242       std::string YUMPackageImpl::url() const
243       { return _url; }
244
245       /** */
246       std::string YUMPackageImpl::os() const
247       // metadata doesn't priovide this attribute
248       { return PackageImplIf::os(); }
249
250       /** */
251       Text YUMPackageImpl::prein() const
252       // metadata doesn't priovide this attribute
253       { return PackageImplIf::prein(); }
254
255       /** */
256       Text YUMPackageImpl::postin() const
257       // metadata doesn't priovide this attribute
258       { return PackageImplIf::postin(); }
259
260       /** */
261       Text YUMPackageImpl::preun() const
262       // metadata doesn't priovide this attribute
263       { return PackageImplIf::preun(); }
264
265       /** */
266       Text YUMPackageImpl::postun() const
267       // metadata doesn't priovide this attribute
268       { return PackageImplIf::postun(); }
269
270       /** */
271       FSize YUMPackageImpl::sourcesize() const
272       { }
273
274       /** */
275       FSize YUMPackageImpl::archivesize() const
276       { }
277
278       /** */
279       Text YUMPackageImpl::authors() const
280       { return _authors; }
281
282       /** */
283       Text YUMPackageImpl::filenames() const
284       { return _filenames; }
285
286       License YUMPackageImpl::licenseToConfirm() const
287       { return _license_to_confirm; }
288
289       /** */
290       std::string YUMPackageImpl::type() const
291       { return _type; }
292
293       /** */
294       std::list<std::string> YUMPackageImpl::keywords() const
295       { return _keywords; }
296
297       bool YUMPackageImpl::installOnly() const
298       { return _install_only; }
299
300       unsigned YUMPackageImpl::mediaId() const
301       { return _mediaid; }
302
303       PackageImplIf::CheckSum YUMPackageImpl::checksum() const
304       { return _checksum; }
305
306       std::list<PackageImplIf::DeltaRpm> YUMPackageImpl::deltaRpms() const
307       { return _delta_rpms; }
308
309       std::list<PackageImplIf::PatchRpm> YUMPackageImpl::patchRpms() const
310       { return _patch_rpms; }
311
312 #if 0
313       /** */
314       std::list<std::string> YUMPackageImpl::insnotify() const
315       { return std::list<std::string>(); }
316       /** */
317       std::list<std::string> YUMPackageImpl::delnotify() const
318       { return std::list<std::string>(); }
319       /** */
320       unsigned YUMPackageImpl::packageSize() const
321       { return _size_package; }
322       /** */
323       unsigned YUMPackageImpl::archiveSize() const
324       { return _size_archive; }
325       /** */
326       unsigned YUMPackageImpl::installedSize() const
327       { return _size_installed; }
328 // FIXME do not understand items below
329       /** */
330       bool YUMPackageImpl::providesSources() const
331       {
332         return false;
333       }
334       /** */
335       std::string YUMPackageImpl::instSrcLabel() const
336       {
337         return "";
338       }
339       /** */
340       std::string YUMPackageImpl::instSrcVendor() const
341       {
342         return "";
343       }
344       /** */
345       unsigned YUMPackageImpl::instSrcRank() const
346       {
347         return 0;
348       }
349       /** */
350       std::string YUMPackageImpl::buildhost() const
351       {
352         return _buildhost;
353       }
354       /** */
355       std::string YUMPackageImpl::distribution() const
356       {
357         return "";
358       }
359       /** */
360       std::string YUMPackageImpl::vendor() const
361       {
362         return _vendor;
363       }
364       /** */
365       std::string YUMPackageImpl::license() const
366       {
367         return _license;
368       }
369       /** */
370       std::list<std::string> YUMPackageImpl::licenseToConfirm() const
371       {
372         return std::list<std::string>();
373       }
374       /** */
375       std::string YUMPackageImpl::packager() const
376       {
377         return _packager;
378       }
379       /** */
380       std::string YUMPackageImpl::group() const
381       {
382         return _group;
383       }
384       /** */
385       std::list<std::string> YUMPackageImpl::changelog() const
386       {}
387       /** */
388       std::string YUMPackageImpl::url() const
389       {
390         return _url;
391       }
392       /** */
393       std::string YUMPackageImpl::os() const
394       {}
395       /** */
396       std::list<std::string> YUMPackageImpl::prein() const
397       {}
398       /** */
399       std::list<std::string> YUMPackageImpl::postin() const
400       {}
401       /** */
402       std::list<std::string> YUMPackageImpl::preun() const
403       {}
404       /** */
405       std::list<std::string> YUMPackageImpl::postun() const
406       {}
407       /** */
408       std::string YUMPackageImpl::sourcepkg() const
409       { return _sourcepkg; }
410       /** */
411       std::list<std::string> YUMPackageImpl::authors() const
412       { return _authors; }
413       /** */
414       std::list<std::string> YUMPackageImpl::filenames() const
415       {}
416       /** */
417       std::list<std::string> YUMPackageImpl::recommends() const
418       {}
419       /** */
420       std::list<std::string> YUMPackageImpl::suggests() const
421       {}
422       /** */
423       std::string YUMPackageImpl::location() const
424       {}
425       /** */
426       std::string YUMPackageImpl::md5sum() const
427       {}
428       /** */
429       std::string YUMPackageImpl::externalUrl() const
430       {}
431       /** */
432       std::list<Edition> YUMPackageImpl::patchRpmBaseVersions() const
433       {}
434       /** */
435       unsigned YUMPackageImpl::patchRpmSize() const
436       {}
437       /** */
438       bool YUMPackageImpl::forceInstall() const
439       {}
440       /** */
441       std::string YUMPackageImpl::patchRpmMD5() const
442       {}
443       /** */
444       bool YUMPackageImpl::isRemote() const
445       {}
446       /** */
447       bool YUMPackageImpl::prefererCandidate() const
448       {}
449
450 #endif
451
452     } // namespace yum
453     /////////////////////////////////////////////////////////////////
454   } // namespace source
455   ///////////////////////////////////////////////////////////////////
456   /////////////////////////////////////////////////////////////////
457 } // namespace zypp
458 ///////////////////////////////////////////////////////////////////