Imported Upstream version 15.1.3 60/94660/1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 1 Nov 2016 01:41:26 +0000 (10:41 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 1 Nov 2016 01:41:27 +0000 (10:41 +0900)
Change-Id: I9dd9a0d10cd74d99a930a37498da2cbd7b666e9f
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
VERSION.cmake
package/libzypp.changes
zypp/RepoManager.cc
zypp/sat/Pool.cc
zypp/sat/Pool.h
zypp/target/TargetImpl.cc

index 6a321b0..083325c 100644 (file)
@@ -61,8 +61,8 @@
 SET(LIBZYPP_MAJOR "15")
 SET(LIBZYPP_COMPATMINOR "1")
 SET(LIBZYPP_MINOR "1")
-SET(LIBZYPP_PATCH "2")
+SET(LIBZYPP_PATCH "3")
 #
-# LAST RELEASED: 15.1.2 (1)
+# LAST RELEASED: 15.1.3 (1)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index b52ea86..dfe542d 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Wed May 13 14:04:04 CEST 2015 - ma@suse.de
+
+- Write solv.idx to speed up bash tab completion (bnc#928650)
+- version 15.1.3 (1)
+
+-------------------------------------------------------------------
 Fri May  8 11:44:44 CEST 2015 - ma@suse.de
 
 - gcc5 fixes
index d9ce8bf..ca2e2e9 100644 (file)
@@ -1293,6 +1293,7 @@ namespace zypp
 
         // We keep it.
         guard.resetDispose();
+       sat::updateSolvFileIndex( solvfile );   // content digest for zypper bash completion
       }
       break;
       default:
index 35d8621..8144440 100644 (file)
@@ -9,8 +9,19 @@
 /** \file      zypp/sat/Pool.cc
  *
 */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+extern "C"
+{
+#include <solv/pool.h>
+#include <solv/repo.h>
+#include <solv/solvable.h>
+}
 
 #include <iostream>
+#include <fstream>
 
 #include "zypp/base/Easy.h"
 #include "zypp/base/Logger.h"
@@ -23,6 +34,8 @@
 #include "zypp/sat/Pool.h"
 #include "zypp/sat/LookupAttr.h"
 
+using std::endl;
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -243,6 +256,65 @@ namespace zypp
     }
 
     /////////////////////////////////////////////////////////////////
+    #undef ZYPP_BASE_LOGGER_LOGGROUP
+    #define ZYPP_BASE_LOGGER_LOGGROUP "solvidx"
+
+    void updateSolvFileIndex( const Pathname & solvfile_r )
+    {
+      AutoDispose<FILE*> solv( ::fopen( solvfile_r.c_str(), "re" ), ::fclose );
+      if ( solv == NULL )
+      {
+       solv.resetDispose();
+       ERR << "Can't open solv-file: " << solv << endl;
+       return;
+      }
+
+      std::string solvidxfile( solvfile_r.extend(".idx").asString() );
+      if ( ::unlink( solvidxfile.c_str() ) == -1 && errno != ENOENT )
+      {
+       ERR << "Can't unlink solv-idx: " << Errno() << endl;
+       return;
+      }
+      {
+       int fd = ::open( solvidxfile.c_str(), O_CREAT|O_EXCL|O_WRONLY|O_TRUNC, 0644 );
+       if ( fd == -1 )
+       {
+         ERR << "Can't create solv-idx: " << Errno() << endl;
+         return;
+       }
+       ::close( fd );
+      }
+      std::ofstream idx( solvidxfile.c_str() );
+
+
+      ::_Pool * _pool = ::pool_create();
+      ::_Repo * _repo = ::repo_create( _pool, "" );
+      if ( ::repo_add_solv( _repo, solv, 0 ) == 0 )
+      {
+       int _id = 0;
+       ::_Solvable * _solv = nullptr;
+       FOR_REPO_SOLVABLES( _repo, _id, _solv )
+       {
+         if ( _solv )
+         {
+#define SEP '\t'
+#define        idstr(V) pool_id2str( _pool, _solv->V )
+           if ( _solv->arch == ARCH_SRC || _solv->arch == ARCH_NOSRC )
+             idx << "srcpackage:" << idstr(name) << SEP << idstr(evr) << SEP << "noarch" << endl;
+           else
+             idx << idstr(name) << SEP << idstr(evr) << SEP << idstr(arch) << endl;
+         }
+       }
+      }
+      else
+      {
+       ERR << "Can't read solv-file: " << ::pool_errstr( _pool ) << endl;
+      }
+      ::repo_free( _repo, 0 );
+      ::pool_free( _pool );
+    }
+
+    /////////////////////////////////////////////////////////////////
   } // namespace sat
   ///////////////////////////////////////////////////////////////////
   /////////////////////////////////////////////////////////////////
index 9a29f33..229fd80 100644 (file)
@@ -261,6 +261,9 @@ namespace zypp
     inline bool operator!=( const Pool & lhs, const Pool & rhs )
     { return lhs.get() != rhs.get(); }
 
+    /** Create solv file content digest for zypper bash completion */
+    void updateSolvFileIndex( const Pathname & solvfile_r );
+
     /////////////////////////////////////////////////////////////////
   } // namespace sat
   ///////////////////////////////////////////////////////////////////
index edd1055..126dd5d 100644 (file)
@@ -1086,6 +1086,7 @@ namespace zypp
 
         // We keep it.
         guard.resetDispose();
+       sat::updateSolvFileIndex( rpmsolv );    // content digest for zypper bash completion
 
        // Finally send notification to plugins
        // NOTE: quick hack looking for spacewalk plugin only