ref: refs/heads/master
commit de41016d737015db9b56889014d223cf8760b2cf
Author: Michael Andres
Date: Mon Apr 27 14:30:27 2009 +0200
backup
---
devel/devel.ma/NewPool.cc | 108 +++++++++++++++++++++++++++++++++++------
devel/devel.ma/Test.cc | 118 ++++++++++-----------------------------------
2 files changed, 118 insertions(+), 108 deletions(-)
diff --git a/devel/devel.ma/NewPool.cc b/devel/devel.ma/NewPool.cc
index 029bfc4..603a08a 100644
--- a/devel/devel.ma/NewPool.cc
+++ b/devel/devel.ma/NewPool.cc
@@ -38,12 +38,14 @@
#include "zypp/sat/Pool.h"
#include "zypp/sat/LocaleSupport.h"
#include "zypp/sat/LookupAttr.h"
+#include "zypp/sat/AttrMatcher.h"
#include "zypp/sat/SolvableSet.h"
#include "zypp/sat/SolvIterMixin.h"
#include "zypp/sat/detail/PoolImpl.h"
#include "zypp/sat/WhatObsoletes.h"
#include "zypp/PoolQuery.h"
#include "zypp/ServiceInfo.h"
+#include "zypp/media/MediaPriority.h"
#include
@@ -428,6 +430,47 @@ void testCMP( const L & lhs, const R & rhs )
#undef OUTS
}
+template
+void diffquery( const Lcont & l, const Rcont & r )
+{
+ MIL << "DIFF " << l.size() << " <-> " << r.size() << endl;
+ sat::SolvableSet ls;
+ sat::SolvableSet bb;
+ sat::SolvableSet rs;
+
+ for_( it, l.begin(), l.end() )
+ {
+ ( r.contains( *it ) ? bb : ls ).insert( *it );
+ }
+ for_( it, r.begin(), r.end() )
+ {
+ if ( ! l.contains( *it ) )
+ rs.insert( *it );
+ }
+
+ MIL << "(" << ls.size() << ") (" << bb.size() << ") (" << rs.size() << ")" << endl;
+ INT << ls << endl;
+ INT << rs << endl;
+}
+
+bool querycompare( const PoolQuery & q )
+{
+ q.begin();
+ SEC << q << endl;
+ unsigned nc = 0;
+ if ( 1 )
+ {
+ Measure x( "new query" );
+ for_( it, q.begin(), q.end() )
+ {
+ ++nc;
+ //DBG << it << endl;
+ }
+ MIL << nc << endl;
+ }
+ return true;
+}
+
/******************************************************************
**
** FUNCTION NAME : main
@@ -444,7 +487,7 @@ try {
ResPool pool( ResPool::instance() );
sat::Pool satpool( sat::Pool::instance() );
- if ( 0 )
+ if ( 1 )
{
Measure x( "INIT TARGET" );
{
@@ -477,7 +520,7 @@ try {
}
}
- if ( 0 )
+ if ( 1 )
{
RepoManager repoManager( makeRepoManager( sysRoot ) );
RepoInfoList repos = repoManager.knownRepositories();
@@ -530,7 +573,7 @@ try {
repoManager.loadFromCache( nrepo );
}
- USR << "pool: " << pool << endl;
+ //USR << "pool: " << pool << endl;
}
}
}
@@ -548,22 +591,55 @@ try {
}
///////////////////////////////////////////////////////////////////
+
+ Match m( Match::GLOB );
+ SEC << m << endl;
+ SEC << Match::REGEX << endl;
+
+ m = Match::GLOB;
+ SEC << m << endl;
+ m = Match::NOTHING
+ | Match::GLOB;
+ SEC << m << endl;
+ m = Match::GLOB
+ | Match::STRING;
+ SEC << m << endl;
+ m = Match::FILES
+ | Match::NOTHING;
+ SEC << m << endl;
+ m = Match::FILES - Match::STRING;
+ SEC << m << endl;
+
+ SEC << (Match::FILES==Match::NOTHING) << endl;
+ SEC << (Match::FILES!=Match::NOTHING) << endl;
+
///////////////////////////////////////////////////////////////////
- RepoManager repoManager( makeRepoManager( sysRoot ) );
- RepoInfoList repos = repoManager.knownRepositories();
- // launch repos
- for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
- {
- RepoInfo & nrepo( *it );
- Url url_r( nrepo.url() );
+ std::string search("devel");
- SEC << url_r << endl;
- MIL << RepoManager::makeStupidAlias( url_r ) << endl;
- }
- MIL << RepoManager::makeStupidAlias() << endl;
- MIL << RepoManager::makeStupidAlias() << endl;
- MIL << RepoManager::makeStupidAlias() << endl;
+ PoolQuery q;
+ //querycompare( q );
+
+ q.addString(search);
+ //q.addAttribute(sat::SolvAttr::name, "augeas" );
+ //q.addAttribute(sat::SolvAttr::name );
+ q.addAttribute(sat::SolvAttr::summary);
+ q.setMatchSubstring();
+ //q.setMatchExact();
+ q.setCaseSensitive( false );
+
+ //q.addRepo( "11.1-update" );
+ //q.addRepo( "@System" );
+
+ //q.addKind( ResKind::package );
+ //q.addKind( ResKind::pattern );
+ //q.addKind( ResKind::patch );
+
+ //q.setEdition( Edition("1.0"), Rel::GE );
+
+ q.setMatchFiles();
+
+ querycompare( q );
#if 0
getZYpp()->resolver()->addRequire( Capability("amarok") );
diff --git a/devel/devel.ma/Test.cc b/devel/devel.ma/Test.cc
index 05cafb8..5255ee4 100644
--- a/devel/devel.ma/Test.cc
+++ b/devel/devel.ma/Test.cc
@@ -3,75 +3,9 @@
#include
#include
+#include
-static std::string pidAndAppname()
-{
- static std::string _val;
- if ( _val.empty() )
- {
- pid_t mypid = getpid();
- Pathname p( "/proc/"+str::numstring(mypid)+"/exe" );
- Pathname myname( filesystem::readlink( p ) );
-
- _val += str::numstring(mypid);
- _val += ":";
- _val += myname.basename();
- }
- return _val;
-}
-
-bool solve()
-{
- static unsigned run = 0;
- USR << "Solve " << run++ << endl;
- bool rres = false;
- {
- //zypp::base::LogControl::TmpLineWriter shutUp;
- getZYpp()->resolver()->setOnlyRequires( true );
- getZYpp()->resolver()->setIgnoreAlreadyRecommended( true );
- rres = getZYpp()->resolver()->resolvePool();
- }
- if ( ! rres )
- {
- ERR << "resolve " << rres << endl;
- getZYpp()->resolver()->problems();
- return false;
- }
-
- return true;
-}
-
-typedef sat::ArrayAttrstd::string,std::string FileList;
-
-#include "zypp/base/IOStream.h"
-bool isProcessRunning(pid_t pid_r)
-{
- std::string _locker_name;
- // it is another program, not me, see if it is still running
- Pathname procdir( Pathname("/proc")/str::numstring(pid_r) );
- PathInfo status( procdir );
- MIL << "Checking " << status << endl;
-
- if ( ! status.isDir() )
- {
- DBG << "No such process." << endl;
- return false;
- }
-
- static char buffer[513];
- buffer[0] = buffer[512] = 0;
- // man proc(5): /proc/[pid]/cmdline is empty if zombie.
- if ( std::ifstream( (procdir/"cmdline").c_str() ).read( buffer, 512 ).gcount() > 0 )
- {
- _locker_name = buffer;
- DBG << "Is running: " << _locker_name << endl;
- return true;
- }
-
- DBG << "In zombie state." << endl;
- return false;
- }
-
+static TestSetup test( Arch_x86_64 ); // use x86_64 as system arch
/******************************************************************
**
@@ -81,40 +15,40 @@ bool isProcessRunning(pid_t pid_r)
int main( int argc, char * argv[] )
{
INT << "===[START]==========================================" << endl;
+ test.loadRepo( "/Local/ROOT/cache/solv/@System/solv" );
- INT << isProcessRunning( 26992 ) << endl;
- INT << isProcessRunning( getpid() ) << endl;;
- INT << isProcessRunning( 10430 ) << endl;
- INT << isProcessRunning( 55 ) << endl;
- INT << "===[END]============================================" << endl << endl;
- return 0;
+ Match t( Match::REGEX );
+ MIL << (t|Match::STRING) << endl;
+ MIL << (t|Match::NOCASE) << endl;
+ MIL << (Match::STRING|t) << endl;
+ MIL << (Match::STRING|Match::NOCASE) << endl;
- Pathname mroot( "/tmp/ToolScanRepos" );
- TestSetup test( mroot, Arch_i686, TSO_CLEANROOT );
- test.loadRepo( "/schnell/CD-ARCHIVE/11.1/FTP" );
- test.loadRepo( "/suse/ma/bug-481836_test.solv" );
- //test.loadRepos();
- ResPool pool( test.pool() );
- Resolver & resolver( test.resolver() );
+ Match m = Match::STRING | Match::NOCASE | Match::GLOB ;
+ m = Match::NOCASE | Match::STRING;
+ MIL << m << endl;
+ MIL << m-Match::NOCASE << endl;
- //dumpRange( USR, pool.begin(), pool.end() );
+ MIL << Match(8765) << endl;
+ MIL << Match() << endl;
- resolver.addRequire( Capability("filesystem") );
- resolver.addRequire( Capability("glibc-locale") );
- resolver.addRequire( Capability("glibc.i586 = 2.9-2.8") );
- resolver.addRequire( Capability("xorg-x11-driver-video-openchrome") );
- resolver.addRequire( Capability("zypper") );
- if ( solve() )
+ INT << "===[END]============================================" << endl << endl;
+ return 0;
+
+
+
+ PoolQuery q;
+ q.addString("foo*|k?");
+ q.setMatchRegex();
+
+ for_( it, q.nbegin(), q.nend() )
{
- vdumpPoolStats( USR << "Transacting:"<< endl,
- make_filter_beginresfilter::ByTransact(pool),
- make_filter_endresfilter::ByTransact(pool) ) << endl;
+ zypp::PoolItem pi( zypp::ResPool::instance().find( *it ) );
+ MIL << pi.resolvable() << endl;
}
-
INT << "===[END]============================================" << endl << endl;
return 0;
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org