## Valid values: boolean
## Default value: false
##
-# solver.onlyRequires = false
\ No newline at end of file
+# solver.onlyRequires = false
+
+##
+## Path to locks file. If not exist then is create.
+## In this file is saved also UI locks.
+##
+## valid value: path to file or place where file can be created
+## default value: /etc/zypp/locks
+##
+# locksfile.path = /etc/zypp/locks
+
+##
+## Whetever to apply locks in locks file after zypp start.
+##
+## Valid values: boolean
+## Default value: true
+##
+# locksfile.apply = true
{
namespace locks
{
-//
-// assign Lock to installed pool item
-//
-
-struct AddLockToPool
-{
- AddLockToPool( const ResPool &pool )
- : _pool(pool)
- , _count(0)
- {
-
- }
-
- bool operator()( const std::string & str_r )
- {
-#warning MUST FIX LOCK IMPLEMENTATION
- // - make Capability's parse 'Name [Op edition]' available so it can be used here
- // - provide new, or extend Capability::Matches, functor to allow pattern (glob/rx) matching
- return false;
- } // end operator()()
-
- ResPool _pool;
- int _count;
-};
-
-//
-// read 'locks' table, evaluate 'glob' column, assign locks to pool
-//
-int
-readLocks(const ResPool & pool, const Pathname &file )
-{
- PathInfo lockrc( file );
- if ( lockrc.isFile() )
- {
- MIL << "Reading " << lockrc << endl;
- ifstream inp( file.c_str() );
- AddLockToPool addlock(pool);
- iostr::forEachLine( inp, addlock);
- MIL << addlock._count << " locks." << endl;
- return addlock._count;
- }
- return 0;
-}
Locks& Locks::instance()
{
{
namespace locks
{
-
- int readLocks(const ResPool & pool, const Pathname &file );
-
class Locks
{
public:
, repo_refresh_delay ( 10 )
, download_use_patchrpm ( true )
, download_use_deltarpm ( true )
+ , apply_locks_file ( true )
, solver_onlyRequires ( false )
{
{
solver_onlyRequires = str::strToBool( value, solver_onlyRequires );
}
- else if ( entry == "locksfile" )
+ else if ( entry == "locksfile.path" )
{
locks_file = Pathname(value);
}
+ else if ( entry == "locksfile.apply" )
+ {
+ apply_locks_file = str::strToBool( value, apply_locks_file );
+ }
}
}
}
bool solver_onlyRequires;
+ bool apply_locks_file;
+
};
///////////////////////////////////////////////////////////////////
? Pathname("/etc/zypp/locks") : _pimpl->locks_file );
}
+ bool ZConfig::apply_locks_file() const
+ {
+ return _pimpl->apply_locks_file;
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
*/
bool solver_onlyRequires() const;
+ /**
+ * Path where zypp can find or create lock file
+ */
Pathname locksFile() const;
+ /**
+ * Whetever locks file should be readed and applied after start
+ */
+ bool apply_locks_file() const;
+
public:
class Impl;
/** Dtor */
#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"
using std::endl;
int ZYppImpl::applyLocks()
{
-#warning make the /etc/zypp/locks path an option zconfig.
- 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 ;(
- }
+ if (!ZConfig::instance().apply_locks_file())
+ return 0;
- 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
+ //TODO catch posibble exceptions
+ locks::Locks::instance().loadLocks();
+
+ //current locks api doesn't support counting lock
+ //so count it after
+ int count = 0;
+ for_(it, sat::Pool::instance().solvablesBegin(),
+ sat::Pool::instance().solvablesEnd())
{
- MIL << "No file '" << locksrcPath << "' to read locks from" << endl;
+ PoolItem i(*it);
+ if ( i.status().isLocked() )
+ count++;
}
- return num;
+
+ return count;
}
/******************************************************************
**