From: DongHun Kwak Date: Tue, 1 Nov 2016 01:41:26 +0000 (+0900) Subject: Imported Upstream version 15.1.3 X-Git-Tag: upstream/16.3.1~66 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f29d161f44d687fc0f94a908d3883d4cf18634d;p=platform%2Fupstream%2Flibzypp.git Imported Upstream version 15.1.3 Change-Id: I9dd9a0d10cd74d99a930a37498da2cbd7b666e9f Signed-off-by: DongHun Kwak --- diff --git a/VERSION.cmake b/VERSION.cmake index 6a321b0..083325c 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -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) #======= diff --git a/package/libzypp.changes b/package/libzypp.changes index b52ea86..dfe542d 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -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 diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc index d9ce8bf..ca2e2e9 100644 --- a/zypp/RepoManager.cc +++ b/zypp/RepoManager.cc @@ -1293,6 +1293,7 @@ namespace zypp // We keep it. guard.resetDispose(); + sat::updateSolvFileIndex( solvfile ); // content digest for zypper bash completion } break; default: diff --git a/zypp/sat/Pool.cc b/zypp/sat/Pool.cc index 35d8621..8144440 100644 --- a/zypp/sat/Pool.cc +++ b/zypp/sat/Pool.cc @@ -9,8 +9,19 @@ /** \file zypp/sat/Pool.cc * */ +#include +#include +#include + +extern "C" +{ +#include +#include +#include +} #include +#include #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 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 /////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// diff --git a/zypp/sat/Pool.h b/zypp/sat/Pool.h index 9a29f33..229fd80 100644 --- a/zypp/sat/Pool.h +++ b/zypp/sat/Pool.h @@ -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 /////////////////////////////////////////////////////////////////// diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index edd1055..126dd5d 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -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