Author: mlandres
Date: Thu Dec 18 22:04:34 2008
New Revision: 11953
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11953&view=rev
Log:
backup
Added:
trunk/libzypp/devel/devel.ma/CommitCb.cc
Added: trunk/libzypp/devel/devel.ma/CommitCb.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/CommitCb.cc?rev=11953&view=auto
==============================================================================
--- trunk/libzypp/devel/devel.ma/CommitCb.cc (added)
+++ trunk/libzypp/devel/devel.ma/CommitCb.cc Thu Dec 18 22:04:34 2008
@@ -0,0 +1,164 @@
+#include "Tools.h"
+#include
+
+#include
+#include
+#include
+
+struct IRR : public zypp::callback::ReceiveReportzypp::target::rpm::InstallResolvableReport
+{
+ 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::ReceiveReportzypp::target::rpm::RemoveResolvableReport
+{
+ 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<Package>( "rpm" )->setToInstall();
+ vdumpPoolStats( USR << "Selected:"<< endl,
+ make_filter_beginresfilter::ByTransact(pool),
+ make_filter_endresfilter::ByTransact(pool) ) << endl;
+
+ if ( solve() )
+ {
+ vdumpPoolStats( USR << "Solved:"<< endl,
+ make_filter_beginresfilter::ByTransact(pool),
+ make_filter_endresfilter::ByTransact(pool) ) << endl;
+
+ install();
+ }
+
+ 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