#
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")
{
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()
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 );
ResPool pool( ResPool::instance() );
sat::Pool satpool( sat::Pool::instance() );
- ssup();
- //sslk( "START" );
-
if ( 1 )
{
RepoManager repoManager( makeRepoManager( sysRoot ) );
}
USR << "pool: " << pool << endl;
-
- sslk( nrepo.alias() );
}
}
}
getZYpp()->initializeTarget( sysRoot );
}
getZYpp()->target()->load();
- sslk( "TARGET" );
}
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- 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;
-------------------------------------------------------------------
+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
SET( zypp_target_SRCS
target/RequestedLocalesFile.cc
target/SoftLocksFile.cc
+ target/HardLocksFile.cc
target/CommitLog.cc
target/CommitPackageCache.cc
target/CommitPackageCacheImpl.cc
SET( zypp_target_HEADERS
target/RequestedLocalesFile.h
target/SoftLocksFile.h
+ target/HardLocksFile.h
target/CommitLog.h
target/CommitPackageCache.h
target/CommitPackageCacheImpl.h
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
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:
void ZYpp::setHomePath( const Pathname & path )
{ _pimpl->setHomePath(path); }
- int ZYpp::applyLocks()
- { return _pimpl->applyLocks(); }
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
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 */
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ 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
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ 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
#include "zypp/base/PtrTypes.h"
+#include "zypp/IdString.h"
#include "zypp/Pathname.h"
-#include "zypp/Locale.h"
///////////////////////////////////////////////////////////////////
namespace zypp
//
// CLASS NAME : SoftLocksFile
//
- /** Save and restore locale set from file.
+ /** Save and restore soft locks.
*/
class SoftLocksFile
{
: _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;
// 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 );
+ }
}
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;
#include "zypp/target/TargetException.h"
#include "zypp/target/RequestedLocalesFile.h"
#include "zypp/target/SoftLocksFile.h"
+#include "zypp/target/HardLocksFile.h"
///////////////////////////////////////////////////////////////////
namespace zypp
RequestedLocalesFile _requestedLocalesFile;
/** Soft-locks database */
SoftLocksFile _softLocksFile;
+ /** Hard-Locks database */
+ HardLocksFile _hardLocksFile;
private:
/** Null implementation */
static TargetImpl_Ptr _nullimpl;
#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"
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<<
void setPartitions(const DiskUsageCounter::MountPointSet &mp);
DiskUsageCounter::MountPointSet getPartitions() const;
- public:
-
- int applyLocks();
-
private:
/** */
Target_Ptr _target;