- option xu only shows affect-package-manager patches when available
authorThomas Goettlicher <tgoettlicher@suse.de>
Wed, 1 Aug 2007 09:17:05 +0000 (09:17 +0000)
committerThomas Goettlicher <tgoettlicher@suse.de>
Wed, 1 Aug 2007 09:17:05 +0000 (09:17 +0000)
  because they have top priority

- added installnotify message to xml

src/zypper-misc.cc
src/zypper-misc.h
src/zypper.cc

index ca4d2cb..5a366c2 100644 (file)
@@ -652,13 +652,19 @@ void show_patches()
 
 // ----------------------------------------------------------------------------
 
-void xml_list_patches ()
+bool xml_list_patches ()
 {
+  // returns true if affects_pkg_manager patches are availble
+  
+  bool pkg_mgr_available = false;
+
+
   const zypp::ResPool& pool = God->pool();
   ResPool::byKind_iterator
     it = pool.byKindBegin<Patch> (),
     e  = pool.byKindEnd<Patch> ();
 
+
   for (; it != e; ++it )
   {
     ResObject::constPtr res = it->resolvable();
@@ -666,29 +672,51 @@ void xml_list_patches ()
     {
       Patch::constPtr patch = asKind<Patch>(res);
 
-      cout << " <update ";
-      cout << "name=\"" << res->name () << "\" " ;
-      cout << "edition=\""  << res->edition ().asString() << "\" ";
-      cout << "category=\"" <<  patch->category() << "\" ";
-      cout << "pkgmanager=\"" << ((patch->affects_pkg_manager()) ? "true" : "false") << "\" ";
-      cout << "restart=\"" << ((patch->reboot_needed()) ? "true" : "false") << "\" ";
-      cout << "interactive=\"" << ((patch->interactive()) ? "true" : "false") << "\" ";
-      cout << "resolvabletype=\"" << "patch" << "\" ";
-      cout << ">" << endl;
-      cout << "  <summary>" << xml_escape(patch->summary()) << "  </summary>" << endl;
-      cout << "  <description>" << xml_escape(patch->description()) << "</description>" << endl;
-      cout << "  <license>" << xml_escape(patch->licenseToConfirm()) << "</license>" << endl;
-
-
-      if ( patch->repository() != Repository::noRepository )
+      if (patch->affects_pkg_manager())
+       pkg_mgr_available = true;
+    }
+  }
+
+
+  it = pool.byKindBegin<Patch> ();
+
+  for (; it != e; ++it )
+  {
+    ResObject::constPtr res = it->resolvable();
+    if ( it->status().isNeeded()) 
+    {
+      Patch::constPtr patch = asKind<Patch>(res);
+      if (pkg_mgr_available && patch->affects_pkg_manager()  ||
+       !pkg_mgr_available )
       {
-        cout << "  <source url=\"" << *(patch->repository().info().baseUrlsBegin());
-        cout << "\" alias=\"" << patch->repository().info().alias() << "\"/>" << endl;
-      }
+        cout << " <update ";
+        cout << "name=\"" << res->name () << "\" " ;
+        cout << "edition=\""  << res->edition ().asString() << "\" ";
+        cout << "category=\"" <<  patch->category() << "\" ";
+        cout << "pkgmanager=\"" << ((patch->affects_pkg_manager()) ? "true" : "false") << "\" ";
+        cout << "restart=\"" << ((patch->reboot_needed()) ? "true" : "false") << "\" ";
+        cout << "interactive=\"" << ((patch->interactive()) ? "true" : "false") << "\" ";
+        cout << "resolvabletype=\"" << "patch" << "\" ";
+        cout << ">" << endl;
+        cout << "  <summary>" << xml_escape(patch->summary()) << "  </summary>" << endl;
+        cout << "  <description>" << xml_escape(patch->description()) << "</description>" << endl;
+        cout << "  <license>" << xml_escape(patch->licenseToConfirm()) << "</license>" << endl;
+        cout << "  <installnotify>" << xml_escape(patch->insnotify()) << "</installnotify>" << endl;
+  
 
-      cout << " </update>" << endl;
+        if ( patch->repository() != Repository::noRepository )
+        {
+          cout << "  <source url=\"" << *(patch->repository().info().baseUrlsBegin());
+          cout << "\" alias=\"" << patch->repository().info().alias() << "\"/>" << endl;
+        }
+  
+        cout << " </update>" << endl;
+      }
     }
   }
+
+  return pkg_mgr_available;
+
 }
 
 
index 0c783d9..27fb6a2 100644 (file)
@@ -61,7 +61,7 @@ void establish ();
 bool resolve();
 void dump_pool ();
 void show_patches();
-void xml_list_patches();
+bool xml_list_patches();
 void xml_list_updates();
 
 
index 775920f..41a0ad6 100644 (file)
@@ -1216,8 +1216,8 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
     cout << "<?xml version='1.0'?>" << endl;
     cout << "<update-status version=\"0.4\">" << endl;
     cout << "<update-list>" << endl;
-    xml_list_patches ();
-    xml_list_updates ();
+    if (!xml_list_patches ())  // Only list updates if no
+      xml_list_updates ();     // affects-pkg-mgr patches are available
     cout << "</update-list>" << endl;
     cout << "</update-status>" << endl;