Imported Upstream version 17.0.0
[platform/upstream/libzypp.git] / zypp / target / TargetImpl.cc
index baffb9b..b894100 100644 (file)
@@ -751,9 +751,11 @@ namespace zypp
 
     void TargetImpl::createAnonymousId() const
     {
+      // bsc#1024741: Omit creating a new uid for chrooted systems (if it already has one, fine)
+      if ( root() != "/" )
+       return;
 
-      // create the anonymous unique id
-      // this value is used for statistics
+      // Create the anonymous unique id, used for download statistics
       Pathname idpath( home() / "AnonymousUniqueId");
 
       try
@@ -1232,7 +1234,7 @@ namespace zypp
       if ( ! policy_r.dryRun() || policy_r.downloadMode() == DownloadOnly )
       {
        // Prepare the package cache. Pass all items requiring download.
-        CommitPackageCache packageCache( root() );
+        CommitPackageCache packageCache;
        packageCache.setCommitList( steps.begin(), steps.end() );
 
         bool miss = false;
@@ -1262,22 +1264,7 @@ namespace zypp
               ManagedFile localfile;
               try
               {
-               // TODO: unify packageCache.get for Package and SrcPackage
-               if ( pi->isKind<Package>() )
-               {
-                 localfile = packageCache.get( pi );
-               }
-               else if ( pi->isKind<SrcPackage>() )
-               {
-                 repo::RepoMediaAccess access;
-                 repo::SrcPackageProvider prov( access );
-                 localfile = prov.provideSrcPackage( pi->asKind<SrcPackage>() );
-               }
-               else
-               {
-                 INT << "Don't know howto cache: Neither Package nor SrcPackage: " << pi << endl;
-                 continue;
-               }
+               localfile = packageCache.get( pi );
                 localfile.resetDispose(); // keep the package file in the cache
               }
               catch ( const AbortRequestException & exp )
@@ -1709,7 +1696,7 @@ namespace zypp
         }
         return std::string();
       }
-    } // namescpace
+    } // namespace
     ///////////////////////////////////////////////////////////////////
 
     Product::constPtr TargetImpl::baseProduct() const
@@ -1733,6 +1720,15 @@ namespace zypp
       return RequestedLocalesFile( home(needroot) / "RequestedLocales" ).locales();
     }
 
+    void TargetImpl::updateAutoInstalled()
+    {
+      MIL << "updateAutoInstalled if changed..." << endl;
+      SolvIdentFile::Data newdata;
+      for ( auto id : sat::Pool::instance().autoInstalled() )
+       newdata.insert( IdString(id) ); // explicit ctor!
+      _autoInstalledFile.setData( std::move(newdata) );
+    }
+
     std::string TargetImpl::targetDistribution() const
     { return baseproductdata( _root ).registerTarget(); }
     // static version:
@@ -1821,15 +1817,29 @@ namespace zypp
     }
 
     ///////////////////////////////////////////////////////////////////
+    namespace
+    {
+      std::string guessAnonymousUniqueId( const Pathname & root_r )
+      {
+       // bsc#1024741: Omit creating a new uid for chrooted systems (if it already has one, fine)
+       std::string ret( firstNonEmptyLineIn( root_r / "/var/lib/zypp/AnonymousUniqueId" ) );
+       if ( ret.empty() && root_r != "/" )
+       {
+         // if it has nonoe, use the outer systems one
+         ret = firstNonEmptyLineIn( "/var/lib/zypp/AnonymousUniqueId" );
+       }
+       return ret;
+      }
+    }
 
     std::string TargetImpl::anonymousUniqueId() const
     {
-      return firstNonEmptyLineIn( home() / "AnonymousUniqueId" );
+      return guessAnonymousUniqueId( root() );
     }
     // static version:
     std::string TargetImpl::anonymousUniqueId( const Pathname & root_r )
     {
-      return firstNonEmptyLineIn( staticGuessRoot(root_r) / "/var/lib/zypp/AnonymousUniqueId" );
+      return guessAnonymousUniqueId( staticGuessRoot(root_r) );
     }
 
     ///////////////////////////////////////////////////////////////////