[zypp-commit] r9927 - in /trunk/libzypp: ./ devel/devel.ma/ package/ zypp/ zypp/target/ zypp/zypp_detail/
Author: mlandres Date: Thu May 1 01:07:34 2008 New Revision: 9927 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9927&view=rev Log: - Load and maintain persistent hard locks stored in /etc/zypp/locks. Locks are loaded together with the target, and changes are writen back on commit. zypp.conf option locksfile.apply can be used to turn this feature on or off. (FATE #120352) Added: trunk/libzypp/zypp/target/HardLocksFile.cc trunk/libzypp/zypp/target/HardLocksFile.h Modified: trunk/libzypp/VERSION.cmake trunk/libzypp/devel/devel.ma/NewPool.cc trunk/libzypp/package/libzypp.changes trunk/libzypp/zypp/CMakeLists.txt trunk/libzypp/zypp/ResPool.cc trunk/libzypp/zypp/ResPool.h trunk/libzypp/zypp/ZYpp.cc trunk/libzypp/zypp/ZYpp.h trunk/libzypp/zypp/target/SoftLocksFile.h trunk/libzypp/zypp/target/TargetImpl.cc trunk/libzypp/zypp/target/TargetImpl.h trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc trunk/libzypp/zypp/zypp_detail/ZYppImpl.h Modified: trunk/libzypp/VERSION.cmake URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/VERSION.cmake (original) +++ trunk/libzypp/VERSION.cmake Thu May 1 01:07:34 2008 @@ -45,6 +45,6 @@ # SET(LIBZYPP_MAJOR "4") -SET(LIBZYPP_MINOR "17") -SET(LIBZYPP_COMPATMINOR "17") -SET(LIBZYPP_PATCH "1") +SET(LIBZYPP_MINOR "18") +SET(LIBZYPP_COMPATMINOR "18") +SET(LIBZYPP_PATCH "0") Modified: trunk/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/NewPool.cc (original) +++ trunk/libzypp/devel/devel.ma/NewPool.cc Thu May 1 01:07:34 2008 @@ -474,13 +474,17 @@ { ResPool pool( ResPool::instance() ); ostream & outs( SEC ); + unsigned cnt = 0; outs << t << ": {" << endl; for_( it, pool.begin(), pool.end() ) { if ( it->status().isLocked() ) + { outs << " " << *it << endl; + ++cnt; + } } - outs << '}' << endl; + outs << '}' << cnt << endl; } void ssup() @@ -503,6 +507,15 @@ dumpRange( DBG, q.begin(), q.end() ) << endl; newLocks.push_back( q ); } + { + PoolQuery q; + q.addAttribute( sat::SolvAttr::name, "amarok" ); + q.addKind( ResKind::package ); + q.setMatchExact(); + q.setCaseSensitive(true); + dumpRange( DBG, q.begin(), q.end() ) << endl; + newLocks.push_back( q ); + } pool.setHardLockQueries( newLocks ); @@ -525,9 +538,6 @@ ResPool pool( ResPool::instance() ); sat::Pool satpool( sat::Pool::instance() ); - ssup(); - //sslk( "START" ); - if ( 1 ) { RepoManager repoManager( makeRepoManager( sysRoot ) ); @@ -582,8 +592,6 @@ } USR << "pool: " << pool << endl; - - sslk( nrepo.alias() ); } } } @@ -597,7 +605,6 @@ getZYpp()->initializeTarget( sysRoot ); } getZYpp()->target()->load(); - sslk( "TARGET" ); } } @@ -615,32 +622,14 @@ /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - INT << "===[END]============================================" << endl << endl; - zypp::base::LogControl::instance().logNothing(); - return 0; - //ResPool pool( ResPool::instance() ); - - // - PoolQueryResult result( pool.byKindBegin<Package>(), pool.byKindEnd<Package>() ); - MIL << result.size() << endl; - - { - PoolQuery q; - q.addAttribute( sat::SolvAttr::name, "[a-zA-Z]*" ); - q.setMatchGlob(); - result -= q; - MIL << result.size() << endl; - } - MIL << result << endl; - - sat::WhatProvides poviders( Capability("3ddiag") ); - result -= PoolQueryResult( poviders.begin(), poviders.end() ); - MIL << result << endl; + //ssup(); + //sslk("X"); + ResPool::HardLockQueries newLocks; + pool.getHardLockQueries( newLocks ); + SEC << newLocks << endl; - result -= result; - MIL << result << endl; + install(); /////////////////////////////////////////////////////////////////// INT << "===[END]============================================" << endl << endl; Modified: trunk/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/package/libzypp.changes (original) +++ trunk/libzypp/package/libzypp.changes Thu May 1 01:07:34 2008 @@ -1,4 +1,14 @@ ------------------------------------------------------------------- +Thu May 1 00:50:51 CEST 2008 - ma@suse.de + +- Load and maintain persistent hard locks stored in /etc/zypp/locks. + Locks are loaded together with the target, and changes are writen + back on commit. zypp.conf option locksfile.apply can be used to turn + this feature on or off. (FATE #120352) +- version 4.18.0 +- revision 9927 + +------------------------------------------------------------------- Wed Apr 30 16:27:49 CEST 2008 - ma@suse.de - Add zypp.conf option solvfilesdir: Path where the repo solv files Modified: trunk/libzypp/zypp/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/zypp/CMakeLists.txt (original) +++ trunk/libzypp/zypp/CMakeLists.txt Thu May 1 01:07:34 2008 @@ -564,6 +564,7 @@ SET( zypp_target_SRCS target/RequestedLocalesFile.cc target/SoftLocksFile.cc + target/HardLocksFile.cc target/CommitLog.cc target/CommitPackageCache.cc target/CommitPackageCacheImpl.cc @@ -576,6 +577,7 @@ SET( zypp_target_HEADERS target/RequestedLocalesFile.h target/SoftLocksFile.h + target/HardLocksFile.h target/CommitLog.h target/CommitPackageCache.h target/CommitPackageCacheImpl.h Modified: trunk/libzypp/zypp/ResPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResPool.cc?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/zypp/ResPool.cc (original) +++ trunk/libzypp/zypp/ResPool.cc Thu May 1 01:07:34 2008 @@ -111,8 +111,8 @@ void ResPool::setHardLockQueries( const HardLockQueries & newLocks_r ) { _pimpl->setHardLockQueries( newLocks_r ); } - bool ResPool::getHardLockQueries( HardLockQueries & activeLocks_r ) - { return _pimpl->getHardLockQueries( activeLocks_r ); } + void ResPool::getHardLockQueries( HardLockQueries & activeLocks_r ) + { _pimpl->getHardLockQueries( activeLocks_r ); } const pool::PoolTraits::ItemContainerT & ResPool::store() const Modified: trunk/libzypp/zypp/ResPool.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResPool.h?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/zypp/ResPool.h (original) +++ trunk/libzypp/zypp/ResPool.h Thu May 1 01:07:34 2008 @@ -357,11 +357,9 @@ void setHardLockQueries( const HardLockQueries & newLocks_r ); /** Suggest a new set of queries based on the current selection. - * (usually remembered on commit). Returns whether the sugested - * set differs from the one that was previously set via - * \ref setHardLockQueries. + * (usually remembered on commit). */ - bool getHardLockQueries( HardLockQueries & activeLocks_r ); + void getHardLockQueries( HardLockQueries & activeLocks_r ); //@} private: Modified: trunk/libzypp/zypp/ZYpp.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZYpp.cc?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/zypp/ZYpp.cc (original) +++ trunk/libzypp/zypp/ZYpp.cc Thu May 1 01:07:34 2008 @@ -118,8 +118,6 @@ void ZYpp::setHomePath( const Pathname & path ) { _pimpl->setHomePath(path); } - int ZYpp::applyLocks() - { return _pimpl->applyLocks(); } ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/zypp/ZYpp.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZYpp.h?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/zypp/ZYpp.h (original) +++ trunk/libzypp/zypp/ZYpp.h Thu May 1 01:07:34 2008 @@ -180,12 +180,11 @@ public: /** - * \short Apply persistant locks to current pool. - * Call this before solving - * - * \returns Number of items locked + * \deprecated Persistent locks are automatically maintained, kept in the pool, loaded and saved together with the Target. + * \ref ZConfig::apply_locks_file tells whether locks are applied or not. */ - int applyLocks(); + ZYPP_DEPRECATED int applyLocks() + { return 0; } protected: /** Dtor */ Added: trunk/libzypp/zypp/target/HardLocksFile.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/HardLocksFile.cc?rev=9927&view=auto ============================================================================== --- trunk/libzypp/zypp/target/HardLocksFile.cc (added) +++ trunk/libzypp/zypp/target/HardLocksFile.cc Thu May 1 01:07:34 2008 @@ -0,0 +1,87 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/target/HardLocksFile.cc + * +*/ +#include <iostream> +#include <fstream> + +#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/HardLocksFile.h" +#include "zypp/PoolQueryUtil.tcc" + +using std::endl; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace target + { ///////////////////////////////////////////////////////////////// + + void HardLocksFile::load( const Pathname & file_r, Data & data_r ) + { + PathInfo pi( file_r ); + if ( ! pi.isFile() ) + { + WAR << "Can't read " << pi << endl; + return; + } + + readPoolQueriesFromFile( file_r, std::back_inserter( data_r ) ); + + MIL << "Read " << pi << endl; + } + + void HardLocksFile::store( const Pathname & file_r, const Data & data_r ) + { + filesystem::TmpFile tmp( filesystem::TmpFile::makeSibling( file_r ) ); + filesystem::chmod( tmp.path(), 0644 ); + + writePoolQueriesToFile( tmp.path(), data_r.begin(), data_r.end() ); + + if ( true ) // by now: no error info from writePoolQueriesToFile + { + 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 HardLocksFile & obj ) + { + str << obj.file() << ' '; + if ( obj._dataPtr ) + str << obj.data(); + else + str << "(unloaded)"; + return str; + } + + ///////////////////////////////////////////////////////////////// + } // namespace target + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// Added: trunk/libzypp/zypp/target/HardLocksFile.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/HardLocksFile.h?rev=9927&view=auto ============================================================================== --- trunk/libzypp/zypp/target/HardLocksFile.h (added) +++ trunk/libzypp/zypp/target/HardLocksFile.h Thu May 1 01:07:34 2008 @@ -0,0 +1,122 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/target/HardLocksFile.h + * +*/ +#ifndef ZYPP_TARGET_HARDLOCKSFILE_H +#define ZYPP_TARGET_HARDLOCKSFILE_H + +#include <iosfwd> + +#include "zypp/base/PtrTypes.h" + +#include "zypp/Pathname.h" +#include "zypp/pool/PoolTraits.h" +#include "zypp/PoolQuery.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace target + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : HardLocksFile + // + /** Save and restore hardlocks. + */ + class HardLocksFile + { + friend std::ostream & operator<<( std::ostream & str, const HardLocksFile & obj ); + public: + + typedef pool::PoolTraits::HardLockQueries Data; + + public: + /** Ctor taking the file to read/write. */ + HardLocksFile( 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; + // Complete diff is too expensive and not necessary here. + // Just check for the same sequence of items. + Data::const_iterator rit = rhs.begin(); + for_( it, lhs.begin(), lhs.end() ) + { + if ( *it != *rit ) + return true; + ++rit; + } + 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<Data> _dataPtr; + }; + /////////////////////////////////////////////////////////////////// + + /** \relates HardLocksFile Stream output */ + std::ostream & operator<<( std::ostream & str, const HardLocksFile & obj ); + + ///////////////////////////////////////////////////////////////// + } // namespace target + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_TARGET_HARDLOCKSFILE_H Modified: trunk/libzypp/zypp/target/SoftLocksFile.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/SoftLocksFile.h?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/zypp/target/SoftLocksFile.h (original) +++ trunk/libzypp/zypp/target/SoftLocksFile.h Thu May 1 01:07:34 2008 @@ -16,8 +16,8 @@ #include "zypp/base/PtrTypes.h" +#include "zypp/IdString.h" #include "zypp/Pathname.h" -#include "zypp/Locale.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -30,7 +30,7 @@ // // CLASS NAME : SoftLocksFile // - /** Save and restore locale set from file. + /** Save and restore soft locks. */ class SoftLocksFile { Modified: trunk/libzypp/zypp/target/TargetImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/zypp/target/TargetImpl.cc (original) +++ trunk/libzypp/zypp/target/TargetImpl.cc Thu May 1 01:07:34 2008 @@ -282,6 +282,7 @@ : _root( root_r ) , _requestedLocalesFile( home() / "RequestedLocales" ) , _softLocksFile( home() / "SoftLocks" ) + , _hardLocksFile( Pathname::assertprefix( _root, ZConfig::instance().locksFile() ) ) { _rpm.initDatabase( root_r, Pathname(), doRebuild_r ); MIL << "Initialized target on " << _root << endl; @@ -442,16 +443,27 @@ // to avoid undoing changes the application applied. We expect this // to happen on a bare metal installation only. An already existing // target should be loaded before its settings are changed. - const LocaleSet & requestedLocales( _requestedLocalesFile.locales() ); - if ( ! requestedLocales.empty() ) { - satpool.setRequestedLocales( requestedLocales ); + const LocaleSet & requestedLocales( _requestedLocalesFile.locales() ); + if ( ! requestedLocales.empty() ) + { + satpool.setRequestedLocales( requestedLocales ); + } } - - const SoftLocksFile::Data & softLocks( _softLocksFile.data() ); - if ( ! softLocks.empty() ) { - ResPool::instance().setAutoSoftLocks( softLocks ); + const SoftLocksFile::Data & softLocks( _softLocksFile.data() ); + if ( ! softLocks.empty() ) + { + ResPool::instance().setAutoSoftLocks( softLocks ); + } + } + if ( ZConfig::instance().apply_locks_file() ) + { + const HardLocksFile::Data & hardLocks( _hardLocksFile.data() ); + if ( ! hardLocks.empty() ) + { + ResPool::instance().setHardLockQueries( hardLocks ); + } } @@ -478,6 +490,12 @@ pool_r.getActiveSoftLocks( newdata ); _softLocksFile.setData( newdata ); } + if ( ZConfig::instance().apply_locks_file() ) + { + HardLocksFile::Data newdata; + pool_r.getHardLockQueries( newdata ); + _hardLocksFile.setData( newdata ); + } // Process packages: ZYppCommitResult result; Modified: trunk/libzypp/zypp/target/TargetImpl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.h?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/zypp/target/TargetImpl.h (original) +++ trunk/libzypp/zypp/target/TargetImpl.h Thu May 1 01:07:34 2008 @@ -30,6 +30,7 @@ #include "zypp/target/TargetException.h" #include "zypp/target/RequestedLocalesFile.h" #include "zypp/target/SoftLocksFile.h" +#include "zypp/target/HardLocksFile.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -154,6 +155,8 @@ RequestedLocalesFile _requestedLocalesFile; /** Soft-locks database */ SoftLocksFile _softLocksFile; + /** Hard-Locks database */ + HardLocksFile _hardLocksFile; private: /** Null implementation */ static TargetImpl_Ptr _nullimpl; Modified: trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc (original) +++ trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc Thu May 1 01:07:34 2008 @@ -22,7 +22,6 @@ #include "zypp/NVRAD.h" #include "zypp/DiskUsageCounter.h" #include "zypp/NameKindProxy.h" -#include "zypp/Locks.h" #include "zypp/ZConfig.h" #include "zypp/sat/Pool.h" #include "zypp/PoolItem.h" @@ -177,27 +176,6 @@ return zypp_tmp_dir.path(); } - int ZYppImpl::applyLocks() - { - if (!ZConfig::instance().apply_locks_file()) - return 0; - - //TODO catch posibble exceptions - Locks::instance().readAndApply(); - - //current locks api doesn't support counting locked solvables - //so count it after - int count = 0; - for_(it, sat::Pool::instance().solvablesBegin(), - sat::Pool::instance().solvablesEnd()) - { - PoolItem i(*it); - if ( i.status().isLocked() ) - count++; - } - - return count; - } /****************************************************************** ** ** FUNCTION NAME : operator<< Modified: trunk/libzypp/zypp/zypp_detail/ZYppImpl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/zypp_detail/ZYppImpl.h?rev=9927&r1=9926&r2=9927&view=diff ============================================================================== --- trunk/libzypp/zypp/zypp_detail/ZYppImpl.h (original) +++ trunk/libzypp/zypp/zypp_detail/ZYppImpl.h Thu May 1 01:07:34 2008 @@ -101,10 +101,6 @@ void setPartitions(const DiskUsageCounter::MountPointSet &mp); DiskUsageCounter::MountPointSet getPartitions() const; - public: - - int applyLocks(); - private: /** */ Target_Ptr _target; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
mlandres@svn.opensuse.org