Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / devel / devel.ma / Main.cc
index d5cb1c1..56ec913 100644 (file)
-#include <iostream>
-#include <iterator>
-#include <functional>
-#include <algorithm>
-#include <zypp/base/Logger.h>
-#include <zypp/Package.h>
-#include <zypp/detail/PackageImpl.h>
+#include "Tools.h"
 
-#define TAG INT << __PRETTY_FUNCTION__ << std::endl
+#include <zypp/PoolQuery.h>
+#include <zypp/target/rpm/librpmDb.h>
+#include <zypp/parser/ProductFileReader.h>
 
-using namespace std;
+#include "zypp/sat/WhatObsoletes.h"
+#include "zypp/ExternalProgram.h"
 
-inline void OUT( zypp::Resolvable::constPtr p )
+///////////////////////////////////////////////////////////////////
+
+//static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" );
+//static const Pathname sysRoot( "/tmp/ToolScanRepos" );
+static const Pathname sysRoot( "/" );
+
+///////////////////////////////////////////////////////////////////
+
+bool solve()
 {
-  if ( p )
-    MIL << *p << endl;
-  else
-    MIL << "NULL" << endl;
+  bool rres = false;
+  {
+    //zypp::base::LogControl::TmpLineWriter shutUp;
+    //getZYpp()->resolver()->setOnlyRequires( true );
+    rres = getZYpp()->resolver()->resolvePool();
+  }
+  if ( ! rres )
+  {
+    ERR << "resolve " << rres << endl;
+    getZYpp()->resolver()->problems();
+    return false;
+  }
+  MIL << "resolve " << rres << endl;
+  return true;
 }
 
-#if 0
-struct PI : public zypp::detail::MessageImplIf
+bool upgrade()
 {
-  virtual std::string text() const { return "message text"; }
-  virtual std::string type() const { return "message type"; }
-  virtual ~PI(){}
-};
-
-template<class _Impl>
-  typename _Impl::ResType::Ptr
-  makeResolvable( zypp::base::shared_ptr<_Impl> & impl_r )
+  bool rres = false;
   {
-    return zypp::detail::makeResolvableAndImpl( "n",
-                                                zypp::Edition("v","r"),
-                                                zypp::Arch(),
-                                                impl_r );
+    //zypp::base::LogControl::TmpLineWriter shutUp;
+    Measure x( "Upgrade" );
+    rres = getZYpp()->resolver()->doUpgrade();
   }
-{
-  zypp::base::shared_ptr<PI> pi;
-  OUT( makeResolvable( pi ) );
+  if ( ! rres )
+  {
+    Measure x( "Upgrade Error" );
+    ERR << "upgrade " << rres << endl;
+    getZYpp()->resolver()->problems();
+    return false;
+  }
+  MIL << "upgrade " << rres << endl;
+  return true;
 }
-#endif
 
-template<class _Impl>
-  typename _Impl::ResType::Ptr
-  makeResolvable( zypp::base::shared_ptr<_Impl> & impl_r )
+namespace zypp
+{
+  namespace target
   {
-    return zypp::detail::makeResolvableAndImpl( "n",
-                                                zypp::Edition("v","r"),
-                                                zypp::Arch(),
-                                                impl_r );
+    void writeUpgradeTestcase();
   }
+}
 
-using namespace zypp;
-/******************************************************************
-**
-**
-**     FUNCTION NAME : main
-**     FUNCTION TYPE : int
-**
-**     DESCRIPTION :
-*/
-int main( int argc, char * argv[] )
+std::ostream & operator<<( std::ostream & str, const sat::Solvable::SplitIdent & obj )
+{
+  str << "{" << obj.ident() << "}{" << obj.kind() << "}{" << obj.name () << "}" << endl;
+  return str;
+}
+
+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 );
+  ///////////////////////////////////////////////////////////////////
 
-  base::shared_ptr<detail::PackageImpl> pi;
-  OUT( makeResolvable( pi ) );
+  ui::Selectable::Ptr p( getSel<Package>( "kruler" ) );
+  if ( p )
+  {
+    USR << p->setToDelete() << endl;
+    getZYpp()->resolver()->setCleandepsOnRemove( true );
+    solve();
+  }
 
-  INT << "===[END]============================================" << endl;
+  ///////////////////////////////////////////////////////////////////
+  INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
   return 0;
 }
+catch ( const Exception & exp )
+{
+  INT << exp << endl << exp.historyAsString();
+}
+catch (...)
+{}