Imported Upstream version 15.18.0
[platform/upstream/libzypp.git] / devel / devel.ma / Parse.cc
index 08f3852..c9e1a49 100644 (file)
@@ -8,21 +8,18 @@
 
 #include "zypp/ZYppFactory.h"
 #include "zypp/ResPoolProxy.h"
-#include <zypp/CapMatchHelper.h>
 
 #include "zypp/ZYppCallbacks.h"
 #include "zypp/NVRAD.h"
 #include "zypp/ResPool.h"
 #include "zypp/ResFilters.h"
-#include "zypp/CapFilters.h"
 #include "zypp/Package.h"
 #include "zypp/Pattern.h"
 #include "zypp/Language.h"
 #include "zypp/Digest.h"
 #include "zypp/PackageKeyword.h"
 #include "zypp/ManagedFile.h"
-#include "zypp/NameKindProxy.h"
-#include "zypp/pool/GetResolvablesToInsDel.h"
+
 
 #include "zypp/parser/TagParser.h"
 #include "zypp/parser/susetags/PackagesFileReader.h"
@@ -35,7 +32,9 @@
 #include "zypp/RepoManager.h"
 #include "zypp/RepoInfo.h"
 
+#include "zypp/repo/DeltaCandidates.h"
 #include "zypp/repo/PackageProvider.h"
+#include "zypp/repo/SrcPackageProvider.h"
 
 #include "zypp/ui/PatchContents.h"
 #include "zypp/ResPoolProxy.h"
@@ -59,10 +58,17 @@ bool queryInstalledEditionHelper( const std::string & name_r,
                                   const Edition &     ed_r,
                                   const Arch &        arch_r )
 {
-  INT << name_r << "-" << ed_r << "." << arch_r << endl;
+  if ( ed_r == Edition::noedition )
+    return true;
+  if ( name_r == "kernel-default" && ed_r == Edition("2.6.22.5-10") )
+    return true;
+  if ( name_r == "update-test-affects-package-manager" && ed_r == Edition("1.1-6") )
+    return true;
+
   return false;
 }
 
+
 ManagedFile repoProvidePackage( const PoolItem & pi )
 {
   ResPool _pool( getZYpp()->pool() );
@@ -86,59 +92,6 @@ ManagedFile repoProvidePackage( const PoolItem & pi )
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-
-template<class _Res>
-Selectable::Ptr getSel( const std::string & name_r )
-{
-  ResPoolProxy uipool( getZYpp()->poolProxy() );
-  for_(it, uipool.byKindBegin<_Res>(), uipool.byKindEnd<_Res>() )
-  {
-    if ( (*it)->name() == name_r )
-      return (*it);
-  }
-  return 0;
-}
-
-template<class _Res>
-PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
-{
-  PoolItem ret;
-  ResPool pool( getZYpp()->pool() );
-  for_(it, pool.byNameBegin(name_r), pool.byNameEnd(name_r) )
-  {
-    if ( !ret && isKind<_Res>( (*it).resolvable() )
-         && ( ed_r == Edition() || ed_r == (*it)->edition() )
-         && ( arch_r == Arch()  || arch_r == (*it)->arch()  ) )
-    {
-      ret = (*it);
-      MIL << "    ->" << *it << endl;
-    }
-    else
-    {
-      DBG << "     ?" << *it << endl;
-    }
-  }
-  return ret;
-}
-template<class _Res>
-PoolItem getPi( const std::string & name_r )
-{
-  return getPi<_Res>( name_r, Edition(), Arch() );
-}
-template<class _Res>
-PoolItem getPi( const std::string & name_r, const Edition & ed_r )
-{
-  return getPi<_Res>( name_r, ed_r, Arch() );
-}
-template<class _Res>
-PoolItem getPi( const std::string & name_r, const Arch & arch_r )
-{
-  return getPi<_Res>( name_r, Edition(), arch_r );
-}
-
-
-
 
 void dbgDu( Selectable::Ptr sel )
 {
@@ -162,6 +115,9 @@ struct Xprint
 {
   bool operator()( const PoolItem & obj_r )
   {
+    if ( obj_r.status().isLocked() )
+      SEC << obj_r << endl;
+
 //     handle( asKind<Package>( obj_r ) );
 //     handle( asKind<Patch>( obj_r ) );
 //     handle( asKind<Pattern>( obj_r ) );
@@ -246,28 +202,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( bool establish = false )
@@ -301,6 +235,12 @@ bool solve( bool establish = false )
   return true;
 }
 
+bool install()
+{
+  SEC << getZYpp()->commit( ZYppCommitPolicy() ) << endl;
+  return true;
+}
+
 ///////////////////////////////////////////////////////////////////
 
 struct ConvertDbReceive : public callback::ReceiveReport<target::ScriptResolvableReport>
@@ -478,41 +418,10 @@ int main( int argc, char * argv[] )
   DigestReceive foo;
   KeyRingSignalsReceive baa;
 
-  DiskUsageCounter::MountPointSet fakePart;
-  fakePart.insert( DiskUsageCounter::MountPoint( "/",        1024, 10240, 5120, 0LL, false ) );
-//   fakePart.insert( DiskUsageCounter::MountPoint( "/usr",     1024, 10240, 5120, 0LL, false ) );
-  fakePart.insert( DiskUsageCounter::MountPoint( "/usr/lib", 1024, 10240, 5120, 0LL, false ) );
-  fakePart.insert( DiskUsageCounter::MountPoint( "/usr/bin", 1024, 10240, 5120, 0LL, false ) );
-  getZYpp()->setPartitions( fakePart );
-
-  ResPool pool( getZYpp()->pool() );
-  vdumpPoolStats( USR << "Initial pool:" << endl,
-                 pool.begin(),
-                 pool.end() ) << endl;
-
-
   RepoManager repoManager( makeRepoManager( "/Local/ROOT" ) );
-  RepoInfoList repos = repoManager.knownRepositories();
-  SEC << repos << endl;
 
-  if ( repos.empty() )
-  {
-    RepoInfo nrepo;
-    nrepo
-       .setAlias( "factorytest" )
-       .setName( "Test Repo for factory." )
-       .setEnabled( true )
-       .setAutorefresh( false )
-       .addBaseUrl( Url("http://dist.suse.de/install/stable-x86/") );
-
-    repoManager.addRepository( nrepo );
-    SEC << "refreshMetadat" << endl;
-    repoManager.refreshMetadata( nrepo );
-    SEC << "buildCache" << endl;
-    repoManager.buildCache( nrepo );
-    SEC << "------" << endl;
-    repos = repoManager.knownRepositories();
-  }
+  RepoInfoList repos = repoManager.knownRepositories();
+  SEC << "/Local/ROOT " << repos << endl;
 
   for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
   {
@@ -528,7 +437,8 @@ int main( int argc, char * argv[] )
        repoManager.cleanCache( nrepo );
       }
       SEC << "refreshMetadata" << endl;
-      repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced );
+      //repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced );
+      repoManager.refreshMetadata( nrepo );
       SEC << "buildCache" << endl;
       repoManager.buildCache( nrepo );
     }
@@ -542,31 +452,29 @@ int main( int argc, char * argv[] )
     getZYpp()->addResolvables( store );
   }
 
+  ResPool pool( getZYpp()->pool() );
   USR << "pool: " << pool << endl;
   SEC << pool.knownRepositoriesSize() << endl;
 
-  if ( 1 )
+  if ( 0 )
   {
     {
-       zypp::base::LogControl::TmpLineWriter shutUp;
+      zypp::base::LogControl::TmpLineWriter shutUp;
       //getZYpp()->initTarget( sysRoot );
       getZYpp()->initTarget( "/" );
     }
     MIL << "Added target: " << pool << endl;
   }
 
-  //std::for_each( pool.begin(), pool.end(), Xprint() );
-
-  repo::DeltaCandidates deltas( repo::makeDeltaCandidates( pool.knownRepositoriesBegin(),
-                                                           pool.knownRepositoriesEnd() ) );
-
-  DBG << "patch: " << deltas.patchRpms(0).size() << " " << deltas.patchRpms(0) << endl;
-  DBG << "delta: " << deltas.deltaRpms(0).size() << " " << deltas.deltaRpms(0) << endl;
 
+  //std::for_each( pool.begin(), pool.end(), Xprint() );
 
-  PoolItem pi( getPi<Package>( "kernel-default" ) );
+  PoolItem pi = getPi<Patch>( "fetchmsttfonts.sh" );
   USR << pi << endl;
 
+  //pi.status().setTransact( true, ResStatus::USER );
+  //install();
+
  ///////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
   zypp::base::LogControl::instance().logNothing();