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(
38 const zypp::parser::yum::YUMPrimaryData & parsed,
39 const zypp::parser::yum::YUMFileListData & filelist,
40 const zypp::parser::yum::YUMOtherData & other
42 : _summary(parsed.summary),
44 _buildtime(strtol(parsed.timeBuild.c_str(), 0, 10)),
45 _buildhost(parsed.buildhost),
47 _vendor( parsed.vendor),
48 _license( parsed.license),
49 _packager(parsed.packager),
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,
60 _location(parsed.location),
64 _install_only(parsed.installOnly)
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),
73 _description.push_back(parsed.description);
74 for (std::list<FileData>::const_iterator it = filelist.files.begin();
75 it != filelist.files.end();
78 _filenames.push_back(it->name);
83 YUMPackageImpl::YUMPackageImpl(
84 const zypp::parser::yum::YUMPatchPackage & parsed
86 : _summary(parsed.summary),
88 _buildtime(strtol(parsed.timeBuild.c_str(), 0, 10)),
89 _buildhost(parsed.buildhost),
91 _vendor( parsed.vendor),
92 _license( parsed.license),
93 _packager( parsed.packager),
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,
104 _location(parsed.plainRpms.begin()->filename),
108 _install_only(parsed.installOnly)
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),
117 _description.push_back(parsed.description);
118 for (std::list<FileData>::const_iterator it = parsed.files.begin();
119 it != parsed.files.end();
122 _filenames.push_back(it->name);
124 for (std::list<zypp::parser::yum::PatchRpm>::const_iterator it
125 = parsed.patchRpms.begin();
126 it != parsed.patchRpms.end();
129 std::list<BaseVersion> base_versions;
130 for (std::list<YUMBaseVersion>::const_iterator bit
131 = it->baseVersions.begin();
132 bit != it->baseVersions.end();
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);
141 PatchRpm patch(Arch(it->arch),
143 strtol(it->downloadsize.c_str(), 0, 10),
144 CheckSum("md5", it->md5sum),
145 strtol(it->buildtime.c_str(), 0, 10),
148 _patch_rpms.push_back(patch);
151 for (std::list<zypp::parser::yum::DeltaRpm>::const_iterator it
152 = parsed.deltaRpms.begin();
153 it != parsed.deltaRpms.end();
156 Edition base_edition(it->baseVersion.ver,
158 it->baseVersion.epoch);
159 BaseVersion base_version(base_edition,
160 CheckSum("md5", it->baseVersion.md5sum),
161 strtol(it->baseVersion.buildtime.c_str(),
163 DeltaRpm delta(Arch(it->arch),
165 strtol(it->downloadsize.c_str(), 0, 10),
166 CheckSum("md5", it->md5sum),
167 strtol(it->buildtime.c_str(), 0, 10),
170 _delta_rpms.push_back(delta);
176 /** Package summary */
177 Label YUMPackageImpl::summary() const
180 /** Package description */
181 Text YUMPackageImpl::description() const
182 { return _description; }
184 Text YUMPackageImpl::insnotify() const
185 // metadata doesn't priovide this attribute
186 { return ResObjectImplIf::insnotify(); }
188 Text YUMPackageImpl::delnotify() const
189 // metadata doesn't priovide this attribute
190 { return ResObjectImplIf::delnotify(); }
192 FSize YUMPackageImpl::size() const
195 bool YUMPackageImpl::providesSources() const
196 { return ResObjectImplIf::providesSources(); }
198 Label YUMPackageImpl::instSrcLabel() const
199 { return ResObjectImplIf::instSrcLabel(); }
201 Vendor YUMPackageImpl::instSrcVendor() const
202 { return ResObjectImplIf::instSrcVendor(); }
205 Date YUMPackageImpl::buildtime() const
206 { return _buildtime; }
209 std::string YUMPackageImpl::buildhost() const
210 { return _buildhost; }
213 Date YUMPackageImpl::installtime() const
214 { return PackageImplIf::installtime(); }
217 std::string YUMPackageImpl::distribution() const
221 Vendor YUMPackageImpl::vendor() const
225 Label YUMPackageImpl::license() const
229 std::string YUMPackageImpl::packager() const
230 { return _packager; }
233 PackageGroup YUMPackageImpl::group() const
237 Text YUMPackageImpl::changelog() const
238 { return _changelog; }
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
246 std::string YUMPackageImpl::os() const
247 // metadata doesn't priovide this attribute
248 { return PackageImplIf::os(); }
251 Text YUMPackageImpl::prein() const
252 // metadata doesn't priovide this attribute
253 { return PackageImplIf::prein(); }
256 Text YUMPackageImpl::postin() const
257 // metadata doesn't priovide this attribute
258 { return PackageImplIf::postin(); }
261 Text YUMPackageImpl::preun() const
262 // metadata doesn't priovide this attribute
263 { return PackageImplIf::preun(); }
266 Text YUMPackageImpl::postun() const
267 // metadata doesn't priovide this attribute
268 { return PackageImplIf::postun(); }
271 FSize YUMPackageImpl::sourcesize() const
275 FSize YUMPackageImpl::archivesize() const
279 Text YUMPackageImpl::authors() const
283 Text YUMPackageImpl::filenames() const
284 { return _filenames; }
286 License YUMPackageImpl::licenseToConfirm() const
287 { return _license_to_confirm; }
290 std::string YUMPackageImpl::type() const
294 std::list<std::string> YUMPackageImpl::keywords() const
295 { return _keywords; }
297 bool YUMPackageImpl::installOnly() const
298 { return _install_only; }
300 unsigned YUMPackageImpl::mediaId() const
303 PackageImplIf::CheckSum YUMPackageImpl::checksum() const
304 { return _checksum; }
306 std::list<PackageImplIf::DeltaRpm> YUMPackageImpl::deltaRpms() const
307 { return _delta_rpms; }
309 std::list<PackageImplIf::PatchRpm> YUMPackageImpl::patchRpms() const
310 { return _patch_rpms; }
314 std::list<std::string> YUMPackageImpl::insnotify() const
315 { return std::list<std::string>(); }
317 std::list<std::string> YUMPackageImpl::delnotify() const
318 { return std::list<std::string>(); }
320 unsigned YUMPackageImpl::packageSize() const
321 { return _size_package; }
323 unsigned YUMPackageImpl::archiveSize() const
324 { return _size_archive; }
326 unsigned YUMPackageImpl::installedSize() const
327 { return _size_installed; }
328 // FIXME do not understand items below
330 bool YUMPackageImpl::providesSources() const
335 std::string YUMPackageImpl::instSrcLabel() const
340 std::string YUMPackageImpl::instSrcVendor() const
345 unsigned YUMPackageImpl::instSrcRank() const
350 std::string YUMPackageImpl::buildhost() const
355 std::string YUMPackageImpl::distribution() const
360 std::string YUMPackageImpl::vendor() const
365 std::string YUMPackageImpl::license() const
370 std::list<std::string> YUMPackageImpl::licenseToConfirm() const
372 return std::list<std::string>();
375 std::string YUMPackageImpl::packager() const
380 std::string YUMPackageImpl::group() const
385 std::list<std::string> YUMPackageImpl::changelog() const
388 std::string YUMPackageImpl::url() const
393 std::string YUMPackageImpl::os() const
396 std::list<std::string> YUMPackageImpl::prein() const
399 std::list<std::string> YUMPackageImpl::postin() const
402 std::list<std::string> YUMPackageImpl::preun() const
405 std::list<std::string> YUMPackageImpl::postun() const
408 std::string YUMPackageImpl::sourcepkg() const
409 { return _sourcepkg; }
411 std::list<std::string> YUMPackageImpl::authors() const
414 std::list<std::string> YUMPackageImpl::filenames() const
417 std::list<std::string> YUMPackageImpl::recommends() const
420 std::list<std::string> YUMPackageImpl::suggests() const
423 std::string YUMPackageImpl::location() const
426 std::string YUMPackageImpl::md5sum() const
429 std::string YUMPackageImpl::externalUrl() const
432 std::list<Edition> YUMPackageImpl::patchRpmBaseVersions() const
435 unsigned YUMPackageImpl::patchRpmSize() const
438 bool YUMPackageImpl::forceInstall() const
441 std::string YUMPackageImpl::patchRpmMD5() const
444 bool YUMPackageImpl::isRemote() const
447 bool YUMPackageImpl::prefererCandidate() const
453 /////////////////////////////////////////////////////////////////
454 } // namespace source
455 ///////////////////////////////////////////////////////////////////
456 /////////////////////////////////////////////////////////////////
458 ///////////////////////////////////////////////////////////////////