Author: mlandres Date: Fri Apr 25 14:37:57 2008 New Revision: 9818 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9818&view=rev Log: - Prevent deselected or deleted items from being re-selected due to recommends (aka. persistent soft locks). Unlike hard locked, those items will be automatically selected if required. The list of soft locked items is stored in /var/lib/zypp/SoftLocks. Added: trunk/libzypp/zypp/target/SoftLocksFile.cc trunk/libzypp/zypp/target/SoftLocksFile.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/target/RequestedLocalesFile.cc trunk/libzypp/zypp/target/TargetImpl.cc trunk/libzypp/zypp/target/TargetImpl.h Modified: trunk/libzypp/VERSION.cmake URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=9818&r1=9817&r2=9818&view=diff ============================================================================== --- trunk/libzypp/VERSION.cmake (original) +++ trunk/libzypp/VERSION.cmake Fri Apr 25 14:37:57 2008 @@ -47,4 +47,4 @@ SET(LIBZYPP_MAJOR "4") SET(LIBZYPP_MINOR "15") SET(LIBZYPP_COMPATMINOR "14") -SET(LIBZYPP_PATCH "0") +SET(LIBZYPP_PATCH "1") Modified: trunk/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=9818&r1=9817&r2=9818&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/NewPool.cc (original) +++ trunk/libzypp/devel/devel.ma/NewPool.cc Fri Apr 25 14:37:57 2008 @@ -259,7 +259,7 @@ bool install() { - SEC << getZYpp()->commit( ZYppCommitPolicy() ) << endl; + SEC << getZYpp()->commit( ZYppCommitPolicy().dryRun() ) << endl; return true; } @@ -521,20 +521,10 @@ ++argv; zypp::base::LogControl::instance().logToStdErr(); INT << "===[START]==========================================" << endl; - ZConfig::instance().setTextLocale(Locale("de")); ResPool pool( ResPool::instance() ); - USR << "pool: " << pool << endl; sat::Pool satpool( sat::Pool::instance() ); - typedef ResPool::AutoSoftLocks AutoSoftLocks; - typedef ResPool::autoSoftLocks_iterator autoSoftLocks_iterator; - - AutoSoftLocks s; - //s.insert( IdString("xorg-x11") ); - pool.setAutoSoftLocks( s ); - sslk( "START" ); - if ( 1 ) { RepoManager repoManager( makeRepoManager( sysRoot ) ); @@ -619,39 +609,9 @@ /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// - sslk( "AFTER LOAD" ); - - //s.clear(); - s.insert( IdString("pattern:office") ); - pool.setAutoSoftLocks( s ); - sslk( "AFTER RESET" ); - - - AutoSoftLocks n; - pool.getActiveSoftLocks( s ); - INT << s << endl; - - PoolItem( sat::Solvable(10340) ).status().setTransact( true, ResStatus::USER ); - PoolItem( sat::Solvable(3500) ).status().setTransact( true, ResStatus::USER ); - vdumpPoolStats( USR << "Transacting:"<< endl, - make_filter_beginresfilter::ByTransact(pool), - make_filter_endresfilter::ByTransact(pool) ) << endl; - pool.getActiveSoftLocks( s ); - INT << s << endl; - - - /////////////////////////////////////////////////////////////////// - - //vdumpPoolStats( USR << "Pool:"<< endl, pool.byKindBegin<Package>(), pool.byKindEnd<Package>() ) << endl; - - /////////////////////////////////////////////////////////////////// - INT << "===[END]============================================" << endl << endl; - zypp::base::LogControl::instance().logNothing(); - return 0; - SEC << zypp::getZYpp()->diskUsage() << endl; - if ( 1 ) + if ( 0 ) { PoolItem pi ( getPi<Package>("amarok") ); MIL << pi << endl; Modified: trunk/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=9818&r1=9817&r2=9818&view=diff ============================================================================== --- trunk/libzypp/package/libzypp.changes (original) +++ trunk/libzypp/package/libzypp.changes Fri Apr 25 14:37:57 2008 @@ -1,4 +1,14 @@ ------------------------------------------------------------------- +Fri Apr 25 14:15:17 CEST 2008 - ma@suse.de + +- Prevent deselected or deleted items from being re-selected due to + recommends (aka. persistent soft locks). Unlike hard locked, those + items will be automatically selected if required. The list of soft + locked items is stored in /var/lib/zypp/SoftLocks. +- version 4.15.1 +- revision 9818 + +------------------------------------------------------------------- Wed Apr 23 22:24:00 CEST 2008 - ma@suse.de - Remove obsolete AdditionalCapabilities interface from ResPool. Modified: trunk/libzypp/zypp/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=9818&r1=9817&r2=9818&view=diff ============================================================================== --- trunk/libzypp/zypp/CMakeLists.txt (original) +++ trunk/libzypp/zypp/CMakeLists.txt Fri Apr 25 14:37:57 2008 @@ -561,6 +561,7 @@ SET( zypp_target_SRCS target/RequestedLocalesFile.cc + target/SoftLocksFile.cc target/CommitLog.cc target/CommitPackageCache.cc target/CommitPackageCacheImpl.cc @@ -572,6 +573,7 @@ SET( zypp_target_HEADERS target/RequestedLocalesFile.h + target/SoftLocksFile.h target/CommitLog.h target/CommitPackageCache.h target/CommitPackageCacheImpl.h Modified: trunk/libzypp/zypp/target/RequestedLocalesFile.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/RequestedLocalesFile.cc?rev=9818&r1=9817&r2=9818&view=diff ============================================================================== --- trunk/libzypp/zypp/target/RequestedLocalesFile.cc (original) +++ trunk/libzypp/zypp/target/RequestedLocalesFile.cc Fri Apr 25 14:37:57 2008 @@ -48,6 +48,7 @@ locales_r.insert( Locale(l) ); } } + MIL << "Read " << pi << endl; } void RequestedLocalesFile::store( const Pathname & file_r, const LocaleSet & locales_r ) @@ -62,6 +63,7 @@ if ( outs.good() ) { filesystem::rename( tmp.path(), file_r ); + MIL << "Wrote " << PathInfo(file_r) << endl; } else { Added: trunk/libzypp/zypp/target/SoftLocksFile.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/SoftLocksFile.cc?rev=9818&view=auto ============================================================================== --- trunk/libzypp/zypp/target/SoftLocksFile.cc (added) +++ trunk/libzypp/zypp/target/SoftLocksFile.cc Fri Apr 25 14:37:57 2008 @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/target/SoftLocksFile.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/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 ) ); + + 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 +/////////////////////////////////////////////////////////////////// Added: trunk/libzypp/zypp/target/SoftLocksFile.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/SoftLocksFile.h?rev=9818&view=auto ============================================================================== --- trunk/libzypp/zypp/target/SoftLocksFile.h (added) +++ trunk/libzypp/zypp/target/SoftLocksFile.h Fri Apr 25 14:37:57 2008 @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/target/SoftLocksFile.h + * +*/ +#ifndef ZYPP_TARGET_SOFTLOCKSFILE_H +#define ZYPP_TARGET_SOFTLOCKSFILE_H + +#include <iosfwd> + +#include "zypp/base/PtrTypes.h" + +#include "zypp/Pathname.h" +#include "zypp/Locale.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace target + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : SoftLocksFile + // + /** Save and restore locale set from file. + */ + class SoftLocksFile + { + friend std::ostream & operator<<( std::ostream & str, const SoftLocksFile & obj ); + public: + typedef std::tr1::unordered_set<IdString> 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<Data> _dataPtr; + }; + /////////////////////////////////////////////////////////////////// + + /** \relates SoftLocksFile Stream output */ + std::ostream & operator<<( std::ostream & str, const SoftLocksFile & obj ); + + ///////////////////////////////////////////////////////////////// + } // namespace target + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_TARGET_SOFTLOCKSFILE_H Modified: trunk/libzypp/zypp/target/TargetImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=9818&r1=9817&r2=9818&view=diff ============================================================================== --- trunk/libzypp/zypp/target/TargetImpl.cc (original) +++ trunk/libzypp/zypp/target/TargetImpl.cc Fri Apr 25 14:37:57 2008 @@ -282,6 +282,7 @@ TargetImpl::TargetImpl( const Pathname & root_r, bool doRebuild_r ) : _root( root_r ) , _requestedLocalesFile( home() / "RequestedLocales" ) + , _softLocksFile( home() / "SoftLocks" ) { _rpm.initDatabase( root_r, Pathname(), doRebuild_r ); MIL << "Initialized target on " << _root << endl; @@ -434,7 +435,7 @@ system.addSolv( rpmsolv ); } - // (Re)Load the requested locales. + // (Re)Load the requested locales et al. // If the requested locales are empty, we leave the pool untouched // to avoid undoing changes the application applied. We expect this // to happen on a bare metal installation only. An already existing @@ -445,6 +446,13 @@ satpool.setRequestedLocales( requestedLocales ); } + const SoftLocksFile::Data & softLocks( _softLocksFile.data() ); + if ( ! softLocks.empty() ) + { + ResPool::instance().setAutoSoftLocks( softLocks ); + } + + MIL << "Target loaded: " << system.solvablesSize() << " resolvables" << endl; } @@ -463,6 +471,11 @@ // Store non-package data: filesystem::assert_dir( home() ); _requestedLocalesFile.setLocales( pool_r.getRequestedLocales() ); + { + SoftLocksFile::Data newdata; + pool_r.getActiveSoftLocks( newdata ); + _softLocksFile.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=9818&r1=9817&r2=9818&view=diff ============================================================================== --- trunk/libzypp/zypp/target/TargetImpl.h (original) +++ trunk/libzypp/zypp/target/TargetImpl.h Fri Apr 25 14:37:57 2008 @@ -29,6 +29,7 @@ #include "zypp/target/rpm/RpmDb.h" #include "zypp/target/TargetException.h" #include "zypp/target/RequestedLocalesFile.h" +#include "zypp/target/SoftLocksFile.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -151,6 +152,8 @@ rpm::RpmDb _rpm; /** Requested Locales database */ RequestedLocalesFile _requestedLocalesFile; + /** Soft-locks database */ + SoftLocksFile _softLocksFile; private: /** Null implementation */ static TargetImpl_Ptr _nullimpl; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org