3 #include <zypp/PoolQuery.h>
4 #include <zypp/target/rpm/librpmDb.h>
5 #include <zypp/parser/ProductFileReader.h>
7 #include "zypp/sat/WhatObsoletes.h"
8 #include "zypp/ExternalProgram.h"
9 #include <zypp/ZYppCallbacks.h>
11 #include "zypp/sat/Transaction.h"
13 ///////////////////////////////////////////////////////////////////
15 //static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" );
16 //static const Pathname sysRoot( "/tmp/ToolScanRepos" );
17 // static const Pathname sysRoot( "/tmp/updateTestcase" );
18 static const Pathname sysRoot( "/tmp/ToolScanRepos" );
20 ///////////////////////////////////////////////////////////////////
21 struct IRR : public zypp::callback::ReceiveReport<zypp::target::rpm::InstallResolvableReport>
27 ABORT, // abort and return error
29 IGNORE // ignore the failure
34 NOT_FOUND, // the requested Url was not found
36 INVALID // th resolvable is invalid
39 // the level of RPM pushing
40 /** \deprecated We fortunately no longer do 3 attempts. */
48 virtual void reportbegin()
50 virtual void reportend()
53 virtual void start(Resolvable::constPtr /*resolvable*/)
56 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
61 INT << "return abort" << endl;
67 virtual Action problem(Resolvable::constPtr /*resolvable*/, Error /*error*/, const std::string &/*description*/, RpmLevel /*level*/)
69 INT << "return abort" << endl;
73 virtual void finish(Resolvable::constPtr /*resolvable*/, Error /*error*/, const std::string &/*reason*/, RpmLevel /*level*/)
77 struct RRR : public zypp::callback::ReceiveReport<zypp::target::rpm::RemoveResolvableReport>
83 ABORT, // abort and return error
85 IGNORE // ignore the failure
90 NOT_FOUND, // the requested Url was not found
92 INVALID // th resolvable is invalid
96 virtual void reportbegin()
98 virtual void reportend()
101 virtual void start( Resolvable::constPtr /*resolvable*/ )
104 virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/)
105 { INT << endl; return true; }
107 virtual Action problem( Resolvable::constPtr /*resolvable*/ , Error /*error*/ , const std::string &/*description*/ )
108 { INT << endl; return ABORT; }
110 virtual void finish( Resolvable::constPtr /*resolvable*/ , Error /*error*/ , const std::string &/*reason*/ )
119 //zypp::base::LogControl::TmpLineWriter shutUp;
120 //getZYpp()->resolver()->setOnlyRequires( true );
121 rres = getZYpp()->resolver()->resolvePool();
125 ERR << "resolve " << rres << endl;
126 getZYpp()->resolver()->problems();
129 MIL << "resolve " << rres << endl;
137 zypp::base::LogControl::TmpLineWriter shutUp;
138 Measure x( "Upgrade" );
139 rres = getZYpp()->resolver()->doUpgrade();
143 Measure x( "Upgrade Error" );
144 ERR << "upgrade " << rres << endl;
145 getZYpp()->resolver()->problems();
148 MIL << "upgrade " << rres << endl;
154 ZYppCommitPolicy pol;
155 //pol.dryRun( true );
156 pol.downloadMode( DownloadAsNeeded );
157 pol.rpmInstFlags( pol.rpmInstFlags().setFlag( target::rpm::RPMINST_JUSTDB ) );
158 ZYppCommitResult res( getZYpp()->commit( pol ) );
160 MIL << res.transactionStepList() << endl;
164 ///////////////////////////////////////////////////////////////////
166 template <class _Iter>
167 unsigned count( _Iter begin, _Iter end )
170 for_( it, begin, end )
175 ///////////////////////////////////////////////////////////////////
176 int main( int argc, char * argv[] )
180 zypp::base::LogControl::instance().logToStdErr();
181 INT << "===[START]==========================================" << endl;
182 ///////////////////////////////////////////////////////////////////
185 if ( sysRoot == "/" )
186 ::unsetenv( "ZYPP_CONF" );
189 const sat::Transaction a;
191 sat::Transaction c( a );
194 ResPool pool( ResPool::instance() );
195 sat::Pool satpool( sat::Pool::instance() );
196 ///////////////////////////////////////////////////////////////////
197 dumpRange( WAR << "satpool.multiversion " , satpool.multiversionBegin(), satpool.multiversionEnd() ) << endl;
198 TestSetup::LoadSystemAt( sysRoot, Arch_i586 );
199 getZYpp()->initializeTarget( sysRoot );
201 ///////////////////////////////////////////////////////////////////
205 getPi<Product>( "openSUSE-CD-retail" ).status().setToBeInstalled( ResStatus::USER );
206 getPi<Pattern>( "devel_qt4" ).status().setToBeInstalled( ResStatus::USER );
207 // getPi<Pattern>( "devel_qt4" ).status().setToBeInstalled( ResStatus::USER );
209 sat::Transaction trans( pool.resolver().getTransaction() );
212 USR << count( trans.actionBegin(), trans.actionEnd() ) << endl;
213 USR << count( trans.actionBegin(sat::Transaction::STEP_TODO), trans.actionEnd() ) << endl;
214 USR << count( trans.actionBegin(sat::Transaction::STEP_DONE), trans.actionEnd() ) << endl;
215 USR << count( trans.actionBegin(sat::Transaction::STEP_ERROR), trans.actionEnd() ) << endl;
216 USR << count( trans.actionBegin(sat::Transaction::STEP_TODO|sat::Transaction::STEP_ERROR), trans.actionEnd() ) << endl;
217 USR << count( trans.actionBegin(~sat::Transaction::STEP_ERROR), trans.actionEnd() ) << endl;
218 USR << count( trans.actionBegin(~sat::Transaction::STEP_TODO), trans.actionEnd() ) << endl;
223 ///////////////////////////////////////////////////////////////////
224 // ResPoolProxy selpool( pool.proxy() );
231 ///////////////////////////////////////////////////////////////////
232 INT << "===[END]============================================" << endl << endl;
233 zypp::base::LogControl::instance().logNothing();
236 catch ( const Exception & exp )
238 INT << exp << endl << exp.historyAsString();