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