Target: maintain AutoInstalled database file
authorMichael Andres <ma@suse.de>
Mon, 28 Apr 2014 13:07:53 +0000 (15:07 +0200)
committerMichael Andres <ma@suse.de>
Mon, 28 Apr 2014 13:07:53 +0000 (15:07 +0200)
Formerly auto/user installed informationn was retrieved from the history
file. This had several drawbacks (log rotation, parsing effort, can't be
tweaked).

zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index 47c852b..17a9db3 100644 (file)
@@ -764,6 +764,7 @@ namespace zypp
     TargetImpl::TargetImpl( const Pathname & root_r, bool doRebuild_r )
     : _root( root_r )
     , _requestedLocalesFile( home() / "RequestedLocales" )
+    , _autoInstalledFile( home() / "AutoInstalled" )
     , _hardLocksFile( Pathname::assertprefix( _root, ZConfig::instance().locksFile() ) )
     {
       _rpm.initDatabase( root_r, Pathname(), doRebuild_r );
@@ -1122,6 +1123,10 @@ namespace zypp
         }
       }
       {
+       sat::StringQueue q;
+       for ( const auto & idstr : _autoInstalledFile.data() )
+         q.push( idstr.id() );
+       satpool.setAutoInstalled( q );
       }
       if ( ZConfig::instance().apply_locks_file() )
       {
@@ -1227,7 +1232,12 @@ namespace zypp
         filesystem::assert_dir( home() );
         // requested locales
         _requestedLocalesFile.setLocales( pool_r.getRequestedLocales() );
+       // autoinstalled
         {
+         SolvIdentFile::Data newdata;
+         for ( sat::Queue::value_type id : result.rTransaction().autoInstalled() )
+           newdata.insert( IdString(id) );
+         _autoInstalledFile.setData( newdata );
         }
         // hard locks
         if ( ZConfig::instance().apply_locks_file() )
index 45ccfa2..353370a 100644 (file)
@@ -27,6 +27,7 @@
 #include "zypp/target/rpm/RpmDb.h"
 #include "zypp/target/TargetException.h"
 #include "zypp/target/RequestedLocalesFile.h"
+#include "zypp/target/SolvIdentFile.h"
 #include "zypp/target/HardLocksFile.h"
 #include "zypp/ManagedFile.h"
 
@@ -209,6 +210,8 @@ namespace zypp
       rpm::RpmDb _rpm;
       /** Requested Locales database */
       RequestedLocalesFile _requestedLocalesFile;
+      /** user/auto installed database */
+      SolvIdentFile _autoInstalledFile;
       /** Hard-Locks database */
       HardLocksFile _hardLocksFile;
       /** Cache distributionVersion */