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