From 3896bd61fd3fbe98c53f49539cb18f076aad5897 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Thu, 18 Dec 2008 21:04:34 +0000 Subject: [PATCH] backup --- devel/devel.ma/CommitCb.cc | 164 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 devel/devel.ma/CommitCb.cc diff --git a/devel/devel.ma/CommitCb.cc b/devel/devel.ma/CommitCb.cc new file mode 100644 index 0000000..a0990ba --- /dev/null +++ b/devel/devel.ma/CommitCb.cc @@ -0,0 +1,164 @@ +#include "Tools.h" +#include + +#include +#include +#include + +struct IRR : public zypp::callback::ReceiveReport +{ + IRR() + { connect(); } +#if 0 + enum Action { + ABORT, // abort and return error + RETRY, // retry + IGNORE // ignore the failure + }; + + enum Error { + NO_ERROR, + NOT_FOUND, // the requested Url was not found + IO, // IO error + INVALID // th resolvable is invalid + }; + + // the level of RPM pushing + /** \deprecated We fortunately no longer do 3 attempts. */ + enum RpmLevel { + RPM, + RPM_NODEPS, + RPM_NODEPS_FORCE + }; +#endif + + virtual void reportbegin() + { SEC << endl; } + virtual void reportend() + { SEC << endl; } + + virtual void start(Resolvable::constPtr /*resolvable*/) + { INT << endl; } + + virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/) + { + static int i = 4; + if ( --i <= 0 ) + { + INT << "return abort" << endl; + return false; + } + return true; + } + + virtual Action problem(Resolvable::constPtr /*resolvable*/, Error /*error*/, const std::string &/*description*/, RpmLevel /*level*/) + { + INT << "return abort" << endl; + return ABORT; + } + + virtual void finish(Resolvable::constPtr /*resolvable*/, Error /*error*/, const std::string &/*reason*/, RpmLevel /*level*/) + { INT << endl; } +}; + +struct RRR : public zypp::callback::ReceiveReport +{ + RRR() + { connect(); } +#if 0 + enum Action { + ABORT, // abort and return error + RETRY, // retry + IGNORE // ignore the failure + }; + + enum Error { + NO_ERROR, + NOT_FOUND, // the requested Url was not found + IO, // IO error + INVALID // th resolvable is invalid + }; +#endif + + virtual void reportbegin() + { SEC << endl; } + virtual void reportend() + { SEC << endl; } + + virtual void start( Resolvable::constPtr /*resolvable*/ ) + { INT << endl; } + + virtual bool progress(int /*value*/, Resolvable::constPtr /*resolvable*/) + { INT << endl; return true; } + + virtual Action problem( Resolvable::constPtr /*resolvable*/ , Error /*error*/ , const std::string &/*description*/ ) + { INT << endl; return ABORT; } + + virtual void finish( Resolvable::constPtr /*resolvable*/ , Error /*error*/ , const std::string &/*reason*/ ) + { INT << endl; } +}; + +bool solve() +{ + static unsigned run = 0; + USR << "Solve " << run++ << endl; + bool rres = false; + { + zypp::base::LogControl::TmpLineWriter shutUp; + rres = getZYpp()->resolver()->resolvePool(); + } + if ( ! rres ) + { + ERR << "resolve " << rres << endl; + getZYpp()->resolver()->problems(); + return false; + } + return true; +} + +bool install() +{ + ZYppCommitPolicy pol; +//pol.dryRun(true); + pol.rpmInstFlags( pol.rpmInstFlags().setFlag( target::rpm::RPMINST_JUSTDB ) ); + SEC << "START commit..." << endl; + SEC << getZYpp()->commit( pol ) << endl; + return true; +} + +/****************************************************************** +** +** FUNCTION NAME : main +** FUNCTION TYPE : int +*/ +int main( int argc, char * argv[] ) +{ + INT << "===[START]==========================================" << endl; + IRR _irr; + RRR _rrr; + Pathname mroot( "/tmp/ToolScanRepos" ); + TestSetup test( mroot, Arch_i586 ); + test.loadTarget(); + test.loadRepos(); + + ResPool pool( test.pool() ); + ui::Selectable::Ptr sel; + + getSel( "rpm" )->setToInstall(); + vdumpPoolStats( USR << "Selected:"<< endl, + make_filter_begin(pool), + make_filter_end(pool) ) << endl; + + if ( solve() ) + { + vdumpPoolStats( USR << "Solved:"<< endl, + make_filter_begin(pool), + make_filter_end(pool) ) << endl; + + install(); + } + + INT << "===[END]============================================" << endl << endl; + return 0; +} + -- 2.7.4