00001
00002
00003
00004
00005
00006
00007
00008
00013 #include "zypp/source/yum/YUMPackageImpl.h"
00014 #include "zypp/base/String.h"
00015 #include "zypp/base/Logger.h"
00016
00017 using namespace std;
00018 using namespace zypp::detail;
00019 using namespace zypp::parser::yum;
00020
00022 namespace zypp
00023 {
00024
00025 namespace source
00026 {
00027 namespace yum
00028 {
00030
00031
00032
00034
00037 YUMPackageImpl::YUMPackageImpl(
00038 Source_Ref source_r,
00039 const zypp::parser::yum::YUMPrimaryData & parsed,
00040 const zypp::parser::yum::YUMFileListData & filelist,
00041 const zypp::parser::yum::YUMOtherData & other
00042 )
00043 : _summary(parsed.summary),
00044 _description(parsed.description),
00045 _license_to_confirm(parsed.license_to_confirm),
00046 _buildtime(str::strtonum<time_t>(parsed.timeBuild)),
00047 _buildhost(parsed.buildhost),
00048 _url(parsed.url),
00049 _vendor( parsed.vendor),
00050 _license( parsed.license),
00051 _packager(parsed.packager),
00052 _group(parsed.group),
00053 _changelog(),
00054 _type(parsed.type),
00055 _authors(parsed.authors),
00056 _keywords( parsed.keywords),
00057 _mediaNumber(str::strtonum<unsigned int>(parsed.media)),
00058 _checksum(parsed.checksumType,
00059 parsed.checksum),
00060 _filenames(),
00061 _location(parsed.location),
00062 _delta_rpms(),
00063 _patch_rpms(),
00064 _install_only(parsed.installOnly),
00065 _package_size(str::strtonum<unsigned int>(parsed.sizePackage)),
00066 _size(str::strtonum<unsigned int>(parsed.sizeInstalled)),
00067 _source(source_r)
00068 #if 0
00069 : _size_package(strtol(parsed.sizePackage.c_str(), 0, 10)),
00070 _size_archive(strtol(parsed.sizeArchive.c_str(), 0, 10)),
00071 _size_installed(strtol(parsed.sizeInstalled.c_str(), 0, 10)),
00072 _sourcepkg(parsed.sourcerpm),
00073 _dir_sizes(parsed.dirSizes),
00074 #endif
00075 {
00076 for (std::list<FileData>::const_iterator it = filelist.files.begin();
00077 it != filelist.files.end();
00078 it++)
00079 {
00080 _filenames.push_back(it->name);
00081 }
00082 for (std::list<zypp::parser::yum::ChangelogEntry>::const_iterator
00083 it = other.changelog.begin();
00084 it != other.changelog.end();
00085 it++)
00086 {
00087 _changelog.push_back(ChangelogEntry(strtol(it->date.c_str(), 0, 10),
00088 it->author,
00089 it->entry));
00090 }
00091 }
00092
00093 YUMPackageImpl::YUMPackageImpl(
00094 Source_Ref source_r,
00095 const zypp::parser::yum::YUMPatchPackage & parsed
00096 )
00097 : _summary(parsed.summary),
00098 _description(parsed.description),
00099 _license_to_confirm(parsed.license_to_confirm),
00100 _buildtime(str::strtonum<time_t>(parsed.timeBuild)),
00101 _buildhost(parsed.buildhost),
00102 _url(parsed.url),
00103 _vendor( parsed.vendor),
00104 _license( parsed.license),
00105 _packager( parsed.packager),
00106 _group(parsed.group),
00107 _changelog(),
00108 _type(parsed.type),
00109 _authors(parsed.authors),
00110 _keywords( parsed.keywords),
00111 _mediaNumber(str::strtonum<unsigned int>(parsed.media)),
00112 _checksum(parsed.checksumType,
00113 parsed.checksum),
00114 _filenames(),
00115 _location( parsed.plainRpms.empty() ? Pathname() : parsed.plainRpms.front().filename),
00116 _delta_rpms(),
00117 _patch_rpms(),
00118 _install_only(parsed.installOnly),
00119 _package_size(str::strtonum<unsigned int>(parsed.sizePackage)),
00120 _size(str::strtonum<unsigned int>(parsed.sizeInstalled)),
00121 _source(source_r)
00122 #if 0
00123 : _size_package( strtol(parsed.sizePackage.c_str(), 0, 10)),
00124 _size_archive( strtol(parsed.sizeArchive.c_str(), 0, 10)),
00125 _size_installed( strtol(parsed.sizeInstalled.c_str(), 0, 10)),
00126 _sourcepkg( parsed.sourcerpm),
00127 _dir_sizes(parsed.dirSizes),
00128 #endif
00129 {
00130 for (std::list<FileData>::const_iterator it = parsed.files.begin();
00131 it != parsed.files.end();
00132 it++)
00133 {
00134 _filenames.push_back(it->name);
00135 }
00136 for (std::list<zypp::parser::yum::YUMPatchRpm>::const_iterator it
00137 = parsed.patchRpms.begin();
00138 it != parsed.patchRpms.end();
00139 it++)
00140 {
00141 std::list<BaseVersion> base_versions;
00142 for (std::list<YUMBaseVersion>::const_iterator bit
00143 = it->baseVersions.begin();
00144 bit != it->baseVersions.end();
00145 bit++)
00146 {
00147 Edition base_edition(bit->ver, bit->rel, bit->epoch);
00148 BaseVersion base_version(base_edition,
00149 CheckSum("md5", bit->md5sum),
00150 strtol(bit->buildtime.c_str(), 0, 10));
00151 base_versions.push_back(base_version);
00152 }
00153 PatchRpm patch(Arch(it->arch),
00154 it->filename,
00155 strtol(it->downloadsize.c_str(), 0, 10),
00156 CheckSum("md5", it->md5sum),
00157 strtol(it->buildtime.c_str(), 0, 10),
00158 base_versions,
00159 strtol(it->media.c_str(), 0, 10)
00160 );
00161 _patch_rpms.push_back(patch);
00162
00163 }
00164 for (std::list<zypp::parser::yum::YUMDeltaRpm>::const_iterator it
00165 = parsed.deltaRpms.begin();
00166 it != parsed.deltaRpms.end();
00167 it++)
00168 {
00169 Edition base_edition(it->baseVersion.ver,
00170 it->baseVersion.rel,
00171 it->baseVersion.epoch);
00172 BaseVersion base_version(base_edition,
00173 CheckSum("md5", it->baseVersion.md5sum),
00174 strtol(it->baseVersion.buildtime.c_str(),
00175 0, 10));
00176 DeltaRpm delta(Arch(it->arch),
00177 it->filename,
00178 strtol(it->downloadsize.c_str(), 0, 10),
00179 CheckSum("md5", it->md5sum),
00180 strtol(it->buildtime.c_str(), 0, 10),
00181 base_version,
00182 strtol(it->media.c_str(), 0, 10)
00183 );
00184 _delta_rpms.push_back(delta);
00185 }
00186 for (std::list<zypp::parser::yum::ChangelogEntry>::const_iterator
00187 it = parsed.changelog.begin();
00188 it != parsed.changelog.end();
00189 it++)
00190 {
00191 _changelog.push_back(ChangelogEntry(strtol(it->date.c_str(), 0, 10),
00192 it->author,
00193 it->entry));
00194 }
00195 }
00196
00197
00199 TranslatedText YUMPackageImpl::summary() const
00200 { return _summary; }
00201
00203 TranslatedText YUMPackageImpl::description() const
00204 { return _description; }
00205
00207 TranslatedText YUMPackageImpl::licenseToConfirm() const
00208 { return _license_to_confirm; }
00209
00211 ByteCount YUMPackageImpl::size() const
00212 { return _size; }
00213
00215 Date YUMPackageImpl::buildtime() const
00216 { return _buildtime; }
00217
00219 std::string YUMPackageImpl::buildhost() const
00220 { return _buildhost; }
00221
00223 Date YUMPackageImpl::installtime() const
00224 { return PackageImplIf::installtime(); }
00225
00227 std::string YUMPackageImpl::distribution() const
00228 #warning fixme
00229 { return string(); }
00230
00232 Vendor YUMPackageImpl::vendor() const
00233 { return _vendor; }
00234
00236 Label YUMPackageImpl::license() const
00237 { return _license; }
00238
00240 std::string YUMPackageImpl::packager() const
00241 { return _packager; }
00242
00244 PackageGroup YUMPackageImpl::group() const
00245 { return _group; }
00246
00248 Changelog YUMPackageImpl::changelog() const
00249 { return _changelog; }
00250
00252 Pathname YUMPackageImpl::location() const
00253 { return _location; }
00254
00257 std::string YUMPackageImpl::url() const
00258 { return _url; }
00259
00261 std::string YUMPackageImpl::os() const
00262
00263 { return PackageImplIf::os(); }
00264
00266 Text YUMPackageImpl::prein() const
00267
00268 { return PackageImplIf::prein(); }
00269
00271 Text YUMPackageImpl::postin() const
00272
00273 { return PackageImplIf::postin(); }
00274
00276 Text YUMPackageImpl::preun() const
00277
00278 { return PackageImplIf::preun(); }
00279
00281 Text YUMPackageImpl::postun() const
00282
00283 { return PackageImplIf::postun(); }
00284
00286 ByteCount YUMPackageImpl::sourcesize() const
00287 #warning fixme
00288 { return 0; }
00289
00291 ByteCount YUMPackageImpl::archivesize() const
00292 { return _package_size; }
00293
00295 std::list<std::string> YUMPackageImpl::authors() const
00296 { return _authors; }
00297
00299 std::list<std::string> YUMPackageImpl::filenames() const
00300 { return _filenames; }
00301
00303 std::string YUMPackageImpl::type() const
00304 { return _type; }
00305
00307 std::list<std::string> YUMPackageImpl::keywords() const
00308 { return _keywords; }
00309
00310 bool YUMPackageImpl::installOnly() const
00311 { return _install_only; }
00312
00313 unsigned YUMPackageImpl::sourceMediaNr() const
00314 { return _mediaNumber; }
00315
00316 CheckSum YUMPackageImpl::checksum() const
00317 { return _checksum; }
00318
00319 std::list<detail::PackageImplIf::DeltaRpm> YUMPackageImpl::deltaRpms() const
00320 { return _delta_rpms; }
00321
00322 std::list<detail::PackageImplIf::PatchRpm> YUMPackageImpl::patchRpms() const
00323 { return _patch_rpms; }
00324
00325 Source_Ref YUMPackageImpl::source() const
00326 { return _source; }
00327
00328 }
00330 }
00333 }