Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / RepoManager.cc
index 3225ad8..3853444 100644 (file)
@@ -18,8 +18,6 @@
 #include <map>
 #include <algorithm>
 
-#include <solv/solvversion.h>
-
 #include "zypp/base/InputStream.h"
 #include "zypp/base/LogTools.h"
 #include "zypp/base/Gettext.h"
@@ -842,7 +840,7 @@ namespace zypp
       // Cleanup orphanded service repos:
       if ( ! orphanedRepos.empty() )
       {
-       for ( const auto & repoInfo : orphanedRepos )
+       for ( auto & repoInfo : orphanedRepos )
        {
          MIL << "Delete orphaned service repo " << repoInfo.alias() << endl;
          // translators: Cleanup a repository previously owned by a meanwhile unknown (deleted) service.
@@ -1081,7 +1079,7 @@ namespace zypp
     assert_urls(info);
 
     // we will throw this later if no URL checks out fine
-    RepoException rexception( info, PL_("Valid metadata not found at specified URL",
+    RepoException rexception( info, _PL("Valid metadata not found at specified URL",
                                        "Valid metadata not found at specified URLs",
                                        info.baseUrlsSize() ) );
 
@@ -1264,14 +1262,8 @@ namespace zypp
       if ( cache_status == raw_metadata_status )
       {
         MIL << info.alias() << " cache is up to date with metadata." << endl;
-        if ( policy == BuildIfNeeded )
-       {
-         // On the fly add missing solv.idx files for bash completion.
-         const Pathname & base = solv_path_for_repoinfo( _options, info);
-         if ( ! PathInfo(base/"solv.idx").isExist() )
-           sat::updateSolvFileIndex( base/"solv" );
-
-         return;
+        if ( policy == BuildIfNeeded ) {
+          return;
         }
         else {
           MIL << info.alias() << " cache rebuild is forced" << endl;
@@ -1375,7 +1367,6 @@ namespace zypp
 
         // We keep it.
         guard.resetDispose();
-       sat::updateSolvFileIndex( solvfile );   // content digest for zypper bash completion
       }
       break;
       default:
@@ -1579,13 +1570,19 @@ namespace zypp
     {
       Repository repo = sat::Pool::instance().addRepoSolv( solvfile, info );
       // test toolversion in order to rebuild solv file in case
-      // it was written by a different libsolv-tool parser.
-      const std::string & toolversion( sat::LookupRepoAttr( sat::SolvAttr::repositoryToolVersion, repo ).begin().asString() );
-      if ( toolversion != LIBSOLV_TOOLVERSION )
+      // it was written by an old libsolv-tool parser.
+      //
+      // Known version strings used:
+      //  - <no string>
+      //  - "1.0"
+      //
+      sat::LookupRepoAttr toolversion( sat::SolvAttr::repositoryToolVersion, repo );
+      if ( toolversion.begin().asString().empty() )
       {
         repo.eraseFromPool();
-        ZYPP_THROW(Exception(str::Str() << "Solv-file was created by '"<<toolversion<<"'-parser (want "<<LIBSOLV_TOOLVERSION<<")."));
+        ZYPP_THROW(Exception("Solv-file was created by old parser."));
       }
+      // else: up-to-date (or even newer).
     }
     catch ( const Exception & exp )
     {
@@ -1866,14 +1863,6 @@ namespace zypp
             newinfo.dumpAsIniOn(file);
       }
 
-      if ( toedit.enabled() && !newinfo.enabled() )
-      {
-       // On the fly remove solv.idx files for bash completion if a repo gets disabled.
-       const Pathname & solvidx = solv_path_for_repoinfo(_options, newinfo)/"solv.idx";
-       if ( PathInfo(solvidx).isExist() )
-         filesystem::unlink( solvidx );
-      }
-
       newinfo.setFilepath(toedit.filepath());
       reposManip().erase(toedit);
       reposManip().insert(newinfo);
@@ -2019,34 +2008,13 @@ 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) || options_r.testFlag( RefreshService_restoreStatus ) ) )
-    {
-      // 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 )
@@ -2068,7 +2036,6 @@ 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
@@ -2076,7 +2043,7 @@ namespace zypp
     // and in zypper.
     std::pair<DefaultIntegral<bool,false>, repo::ServicePluginInformalException> uglyHack;
     try {
-      ServiceRepos( service, bind( &RepoCollector::collect, &collector, _1 ) );
+      ServiceRepos repos(service, bind( &RepoCollector::collect, &collector, _1 ));
     }
     catch ( const repo::ServicePluginInformalException & e )
     {
@@ -2084,12 +2051,7 @@ 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.
@@ -2352,19 +2314,10 @@ namespace zypp
 
     ////////////////////////////////////////////////////////////////////////////
     // save service if modified: (unless a plugin service)
-    if ( service.type() != ServiceType::PLUGIN )
+    if ( serviceModified && service.type() != ServiceType::PLUGIN )
     {
-      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 );
-      }
+      // write out modified service file.
+      modifyService( service.alias(), service );
     }
 
     if ( uglyHack.first )