backup
authorMichael Andres <ma@suse.de>
Thu, 29 Apr 2010 15:22:24 +0000 (17:22 +0200)
committerMichael Andres <ma@suse.de>
Thu, 29 Apr 2010 15:22:24 +0000 (17:22 +0200)
devel/devel.ma/CleandepsOnRemove.cc [new file with mode: 0644]
devel/devel.ma/Main.cc

diff --git a/devel/devel.ma/CleandepsOnRemove.cc b/devel/devel.ma/CleandepsOnRemove.cc
new file mode 100644 (file)
index 0000000..003de04
--- /dev/null
@@ -0,0 +1,141 @@
+#include "Tools.h"
+
+#include <zypp/PoolQuery.h>
+#include <zypp/target/rpm/librpmDb.h>
+#include <zypp/parser/ProductFileReader.h>
+#include "zypp/pool/GetResolvablesToInsDel.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 )
+  {
+    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();
+  }
+}
+
+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.multiversionBegin(), satpool.multiversionEnd() ) << endl;
+  TestSetup::LoadSystemAt( sysRoot, Arch_i586 );
+  ///////////////////////////////////////////////////////////////////
+
+  char * fix[] = {
+      "test"
+  };
+  argv = fix;
+  argc = arraySize(fix);
+  for ( ; argc; --argc,++argv )
+  {
+    ui::Selectable::Ptr p( getSel<Package>( *argv ) );
+    if ( p )
+      USR << p->setToDelete() << endl;
+    else
+      ERR << p << endl;
+  }
+
+  std::set<PoolItem> todel;
+  {
+    getZYpp()->resolver()->setCleandepsOnRemove( false );
+    SEC << "=== Solve noclean:" << endl;
+    solve();
+    std::copy( make_filter_begin<resfilter::ByTransact>(pool),
+              make_filter_end<resfilter::ByTransact>(pool),
+              std::inserter( todel, todel.begin() ) );
+    WAR << todel << endl;
+  }
+  {
+    getZYpp()->resolver()->setCleandepsOnRemove( true );
+    SEC << "=== Solve clean:" << endl;
+    solve();
+    SEC << "========================================================" << endl;
+    for_( it, make_filter_begin<resfilter::ByTransact>(pool), make_filter_end<resfilter::ByTransact>(pool) )
+    {
+      ( todel.find( *it ) == todel.end() ? INT : USR ) << *it << endl;
+    }
+    SEC << "========================================================" << endl;
+  }
+
+
+
+  ///////////////////////////////////////////////////////////////////
+  INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
+  return 0;
+}
+catch ( const Exception & exp )
+{
+  INT << exp << endl << exp.historyAsString();
+}
+catch (...)
+{}
+
index 4fb404c..513cb09 100644 (file)
@@ -90,28 +90,14 @@ try {
   TestSetup::LoadSystemAt( sysRoot, Arch_i586 );
   ///////////////////////////////////////////////////////////////////
 
-  PoolQuery q;
-  q.setMatchGlob();
-
-  //q.addDependency( sat::SolvAttr("solvable:provides"), Capability("zypper = 1.4.1-1.1") );
-  //q.addDependency( sat::SolvAttr("solvable:provides"), Capability("z* = 1.2.8") );
-  q.addDependency( sat::SolvAttr("solvable:name"), "zypp*", Rel("="), Edition("1.2.8") );
-  //q.addDependency( sat::SolvAttr("solvable:provides"), "zypp*" );
-  q.serialize( SEC );
-
-  for_( solvIter, q.begin(), q.end() )
+  ui::Selectable::Ptr p( getSel<Package>( "kruler" ) );
+  if ( p )
   {
-    sat::Solvable solvable( *solvIter );
-    USR << "Found matches in " << solvable << endl;
-    if ( true )
-      for_( attrIter, solvIter.matchesBegin(), solvIter.matchesEnd() )
-      {
-       sat::LookupAttr::iterator attr( *attrIter );
-       USR << "    " << attr.inSolvAttr() << "\t\"" << attr.asString() << "\"" << endl;
-      }
+    USR << p->setToDelete() << endl;
+    getZYpp()->resolver()->setCleandepsOnRemove( true );
+    solve();
   }
 
-
   ///////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
   zypp::base::LogControl::instance().logNothing();