Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / devel / devel.ma / Main.cc
index 1b6d86d..56ec913 100644 (file)
-#include <iostream>
-#include <iterator>
-#include <functional>
-#include <set>
-#include <algorithm>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/base/ReferenceCounted.h>
-#include <zypp/Arch.h>
-#include <zypp/Edition.h>
-#include <zypp/Rel.h>
-#include <zypp/Capability.h>
-
-using namespace std;
-
-#define TAG INT << __PRETTY_FUNCTION__ << endl
-
-template<class _C>
-  void outc( const _C & cont, ostream & str )
+#include "Tools.h"
+
+#include <zypp/PoolQuery.h>
+#include <zypp/target/rpm/librpmDb.h>
+#include <zypp/parser/ProductFileReader.h>
+
+#include "zypp/sat/WhatObsoletes.h"
+#include "zypp/ExternalProgram.h"
+
+///////////////////////////////////////////////////////////////////
+
+//static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" );
+//static const Pathname sysRoot( "/tmp/ToolScanRepos" );
+static const Pathname sysRoot( "/" );
+
+///////////////////////////////////////////////////////////////////
+
+bool solve()
+{
+  bool rres = false;
+  {
+    //zypp::base::LogControl::TmpLineWriter shutUp;
+    //getZYpp()->resolver()->setOnlyRequires( true );
+    rres = getZYpp()->resolver()->resolvePool();
+  }
+  if ( ! rres )
   {
-    copy( cont.begin(), cont.end(),
-          ostream_iterator<typename _C::value_type>(str,"\n") );
+    ERR << "resolve " << rres << endl;
+    getZYpp()->resolver()->problems();
+    return false;
   }
+  MIL << "resolve " << rres << endl;
+  return true;
+}
+
+bool upgrade()
+{
+  bool rres = false;
+  {
+    //zypp::base::LogControl::TmpLineWriter shutUp;
+    Measure x( "Upgrade" );
+    rres = getZYpp()->resolver()->doUpgrade();
+  }
+  if ( ! rres )
+  {
+    Measure x( "Upgrade Error" );
+    ERR << "upgrade " << rres << endl;
+    getZYpp()->resolver()->problems();
+    return false;
+  }
+  MIL << "upgrade " << rres << endl;
+  return true;
+}
 
 namespace zypp
 {
+  namespace target
+  {
+    void writeUpgradeTestcase();
+  }
 }
 
-using namespace zypp;
+std::ostream & operator<<( std::ostream & str, const sat::Solvable::SplitIdent & obj )
+{
+  str << "{" << obj.ident() << "}{" << obj.kind() << "}{" << obj.name () << "}" << endl;
+  return str;
+}
 
-/******************************************************************
-**
-**
-**     FUNCTION NAME : main
-**     FUNCTION TYPE : int
-**
-**     DESCRIPTION :
-*/
-int main( int argc, char * argv[] )
+namespace zypp {
+std::ostream & dumpOn( std::ostream & str, const Url & obj )
 {
+  str << "{" << obj.getHost() << "}{" << obj.getPort() << "}";
+  return str;
+}
+}
+
+int main( int argc, char * argv[] )
+try {
+  --argc;
+  ++argv;
+  zypp::base::LogControl::instance().logToStdErr();
   INT << "===[START]==========================================" << endl;
+  ///////////////////////////////////////////////////////////////////
+  if ( sysRoot == "/" )
+    ::unsetenv( "ZYPP_CONF" );
+  ResPool   pool( ResPool::instance() );
+  sat::Pool satpool( sat::Pool::instance() );
+  ///////////////////////////////////////////////////////////////////
+  dumpRange( WAR << "satpool.multiversion " , satpool.multiversion().begin(), satpool.multiversion().end() ) << endl;
+  TestSetup::LoadSystemAt( sysRoot, Arch_i586 );
+  ///////////////////////////////////////////////////////////////////
 
-  for ( int i = 1; i < 10; ++i )
-    try
-      {
-        ZYPP_THROW( "Something bad happened." );
-      }
-    catch ( Exception & excpt )
-      {
-        ZYPP_CAUGHT( excpt );
-        break;
-      }
-
-  INT << "===[END]============================================" << endl;
+  ui::Selectable::Ptr p( getSel<Package>( "kruler" ) );
+  if ( p )
+  {
+    USR << p->setToDelete() << endl;
+    getZYpp()->resolver()->setCleandepsOnRemove( true );
+    solve();
+  }
+
+  ///////////////////////////////////////////////////////////////////
+  INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
   return 0;
 }
+catch ( const Exception & exp )
+{
+  INT << exp << endl << exp.historyAsString();
+}
+catch (...)
+{}