From a0675ac7441522a26ed047277d64ad14c189aff0 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Thu, 9 Aug 2007 12:24:36 +0000 Subject: [PATCH] add applyLocks() to apply persistant locks before solving --- zypp/ZYpp.cc | 2 ++ zypp/ZYpp.h | 10 ++++++++++ zypp/zypp_detail/ZYppImpl.cc | 29 +++++++++++++++++++++++++++++ zypp/zypp_detail/ZYppImpl.h | 4 ++++ 4 files changed, 45 insertions(+) diff --git a/zypp/ZYpp.cc b/zypp/ZYpp.cc index 2076853..3a9d952 100644 --- a/zypp/ZYpp.cc +++ b/zypp/ZYpp.cc @@ -146,6 +146,8 @@ namespace zypp void ZYpp::setHomePath( const Pathname & path ) { _pimpl->setHomePath(path); } + int ZYpp::applyLocks() + { return _pimpl->applyLocks(); } ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// diff --git a/zypp/ZYpp.h b/zypp/ZYpp.h index 6442d15..c4dcdfa 100644 --- a/zypp/ZYpp.h +++ b/zypp/ZYpp.h @@ -174,6 +174,16 @@ namespace zypp won't be able to install incompatible packages ;-) */ void setArchitecture( const Arch & arch ); + public: + + /** + * \short Apply persistant locks to current pool. + * Call this before solving + * + * \returns Number of items locked + */ + int applyLocks(); + protected: /** Dtor */ virtual ~ZYpp(); diff --git a/zypp/zypp_detail/ZYppImpl.cc b/zypp/zypp_detail/ZYppImpl.cc index 820d2d6..30f491b 100644 --- a/zypp/zypp_detail/ZYppImpl.cc +++ b/zypp/zypp_detail/ZYppImpl.cc @@ -27,6 +27,7 @@ #include "zypp/Language.h" #include "zypp/DiskUsageCounter.h" #include "zypp/NameKindProxy.h" +#include "zypp/Locks.h" using std::endl; @@ -399,6 +400,34 @@ namespace zypp return zypp_tmp_dir.path(); } + int ZYppImpl::applyLocks() + { + Pathname locksrcPath( "/etc/zypp/locks" ); + try + { + Target_Ptr trg( target() ); + if ( trg ) + locksrcPath = trg->root() / locksrcPath; + } + catch ( ... ) + { + // noop: Someone decided to let target() throw if the ptr is NULL ;( + } + + int num=0; + PathInfo locksrc( locksrcPath ); + if ( locksrc.isFile() ) + { + MIL << "Reading locks from '" << locksrcPath << "'" << endl; + num = zypp::locks::readLocks( pool(), locksrcPath ); + MIL << num << " items locked." << endl; + } + else + { + MIL << "No file '" << locksrcPath << "' to read locks from" << endl; + } + return num; + } /****************************************************************** ** ** FUNCTION NAME : operator<< diff --git a/zypp/zypp_detail/ZYppImpl.h b/zypp/zypp_detail/ZYppImpl.h index 3643123..e8fdbd4 100644 --- a/zypp/zypp_detail/ZYppImpl.h +++ b/zypp/zypp_detail/ZYppImpl.h @@ -146,6 +146,10 @@ namespace zypp void setPartitions(const DiskUsageCounter::MountPointSet &mp); DiskUsageCounter::MountPointSet getPartitions() const; + public: + + int applyLocks(); + private: /** */ ResPoolManager _pool; -- 2.7.4