00001
00002
00003
00004
00005
00006
00007
00008
00013 #include "zypp/source/yum/YUMPatchImpl.h"
00014 #include "zypp/source/yum/YUMSourceImpl.h"
00015 #include <zypp/CapFactory.h>
00016 #include "zypp/parser/yum/YUMParserData.h"
00017 #include <zypp/parser/yum/YUMParser.h>
00018 #include "zypp/Package.h"
00019 #include "zypp/Script.h"
00020 #include "zypp/Message.h"
00021 #include "zypp/base/Logger.h"
00022
00023
00024 using namespace std;
00025 using namespace zypp::detail;
00026 using namespace zypp::parser::yum;
00027
00029 namespace zypp
00030 {
00031
00032 namespace source
00033 {
00034 namespace yum
00035 {
00037
00038
00039
00041
00045 YUMPatchImpl::YUMPatchImpl(
00046 Source_Ref source_r,
00047 const zypp::parser::yum::YUMPatchData & parsed,
00048 YUMSourceImpl & srcimpl_r
00049 )
00050 : _source(source_r)
00051 {
00052 _patch_id = parsed.patchId;
00053 _timestamp = str::strtonum<time_t>(parsed.timestamp);
00054 _category = parsed.category;
00055 _reboot_needed = parsed.rebootNeeded;
00056 _affects_pkg_manager = parsed.packageManager;
00057 std::string updateScript;
00058 _summary = parsed.summary;
00059 _description = parsed.description;
00060 _license_to_confirm = parsed.license_to_confirm;
00061 #if 0 // not active any more, see YUMSourceImpl::createPatch()
00062
00063 CapFactory _f;
00064 Capability cap( _f.parse(
00065 ResType::TraitsType::kind,
00066 parsed.name,
00067 Rel::EQ,
00068 Edition(parsed.ver, parsed.rel, parsed.epoch)
00069 ));
00070 for (std::list<shared_ptr<YUMPatchAtom> >::const_iterator it
00071 = parsed.atoms.begin();
00072 it != parsed.atoms.end();
00073 it++)
00074 {
00075 switch ((*it)->atomType())
00076 {
00077 case YUMPatchAtom::Package:
00078 {
00079 shared_ptr<YUMPatchPackage> package_data
00080 = dynamic_pointer_cast<YUMPatchPackage>(*it);
00081 Atom::Ptr atom = srcimpl_r.augmentPackage( _source, *package_data );
00082 _atoms.push_back(atom);
00083 break;
00084 }
00085 case YUMPatchAtom::Message:
00086 {
00087 shared_ptr<YUMPatchMessage> message_data
00088 = dynamic_pointer_cast<YUMPatchMessage>(*it);
00089 Message::Ptr message = srcimpl_r.createMessage(_source, *message_data);
00090 _atoms.push_back(message);
00091 break;
00092 }
00093 case YUMPatchAtom::Script:
00094 {
00095 shared_ptr<YUMPatchScript> script_data
00096 = dynamic_pointer_cast<YUMPatchScript>(*it);
00097 Script::Ptr script = srcimpl_r.createScript(_source, *script_data);
00098 _atoms.push_back(script);
00099 break;
00100 }
00101 default:
00102 ERR << "Unknown type of atom" << endl;
00103 }
00104 for (AtomList::iterator it = _atoms.begin();
00105 it != _atoms.end();
00106 it++)
00107 {
00108 (*it)->injectRequires(cap);
00109 }
00110
00111 }
00112 #endif
00113 }
00114
00115 std::string YUMPatchImpl::id() const
00116 {
00117 return _patch_id;
00118 }
00119 Date YUMPatchImpl::timestamp() const
00120 {
00121 return _timestamp;
00122 }
00123
00124 TranslatedText YUMPatchImpl::summary() const
00125 {
00126 return _summary;
00127 }
00128
00129 TranslatedText YUMPatchImpl::description() const
00130 {
00131 return _description;
00132 }
00133
00134 TranslatedText YUMPatchImpl::licenseToConfirm() const
00135 {
00136 return _license_to_confirm;
00137 }
00138
00139 std::string YUMPatchImpl::category() const
00140 {
00141 return _category;
00142 }
00143
00144 bool YUMPatchImpl::reboot_needed() const
00145 {
00146 return _reboot_needed;
00147 }
00148
00149 bool YUMPatchImpl::affects_pkg_manager() const
00150 {
00151 return _affects_pkg_manager;
00152 }
00153
00154 YUMPatchImpl::AtomList YUMPatchImpl::all_atoms() const
00155 {
00156 return _atoms;
00157 }
00158
00159 Source_Ref YUMPatchImpl::source() const
00160 {
00161 return _source;
00162 }
00163
00164 }
00166 }
00169 }