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