00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #include <iostream> 00013 00014 #include "zypp/base/Easy.h" 00015 #include "zypp/base/Logger.h" 00016 #include "zypp/ResStore.h" 00017 #include "zypp/CapMatchHelper.h" 00018 00019 #include "zypp/detail/PatchImplIf.h" 00020 00021 using std::endl; 00022 00024 namespace zypp 00025 { 00026 00027 namespace detail 00028 { 00029 00031 // Default implementation of PatchImplIf attributes, 00032 // as far as resonable. 00034 00035 std::string PatchImplIf::id() const 00036 { return std::string(); } 00037 00038 Date PatchImplIf::timestamp() const 00039 { return Date(); } 00040 00041 std::string PatchImplIf::category() const 00042 { return std::string(); } 00043 00044 bool PatchImplIf::reboot_needed() const 00045 { return false; } 00046 00047 bool PatchImplIf::affects_pkg_manager() const 00048 { return false; } 00049 00050 bool PatchImplIf::interactive() const 00051 { 00052 if ( reboot_needed() 00053 || ! licenseToConfirm().empty() ) 00054 { 00055 return true; 00056 } 00057 00058 AtomList atoms = all_atoms(); 00059 for ( AtomList::const_iterator it = atoms.begin(); it != atoms.end(); it++) 00060 { 00061 if ( isKind<Message>( *it ) 00062 || ! licenseToConfirm().empty() ) 00063 { 00064 return true; 00065 } 00066 } 00067 00068 return false; 00069 } 00070 00071 PatchImplIf::AtomList PatchImplIf::all_atoms() const 00072 { 00073 if ( ! _atomlist ) 00074 { 00075 if ( ! hasBackRef() ) 00076 { 00077 // We are not jet connected to the Resolvable that 00078 // contains our dependencies. 00079 return AtomList(); 00080 } 00081 00082 // lazy init 00083 _atomlist.reset( new AtomList ); 00084 00085 // Build the list using the repositories resolvables. 00086 // Installed Patches (no repository) have this method overloaded. 00087 if ( repository() ) 00088 { 00089 const CapSet & requires( self()->dep( Dep::REQUIRES ) ); 00090 const ResStore & store( repository().resolvables() ); 00091 00092 for_( req, requires.begin(), requires.end() ) 00093 { 00094 // lookup Patch requirements that refer to an Atom, Script or Message. 00095 if ( refersTo<Atom>( *req ) || refersTo<Script>( *req ) || refersTo<Message>( *req ) ) 00096 { 00097 for_( res, store.begin(), store.end() ) 00098 { 00099 // Collect ALL matches in the store. 00100 if ( hasMatches( (*res)->dep( Dep::PROVIDES ), (*req) ) ) 00101 { 00102 _atomlist->push_back( *res ); 00103 } 00104 } 00105 } 00106 } 00107 } 00108 } 00109 return *_atomlist; 00110 } 00111 00113 } // namespace detail 00116 } // namespace zypp
1.5.3