From c287b690cbf2ca3dd32e355f7986587e6defe983 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Wed, 23 Apr 2014 11:10:19 +0200 Subject: [PATCH] Remove SoftLock artefacts --- zypp/CMakeLists.txt | 2 - zypp/ResPool.cc | 20 -------- zypp/ResPool.h | 36 ------------- zypp/pool/PoolImpl.h | 77 ---------------------------- zypp/pool/PoolTraits.h | 6 --- zypp/target/SoftLocksFile.cc | 95 ----------------------------------- zypp/target/SoftLocksFile.h | 117 ------------------------------------------- zypp/target/TargetImpl.cc | 19 ------- zypp/target/TargetImpl.h | 3 -- 9 files changed, 375 deletions(-) delete mode 100644 zypp/target/SoftLocksFile.cc delete mode 100644 zypp/target/SoftLocksFile.h diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt index 1460c81..de601e3 100644 --- a/zypp/CMakeLists.txt +++ b/zypp/CMakeLists.txt @@ -571,7 +571,6 @@ INSTALL( FILES SET( zypp_target_SRCS target/RpmPostTransCollector.cc target/RequestedLocalesFile.cc - target/SoftLocksFile.cc target/HardLocksFile.cc target/CommitPackageCache.cc target/CommitPackageCacheImpl.cc @@ -586,7 +585,6 @@ SET( zypp_target_SRCS SET( zypp_target_HEADERS target/RpmPostTransCollector.h target/RequestedLocalesFile.h - target/SoftLocksFile.h target/HardLocksFile.h target/CommitPackageCache.h target/CommitPackageCacheImpl.h diff --git a/zypp/ResPool.cc b/zypp/ResPool.cc index de43071..fa708ee 100644 --- a/zypp/ResPool.cc +++ b/zypp/ResPool.cc @@ -83,26 +83,6 @@ namespace zypp Repository ResPool::reposFind( const std::string & alias_r ) const { return _pimpl->reposFind( alias_r ); } -#ifdef WITHSOFTLOCKS - bool ResPool::autoSoftLocksEmpty() const - { return _pimpl->autoSoftLocks().empty(); } - - ResPool::size_type ResPool::autoSoftLocksSize() const - { return _pimpl->autoSoftLocks().size(); } - - ResPool::autoSoftLocks_iterator ResPool::autoSoftLocksBegin() const - { return _pimpl->autoSoftLocks().begin(); } - - ResPool::autoSoftLocks_iterator ResPool::autoSoftLocksEnd() const - { return _pimpl->autoSoftLocks().end(); } - - void ResPool::setAutoSoftLocks( const AutoSoftLocks & newLocks_r ) - { _pimpl->setAutoSoftLocks( newLocks_r ); } - - void ResPool::getActiveSoftLocks( AutoSoftLocks & activeLocks_r ) - { _pimpl->getActiveSoftLocks( activeLocks_r ); } -#endif - bool ResPool::hardLockQueriesEmpty() const { return _pimpl->hardLockQueries().empty(); } diff --git a/zypp/ResPool.h b/zypp/ResPool.h index a4f5032..a8d37d9 100644 --- a/zypp/ResPool.h +++ b/zypp/ResPool.h @@ -320,42 +320,6 @@ namespace zypp bool isAvailableLocale( const Locale & locale_r ) const; //@} -#ifdef WITHSOFTLOCKS - public: - /** \name Handle automatic soft-locks. - * - * Solvables with and ident listed here are per default created with - * a setSoftLock applied. I.e. the \ref Resolver should not automatically - * select them, if they are just recommended. - * - * This list is considered when adding new repos to the pool. It is - * \b not the list of currently softLocked items. - * - * Mainly used to re-apply soft-locks remembered during the last commit. - */ - //@{ - typedef pool::PoolTraits::AutoSoftLocks AutoSoftLocks; - typedef pool::PoolTraits::autoSoftLocks_iterator autoSoftLocks_iterator; - - bool autoSoftLocksEmpty() const; - size_type autoSoftLocksSize() const; - autoSoftLocks_iterator autoSoftLocksBegin() const; - autoSoftLocks_iterator autoSoftLocksEnd() const; - - /** Set a new soft-lock list. - * The soft-locks of existing PoolItems are adjusted according - * to the list. (usually called on target load) - */ - void setAutoSoftLocks( const AutoSoftLocks & newLocks_r ); - - /** Suggest a new soft-lock list based on the current selection. - * Based on the the current soft-lock list. Items tagged to be - * installed are removed, and those tagged to be deleted are added. - * (usually remembered on commit). - */ - void getActiveSoftLocks( AutoSoftLocks & activeLocks_r ); - //@} -#endif public: /** \name Handle hard locks (e.g set from /etc/zypp/locks). * diff --git a/zypp/pool/PoolImpl.h b/zypp/pool/PoolImpl.h index de2a615..9c0aeb5 100644 --- a/zypp/pool/PoolImpl.h +++ b/zypp/pool/PoolImpl.h @@ -298,72 +298,6 @@ namespace zypp return setChanged; } -#ifdef WITHSOFTLOCKS - public: - typedef PoolTraits::AutoSoftLocks AutoSoftLocks; - typedef PoolTraits::autoSoftLocks_iterator autoSoftLocks_iterator; - - const AutoSoftLocks & autoSoftLocks() const - { return _autoSoftLocks; } - - bool autoSoftLockAppliesTo( sat::Solvable solv_r ) const - { return( _autoSoftLocks.find( solv_r.ident() ) != _autoSoftLocks.end() ); } - - void setAutoSoftLocks( const AutoSoftLocks & newLocks_r ) - { - MIL << "Apply " << newLocks_r.size() << " AutoSoftLocks: " << newLocks_r << endl; - _autoSoftLocks = newLocks_r; - // now adjust the pool status - for_( it, begin(), end() ) - { - if ( ! it->status().isKept() ) - continue; - - if ( autoSoftLockAppliesTo( it->satSolvable() ) ) - it->status().setSoftLock( ResStatus::USER ); - else - it->status().resetTransact( ResStatus::USER ); - } - } - - void getActiveSoftLocks( AutoSoftLocks & activeLocks_r ) - { - activeLocks_r = _autoSoftLocks; // current soft-locks - AutoSoftLocks todel; // + names to be deleted - AutoSoftLocks toins; // - names to be installed - - for_( it, begin(), end() ) - { - ResStatus & status( it->status() ); - if ( ! ( status.isByUser() || status.isByApplLow() ) ) - continue; // ignore non-user requests; ApplLow means selected - // by solver, but on behalf of a user request. - - switch ( status.getTransactValue() ) - { - case ResStatus::KEEP_STATE: - // Filter only items included in the last recommended set. - if ( status.isRecommended() ) - activeLocks_r.insert( it->satSolvable().ident() ); - break; - case ResStatus::LOCKED: - // NOOP - break; - case ResStatus::TRANSACT: - (status.isInstalled() ? todel : toins).insert( it->satSolvable().ident() ); - break; - } - } - for_( it, todel.begin(), todel.end() ) - { - activeLocks_r.insert( *it ); - } - for_( it, toins.begin(), toins.end() ) - { - activeLocks_r.erase( *it ); - } - } -#endif public: const ContainerT & store() const { @@ -394,13 +328,6 @@ namespace zypp // remember products for buddy processing (requires clean store) if ( s.isKind( ResKind::product ) ) addedProducts.push_back( pi ); -#ifdef WITHSOFTLOCKS - // and on the fly check for weak locks... - if ( autoSoftLockAppliesTo( s ) ) - { - pi.status().setSoftLock( ResStatus::USER ); - } -#endif if ( !addedItems ) addedItems = true; } @@ -480,10 +407,6 @@ namespace zypp mutable shared_ptr _poolProxy; private: -#ifdef WITHSOFTLOCKS - /** Set of solvable idents that should be soft locked per default. */ - AutoSoftLocks _autoSoftLocks; -#endif /** Set of queries that define hardlocks. */ HardLockQueries _hardLockQueries; }; diff --git a/zypp/pool/PoolTraits.h b/zypp/pool/PoolTraits.h index 3df8feb..5b2770b 100644 --- a/zypp/pool/PoolTraits.h +++ b/zypp/pool/PoolTraits.h @@ -84,12 +84,6 @@ namespace zypp /** list of known Repositories */ typedef sat::Pool::RepositoryIterator repository_iterator; -#ifdef WITHSOFTLOCKS - /** soft locks */ - typedef std::tr1::unordered_set AutoSoftLocks; - typedef AutoSoftLocks::const_iterator autoSoftLocks_iterator; -#endif - /** hard locks from etc/zypp/locks */ typedef std::list HardLockQueries; typedef HardLockQueries::const_iterator hardLockQueries_iterator; diff --git a/zypp/target/SoftLocksFile.cc b/zypp/target/SoftLocksFile.cc deleted file mode 100644 index 4e117d2..0000000 --- a/zypp/target/SoftLocksFile.cc +++ /dev/null @@ -1,95 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ -/** \file zypp/target/SoftLocksFile.cc - * -*/ -#include -#include - -#include "zypp/base/LogTools.h" -#include "zypp/base/IOStream.h" -#include "zypp/base/String.h" - -#include "zypp/PathInfo.h" -#include "zypp/TmpPath.h" -#include "zypp/Date.h" - -#include "zypp/target/SoftLocksFile.h" - -using std::endl; - -/////////////////////////////////////////////////////////////////// -namespace zypp -{ ///////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - namespace target - { ///////////////////////////////////////////////////////////////// - - void SoftLocksFile::load( const Pathname & file_r, Data & data_r ) - { - PathInfo pi( file_r ); - if ( ! pi.isFile() ) - { - WAR << "Can't read " << pi << endl; - return; - } - std::ifstream infile( file_r.c_str() ); - for( iostr::EachLine in( infile ); in; in.next() ) - { - std::string l( str::trim(*in) ); - if ( ! l.empty() && l[0] != '#' ) - { - data_r.insert( IdString(l) ); - } - } - MIL << "Read " << pi << endl; - } - - void SoftLocksFile::store( const Pathname & file_r, const Data & data_r ) - { - filesystem::TmpFile tmp( filesystem::TmpFile::makeSibling( file_r ) ); - filesystem::chmod( tmp.path(), 0644 ); - - std::ofstream outs( tmp.path().c_str() ); - outs << "# zypp::SoftLocksFile generated " << Date::now() << endl; - dumpRange( outs, data_r.begin(), data_r.end(), "#", "\n", "\n", "\n", "#\n" ); - outs.close(); - - if ( outs.good() ) - { - filesystem::rename( tmp.path(), file_r ); - MIL << "Wrote " << PathInfo(file_r) << endl; - } - else - { - ERR << "Can't write " << PathInfo(tmp.path()) << endl; - } - } - - /****************************************************************** - ** - ** FUNCTION NAME : operator<< - ** FUNCTION TYPE : std::ostream & - */ - std::ostream & operator<<( std::ostream & str, const SoftLocksFile & obj ) - { - str << obj.file() << ' '; - if ( obj._dataPtr ) - str << obj.data(); - else - str << "(unloaded)"; - return str; - } - - ///////////////////////////////////////////////////////////////// - } // namespace target - /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// -} // namespace zypp -/////////////////////////////////////////////////////////////////// diff --git a/zypp/target/SoftLocksFile.h b/zypp/target/SoftLocksFile.h deleted file mode 100644 index bd91d6a..0000000 --- a/zypp/target/SoftLocksFile.h +++ /dev/null @@ -1,117 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ -/** \file zypp/target/SoftLocksFile.h - * -*/ -#ifndef ZYPP_TARGET_SOFTLOCKSFILE_H -#define ZYPP_TARGET_SOFTLOCKSFILE_H - -#include - -#include "zypp/base/PtrTypes.h" - -#include "zypp/IdString.h" -#include "zypp/Pathname.h" - -/////////////////////////////////////////////////////////////////// -namespace zypp -{ ///////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - namespace target - { ///////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : SoftLocksFile - // - /** Save and restore soft locks. - */ - class SoftLocksFile - { - friend std::ostream & operator<<( std::ostream & str, const SoftLocksFile & obj ); - public: - typedef std::tr1::unordered_set Data; - - public: - /** Ctor taking the file to read/write. */ - SoftLocksFile( const Pathname & file_r ) - : _file( file_r ) - {} - - /** Return the file path. */ - const Pathname & file() const - { return _file; } - - /** Return the data. - * The file is read once on demand. Returns empty \ref Data if - * the file does not exist or is not readable. - */ - const Data & data() const - { - if ( !_dataPtr ) - { - _dataPtr.reset( new Data ); - Data & mydata( *_dataPtr ); - load( _file, mydata ); - } - return *_dataPtr; - } - - /** Store new \ref Data. - * Write the new \ref Data to file, unless we know it - * did not change. The directory containing file must - * exist. - */ - void setData( const Data & data_r ) - { - if ( !_dataPtr ) - _dataPtr.reset( new Data ); - - if ( differs( *_dataPtr, data_r ) ) - { - store( _file, data_r ); - *_dataPtr = data_r; - } - } - - private: - /** Helper testing whether two \ref Data differ. */ - bool differs( const Data & lhs, const Data & rhs ) const - { - - if ( lhs.size() != rhs.size() ) - return true; - for_( it, lhs.begin(), lhs.end() ) - { - if ( rhs.find( *it ) == rhs.end() ) - return true; - } - return false; - } - /** Read \ref Data from \c file_r. */ - static void load( const Pathname & file_r, Data & data_r ); - /** Write \ref Data to \c file_r. */ - static void store( const Pathname & file_r, const Data & data_r ); - - private: - Pathname _file; - mutable scoped_ptr _dataPtr; - }; - /////////////////////////////////////////////////////////////////// - - /** \relates SoftLocksFile Stream output */ - std::ostream & operator<<( std::ostream & str, const SoftLocksFile & obj ); - - ///////////////////////////////////////////////////////////////// - } // namespace target - /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// -} // namespace zypp -/////////////////////////////////////////////////////////////////// -#endif // ZYPP_TARGET_SOFTLOCKSFILE_H diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index f908895..47c852b 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -764,7 +764,6 @@ namespace zypp TargetImpl::TargetImpl( const Pathname & root_r, bool doRebuild_r ) : _root( root_r ) , _requestedLocalesFile( home() / "RequestedLocales" ) - , _softLocksFile( home() / "SoftLocks" ) , _hardLocksFile( Pathname::assertprefix( _root, ZConfig::instance().locksFile() ) ) { _rpm.initDatabase( root_r, Pathname(), doRebuild_r ); @@ -1122,20 +1121,8 @@ namespace zypp satpool.setRequestedLocales( requestedLocales ); } } -#ifdef WITHSOFTLOCKS { - SoftLocksFile::Data softLocks( _softLocksFile.data() ); - if ( ! softLocks.empty() ) - { - // Don't soft lock any installed item. - for_( it, system.solvablesBegin(), system.solvablesEnd() ) - { - softLocks.erase( it->ident() ); - } - ResPool::instance().setAutoSoftLocks( softLocks ); - } } -#endif if ( ZConfig::instance().apply_locks_file() ) { const HardLocksFile::Data & hardLocks( _hardLocksFile.data() ); @@ -1240,14 +1227,8 @@ namespace zypp filesystem::assert_dir( home() ); // requested locales _requestedLocalesFile.setLocales( pool_r.getRequestedLocales() ); -#ifdef WITHSOFTLOCKS - // weak locks { - SoftLocksFile::Data newdata; - pool_r.getActiveSoftLocks( newdata ); - _softLocksFile.setData( newdata ); } -#endif // hard locks if ( ZConfig::instance().apply_locks_file() ) { diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index dbd2062..45ccfa2 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -27,7 +27,6 @@ #include "zypp/target/rpm/RpmDb.h" #include "zypp/target/TargetException.h" #include "zypp/target/RequestedLocalesFile.h" -#include "zypp/target/SoftLocksFile.h" #include "zypp/target/HardLocksFile.h" #include "zypp/ManagedFile.h" @@ -210,8 +209,6 @@ namespace zypp rpm::RpmDb _rpm; /** Requested Locales database */ RequestedLocalesFile _requestedLocalesFile; - /** Soft-locks database */ - SoftLocksFile _softLocksFile; /** Hard-Locks database */ HardLocksFile _hardLocksFile; /** Cache distributionVersion */ -- 2.7.4