1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/source/yum/YUMPackageImpl.cc
13 #include "zypp/source/yum/YUMPackageImpl.h"
14 #include "zypp/base/String.h"
15 #include "zypp/base/Logger.h"
18 using namespace zypp::detail;
19 using namespace zypp::parser::yum;
21 ///////////////////////////////////////////////////////////////////
23 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
29 ///////////////////////////////////////////////////////////////////
31 // CLASS NAME : YUMPackageImpl
33 ///////////////////////////////////////////////////////////////////
37 YUMPackageImpl::YUMPackageImpl(
39 const zypp::parser::yum::YUMPrimaryData & parsed,
40 const zypp::parser::yum::YUMFileListData & filelist,
41 const zypp::parser::yum::YUMOtherData & other
43 : _summary(parsed.summary),
45 _buildtime(strtol(parsed.timeBuild.c_str(), 0, 10)),
46 _buildhost(parsed.buildhost),
48 _vendor( parsed.vendor),
49 _license( parsed.license),
50 _packager(parsed.packager),
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,
61 _location(parsed.location),
65 _install_only(parsed.installOnly),
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),
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();
81 _filenames.push_back(it->name);
83 for (std::list<zypp::parser::yum::ChangelogEntry>::const_iterator
84 it = other.changelog.begin();
85 it != other.changelog.end();
88 _changelog.push_back(ChangelogEntry(strtol(it->date.c_str(), 0, 10),
94 YUMPackageImpl::YUMPackageImpl(
96 const zypp::parser::yum::YUMPatchPackage & parsed
98 : _summary(parsed.summary),
100 _buildtime(strtol(parsed.timeBuild.c_str(), 0, 10)),
101 _buildhost(parsed.buildhost),
103 _vendor( parsed.vendor),
104 _license( parsed.license),
105 _packager( parsed.packager),
106 _group(parsed.group),
107 _changelog(), // TODO
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,
116 _location( parsed.plainRpms.empty() ? Pathname() : parsed.plainRpms.front().filename),
120 _install_only(parsed.installOnly),
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),
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();
136 _filenames.push_back(it->name);
138 for (std::list<zypp::parser::yum::YUMPatchRpm>::const_iterator it
139 = parsed.patchRpms.begin();
140 it != parsed.patchRpms.end();
143 std::list<BaseVersion> base_versions;
144 for (std::list<YUMBaseVersion>::const_iterator bit
145 = it->baseVersions.begin();
146 bit != it->baseVersions.end();
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);
155 PatchRpm patch(Arch(it->arch),
157 strtol(it->downloadsize.c_str(), 0, 10),
158 CheckSum("md5", it->md5sum),
159 strtol(it->buildtime.c_str(), 0, 10),
162 _patch_rpms.push_back(patch);
165 for (std::list<zypp::parser::yum::YUMDeltaRpm>::const_iterator it
166 = parsed.deltaRpms.begin();
167 it != parsed.deltaRpms.end();
170 Edition base_edition(it->baseVersion.ver,
172 it->baseVersion.epoch);
173 BaseVersion base_version(base_edition,
174 CheckSum("md5", it->baseVersion.md5sum),
175 strtol(it->baseVersion.buildtime.c_str(),
177 DeltaRpm delta(Arch(it->arch),
179 strtol(it->downloadsize.c_str(), 0, 10),
180 CheckSum("md5", it->md5sum),
181 strtol(it->buildtime.c_str(), 0, 10),
184 _delta_rpms.push_back(delta);
186 for (std::list<zypp::parser::yum::ChangelogEntry>::const_iterator
187 it = parsed.changelog.begin();
188 it != parsed.changelog.end();
191 _changelog.push_back(ChangelogEntry(strtol(it->date.c_str(), 0, 10),
198 /** Package summary */
199 TranslatedText YUMPackageImpl::summary() const
202 /** Package description */
203 TranslatedText YUMPackageImpl::description() const
204 { return _description; }
206 ByteCount YUMPackageImpl::size() const
211 Date YUMPackageImpl::buildtime() const
212 { return _buildtime; }
215 std::string YUMPackageImpl::buildhost() const
216 { return _buildhost; }
219 Date YUMPackageImpl::installtime() const
220 { return PackageImplIf::installtime(); }
223 std::string YUMPackageImpl::distribution() const
228 Vendor YUMPackageImpl::vendor() const
232 Label YUMPackageImpl::license() const
236 std::string YUMPackageImpl::packager() const
237 { return _packager; }
240 PackageGroup YUMPackageImpl::group() const
244 Changelog YUMPackageImpl::changelog() const
245 { return _changelog; }
248 Pathname YUMPackageImpl::location() const
249 { return _location; }
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
257 std::string YUMPackageImpl::os() const
258 // metadata doesn't priovide this attribute
259 { return PackageImplIf::os(); }
262 Text YUMPackageImpl::prein() const
263 // metadata doesn't priovide this attribute
264 { return PackageImplIf::prein(); }
267 Text YUMPackageImpl::postin() const
268 // metadata doesn't priovide this attribute
269 { return PackageImplIf::postin(); }
272 Text YUMPackageImpl::preun() const
273 // metadata doesn't priovide this attribute
274 { return PackageImplIf::preun(); }
277 Text YUMPackageImpl::postun() const
278 // metadata doesn't priovide this attribute
279 { return PackageImplIf::postun(); }
282 ByteCount YUMPackageImpl::sourcesize() const
287 ByteCount YUMPackageImpl::archivesize() const
292 std::list<std::string> YUMPackageImpl::authors() const
296 std::list<std::string> YUMPackageImpl::filenames() const
297 { return _filenames; }
299 License YUMPackageImpl::licenseToConfirm() const
300 { return _license_to_confirm; }
303 std::string YUMPackageImpl::type() const
307 std::list<std::string> YUMPackageImpl::keywords() const
308 { return _keywords; }
310 bool YUMPackageImpl::installOnly() const
311 { return _install_only; }
313 unsigned YUMPackageImpl::mediaId() const
316 CheckSum YUMPackageImpl::checksum() const
317 { return _checksum; }
319 std::list<DeltaRpm> YUMPackageImpl::deltaRpms() const
320 { return _delta_rpms; }
322 std::list<PatchRpm> YUMPackageImpl::patchRpms() const
323 { return _patch_rpms; }
325 Source_Ref YUMPackageImpl::source() const
330 unsigned YUMPackageImpl::packageSize() const
331 { return _size_package; }
333 unsigned YUMPackageImpl::archiveSize() const
334 { return _size_archive; }
336 unsigned YUMPackageImpl::installedSize() const
337 { return _size_installed; }
338 // FIXME do not understand items below
340 bool YUMPackageImpl::providesSources() const
345 std::string YUMPackageImpl::instSrcLabel() const
350 std::string YUMPackageImpl::instSrcVendor() const
355 unsigned YUMPackageImpl::instSrcRank() const
360 std::string YUMPackageImpl::buildhost() const
365 std::string YUMPackageImpl::distribution() const
370 std::string YUMPackageImpl::vendor() const
375 std::string YUMPackageImpl::license() const
380 std::list<std::string> YUMPackageImpl::licenseToConfirm() const
382 return std::list<std::string>();
385 std::string YUMPackageImpl::packager() const
390 std::string YUMPackageImpl::group() const
395 std::list<std::string> YUMPackageImpl::changelog() const
398 std::string YUMPackageImpl::url() const
403 std::string YUMPackageImpl::os() const
406 std::list<std::string> YUMPackageImpl::prein() const
409 std::list<std::string> YUMPackageImpl::postin() const
412 std::list<std::string> YUMPackageImpl::preun() const
415 std::list<std::string> YUMPackageImpl::postun() const
418 std::string YUMPackageImpl::sourcepkg() const
419 { return _sourcepkg; }
421 std::list<std::string> YUMPackageImpl::authors() const
424 std::list<std::string> YUMPackageImpl::filenames() const
427 std::string YUMPackageImpl::location() const
430 std::string YUMPackageImpl::md5sum() const
433 std::string YUMPackageImpl::externalUrl() const
436 std::list<Edition> YUMPackageImpl::patchRpmBaseVersions() const
439 unsigned YUMPackageImpl::patchRpmSize() const
442 bool YUMPackageImpl::forceInstall() const
445 std::string YUMPackageImpl::patchRpmMD5() const
448 bool YUMPackageImpl::isRemote() const
451 bool YUMPackageImpl::prefererCandidate() const
457 /////////////////////////////////////////////////////////////////
458 } // namespace source
459 ///////////////////////////////////////////////////////////////////
460 /////////////////////////////////////////////////////////////////
462 ///////////////////////////////////////////////////////////////////