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 #if 0 // not active any more, see YUMSourceImpl::createPatch()
00061
00062 CapFactory _f;
00063 Capability cap( _f.parse(
00064 ResType::TraitsType::kind,
00065 parsed.name,
00066 Rel::EQ,
00067 Edition(parsed.ver, parsed.rel, parsed.epoch)
00068 ));
00069 for (std::list<shared_ptr<YUMPatchAtom> >::const_iterator it
00070 = parsed.atoms.begin();
00071 it != parsed.atoms.end();
00072 it++)
00073 {
00074 switch ((*it)->atomType())
00075 {
00076 case YUMPatchAtom::Package: {
00077 shared_ptr<YUMPatchPackage> package_data
00078 = dynamic_pointer_cast<YUMPatchPackage>(*it);
00079 Atom::Ptr atom = srcimpl_r.augmentPackage( _source, *package_data );
00080 _atoms.push_back(atom);
00081 break;
00082 }
00083 case YUMPatchAtom::Message: {
00084 shared_ptr<YUMPatchMessage> message_data
00085 = dynamic_pointer_cast<YUMPatchMessage>(*it);
00086 Message::Ptr message = srcimpl_r.createMessage(_source, *message_data);
00087 _atoms.push_back(message);
00088 break;
00089 }
00090 case YUMPatchAtom::Script: {
00091 shared_ptr<YUMPatchScript> script_data
00092 = dynamic_pointer_cast<YUMPatchScript>(*it);
00093 Script::Ptr script = srcimpl_r.createScript(_source, *script_data);
00094 _atoms.push_back(script);
00095 break;
00096 }
00097 default:
00098 ERR << "Unknown type of atom" << endl;
00099 }
00100 for (AtomList::iterator it = _atoms.begin();
00101 it != _atoms.end();
00102 it++)
00103 {
00104 (*it)->injectRequires(cap);
00105 }
00106
00107 }
00108 #endif
00109 }
00110
00111 std::string YUMPatchImpl::id() const
00112 {
00113 return _patch_id;
00114 }
00115 Date YUMPatchImpl::timestamp() const
00116 {
00117 return _timestamp;
00118 }
00119
00120 TranslatedText YUMPatchImpl::summary() const
00121 { return _summary; }
00122
00123 TranslatedText YUMPatchImpl::description() const
00124 { return _description; }
00125
00126
00127 std::string YUMPatchImpl::category() const
00128 {
00129 return _category;
00130 }
00131
00132 bool YUMPatchImpl::reboot_needed() const
00133 {
00134 return _reboot_needed;
00135 }
00136
00137 bool YUMPatchImpl::affects_pkg_manager() const
00138 {
00139 return _affects_pkg_manager;
00140 }
00141
00142 bool YUMPatchImpl::interactive() const {
00143 if (_reboot_needed)
00144 {
00145 DBG << "Patch needs reboot" << endl;
00146 return true;
00147 }
00148 AtomList not_installed = not_installed_atoms();
00149 for (AtomList::iterator it = not_installed.begin();
00150 it != not_installed.end();
00151 it++)
00152 {
00153 if ((*it)->kind() == "Message")
00154 {
00155
00156 return true;
00157 }
00158 if ((*it)->kind() == "Package")
00159 {
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 if (false)
00176 {
00177
00178 return true;
00179 }
00180 }
00181 }
00182 return false;
00183 }
00184
00185 YUMPatchImpl::AtomList YUMPatchImpl::all_atoms() const {
00186 return _atoms;
00187 }
00188
00189 YUMPatchImpl::AtomList YUMPatchImpl::not_installed_atoms() const {
00190 AtomList ret;
00191 for (AtomList::const_iterator it = _atoms.begin();
00192 it != _atoms.end();
00193 it++)
00194 {
00195 if (true)
00196 {
00197 ret.push_back(*it);
00198 }
00199 }
00200 return ret;
00201 }
00202
00203
00204
00205 bool YUMPatchImpl::any_atom_selected() const {
00206 for (AtomList::const_iterator it = _atoms.begin();
00207 it != _atoms.end();
00208 it++)
00209 {
00210 if (false)
00211 {
00212 return true;
00213 }
00214 }
00215 return false;
00216 }
00217
00218 void YUMPatchImpl::mark_atoms_to_freshen( bool freshen ) {
00219 for (AtomList::iterator it = _atoms.begin();
00220 it != _atoms.end();
00221 it++)
00222 {
00223
00224 }
00225 }
00226
00227 Source_Ref YUMPatchImpl::source() const
00228 { return _source; }
00229
00230 }
00232 }
00235 }