Resolvertestcase:
authorStefan Schubert <schubi@suse.de>
Fri, 28 Sep 2007 16:40:41 +0000 (16:40 +0000)
committerStefan Schubert <schubi@suse.de>
Fri, 28 Sep 2007 16:40:41 +0000 (16:40 +0000)
- log Repository info
- set keep state in the testcase
- handle vendor

zypp/solver/detail/Testcase.cc
zypp/solver/detail/Testcase.h

index 36a9c33..ff76d2c 100644 (file)
@@ -158,8 +158,9 @@ std::string helixXML( const Dependencies &dep )
     return str.str();    
 }
 
-std::string helixXML( const Resolvable::constPtr &resolvable )
+std::string helixXML( const PoolItem_Ref &item )
 {
+  const Resolvable::constPtr resolvable = item.resolvable();
   stringstream str;
   if ( isKind<SystemResObject>(resolvable)
        || isKind<Language>(resolvable) ) {
@@ -169,7 +170,8 @@ std::string helixXML( const Resolvable::constPtr &resolvable )
   }
   
   str << "<" << toLower (resolvable->kind().asString()) << ">" << endl;
-  str << TAB << xml_tag_enclose (resolvable->name(), "name", true) << endl;  
+  str << TAB << xml_tag_enclose (resolvable->name(), "name", true) << endl;
+  str << TAB << xml_tag_enclose (item->vendor(), "vendor", true) << endl;    
   if ( isKind<Package>(resolvable) ) {
       str << TAB << "<history>" << endl << TAB << "<update>" << endl;
       str << TAB2 << helixXML (resolvable->arch()) << endl;
@@ -232,7 +234,8 @@ bool Testcase::createTestcase(Resolver & resolver)
     RepositoryTable            repoTable;
     PoolItemList       items_to_install;
     PoolItemList       items_to_remove;
-    PoolItemList       items_locked;    
+    PoolItemList       items_locked;
+    PoolItemList       items_keep;    
     PoolItemList       language;
     HelixResolvable    system (dumpPath + "/solver-system.xml");    
 
@@ -248,7 +251,7 @@ bool Testcase::createTestcase(Resolver & resolver)
        } else {
            if ( it->status().isInstalled() ) {
                // system channel
-               system.addResolvable (res);
+               system.addResolvable (*it);
            } else {
                // repo channels
                ResObject::constPtr repoItem = it->resolvable();
@@ -258,13 +261,17 @@ bool Testcase::createTestcase(Resolver & resolver)
                                                          + numstring(repo.numericId())
                                                          + "-package.xml");
                }
-               repoTable[repo]->addResolvable (res);
+               repoTable[repo]->addResolvable (*it);
            }
        
            if ( it->status().isToBeInstalled()
                 && !(it->status().isBySolver())) {
                items_to_install.push_back (*it);
            }
+           if ( it->status().isKept()
+                && !(it->status().isBySolver())) {
+               items_keep.push_back (*it);
+           }       
            if ( it->status().isToBeUninstalled()
                 && !(it->status().isBySolver())) {
                items_to_remove.push_back (*it);
@@ -293,6 +300,9 @@ bool Testcase::createTestcase(Resolver & resolver)
        control.lockResolvable (iter->resolvable());    
     }
     
+    for (PoolItemList::const_iterator iter = items_keep.begin(); iter != items_keep.end(); iter++) {
+       control.keepResolvable (iter->resolvable());    
+    }
 
     for (PoolItemList::const_iterator iter = items_to_remove.begin(); iter != items_to_remove.end(); iter++) {
        control.deleteResolvable (iter->resolvable());  
@@ -322,9 +332,9 @@ HelixResolvable::~HelixResolvable()
 }
     
 
-void HelixResolvable::addResolvable(const Resolvable::constPtr &resolvable)
+void HelixResolvable::addResolvable(const PoolItem_Ref item)
 {
-    *file << helixXML (resolvable);
+    *file << helixXML (item);
 }
 
 //---------------------------------------------------------------------------
@@ -345,13 +355,25 @@ HelixControl::HelixControl(const std::string & controlPath,
          << "<!-- testcase generated by YaST -->" << endl
          << "<test>" << endl
          << "<setup arch=\"" << systemArchitecture << "\">" << endl
-         << TAB << "<system file=\"" << systemPath << "\"/>" << endl;
+         << TAB << "<system file=\"" << systemPath << "\"/>" << endl << endl;
     for ( RepositoryTable::const_iterator it = repoTable.begin();
          it != repoTable.end(); ++it ) {
        Repository repo = it->first;
+       *file << TAB << "<!-- " << endl
+             << TAB << "- alias       : " << repo.info().alias() << endl;
+       for ( RepoInfo::urls_const_iterator itUrl = repo.info().baseUrlsBegin();
+             itUrl != repo.info().baseUrlsEnd();
+             ++itUrl )
+       {
+           *file << TAB << "- url         : " << *itUrl << endl;
+       }       
+       *file << TAB << "- path        : " << repo.info().path() << endl;
+       *file << TAB << "- type        : " << repo.info().type() << endl;       
+       *file << TAB << " -->" << endl;
+       
        *file << TAB << "<channel file=\"" << numstring(repo.numericId())
              << "-package.xml\" name=\"" << numstring(repo.numericId())
-             << "\" />" << endl;
+             << "\" />" << endl << endl;
     }
     for (PoolItemList::const_iterator iter = languages.begin(); iter != languages.end(); iter++) {
        *file << TAB << "<locale name=\"" <<  iter->resolvable()->name()
@@ -393,6 +415,15 @@ void HelixControl::lockResolvable(const ResObject::constPtr &resObject)
          << " version=\"" << resObject->edition().version() << "\"" << " release=\"" << resObject->edition().release() << "\"" 
          << "/>" << endl;
 }
+
+void HelixControl::keepResolvable(const ResObject::constPtr &resObject)
+{
+    Repository repo  = resObject->repository();
+    *file << "<keep channel=\"" << numstring(repo.numericId()) << "\" kind=\"" << toLower (resObject->kind().asString()) << "\""
+         << " name=\"" << resObject->name() << "\"" << " arch=\"" << resObject->arch().asString() << "\""
+         << " version=\"" << resObject->edition().version() << "\"" << " release=\"" << resObject->edition().release() << "\"" 
+         << "/>" << endl;
+}
     
 void HelixControl::deleteResolvable(const ResObject::constPtr &resObject)
 {
index c9dca79..64506de 100644 (file)
@@ -20,6 +20,7 @@
 #include "zypp/base/PtrTypes.h"
 #include "zypp/solver/detail/Resolver.h"
 #include "zypp/CapSet.h"
+#include "zypp/ResPool.h"
 
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
@@ -51,7 +52,7 @@ template<>
 std::string helixXML( const Dependencies &dep );
        
 template<> 
-std::string helixXML( const Resolvable::constPtr &resolvable );
+std::string helixXML( const PoolItem_Ref &item );
 
 
 ///////////////////////////////////////////////////////////////////
@@ -71,7 +72,7 @@ class  HelixResolvable : public base::ReferenceCounted, private base::NonCopyabl
     HelixResolvable (const std::string & path);
     ~HelixResolvable ();
 
-    void addResolvable (const Resolvable::constPtr &resolvable);
+    void addResolvable (const PoolItem_Ref item);
     std::string filename () { return dumpFile; }
 };
 
@@ -101,7 +102,8 @@ class  HelixControl {
     ~HelixControl ();
 
     void installResolvable (const ResObject::constPtr &resObject);
-    void lockResolvable (const ResObject::constPtr &resObject);    
+    void lockResolvable (const ResObject::constPtr &resObject);
+    void keepResolvable (const ResObject::constPtr &resObject);        
     void deleteResolvable (const ResObject::constPtr &resObject);
     void addDependencies (const CapSet &capRequire, const CapSet &capConflict);
     std::string filename () { return dumpFile; }