Imported Upstream version 15.13.0 73/94673/1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 1 Nov 2016 01:49:08 +0000 (10:49 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 1 Nov 2016 01:49:09 +0000 (10:49 +0900)
Change-Id: Id6241f85d9f495650dae2442a51e1bb6137564eb
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
17 files changed:
VERSION.cmake
package/libzypp.changes
po/zypp-po.tar.bz2
tests/zypp/Url_test.cc
zypp/Date.h
zypp/RepoManager.cc
zypp/RepoManager.h
zypp/ServiceInfo.cc
zypp/ServiceInfo.h
zypp/base/String.h
zypp/parser/RepoindexFileReader.cc
zypp/parser/RepoindexFileReader.h
zypp/parser/ServiceFileReader.cc
zypp/repo/ServiceRepos.cc
zypp/repo/ServiceRepos.h
zypp/solver/detail/SATResolver.cc
zypp/url/UrlUtils.h

index 3ede5f0..71c3796 100644 (file)
@@ -60,9 +60,9 @@
 #
 SET(LIBZYPP_MAJOR "15")
 SET(LIBZYPP_COMPATMINOR "11")
-SET(LIBZYPP_MINOR "12")
+SET(LIBZYPP_MINOR "13")
 SET(LIBZYPP_PATCH "0")
 #
-# LAST RELEASED: 15.12.0 (11)
+# LAST RELEASED: 15.13.0 (11)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index 5b56a0d..91d94f6 100644 (file)
@@ -1,4 +1,19 @@
 -------------------------------------------------------------------
+Thu Aug 13 18:16:52 CEST 2015 - ma@suse.de
+
+- Support caching of service metadata. A TTL for the service 
+  metadata may be provided in the repoindex.xml itself. The 
+  default is 'no caching'. (FATE#318136)
+- Fix setting dup_allow* solver options (bnc#941463)
+- Don't make zypper encode {} around repo vars (bnc#941453)
+- version 15.13.0 (11)
+
+-------------------------------------------------------------------
+Thu Aug 13 01:13:43 CEST 2015 - ma@suse.de
+
+- Update zypp-po.tar.bz2
+
+-------------------------------------------------------------------
 Tue Aug 11 18:48:57 CEST 2015 - ma@suse.de
 
 - History: Add 'command' tag showing who triggered the commit.
index f9af4e2..b0102d4 100644 (file)
Binary files a/po/zypp-po.tar.bz2 and b/po/zypp-po.tar.bz2 differ
index 60d8e49..ad82d48 100644 (file)
@@ -273,6 +273,13 @@ BOOST_AUTO_TEST_CASE( test_url4)
   }
 }
 
+BOOST_AUTO_TEST_CASE( test_url5)
+{
+  std::string str( "file:/some/${var:+path}/${var:-with}/${vars}" );
+  BOOST_CHECK_EQUAL( Url(str).asString(), str );
+  BOOST_CHECK_EQUAL( Url(zypp::url::encode( str, URL_SAFE_CHARS )).asString(), str );
+}
+
 BOOST_AUTO_TEST_CASE(plugin_querystring_args)
 {
   // url querysting options without value must be possible
index e002c2c..c15e693 100644 (file)
@@ -36,6 +36,7 @@ namespace zypp
   public:
 
     typedef time_t ValueType;
+    typedef time_t Duration;
 
     static const ValueType second      = 1;
     static const ValueType minute      = 60;
index 38f0f18..40c9eeb 100644 (file)
@@ -1940,13 +1940,34 @@ namespace zypp
     ServiceInfo service( getService( alias ) );
     assert_alias( service );
     assert_url( service );
+    MIL << "Going to refresh service '" << service.alias() <<  "', url: " << service.url() << ", opts: " << options_r << endl;
+
+    if ( service.ttl() && !options_r.testFlag( RefreshService_forceRefresh ) )
+    {
+      // Service defines a TTL; maybe we can re-use existing data without refresh.
+      Date lrf = service.lrf();
+      if ( lrf )
+      {
+       Date now( Date::now() );
+       if ( lrf <= now )
+       {
+         if ( (lrf+=service.ttl()) > now ) // lrf+= !
+         {
+           MIL << "Skip: '" << service.alias() << "' metadata valid until " << lrf << endl;
+           return;
+         }
+       }
+       else
+         WAR << "Force: '" << service.alias() << "' metadata last refresh in the future: " << lrf << endl;
+      }
+    }
+
     // NOTE: It might be necessary to modify and rewrite the service info.
     // Either when probing the type, or when adjusting the repositories
     // enable/disable state.:
     bool serviceModified = false;
-    MIL << "Going to refresh service '" << service.alias() << "', url: "<< service.url() << ", opts: " << options_r << endl;
 
-    //! \todo add callbacks for apps (start, end, repo removed, repo added, repo changed)
+    //! \todo add callbacks for apps (start, end, repo removed, repo added, repo changed)?
 
     // if the type is unknown, try probing.
     if ( service.type() == repo::ServiceType::NONE )
@@ -1968,6 +1989,7 @@ namespace zypp
     DBG << "ServicesTargetDistro: " << servicesTargetDistro << endl;
 
     // parse it
+    Date::Duration origTtl = service.ttl();    // FIXME Ugly hack: const service.ttl modified when parsing
     RepoCollector collector(servicesTargetDistro);
     // FIXME Ugly hack: ServiceRepos may throw ServicePluginInformalException
     // which is actually a notification. Using an exception for this
@@ -1975,7 +1997,7 @@ namespace zypp
     // and in zypper.
     std::pair<DefaultIntegral<bool,false>, repo::ServicePluginInformalException> uglyHack;
     try {
-      ServiceRepos repos(service, bind( &RepoCollector::collect, &collector, _1 ));
+      ServiceRepos( service, bind( &RepoCollector::collect, &collector, _1 ) );
     }
     catch ( const repo::ServicePluginInformalException & e )
     {
@@ -1983,7 +2005,12 @@ namespace zypp
       uglyHack.first = true;
       uglyHack.second = e;
     }
-
+    if ( service.ttl() != origTtl )    // repoindex.xml changed ttl
+    {
+      if ( !service.ttl() )
+       service.setLrf( Date() );       // don't need lrf when zero ttl
+      serviceModified = true;
+    }
     ////////////////////////////////////////////////////////////////////////////
     // On the fly remember the new repo states as defined the reopoindex.xml.
     // Move into ServiceInfo later.
@@ -2214,10 +2241,19 @@ namespace zypp
 
     ////////////////////////////////////////////////////////////////////////////
     // save service if modified: (unless a plugin service)
-    if ( serviceModified && service.type() != ServiceType::PLUGIN )
+    if ( service.type() != ServiceType::PLUGIN )
     {
-      // write out modified service file.
-      modifyService( service.alias(), service );
+      if ( service.ttl() )
+      {
+       service.setLrf( Date::now() );  // remember last refresh
+       serviceModified =  true;        // or use a cookie file
+      }
+
+      if ( serviceModified )
+      {
+       // write out modified service file.
+       modifyService( service.alias(), service );
+      }
     }
 
     if ( uglyHack.first )
index 5653939..3d0bdfd 100644 (file)
@@ -141,7 +141,8 @@ namespace zypp
     /** Flags for tuning RefreshService */
     enum RefreshServiceBit
     {
-      RefreshService_restoreStatus     = (1<<0)        ///< Force restoring repo enabled/disabled staus
+      RefreshService_restoreStatus     = (1<<0),       ///< Force restoring repo enabled/disabled status
+      RefreshService_forceRefresh      = (1<<1),       ///< Force refresh even if TTL is not reached
     };
     ZYPP_DECLARE_FLAGS(RefreshServiceFlags,RefreshServiceBit);
 
index 1242990..2f7c073 100644 (file)
@@ -13,6 +13,7 @@
 #include <iostream>
 
 #include "zypp/base/String.h"
+#include "zypp/base/DefaultIntegral.h"
 #include "zypp/parser/xml/XmlEscape.h"
 
 #include "zypp/RepoInfo.h"
@@ -35,33 +36,32 @@ namespace zypp
     typedef ServiceInfo::ReposToDisable ReposToDisable;
 
   public:
-    RepoVariablesReplacedUrl url;
-    repo::ServiceType type;
-    ReposToEnable  reposToEnable;
-    ReposToDisable reposToDisable;
-    RepoStates     repoStates;
-
+    RepoVariablesReplacedUrl _url;
+    repo::ServiceType _type;
+    ReposToEnable _reposToEnable;
+    ReposToDisable _reposToDisable;
+    RepoStates _repoStates;
+    DefaultIntegral<Date::Duration,0> _ttl;
+    Date _lrf;
 
   public:
     Impl()
-      : type(repo::ServiceType::NONE_e)
     {}
 
-    Impl(const Url & url_)
-      : url(url_)
-      , type(repo::ServiceType::NONE_e)
+    Impl( const Url & url_r )
+    : _url( url_r )
     {}
 
     ~Impl()
     {}
 
-    void setProbedType( const repo::ServiceType & t ) const
+    void setProbedType( const repo::ServiceType & type_r ) const
     {
-      if ( type == repo::ServiceType::NONE
-           && t != repo::ServiceType::NONE )
+      if ( _type == repo::ServiceType::NONE
+           && type_r != repo::ServiceType::NONE )
       {
         // lazy init!
-        const_cast<Impl*>(this)->type = t;
+        const_cast<Impl*>(this)->_type = type_r;
       }
     }
 
@@ -97,82 +97,70 @@ namespace zypp
   {}
 
   Url ServiceInfo::url() const                 // Variables replaced
-  { return _pimpl->url.transformed(); }
+  { return _pimpl->_url.transformed(); }
 
   Url ServiceInfo::rawUrl() const              // Raw
-  { return _pimpl->url.raw(); }
+  { return _pimpl->_url.raw(); }
 
   void ServiceInfo::setUrl( const Url& url )   // Raw
-  { _pimpl->url.raw() = url; }
-
-  repo::ServiceType ServiceInfo::type() const
-  { return _pimpl->type; }
-  void ServiceInfo::setType( const repo::ServiceType & type )
-  { _pimpl->type = type; }
-
-  void ServiceInfo::setProbedType( const repo::ServiceType &t ) const
-  { _pimpl->setProbedType( t ); }
+  { _pimpl->_url.raw() = url; }
 
-  bool ServiceInfo::reposToEnableEmpty() const
-  { return _pimpl->reposToEnable.empty(); }
+  repo::ServiceType ServiceInfo::type() const                          { return _pimpl->_type; }
+  void ServiceInfo::setType( const repo::ServiceType & type )          { _pimpl->_type = type; }
+  void ServiceInfo::setProbedType( const repo::ServiceType &t ) const  { _pimpl->setProbedType( t ); }
 
-  ServiceInfo::ReposToEnable::size_type ServiceInfo::reposToEnableSize() const
-  { return _pimpl->reposToEnable.size(); }
+  Date::Duration ServiceInfo::ttl() const                      { return _pimpl->_ttl; }
+  void ServiceInfo::setTtl( Date::Duration ttl_r )             { _pimpl->_ttl = ttl_r; }
+  void ServiceInfo::setProbedTtl( Date::Duration ttl_r ) const { const_cast<ServiceInfo*>(this)->setTtl( ttl_r ); }
 
-  ServiceInfo::ReposToEnable::const_iterator ServiceInfo::reposToEnableBegin() const
-  { return _pimpl->reposToEnable.begin(); }
+  Date ServiceInfo::lrf() const                                        { return _pimpl->_lrf; }
+  void ServiceInfo::setLrf( Date lrf_r )                       { _pimpl->_lrf = lrf_r; }
 
-  ServiceInfo::ReposToEnable::const_iterator ServiceInfo::reposToEnableEnd() const
-  { return _pimpl->reposToEnable.end(); }
+  bool ServiceInfo::reposToEnableEmpty() const                                         { return _pimpl->_reposToEnable.empty(); }
+  ServiceInfo::ReposToEnable::size_type ServiceInfo::reposToEnableSize() const         { return _pimpl->_reposToEnable.size(); }
+  ServiceInfo::ReposToEnable::const_iterator ServiceInfo::reposToEnableBegin() const   { return _pimpl->_reposToEnable.begin(); }
+  ServiceInfo::ReposToEnable::const_iterator ServiceInfo::reposToEnableEnd() const     { return _pimpl->_reposToEnable.end(); }
 
   bool ServiceInfo::repoToEnableFind( const std::string & alias_r ) const
-  { return( _pimpl->reposToEnable.find( alias_r ) != _pimpl->reposToEnable.end() ); }
+  { return( _pimpl->_reposToEnable.find( alias_r ) != _pimpl->_reposToEnable.end() ); }
 
   void ServiceInfo::addRepoToEnable( const std::string & alias_r )
   {
-    _pimpl->reposToEnable.insert( alias_r );
-    _pimpl->reposToDisable.erase( alias_r );
+    _pimpl->_reposToEnable.insert( alias_r );
+    _pimpl->_reposToDisable.erase( alias_r );
   }
 
   void ServiceInfo::delRepoToEnable( const std::string & alias_r )
-  { _pimpl->reposToEnable.erase( alias_r ); }
+  { _pimpl->_reposToEnable.erase( alias_r ); }
 
   void ServiceInfo::clearReposToEnable()
-  { _pimpl->reposToEnable.clear(); }
-
-
-  bool ServiceInfo::reposToDisableEmpty() const
-  { return _pimpl->reposToDisable.empty(); }
+  { _pimpl->_reposToEnable.clear(); }
 
-  ServiceInfo::ReposToDisable::size_type ServiceInfo::reposToDisableSize() const
-  { return _pimpl->reposToDisable.size(); }
 
-  ServiceInfo::ReposToDisable::const_iterator ServiceInfo::reposToDisableBegin() const
-  { return _pimpl->reposToDisable.begin(); }
-
-  ServiceInfo::ReposToDisable::const_iterator ServiceInfo::reposToDisableEnd() const
-  { return _pimpl->reposToDisable.end(); }
+  bool ServiceInfo::reposToDisableEmpty() const                                                { return _pimpl->_reposToDisable.empty(); }
+  ServiceInfo::ReposToDisable::size_type ServiceInfo::reposToDisableSize() const       { return _pimpl->_reposToDisable.size(); }
+  ServiceInfo::ReposToDisable::const_iterator ServiceInfo::reposToDisableBegin() const { return _pimpl->_reposToDisable.begin(); }
+  ServiceInfo::ReposToDisable::const_iterator ServiceInfo::reposToDisableEnd() const   { return _pimpl->_reposToDisable.end(); }
 
   bool ServiceInfo::repoToDisableFind( const std::string & alias_r ) const
-  { return( _pimpl->reposToDisable.find( alias_r ) != _pimpl->reposToDisable.end() ); }
+  { return( _pimpl->_reposToDisable.find( alias_r ) != _pimpl->_reposToDisable.end() ); }
 
   void ServiceInfo::addRepoToDisable( const std::string & alias_r )
   {
-    _pimpl->reposToDisable.insert( alias_r );
-    _pimpl->reposToEnable.erase( alias_r );
+    _pimpl->_reposToDisable.insert( alias_r );
+    _pimpl->_reposToEnable.erase( alias_r );
   }
 
   void ServiceInfo::delRepoToDisable( const std::string & alias_r )
-  { _pimpl->reposToDisable.erase( alias_r ); }
+  { _pimpl->_reposToDisable.erase( alias_r ); }
 
   void ServiceInfo::clearReposToDisable()
-  { _pimpl->reposToDisable.clear(); }
+  { _pimpl->_reposToDisable.clear(); }
+
 
-  const ServiceInfo::RepoStates & ServiceInfo::repoStates() const
-  { return _pimpl->repoStates; }
+  const ServiceInfo::RepoStates & ServiceInfo::repoStates() const      { return _pimpl->_repoStates; }
+  void ServiceInfo::setRepoStates( RepoStates newStates_r )            { swap( _pimpl->_repoStates, newStates_r ); }
 
-  void ServiceInfo::setRepoStates( RepoStates newStates_r )
-  { swap( _pimpl->repoStates, newStates_r ); }
 
   std::ostream & operator<<( std::ostream & str, const ServiceInfo::RepoState & obj )
   {
@@ -188,6 +176,12 @@ namespace zypp
       << "url = " << rawUrl() << endl
       << "type = " << type() << endl;
 
+    if ( ttl() )
+      str << "ttl_sec = " << ttl() << endl;
+
+    if ( lrf() )
+      str << "lrf_dat = " << lrf().asSeconds() << endl;
+
     if ( ! repoStates().empty() )
     {
       unsigned cnt = 0U;
@@ -222,7 +216,8 @@ namespace zypp
       << " enabled=\"" << enabled() << "\""
       << " autorefresh=\"" << autorefresh() << "\""
       << " url=\"" << escape(url().asString()) << "\""
-      << " type=\"" << type().asString() << "\"";
+      << " type=\"" << type().asString() << "\""
+      << " ttl_sec\"" << ttl() << "\"";
 
     if (content.empty())
       str << "/>" << endl;
index 991f3a6..e5b27cb 100644 (file)
 
 #include "zypp/Url.h"
 
+#include "zypp/base/Iterable.h"
 #include "zypp/repo/ServiceType.h"
 #include "zypp/RepoInfo.h"
-
+#include "zypp/Date.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -80,7 +81,29 @@ namespace zypp
     /** Lazy init service type */
     void setProbedType( const repo::ServiceType & t ) const;
 
+    /** \name Housekeeping data
+     * You don't want to use the setters unless you are a \ref RepoManager.
+     */
+    //@{
+    /** Sugested TTL between two metadata auto-refreshs.
+     * The value (in seconds) may be provided in repoindex.xml:xpath:/repoindex@ttl.
+     * Default is \a 0 - perform each auto-refresh request.
+     */
+    Date::Duration ttl() const;
+
+    /** Set sugested TTL. */
+    void setTtl( Date::Duration ttl_r );
+
+    /** Lazy init sugested TTL. */
+    void setProbedTtl( Date::Duration ttl_r ) const;
 
+    /** Date of last refresh (if known). */
+    Date lrf() const;
+
+    /** Set date of last refresh. */
+    void setLrf( Date lrf_r );
+    //@}
+    //
     /** \name Set of repos (repository aliases) to enable on next refresh.
      *
      * Per default new repositories are created in disabled state. But repositories
@@ -94,6 +117,8 @@ namespace zypp
     ReposToEnable::size_type      reposToEnableSize() const;
     ReposToEnable::const_iterator reposToEnableBegin() const;
     ReposToEnable::const_iterator reposToEnableEnd() const;
+    Iterable<ReposToEnable::const_iterator> reposToEnable() const
+    { return makeIterable( reposToEnableBegin(), reposToEnableEnd() ); }
 
     /** Whether \c alias_r is mentioned in ReposToEnable. */
     bool repoToEnableFind( const std::string & alias_r ) const;
@@ -118,6 +143,8 @@ namespace zypp
     ReposToDisable::size_type      reposToDisableSize() const;
     ReposToDisable::const_iterator reposToDisableBegin() const;
     ReposToDisable::const_iterator reposToDisableEnd() const;
+    Iterable<ReposToDisable::const_iterator> reposToDisable() const
+    { return makeIterable( reposToDisableBegin(), reposToDisableEnd() ); }
 
     /** Whether \c alias_r is mentioned in ReposToDisable. */
     bool repoToDisableFind( const std::string & alias_r ) const;
index 1b56e90..2321593 100644 (file)
@@ -240,6 +240,9 @@ namespace zypp
       Str & operator<<( const _Tp & val )
       { _str << val; return *this; }
 
+      Str & operator<<( std::ostream& (*iomanip)( std::ostream& ) )
+      { _str << iomanip; return *this; }
+
       operator std::string() const
       { return _str.str(); }
 
index 4207606..a06effb 100644 (file)
@@ -16,6 +16,7 @@
 #include "zypp/base/Logger.h"
 #include "zypp/base/Gettext.h"
 #include "zypp/base/InputStream.h"
+#include "zypp/base/DefaultIntegral.h"
 
 #include "zypp/Pathname.h"
 
@@ -48,9 +49,9 @@ namespace zypp
        /** */
        void setVar( const std::string & key_r, const std::string & val_r )
        {
-         MIL << "*** Inject " << key_r << " = " << val_r;
+         //MIL << "*** Inject " << key_r << " = " << val_r;
          _vars[key_r] = replace( val_r );
-         MIL << " (" << _vars[key_r] << ")" << endl;
+         //MIL << " (" << _vars[key_r] << ")" << endl;
        }
 
        std::string replace( const std::string & val_r ) const
@@ -112,6 +113,8 @@ namespace zypp
      */
     bool consumeNode( Reader & reader_r );
 
+    DefaultIntegral<Date::Duration,2> _ttl;
+
   private:
     bool getAttrValue( const std::string & key_r, Reader & reader_r, std::string & value_r )
     {
@@ -162,7 +165,14 @@ namespace zypp
       if ( reader_r->name() == "repoindex" )
       {
        while ( reader_r.nextNodeAttribute() )
-         _replacer.setVar( reader_r->localName().asString(), reader_r->value().asString() );
+       {
+         const std::string & name( reader_r->localName().asString() );
+         const std::string & value( reader_r->value().asString() );
+         _replacer.setVar( name, value );
+         // xpath: /repoindex@ttl
+         if ( name == "ttl" )
+           _ttl = str::strtonum<Date::Duration>(value);
+       }
         return true;
       }
 
@@ -252,20 +262,18 @@ namespace zypp
   //
   ///////////////////////////////////////////////////////////////////
 
-  RepoindexFileReader::RepoindexFileReader(
-      const Pathname & repoindex_file, const ProcessResource & callback)
-    :
-      _pimpl(new Impl(InputStream(repoindex_file), callback))
+  RepoindexFileReader::RepoindexFileReader( const Pathname & repoindex_file, const ProcessResource & callback )
+  : _pimpl(new Impl(InputStream(repoindex_file), callback))
   {}
 
-  RepoindexFileReader::RepoindexFileReader(
-       const InputStream &is, const ProcessResource & callback )
-    : _pimpl(new Impl(is, callback))
+  RepoindexFileReader::RepoindexFileReader( const InputStream &is, const ProcessResource & callback )
+  : _pimpl(new Impl(is, callback))
   {}
 
   RepoindexFileReader::~RepoindexFileReader()
   {}
 
+  Date::Duration RepoindexFileReader::ttl() const      { return _pimpl->_ttl; }
 
   } // ns parser
 } // ns zypp
index c720f58..500b29f 100644 (file)
@@ -17,6 +17,7 @@
 #include "zypp/base/Function.h"
 #include "zypp/base/InputStream.h"
 #include "zypp/Pathname.h"
+#include "zypp/Date.h"
 
 namespace zypp
 {
@@ -48,9 +49,7 @@ namespace zypp
     * First parameter is a \ref RepoInfo object with the resource
     * FIXME return value is ignored
     */
-    typedef function< bool(
-        const RepoInfo & )>
-      ProcessResource;
+    typedef function< bool( const RepoInfo & )> ProcessResource;
 
    /**
     * CTOR. Creates also \ref xml::Reader and starts reading.
@@ -79,6 +78,9 @@ namespace zypp
      */
     ~RepoindexFileReader();
 
+    /** Metadata TTL (repoindex.xml:xpath:/repoindex@ttl or 0). */
+    Date::Duration ttl() const;
+
   private:
     class Impl;
     RW_pointer<Impl,rw_pointer::Scoped<Impl> > _pimpl;
index e814dac..0f841a7 100644 (file)
@@ -72,6 +72,10 @@ namespace zypp
             service.setAutorefresh( str::strToTrue( it->second ) );
           else if ( it->first == "type" )
             service.setType( repo::ServiceType(it->second) );
+         else if ( it->first == "ttl_sec" )
+           service.setTtl( str::strtonum<Date::Duration>(it->second) );
+         else if ( it->first == "lrf_dat" )
+           service.setLrf( Date( it->second ) );
           else if ( it->first == "repostoenable" )
           {
             std::vector<std::string> aliases;
index 86d0dc5..e27c260 100644 (file)
 using std::stringstream;
 using std::endl;
 
+///////////////////////////////////////////////////////////////////
 namespace zypp
 {
-namespace repo
-{
+  ///////////////////////////////////////////////////////////////////
+  namespace repo
+  {
+    struct ServiceRepos::Impl
+    { virtual ~Impl() {} };
 
-class ServiceRepos::Impl
-{
-public:
-    Impl()
-    {
-    }
+    ///////////////////////////////////////////////////////////////////
 
-    virtual ~Impl()
+    struct RIMServiceRepos : public ServiceRepos::Impl
     {
-    }
-};
-
-class RIMServiceRepos : public ServiceRepos::Impl
-{
-public:
-    ServiceRepos::ProcessRepo _callback;
-
-    RIMServiceRepos(const ServiceInfo &service,
-                    const ServiceRepos::ProcessRepo & callback,
-                    const ProgressData::ReceiverFnc &progress = ProgressData::ReceiverFnc() )
-        : _callback(callback)
-    {
-      // repoindex.xml must be fetched always without using cookies (bnc #573897)
-      Url serviceUrl( service.url() );
-      serviceUrl.setQueryParam( "cookies", "0" );
-
-      // download the repo index file
-      media::MediaManager mediamanager;
-      media::MediaAccessId mid = mediamanager.open( serviceUrl );
-      mediamanager.attach( mid );
-      mediamanager.provideFile( mid, "repo/repoindex.xml" );
-      Pathname path = mediamanager.localPath(mid, "repo/repoindex.xml" );
-      parser::RepoindexFileReader reader(path, _callback);
-      mediamanager.release( mid );
-      mediamanager.close( mid );
-    }
-
-    ~RIMServiceRepos()
-    {
-
-    }
-};
+      RIMServiceRepos( const ServiceInfo & service,
+                      const ServiceRepos::ProcessRepo & callback,
+                      const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() )
+      {
+       // repoindex.xml must be fetched always without using cookies (bnc #573897)
+       Url serviceUrl( service.url() );
+       serviceUrl.setQueryParam( "cookies", "0" );
+
+       // download the repo index file
+       media::MediaManager mediamanager;
+       media::MediaAccessId mid = mediamanager.open( serviceUrl );
+       mediamanager.attach( mid );
+       mediamanager.provideFile( mid, "repo/repoindex.xml" );
+       Pathname path = mediamanager.localPath(mid, "repo/repoindex.xml" );
+       parser::RepoindexFileReader reader(path, callback);
+       service.setProbedTtl( reader.ttl() );   // hack! Modifying the const Service to set parsed TTL
+       mediamanager.release( mid );
+       mediamanager.close( mid );
+      }
+    };
 
-class PluginServiceRepos : public ServiceRepos::Impl
-{
-public:
-    ServiceRepos::ProcessRepo _callback;
+    ///////////////////////////////////////////////////////////////////
 
-    PluginServiceRepos(const ServiceInfo &service,
-                      const ServiceRepos::ProcessRepo & callback,
-                      const ProgressData::ReceiverFnc &progress = ProgressData::ReceiverFnc() )
-        : _callback(callback)
+    struct PluginServiceRepos : public ServiceRepos::Impl
     {
-      Url serviceUrl( service.url() );
-      stringstream buffer;
-
-      ExternalProgram::Arguments args;
-      args.reserve( 3 );
-      args.push_back( "/bin/sh" );
-      args.push_back( "-c" );
-      args.push_back( serviceUrl.getPathName() );
-      ExternalProgramWithStderr prog( args );
-      prog >> buffer;
-
-      if ( prog.close() != 0 )
+      PluginServiceRepos( const ServiceInfo & service,
+                         const ServiceRepos::ProcessRepo & callback,
+                         const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() )
       {
-       // ServicePluginInformalException:
-       // Ignore this error but we'd like to report it somehow...
-       std::string errbuffer;
-       prog.stderrGetUpTo( errbuffer, '\0' );
-       ERR << "Capture plugin error:[" << endl << errbuffer << endl << ']' << endl;
-       ZYPP_THROW( repo::ServicePluginInformalException( service, errbuffer ) );
+       Url serviceUrl( service.url() );
+       stringstream buffer;
+
+       ExternalProgram::Arguments args;
+       args.reserve( 3 );
+       args.push_back( "/bin/sh" );
+       args.push_back( "-c" );
+       args.push_back( serviceUrl.getPathName() );
+       ExternalProgramWithStderr prog( args );
+       prog >> buffer;
+
+       if ( prog.close() != 0 )
+       {
+         // ServicePluginInformalException:
+         // Ignore this error but we'd like to report it somehow...
+         std::string errbuffer;
+         prog.stderrGetUpTo( errbuffer, '\0' );
+         ERR << "Capture plugin error:[" << endl << errbuffer << endl << ']' << endl;
+         ZYPP_THROW( repo::ServicePluginInformalException( service, errbuffer ) );
+       }
+       parser::RepoFileReader parser( buffer, callback );
       }
+    };
 
-      parser::RepoFileReader parser(buffer, _callback);
-    }
+    ///////////////////////////////////////////////////////////////////
 
-    ~PluginServiceRepos()
+    ServiceRepos::ServiceRepos( const ServiceInfo & service,
+                               const ServiceRepos::ProcessRepo & callback,
+                               const ProgressData::ReceiverFnc &progress )
+    : _impl( ( service.type() == ServiceType::PLUGIN )
+          ? static_cast<ServiceRepos::Impl*>( new PluginServiceRepos( service, callback, progress ) )
+           : static_cast<ServiceRepos::Impl*>( new RIMServiceRepos (service, callback, progress ) ) )
     {}
-};
-
-
-ServiceRepos::ServiceRepos(const ServiceInfo &service,
-                           const ServiceRepos::ProcessRepo & callback,
-                           const ProgressData::ReceiverFnc &progress)
-    : _impl( (service.type() == ServiceType::PLUGIN) ? (ServiceRepos::Impl *)(new PluginServiceRepos(service, callback, progress)) : (ServiceRepos::Impl *)(new RIMServiceRepos(service, callback, progress)))
-{
-}
-
-ServiceRepos::~ServiceRepos()
-{
-}
 
+    ServiceRepos::~ServiceRepos()
+    {}
 
-}
-}
+  } // namespace repo
+  ///////////////////////////////////////////////////////////////////
+} //namespace zypp
+///////////////////////////////////////////////////////////////////
index 66bef82..25e9240 100644 (file)
@@ -20,30 +20,24 @@ namespace zypp
   namespace repo
   {
     /**
-     * Retrieval of repository list for
-     * a service
+     * Retrieval of repository list for a service.
      */
     class ServiceRepos : private base::NonCopyable
     {
     public:
-
      /**
-      * Callback definition.
-      * First parameter is a \ref RepoInfo object with the resource
-      * second parameter is the resource type.
-      *
       * Return false from the callback to get a \ref AbortRequestException
       * to be thrown and the processing to be cancelled.
       */
       typedef function< bool( const RepoInfo & )> ProcessRepo;
 
-      ServiceRepos(const ServiceInfo &service,
-                   const ProcessRepo & callback,
-                   const ProgressData::ReceiverFnc &progress = ProgressData::ReceiverFnc() );
+      ServiceRepos( const ServiceInfo & service,
+                    const ProcessRepo & callback,
+                    const ProgressData::ReceiverFnc &progress = ProgressData::ReceiverFnc() );
       ~ServiceRepos();
 
-      /** Implementation  */
-      class Impl;
+    public:
+      class Impl;      //!< Expose type only
     private:
       RW_pointer<Impl> _impl;
     };
index 866b2dc..c4b7417 100644 (file)
@@ -493,15 +493,15 @@ SATResolver::solving(const CapabilitySet & requires_caps,
     solver_set_flag(_solv, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
     solver_set_flag(_solv, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
     solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_DOWNGRADE,    _dup_allowdowngrade );
-    solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE,   _dup_allownamechange );
-    solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE, _dup_allowarchchange );
-    solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_NAMECHANGE,   _dup_allowvendorchange );
+    solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_NAMECHANGE,   _dup_allownamechange );
+    solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE,   _dup_allowarchchange );
+    solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE, _dup_allowvendorchange );
 #if 1
 #define HACKENV(X,D) solver_set_flag(_solv, X, env::HACKENV( #X, D ) );
     HACKENV( SOLVER_FLAG_DUP_ALLOW_DOWNGRADE,  _dup_allowdowngrade );
-    HACKENV( SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE, _dup_allownamechange );
-    HACKENV( SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE,_dup_allowarchchange );
-    HACKENV( SOLVER_FLAG_DUP_ALLOW_NAMECHANGE, _dup_allowvendorchange );
+    HACKENV( SOLVER_FLAG_DUP_ALLOW_NAMECHANGE, _dup_allownamechange );
+    HACKENV( SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE, _dup_allowarchchange );
+    HACKENV( SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE,_dup_allowvendorchange );
 #undef HACKENV
 #endif
     sat::Pool::instance().prepareForSolving();
index 5189a57..69bc679 100644 (file)
@@ -19,7 +19,7 @@
 #include <map>
 
 /** Characters that are safe for URL without percent-encoding. */
-#define URL_SAFE_CHARS ":/?#[]@!$&'()*+,;="
+#define URL_SAFE_CHARS ":/?#[]@!$&'(){}*+,;="
 
 //////////////////////////////////////////////////////////////////////
 namespace zypp