-------------------------------------------------------------------
+Wed Apr 5 12:48:19 CEST 2006 - visnov@suse.cz
+
+- only try to create a source of a given type when restoring
+ from the persistent store (#162111)
+
+-------------------------------------------------------------------
Wed Apr 5 11:36:54 CEST 2006 - kkaempf@suse.de
- parse all dependencies for patterns (.pat) files (#160602)
return Source_Ref(); // not reached!!
}
+ Source_Ref SourceFactory::createFrom( const std::string & type, const Url & url_r, const Pathname & path_r, const std::string & alias_r, const Pathname & cache_dir_r )
+ {
+ if (! url_r.isValid())
+ ZYPP_THROW( Exception("Empty URL passed to SourceFactory") );
+
+ callback::SendReport<CreateSourceReport> report;
+
+ report->startProbe (url_r);
+
+#warning if cache_dir is provided, no need to open the original url
+ // open the media
+ media::MediaId id = media_mgr.open(url_r);
+
+ // add dummy verifier
+ media_mgr.addVerifier(id, media::MediaVerifierRef(new media::NoVerifier()));
+ // attach only if initializing from media and not from cache (#153073)
+ if (cache_dir_r == "")
+ {
+ media_mgr.attach(id);
+ }
+ else
+ {
+ MIL << "Initializing from cache" << endl;
+ }
+
+ try
+ {
+
+ Source_Ref::Impl_Ptr impl;
+
+ if( type == yum::YUMSourceImpl::typeString() ) {
+ MIL << "Trying the YUM source" << endl;
+ impl = Source_Ref::Impl_Ptr( Impl::createSourceImpl<yum::YUMSourceImpl>(id, path_r, alias_r, cache_dir_r) );
+ MIL << "Found the YUM source" << endl;
+ } else if ( type == susetags::SuseTagsImpl::typeString() ) {
+ MIL << "Trying the SUSE tags source" << endl;
+#warning TODO pass cache_dir_r once constructor adapted
+ impl = Source_Ref::Impl_Ptr( Impl::createSourceImpl<susetags::SuseTagsImpl>(id, path_r, alias_r, cache_dir_r) );
+ MIL << "Found the SUSE tags source" << endl;
+ } else {
+ ZYPP_THROW( Exception ("Cannot create source of unknown type '" + type + "'"));
+ }
+
+ report->endProbe (url_r);
+
+ return Source_Ref(impl);
+ }
+ catch (const Exception & excpt_r)
+ {
+ ZYPP_CAUGHT(excpt_r);
+ MIL << "Creating a source of type " << type << " failed " << endl;
+ }
+
+ report->endProbe (url_r);
+
+ ERR << "No next type of source" << endl;
+ ZYPP_THROW(Exception("Cannot create the installation source"));
+ return Source_Ref(); // not reached!!
+ }
+
+
/******************************************************************
**
** FUNCTION NAME : operator<<
*/
Source_Ref createFrom( const Url & url_r, const Pathname & path_r = "/", const std::string & alias_r = "", const Pathname & cache_dir_r = "" );
+ /** Construct source of a given type.
+ * \throw EXCEPTION on fail
+ */
+ Source_Ref createFrom( const std::string & type, const Url & url_r, const Pathname & path_r = "/", const std::string & alias_r = "", const Pathname & cache_dir_r = "" );
+
private:
/** Implementation */
class Impl;
virtual ResStore provideResolvables(Source_Ref source_r, zypp::Resolvable::Kind kind);
virtual std::string type(void) const
- { return "YaST"; }
+ { return typeString(); }
+
+ /** Text used for identifying the type of the source.
+ * Used by the \ref SourceFactory when creating a
+ * source of a given type only.
+ */
+ static std::string typeString(void)
+ { return "YaST"; }
virtual unsigned numberOfMedia(void) const;
virtual std::string vendor (void) const;
virtual void storeMetadata(const Pathname & cache_dir_r);
virtual std::string type(void) const
+ { return typeString(); }
+
+ /** Text used for identifying the type of the source.
+ * Used by the \ref SourceFactory when creating a
+ * source of a given type only.
+ */
+ static std::string typeString(void)
{ return "YUM"; }
virtual void createResolvables(Source_Ref source_r);