(no commit message)
authorMichael Andres <ma@suse.de>
Thu, 12 Apr 2007 00:32:34 +0000 (00:32 +0000)
committerMichael Andres <ma@suse.de>
Thu, 12 Apr 2007 00:32:34 +0000 (00:32 +0000)
devel/devel.ma/AOUT.cc
devel/devel.ma/FakePool.h
devel/devel.ma/Iorder.cc
devel/devel.ma/Main.cc
devel/devel.ma/iorderbug.pool [new file with mode: 0644]
devel/genclass.in
zypp/source/yum/YUMSourceImpl.cc

index 81b5837..b1b61c1 100644 (file)
@@ -40,6 +40,7 @@ int main( int argc, char * argv[] )
 
 
   DBG << "===[END]============================================" << endl;
+  zypp::base::LogControl::instance().logNothing();
   return 0;
 }
 
index f9e4f41..740c853 100644 (file)
 #include "zypp/base/Algorithm.h"
 #include "zypp/base/Function.h"
 #include "zypp/base/Functional.h"
+#include "zypp/base/IOStream.h"
 #include "zypp/base/String.h"
 
+#include "zypp/ZYppFactory.h"
 #include "zypp/ResPool.h"
+#include "zypp/ResPoolProxy.h"
+#include "zypp/NameKindProxy.h"
 #include "zypp/CapFactory.h"
 
 #include "zypp/Atom.h"
@@ -25,6 +29,7 @@
 #include "zypp/Script.h"
 #include "zypp/Message.h"
 #include "zypp/Language.h"
+#include "zypp/VendorAttr.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -38,9 +43,9 @@ namespace zypp
      * const char * data[] = {
      * "@ product"
      * ,"@ installed"
-     * ,"prodold 1 1 x86_64"
+     * ,"prodold 1 1 x86_64"
      * ,"@ available"
-     * ,"prodnew 1 1 x86_64"
+     * ,"prodnew 1 1 x86_64"
      * ,"@ obsoletes"
      * ,"prodold"
      * ,"@ fin"
@@ -59,10 +64,15 @@ namespace zypp
       , _defdep( Dep::PROVIDES )
       , _defdepref( _defkind )
       , _verbose( verbose_r )
-      {}
+      {
+       VendorAttr::disableAutoProtect();
+      }
 
-      void operator()( const std::string & line_r )
-      { parseLine( line_r ); }
+      bool operator()( const std::string & line_r )
+      {
+       parseLine( str::trim( line_r ) );
+       return true;
+      }
 
       const ResStore & installed() const
       { return _installed; }
@@ -94,7 +104,10 @@ namespace zypp
     private:
       void parseLine( const std::string & line_r )
       {
-        std::vector<std::string> words;
+       if ( line_r.empty() || line_r[0] == '#' )
+         return;
+
+       std::vector<std::string> words;
         str::split( line_r, std::back_inserter( words ) );
         if ( words.empty() )
           return;
@@ -203,7 +216,7 @@ namespace zypp
     };
     ///////////////////////////////////////////////////////////////////
 
-    /** \refers DataCollect Stream output. */
+    /** \relates DataCollect Stream output. */
     inline std::ostream & operator<<( std::ostream & str, const DataCollect & obj )
     {
       dumpRange( str << "Installed" << endl,
@@ -217,6 +230,25 @@ namespace zypp
 
     ///////////////////////////////////////////////////////////////////
 
+    template<class _Iterator>
+       inline void addPool( _Iterator begin_r, _Iterator end_r )
+    {
+      DataCollect dataCollect;
+      dataCollect.collect( begin_r, end_r );
+      getZYpp()->addResolvables( dataCollect.installed(), true );
+      getZYpp()->addResolvables( dataCollect.available() );
+    }
+
+    inline void addPool( const Pathname & file_r )
+    {
+      std::ifstream in( file_r.c_str() );
+      DataCollect dataCollect;
+      function<bool(const std::string &)> fnc( ref(dataCollect) );
+      iostr::forEachLine( in, fnc );
+      getZYpp()->addResolvables( dataCollect.installed(), true );
+      getZYpp()->addResolvables( dataCollect.available() );
+    }
+
     /////////////////////////////////////////////////////////////////
   } // namespace debug
   ///////////////////////////////////////////////////////////////////
index 5b05fd0..5e15558 100644 (file)
@@ -276,13 +276,12 @@ int main( int argc, char * argv[] )
   pool::GetResolvablesToInsDel collect( pool, pool::GetResolvablesToInsDel::ORDER_BY_MEDIANR );
   MIL << "GetResolvablesToInsDel:" << endl << collect << endl;
 
-  typedef pool::GetResolvablesToInsDel::PoolItemList PoolItemList;
-
   if ( 1 )
     {
       // Collect until the 1st package from an unwanted media occurs.
       // Further collection could violate install order.
       bool hitUnwantedMedia = false;
+      typedef pool::GetResolvablesToInsDel::PoolItemList PoolItemList;
       PoolItemList::iterator fst=collect._toInstall.end();
       for ( PoolItemList::iterator it = collect._toInstall.begin(); it != collect._toInstall.end(); ++it)
         {
index ea5cc52..70f8655 100644 (file)
@@ -7,21 +7,14 @@
 #include <zypp/base/Function.h>
 #include <zypp/base/Iterator.h>
 
-#include "zypp/ZYppFactory.h"
-#include "zypp/ResPoolProxy.h"
 #include <zypp/SourceManager.h>
 #include <zypp/SourceFactory.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/PackageKeyword.h"
-#include "zypp/NameKindProxy.h"
 #include "zypp/pool/GetResolvablesToInsDel.h"
 
 using namespace std;
@@ -29,19 +22,88 @@ using namespace zypp;
 
 ///////////////////////////////////////////////////////////////////
 
-template<class _Iterator>
-    void addPool( _Iterator begin_r, _Iterator end_r )
+struct SetTransactValue
+{
+  SetTransactValue( ResStatus::TransactValue newVal_r, ResStatus::TransactByValue causer_r )
+  : _newVal( newVal_r )
+  , _causer( causer_r )
+  {}
+
+  ResStatus::TransactValue   _newVal;
+  ResStatus::TransactByValue _causer;
+
+  bool operator()( const PoolItem & pi ) const
+  {
+    bool ret = pi.status().setTransactValue( _newVal, _causer );
+    if ( ! ret )
+      ERR << _newVal <<  _causer << " " << pi << endl;
+    return ret;
+  }
+};
+
+struct StatusReset : public SetTransactValue
+{
+  StatusReset()
+  : SetTransactValue( ResStatus::KEEP_STATE, ResStatus::USER )
+  {}
+};
+
+struct StatusInstall : public SetTransactValue
+{
+  StatusInstall()
+  : SetTransactValue( ResStatus::TRANSACT, ResStatus::USER )
+  {}
+};
+
+inline bool selectForTransact( 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 )
 {
-  using zypp::debug::DataCollect;
-  DataCollect dataCollect;
-  dataCollect.collect( begin_r, end_r );
-  getZYpp()->addResolvables( dataCollect.installed(), true );
-  getZYpp()->addResolvables( dataCollect.available() );
-  vdumpPoolStats( USR << "Pool:" << endl,
-                 getZYpp()->pool().begin(),
-                 getZYpp()->pool().end() ) << endl;
+  if ( establish )
+  {
+    bool eres = getZYpp()->resolver()->establishPool();
+    if ( ! eres )
+    {
+      ERR << "establish " << eres << endl;
+      return false;
+    }
+    MIL << "establish " << eres << endl;
+  }
+
+  bool rres = getZYpp()->resolver()->resolvePool();
+  if ( ! rres )
+  {
+    ERR << "resolve " << rres << endl;
+    return false;
+  }
+  MIL << "resolve " << rres << endl;
+  return true;
 }
 
+///////////////////////////////////////////////////////////////////
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -50,33 +112,101 @@ template<class _Iterator>
 int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
+  ///////////////////////////////////////////////////////////////////
+  // define pool
+  ///////////////////////////////////////////////////////////////////
+  if ( 0 )
+  {
+    const char * data[] = {
+      "@ product",
+      "@ installed",
+      "- prodold 1 1 x86_64",
+      "@ available",
+      "- prodnew 1 1 x86_64",
+      "@ obsoletes",
+      "prodold",
+      "@ fin",
+    };
+    debug::addPool( data, data + ( sizeof(data) / sizeof(const char *) ) );
+  }
+  else
+  {
+    debug::addPool( "SRC/iorderbug.pool" );
+  }
+  ResPool pool( getZYpp()->pool() );
+  vdumpPoolStats( USR << "Initial pool:" << endl,
+                 pool.begin(),
+                 pool.end() ) << endl;
 
-  const char * data[] = {
-    "@ package",
-    "@ installed",
-    "@ available",
-    "- glibc 2.3.4 31 i686",
-    "- glibc 2.3.5 28 i586",
-    "- glibc-locale 2.3.5 28 i686",
-    "@ requires",
-    "glibc == 2.3.5",
-    "@ fin"
-  };
-  addPool( data, data + ( sizeof(data) / sizeof(const char *) ) );
+  ///////////////////////////////////////////////////////////////////
+  // define transaction
+  ///////////////////////////////////////////////////////////////////
+  if ( 0 )
+    for_each( pool.byKindBegin<Product>(), pool.byKindEnd<Product>(), StatusInstall() );
 
-  ResPool pool( getZYpp()->pool() );
+#define selt(K,N) selectForTransact( nameKindProxy<K>( pool, #N ) )
+  selt( Package, bash );
+  selt( Package, readline );
+  selt( Package, fontcfg );
+#undef selt
+
+  ///////////////////////////////////////////////////////////////////
+  // solve
+  ///////////////////////////////////////////////////////////////////
+  if ( 0 )
+  {
+    solve();
+  }
+
+  vdumpPoolStats( USR << "Transacting:"<< endl,
+                 make_filter_begin<resfilter::ByTransact>(pool),
+                 make_filter_end<resfilter::ByTransact>(pool) ) << endl;
 
-  vdumpPoolStats( USR << "Pool:" << endl,
-                 getZYpp()->pool().begin(),
-                 getZYpp()->pool().end() ) << endl;
+  ///////////////////////////////////////////////////////////////////
+  // install order
+  ///////////////////////////////////////////////////////////////////
+  pool::GetResolvablesToInsDel collect( pool, pool::GetResolvablesToInsDel::ORDER_BY_MEDIANR );
+  MIL << "GetResolvablesToInsDel:" << endl << collect << endl;
 
- // solve();
+  if ( 1 )
+  {
+    // Collect until the 1st package from an unwanted media occurs.
+    // Further collection could violate install order.
+    bool hitUnwantedMedia = false;
+    typedef pool::GetResolvablesToInsDel::PoolItemList PoolItemList;
+    PoolItemList::iterator fst=collect._toInstall.end();
+    for ( PoolItemList::iterator it = collect._toInstall.begin(); it != collect._toInstall.end(); ++it)
+    {
+      ResObject::constPtr res( it->resolvable() );
 
-  vdumpPoolStats( USR << "Pool:" << endl,
-                 getZYpp()->pool().begin(),
-                 getZYpp()->pool().end() ) << endl;
+      if ( hitUnwantedMedia
+          || ( res->sourceMediaNr() && res->sourceMediaNr() != 1 ) )
+      {
+       if ( !hitUnwantedMedia )
+         fst=it;
+       hitUnwantedMedia = true;
+      }
+      else
+      {
+      }
+    }
+    dumpRange( WAR << "toInstall1: " << endl,
+              collect._toInstall.begin(), fst ) << endl;
+    dumpRange( WAR << "toInstall2: " << endl,
+              fst, collect._toInstall.end() ) << endl;
+    dumpRange( ERR << "toDelete: " << endl,
+              collect._toDelete.begin(), collect._toDelete.end() ) << endl;
+  }
+  else
+  {
+    dumpRange( WAR << "toInstall: " << endl,
+              collect._toInstall.begin(), collect._toInstall.end() ) << endl;
+    dumpRange( ERR << "toDelete: " << endl,
+              collect._toDelete.begin(), collect._toDelete.end() ) << endl;
+  }
 
   INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
   return 0;
 }
 
diff --git a/devel/devel.ma/iorderbug.pool b/devel/devel.ma/iorderbug.pool
new file mode 100644 (file)
index 0000000..1e6be3c
--- /dev/null
@@ -0,0 +1,26 @@
+@ package
+@ installed
+
+- readline 1 1 i686
+
+- bash 1 1 i686
+@ requires
+readline = 1
+
+- fontcfg 1 1 i686
+@ prerequires
+bash
+
+@ available
+
+- readline 2 1 i686
+
+- bash 2 1 i686
+@ requires
+readline = 2
+
+- fontcfg 2 1 i686
+#@ prerequires
+#bash
+
+@ fin
index 0934bd3..414c0f7 100644 (file)
@@ -10,9 +10,9 @@ EOF
 
 test -z "$1" && usage "Missing name!"
 
-TOPSRCDIR=$( cd @abs_top_srcdir@ && pwd )
+TOPSRCDIR=${XTOPSRCDIR:-$(cd @abs_top_srcdir@ && pwd)}
 test -z "$TOPSRCDIR" && {
-   echo "Dir does not exist '@abs_top_srcdir@'" >&2
+   echo "Dir does not exist '$TOPSRCDIR'" >&2
    exit 1
 }
 
index 30ff0d9..935bf54 100644 (file)
@@ -326,7 +326,7 @@ void YUMSourceImpl::storeMetadata(const Pathname & cache_dir_r)
 
   MIL << "Metadata saved in " << cache_dir_r << ". Setting as cache." << std::endl;
   _cache_dir = cache_dir_r;
+
   readRepomd();
 }
 
@@ -377,7 +377,7 @@ void YUMSourceImpl::readRepomd()
   _repo_pattern.clear();
   _repo_product.clear();
   _repo_patches.clear();
-  
+
   parser::ParserProgress::Ptr progress;
   callback::SendReport<SourceReport> report;
   YUMSourceEventHandler npp(report);
@@ -422,22 +422,22 @@ std::set<zypp::Resolvable::Kind>
 YUMSourceImpl::resolvableKinds() const
 {
   std::set<zypp::Resolvable::Kind> kinds;
-  
+
   if (_repo_product.size() > 0 )
-    kinds.insert( ResTraits<zypp::Product>::kind ); 
-  
+    kinds.insert( ResTraits<zypp::Product>::kind );
+
   if (_repo_pattern.size() > 0 )
     kinds.insert( ResTraits<zypp::Pattern>::kind );
-  
+
   if (_repo_group.size() > 0 )
     kinds.insert( ResTraits<zypp::Selection>::kind );
-  
+
   if (_repo_primary.size() > 0 )
   kinds.insert( ResTraits<zypp::Package>::kind );
-  
+
   if (_repo_patches.size() > 0 )
     kinds.insert( ResTraits<zypp::Patch>::kind );
-  
+
   return kinds;
 }
 
@@ -462,7 +462,7 @@ void YUMSourceImpl::provideProducts(Source_Ref source_r, ResStore& store)
 
        // TranslatorExplanation %s = product file
       report->start( selfSourceRef(), str::form(_("Reading product from %s"), filename.asString().c_str()) );
-      
+
       YUMProductParser product(st, "", progress);
       for (; !product.atEnd(); ++product)
       {
@@ -1148,10 +1148,10 @@ Product::Ptr YUMSourceImpl::createProduct(
     Arch arch;
     if (!parsed.arch.empty())
       arch = Arch(parsed.arch);
-    
+
     string name(parsed.name);
     std::replace(name.begin(), name.end(), ' ', '_');
-    
+
     NVRAD dataCollect( name,
                        Edition( parsed.ver, parsed.rel, parsed.epoch ),
                        arch,