Mailinglist Archive: zypp-commit (606 mails)
| < Previous | Next > |
[zypp-commit] r9524 - in /trunk/libzypp: zypp.conf zypp/Locks.cc zypp/Locks.h zypp/ZConfig.cc zypp/ZConfig.h zypp/zypp_detail/ZYppImpl.cc
- From: jreidinger@xxxxxxxxxxxxxxxx
- Date: Fri, 11 Apr 2008 10:04:23 -0000
- Message-id: <20080411100423.C438F26F40@xxxxxxxxxxxxxxxx>
Author: jreidinger
Date: Fri Apr 11 12:04:23 2008
New Revision: 9524
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9524&view=rev
Log:
switch to new locks api
Modified:
trunk/libzypp/zypp.conf
trunk/libzypp/zypp/Locks.cc
trunk/libzypp/zypp/Locks.h
trunk/libzypp/zypp/ZConfig.cc
trunk/libzypp/zypp/ZConfig.h
trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc
Modified: trunk/libzypp/zypp.conf
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp.conf?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp.conf (original)
+++ trunk/libzypp/zypp.conf Fri Apr 11 12:04:23 2008
@@ -141,4 +141,21 @@
## 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
Modified: trunk/libzypp/zypp/Locks.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Locks.cc?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp/Locks.cc (original)
+++ trunk/libzypp/zypp/Locks.cc Fri Apr 11 12:04:23 2008
@@ -34,49 +34,6 @@
{
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()
{
Modified: trunk/libzypp/zypp/Locks.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Locks.h?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp/Locks.h (original)
+++ trunk/libzypp/zypp/Locks.h Fri Apr 11 12:04:23 2008
@@ -11,9 +11,6 @@
{
namespace locks
{
-
- int readLocks(const ResPool & pool, const Pathname &file );
-
class Locks
{
public:
Modified: trunk/libzypp/zypp/ZConfig.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.cc?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp/ZConfig.cc (original)
+++ trunk/libzypp/zypp/ZConfig.cc Fri Apr 11 12:04:23 2008
@@ -148,6 +148,7 @@
, repo_refresh_delay ( 10 )
, download_use_patchrpm ( true )
, download_use_deltarpm ( true )
+ , apply_locks_file ( true )
, solver_onlyRequires ( false )
{
@@ -237,10 +238,14 @@
{
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 );
+ }
}
}
}
@@ -288,6 +293,8 @@
bool solver_onlyRequires;
+ bool apply_locks_file;
+
};
///////////////////////////////////////////////////////////////////
@@ -438,6 +445,11 @@
? Pathname("/etc/zypp/locks") : _pimpl->locks_file );
}
+ bool ZConfig::apply_locks_file() const
+ {
+ return _pimpl->apply_locks_file;
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/ZConfig.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.h?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp/ZConfig.h (original)
+++ trunk/libzypp/zypp/ZConfig.h Fri Apr 11 12:04:23 2008
@@ -143,8 +143,16 @@
*/
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 */
Modified: trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc (original)
+++ trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc Fri Apr 11 12:04:23 2008
@@ -23,6 +23,9 @@
#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;
@@ -176,32 +179,24 @@
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;
}
/******************************************************************
**
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx
Date: Fri Apr 11 12:04:23 2008
New Revision: 9524
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9524&view=rev
Log:
switch to new locks api
Modified:
trunk/libzypp/zypp.conf
trunk/libzypp/zypp/Locks.cc
trunk/libzypp/zypp/Locks.h
trunk/libzypp/zypp/ZConfig.cc
trunk/libzypp/zypp/ZConfig.h
trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc
Modified: trunk/libzypp/zypp.conf
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp.conf?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp.conf (original)
+++ trunk/libzypp/zypp.conf Fri Apr 11 12:04:23 2008
@@ -141,4 +141,21 @@
## 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
Modified: trunk/libzypp/zypp/Locks.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Locks.cc?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp/Locks.cc (original)
+++ trunk/libzypp/zypp/Locks.cc Fri Apr 11 12:04:23 2008
@@ -34,49 +34,6 @@
{
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()
{
Modified: trunk/libzypp/zypp/Locks.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Locks.h?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp/Locks.h (original)
+++ trunk/libzypp/zypp/Locks.h Fri Apr 11 12:04:23 2008
@@ -11,9 +11,6 @@
{
namespace locks
{
-
- int readLocks(const ResPool & pool, const Pathname &file );
-
class Locks
{
public:
Modified: trunk/libzypp/zypp/ZConfig.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.cc?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp/ZConfig.cc (original)
+++ trunk/libzypp/zypp/ZConfig.cc Fri Apr 11 12:04:23 2008
@@ -148,6 +148,7 @@
, repo_refresh_delay ( 10 )
, download_use_patchrpm ( true )
, download_use_deltarpm ( true )
+ , apply_locks_file ( true )
, solver_onlyRequires ( false )
{
@@ -237,10 +238,14 @@
{
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 );
+ }
}
}
}
@@ -288,6 +293,8 @@
bool solver_onlyRequires;
+ bool apply_locks_file;
+
};
///////////////////////////////////////////////////////////////////
@@ -438,6 +445,11 @@
? Pathname("/etc/zypp/locks") : _pimpl->locks_file );
}
+ bool ZConfig::apply_locks_file() const
+ {
+ return _pimpl->apply_locks_file;
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/ZConfig.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.h?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp/ZConfig.h (original)
+++ trunk/libzypp/zypp/ZConfig.h Fri Apr 11 12:04:23 2008
@@ -143,8 +143,16 @@
*/
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 */
Modified: trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc?rev=9524&r1=9523&r2=9524&view=diff
==============================================================================
--- trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc (original)
+++ trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc Fri Apr 11 12:04:23 2008
@@ -23,6 +23,9 @@
#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;
@@ -176,32 +179,24 @@
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;
}
/******************************************************************
**
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx
| < Previous | Next > |