From e797c188f61b93724752f4b3ac8ea78585bfbc14 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Mon, 28 Apr 2014 12:08:35 +0200 Subject: [PATCH] sat::Pool: Keep list of autoinstalled solvables (read from dd file) --- zypp/sat/Pool.cc | 7 ++-- zypp/sat/Pool.h | 17 ++++------ zypp/sat/detail/PoolImpl.cc | 82 ++------------------------------------------- zypp/sat/detail/PoolImpl.h | 22 +++++------- 4 files changed, 20 insertions(+), 108 deletions(-) diff --git a/zypp/sat/Pool.cc b/zypp/sat/Pool.cc index 9c4a2e3..dffd337 100644 --- a/zypp/sat/Pool.cc +++ b/zypp/sat/Pool.cc @@ -220,11 +220,8 @@ namespace zypp Pool::MultiversionIterator Pool::multiversionEnd() const { return myPool().multiversionList().end(); } bool Pool::isMultiversion( IdString ident_r ) const { return myPool().isMultiversion( ident_r ); } - bool Pool::onSystemByUserEmpty() const { return myPool().onSystemByUserList().empty(); } - size_t Pool::onSystemByUserSize() const { return myPool().onSystemByUserList().size(); } - Pool::OnSystemByUserIterator Pool::onSystemByUserBegin() const { return myPool().onSystemByUserList().begin(); } - Pool::OnSystemByUserIterator Pool::onSystemByUserEnd() const { return myPool().onSystemByUserList().end(); } - bool Pool::isOnSystemByUser( IdString ident_r ) const { return myPool().isOnSystemByUser( ident_r ); } + Queue Pool::autoInstalled() const { return myPool().autoInstalled(); } + void Pool::setAutoInstalled( const Queue & autoInstalled_r ){ myPool().setAutoInstalled( autoInstalled_r ); } /****************************************************************** ** diff --git a/zypp/sat/Pool.h b/zypp/sat/Pool.h index 188cd59..845df55 100644 --- a/zypp/sat/Pool.h +++ b/zypp/sat/Pool.h @@ -19,6 +19,7 @@ #include "zypp/sat/detail/PoolMember.h" #include "zypp/Repository.h" #include "zypp/sat/WhatProvides.h" +#include "zypp/sat/Queue.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -226,18 +227,12 @@ namespace zypp //@} public: - /** \name Installed on behalf of a user request hint. - * This is a hint guessed by evaluating an available install history. - */ + /** \name Autoinstalled */ //@{ - typedef IdStringSet::const_iterator OnSystemByUserIterator; - - bool onSystemByUserEmpty() const; - size_t onSystemByUserSize() const; - OnSystemByUserIterator onSystemByUserBegin() const; - OnSystemByUserIterator onSystemByUserEnd() const; - - bool isOnSystemByUser( IdString ident_r ) const; + /** Get ident list of all autoinstalled solvables. */ + Queue autoInstalled() const; + /** Set ident list of all autoinstalled solvables. */ + void setAutoInstalled( const Queue & autoInstalled_r ); //@} public: diff --git a/zypp/sat/detail/PoolImpl.cc b/zypp/sat/detail/PoolImpl.cc index e91caca..be3082e 100644 --- a/zypp/sat/detail/PoolImpl.cc +++ b/zypp/sat/detail/PoolImpl.cc @@ -293,13 +293,10 @@ namespace zypp void PoolImpl::_deleteRepo( ::_Repo * repo_r ) { setDirty(__FUNCTION__, repo_r->name ); - ::repo_free( repo_r, /*reuseids*/false ); - eraseRepoInfo( repo_r ); if ( isSystemRepo( repo_r ) ) - { - // systemRepo added - _onSystemByUserListPtr.reset(); // re-evaluate - } + _autoinstalled.clear(); + eraseRepoInfo( repo_r ); + ::repo_free( repo_r, /*reuseids*/false ); } int PoolImpl::_addSolv( ::_Repo * repo_r, FILE * file_r ) @@ -362,11 +359,6 @@ namespace zypp blockBegin = blockSize = 0; } } - else - { - // systemRepo added - _onSystemByUserListPtr.reset(); // re-evaluate - } } detail::SolvableIdType PoolImpl::_addSolvables( ::_Repo * repo_r, unsigned count_r ) @@ -555,74 +547,6 @@ namespace zypp } } - void PoolImpl::onSystemByUserListInit() const - { - _onSystemByUserListPtr.reset( new OnSystemByUserList ); - OnSystemByUserList & onSystemByUserList( *_onSystemByUserListPtr ); - - Pathname root( ZConfig::instance().systemRoot() ); - if ( root.empty() ) - { - MIL << "Target not initialized." << endl; - return; - } - PathInfo pi( root / ZConfig::instance().historyLogFile() ); - MIL << "onSystemByUserList from history: " << pi << endl; - if ( ! pi.isFile() ) - return; - - // go and parse it: 'who' must constain an '@', then it was installed by user request. - // 2009-09-29 07:25:19|install|lirc-remotes|0.8.5-3.2|x86_64|root@opensuse|InstallationImage|a204211eb0... - std::ifstream infile( pi.path().c_str() ); - for( iostr::EachLine in( infile ); in; in.next() ) - { - const char * ch( (*in).c_str() ); - // start with year - if ( *ch < '1' || '9' < *ch ) - continue; - const char * sep1 = ::strchr( ch, '|' ); // | after date - if ( !sep1 ) - continue; - ++sep1; - // if logs an install or delete - bool installs = true; - if ( ::strncmp( sep1, "install|", 8 ) ) - { - if ( ::strncmp( sep1, "remove |", 8 ) ) - continue; // no install and no remove - else - installs = false; // remove - } - sep1 += 8; // | after what - // get the package name - const char * sep2 = ::strchr( sep1, '|' ); // | after name - if ( !sep2 || sep1 == sep2 ) - continue; - (*in)[sep2-ch] = '\0'; - IdString pkg( sep1 ); - // we're done, if a delete - if ( !installs ) - { - onSystemByUserList.erase( pkg ); - continue; - } - // now guess whether user installed or not (3rd next field contains 'user@host') - if ( (sep1 = ::strchr( sep2+1, '|' )) // | after version - && (sep1 = ::strchr( sep1+1, '|' )) // | after arch - && (sep2 = ::strchr( sep1+1, '|' )) ) // | after who - { - (*in)[sep2-ch] = '\0'; - if ( ::strchr( sep1+1, '@' ) ) - { - // by user - onSystemByUserList.insert( pkg ); - continue; - } - } - } - MIL << "onSystemByUserList found: " << onSystemByUserList.size() << endl; - } - const std::set & PoolImpl::requiredFilesystems() const { if ( ! _requiredFilesystemsPtr ) diff --git a/zypp/sat/detail/PoolImpl.h b/zypp/sat/detail/PoolImpl.h index d4a248f..4eec4c1 100644 --- a/zypp/sat/detail/PoolImpl.h +++ b/zypp/sat/detail/PoolImpl.h @@ -25,6 +25,7 @@ extern "C" #include "zypp/base/NonCopyable.h" #include "zypp/base/SerialNumber.h" #include "zypp/sat/detail/PoolMember.h" +#include "zypp/sat/Queue.h" #include "zypp/RepoInfo.h" #include "zypp/Locale.h" #include "zypp/Capability.h" @@ -247,20 +248,16 @@ namespace zypp public: /** \name Installed on behalf of a user request hint. */ //@{ - typedef IdStringSet OnSystemByUserList; + /** Get ident list of all autoinstalled solvables. */ + StringQueue autoInstalled() const + { return _autoinstalled; } - const OnSystemByUserList & onSystemByUserList() const - { - if ( ! _onSystemByUserListPtr ) - onSystemByUserListInit(); - return *_onSystemByUserListPtr; - } + /** Set ident list of all autoinstalled solvables. */ + void setAutoInstalled( const StringQueue & autoInstalled_r ) + { _autoinstalled = autoInstalled_r; } bool isOnSystemByUser( IdString ident_r ) const - { - const OnSystemByUserList & l( onSystemByUserList() ); - return l.find( ident_r ) != l.end(); - } + { return !_autoinstalled.contains( ident_r.id() ); } //@} public: @@ -287,8 +284,7 @@ namespace zypp mutable scoped_ptr _multiversionListPtr; /** */ - void onSystemByUserListInit() const; - mutable scoped_ptr _onSystemByUserListPtr; + sat::StringQueue _autoinstalled; /** filesystems mentioned in /etc/sysconfig/storage */ mutable scoped_ptr > _requiredFilesystemsPtr; -- 2.7.4