Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / devel / devel.ma / NewPool.cc
index 029bfc4..a8cf123 100644 (file)
 #include "zypp/PackageKeyword.h"
 #include "zypp/TmpPath.h"
 #include "zypp/ManagedFile.h"
-#include "zypp/NameKindProxy.h"
-#include "zypp/pool/GetResolvablesToInsDel.h"
+#include "zypp/MediaSetAccess.h"
+
 
 #include "zypp/RepoManager.h"
 #include "zypp/Repository.h"
 #include "zypp/RepoInfo.h"
-
+#include "zypp/TriBool.h"
 #include "zypp/repo/PackageProvider.h"
 
 #include "zypp/ResPoolProxy.h"
 #include "zypp/sat/Pool.h"
 #include "zypp/sat/LocaleSupport.h"
 #include "zypp/sat/LookupAttr.h"
+#include "zypp/sat/AttrMatcher.h"
 #include "zypp/sat/SolvableSet.h"
 #include "zypp/sat/SolvIterMixin.h"
 #include "zypp/sat/detail/PoolImpl.h"
 #include "zypp/sat/WhatObsoletes.h"
 #include "zypp/PoolQuery.h"
 #include "zypp/ServiceInfo.h"
+#include "zypp/media/MediaPriority.h"
+
+#include "zypp/target/rpm/RpmDb.h"
+#include "zypp/target/rpm/RpmHeader.h"
+#include "zypp/target/rpm/librpmDb.h"
 
 #include <boost/mpl/int.hpp>
 
@@ -219,28 +225,6 @@ struct StatusInstall : public SetTransactValue
   {}
 };
 
-inline bool g( const NameKindProxy & nkp, Arch arch = Arch() )
-{
-  if ( nkp.availableEmpty() )
-  {
-    ERR << "No Item to select: " << nkp << endl;
-    return false;
-    ZYPP_THROW( Exception("No Item to select") );
-  }
-
-  if ( arch != Arch() )
-  {
-    typeof( nkp.availableBegin() ) it =  nkp.availableBegin();
-    for ( ; it != nkp.availableEnd(); ++it )
-    {
-      if ( (*it)->arch() == arch )
-       return (*it).status().setTransact( true, ResStatus::USER );
-    }
-  }
-
-  return nkp.availableBegin()->status().setTransact( true, ResStatus::USER );
-}
-
 ///////////////////////////////////////////////////////////////////
 
 bool solve()
@@ -428,6 +412,66 @@ void testCMP( const L & lhs, const R & rhs )
 #undef OUTS
 }
 
+#include "zypp/Locks.h"
+#include "zypp/target/HardLocksFile.h"
+inline PoolQuery makeTrivialQuery( IdString ident_r )
+{
+  sat::Solvable::SplitIdent ident( ident_r );
+
+  PoolQuery q;
+  q.addAttribute( sat::SolvAttr::name, ident.name().asString() );
+  q.addKind( ident.kind() );
+  q.setMatchExact();
+  q.setCaseSensitive(true);
+  return q;
+}
+inline PoolQuery makeTrivialQuery( const char * ch )
+{ return makeTrivialQuery( IdString(ch) ); }
+void lktest()
+{
+  static unsigned i = 0;
+  ResPool pool( ResPool::instance() );
+  target::HardLocksFile::Data newdata;
+  pool.getHardLockQueries( newdata );
+  SEC << '[' << i++ << ']' << newdata << endl;
+}
+
+
+Capability guessPackageSpec( const std::string & str_r )
+{
+  return Capability::guessPackageSpec( str_r );
+}
+
+
+
+
+void cut( const Capability & cap )
+{
+  CapDetail detail( cap.detail() );
+  if ( detail.isSimple() )
+  {
+    MIL << detail.kind() << ": " << detail.name();
+    if ( detail.hasArch() )
+      MIL << " (" << detail.arch() << ")";
+    if ( detail.isVersioned() )
+      MIL << " " << detail.op() << " " << detail.ed();
+    MIL << endl;
+  }
+  else
+  {
+    MIL << "---???---" << endl;
+  }
+}
+
+namespace zypp { namespace target {
+  void XRunUpdateMessages( const Pathname & root_r,
+                           const Pathname & messagesPath_r,
+                           const std::vector<sat::Solvable> & checkPackages_r,
+                           ZYppCommitResult & result_r );
+
+}}
+using zypp::target::XRunUpdateMessages;
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -435,8 +479,13 @@ void testCMP( const L & lhs, const R & rhs )
 */
 int main( int argc, char * argv[] )
 try {
-  --argc;
-  ++argv;
+  --argc,++argv;
+  if (0) {
+    // download the repo index file
+    media::MediaManager mediamanager;
+    media::MediaAccessId mid = mediamanager.open( Url("http://download.opensuse.org") );
+    mediamanager.attach( mid );
+  }
   zypp::base::LogControl::instance().logToStdErr();
   INT << "===[START]==========================================" << endl;
   ZConfig::instance();
@@ -477,7 +526,7 @@ try {
     }
   }
 
-  if ( 0 )
+  if ( 1 )
   {
     RepoManager repoManager( makeRepoManager( sysRoot ) );
     RepoInfoList repos = repoManager.knownRepositories();
@@ -530,7 +579,7 @@ try {
           repoManager.loadFromCache( nrepo );
         }
 
-        USR << "pool: " << pool << endl;
+        //USR << "pool: " << pool << endl;
       }
     }
   }
@@ -543,30 +592,18 @@ try {
   if ( 0 )
   {
     Measure x( "Upgrade" );
-    UpgradeStatistics u;
-    getZYpp()->resolver()->doUpgrade( u );
+    getZYpp()->resolver()->doUpgrade();
   }
 
   ///////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////
 
-  RepoManager repoManager( makeRepoManager( sysRoot ) );
-  RepoInfoList repos = repoManager.knownRepositories();
-  // launch repos
-  for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
-  {
-     RepoInfo & nrepo( *it );
-     Url url_r( nrepo.url() );
 
-     SEC << url_r << endl;
-     MIL << RepoManager::makeStupidAlias( url_r ) << endl;
-  }
-  MIL << RepoManager::makeStupidAlias() << endl;
-  MIL << RepoManager::makeStupidAlias() << endl;
-  MIL << RepoManager::makeStupidAlias() << endl;
 
-#if 0
+
+
+#if 1
   getZYpp()->resolver()->addRequire( Capability("amarok") );
+  pool.byKindBegin<Package>()->status().setTransact( true, ResStatus::USER );
   solve();
   vdumpPoolStats( USR << "Transacting:"<< endl,
                   make_filter_begin<resfilter::ByTransact>(pool),
@@ -581,8 +618,11 @@ try {
 catch ( const Exception & exp )
 {
   INT << exp << endl << exp.historyAsString();
+  throw;
 }
 catch (...)
-{}
+{
+  throw;
+}