Imported Upstream version 1.11.44 74/109374/1 upstream/1.11.44
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 10 Jan 2017 05:27:21 +0000 (14:27 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 10 Jan 2017 05:27:22 +0000 (14:27 +0900)
Change-Id: If78d05eba9ce4abd6d3b0f07ff1082dbaee481c4
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
VERSION.cmake
package/zypper.changes
po/sle-zypper-po.tar.bz2
src/output/xmlout.rnc
src/update.cc
src/update.h

index d222d1e..ec50ece 100644 (file)
@@ -34,7 +34,7 @@
 #
 SET(VERSION_MAJOR "1")
 SET(VERSION_MINOR "11")
-SET(VERSION_PATCH "43")
+SET(VERSION_PATCH "44")
 
-# LAST RELEASED: 1.11.43
+# LAST RELEASED: 1.11.44
 #=======
index ea32f40..04b6832 100644 (file)
@@ -1,4 +1,19 @@
 -------------------------------------------------------------------
+Tue Dec  1 12:39:25 CET 2015 - ma@suse.de
+
+- lu/lp: fix different data returned in xml and text output
+  (bsc#793424, bsc#893833)
+- pchk: also report needed but locked patches
+- remove unused function
+- no using namespace std/boost
+- version 1.11.44
+
+-------------------------------------------------------------------
+Thu Nov 26 01:16:01 CET 2015 - ma@suse.de
+
+- Update sle-zypper-po.tar.bz2
+
+-------------------------------------------------------------------
 Thu Nov 19 13:29:05 CET 2015 - ma@suse.de
 
 - Fix tab-completion if zypper is defined as an alias (bsc#955615)
index d9df3c5..528fd7c 100644 (file)
Binary files a/po/sle-zypper-po.tar.bz2 and b/po/sle-zypper-po.tar.bz2 differ
index a9f57f6..9a95045 100644 (file)
@@ -77,6 +77,7 @@ update-status-element =
   element update-status {
     attribute version {xsd:string},
     element update-list { ( patch-update | other-update )* }
+    element blocked-update-list { ( patch-update )* }? # applicable patches waiting for a pending software stack update to be installed first
   }
 
 update-commons =
@@ -95,6 +96,8 @@ other-update =
   element update {
     update-commons,
     attribute kind { "package" | "pattern" | "product" }
+    attribute edition-old { xsd:string }?, # currently installed version in case of upgrade
+    attribute arch-old { xsd:string }?,    # currently installed architecture if arch changed
   }
 
 patch-update =
index 36cfcc9..93ebc6b 100755 (executable)
 #include "update.h"
 #include "main.h"
 
-using namespace std;
 using namespace zypp;
-using namespace boost;
+typedef std::set<PoolItem> Candidates;
 
 extern ZYpp::Ptr God;
 
-typedef set<PoolItem> Candidates;
-
 static void
 find_updates( const ResKindSet & kinds, Candidates & candidates );
 
+///////////////////////////////////////////////////////////////////
+namespace
+{
+  inline bool patchIsApplicable( const PoolItem & pi ) ///< Default content for all patch lists: needed and not locked
+  { return( pi.isBroken() && ! pi.isUnwanted() ); }
+} //namespace
+///////////////////////////////////////////////////////////////////
+
 // ----------------------------------------------------------------------------
 //
 // Updates
@@ -49,6 +54,7 @@ void patch_check ()
   RuntimeData & gData = Zypper::instance()->runtimeData();
   DBG << "patch check" << endl;
   gData.patches_count = gData.security_patches_count = 0;
+  unsigned lockedPatches = 0;
   bool updatestackOnly = Zypper::instance()->cOpts().count("updatestack-only");
 
   for_( it, God->pool().byKindBegin(ResKind::patch), God->pool().byKindEnd(ResKind::patch) )
@@ -56,23 +62,32 @@ void patch_check ()
     const PoolItem & pi( *it );
     if ( pi.isBroken() )
     {
-      Patch::constPtr patch( pi->asKind<Patch>() );
-      if ( !updatestackOnly || patch->restartSuggested() )
+      if ( pi.isUnwanted() )
+      { ++lockedPatches; }
+      else
       {
-       ++gData.patches_count;
-       if ( patch->categoryEnum() == Patch::CAT_SECURITY )
-         ++gData.security_patches_count;
+       Patch::constPtr patch( pi->asKind<Patch>() );
+       if ( !updatestackOnly || patch->restartSuggested() )
+       {
+         ++gData.patches_count;
+         if ( patch->categoryEnum() == Patch::CAT_SECURITY )
+           ++gData.security_patches_count;
+       }
       }
     }
   }
 
-  ostringstream s;
+  if ( lockedPatches )
+  {
+    out.info( (boost::format(_PL("%d patch locked", "%d patches locked", lockedPatches )) % lockedPatches).str(), Out::QUIET);
+  }
+  std::ostringstream s;
   // translators: %d is the number of needed patches
-  s << format(_PL("%d patch needed", "%d patches needed", gData.patches_count))
+  s << boost::format(_PL("%d patch needed", "%d patches needed", gData.patches_count))
       % gData.patches_count
     << " ("
     // translators: %d is the number of security patches
-    << format(_PL("%d security patch", "%d security patches", gData.security_patches_count))
+    << boost::format(_PL("%d security patch", "%d security patches", gData.security_patches_count))
       % gData.security_patches_count
     << ")";
   out.info(s.str(), Out::QUIET);
@@ -95,66 +110,74 @@ inline const char *const patchStatusAsString( const PoolItem & pi_r )
   return "undetermined";
 }
 
+static void xml_print_patch( Zypper & zypper, const PoolItem & pi )
+{
+  Patch::constPtr patch = pi->asKind<Patch>();
+
+  cout << " <update ";
+  cout << "name=\"" << patch->name () << "\" ";
+  cout << "edition=\""  << patch->edition() << "\" ";
+  cout << "arch=\""  << patch->arch() << "\" ";
+  cout << "status=\""  << patchStatusAsString( pi ) << "\" ";
+  cout << "category=\"" <<  patch->category() << "\" ";
+  cout << "severity=\"" <<  patch->severity() << "\" ";
+  cout << "pkgmanager=\"" << (patch->restartSuggested() ? "true" : "false") << "\" ";
+  cout << "restart=\"" << (patch->rebootSuggested() ? "true" : "false") << "\" ";
+
+  Patch::InteractiveFlags ignoreFlags = Patch::NoFlags;
+  if (zypper.globalOpts().reboot_req_non_interactive)
+    ignoreFlags |= Patch::Reboot;
+  if ( zypper.cOpts().count("auto-agree-with-licenses") || zypper.cOpts().count("agree-to-third-party-licenses") )
+    ignoreFlags |= Patch::License;
+
+  cout << "interactive=\"" << (patch->interactiveWhenIgnoring(ignoreFlags) ? "true" : "false") << "\" ";
+  cout << "kind=\"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->repoInfo().alias().empty() )
+  {
+    cout << "  <source url=\"" << xml::escape(patch->repoInfo().url().asString());
+    cout << "\" alias=\"" << xml::escape(patch->repoInfo().alias()) << "\"/>" << endl;
+  }
+
+  cout << " </update>" << endl;
+}
+
+
 // returns true if restartSuggested() patches are availble
 static bool xml_list_patches (Zypper & zypper)
 {
   const zypp::ResPool& pool = God->pool();
 
-  unsigned int patchcount=0;
-  bool pkg_mgr_available = false;
-  Patch::constPtr patch;
-
   // check whether there are packages affecting the update stack
+  bool pkg_mgr_available = false;
   for_( it, pool.byKindBegin(ResKind::patch), pool.byKindEnd(ResKind::patch) )
   {
     const PoolItem & pi( *it );
-    if ( pi.isBroken() && pi->asKind<Patch>()->restartSuggested())
+
+    if ( patchIsApplicable( pi ) && pi->asKind<Patch>()->restartSuggested() )
     {
       pkg_mgr_available = true;
       break;
     }
   }
 
+  unsigned patchcount = 0;
+  bool all = zypper.cOpts().count("all");
   for_( it, pool.byKindBegin(ResKind::patch), pool.byKindEnd(ResKind::patch) )
   {
-    if (zypper.cOpts().count("all") || it->isBroken())
+    if ( all || patchIsApplicable( *it ) )
     {
-      ResObject::constPtr res = it->resolvable();
-      Patch::constPtr patch = asKind<Patch>(res);
+      const PoolItem & pi( *it );
+      Patch::constPtr patch = pi->asKind<Patch>();
 
       // if updates stack patches are available, show only those
-      if ((pkg_mgr_available && patch->restartSuggested()) || !pkg_mgr_available)
+      if ( all || !pkg_mgr_available || patch->restartSuggested() )
       {
-        cout << " <update ";
-        cout << "name=\"" << res->name () << "\" ";
-        cout << "edition=\""  << res->edition ().asString() << "\" ";
-       cout << "arch=\""  << res->arch().asString() << "\" ";
-       cout << "status=\""  << patchStatusAsString( *it ) << "\" ";
-        cout << "category=\"" <<  patch->category() << "\" ";
-        cout << "severity=\"" <<  patch->severity() << "\" ";
-        cout << "pkgmanager=\"" << (patch->restartSuggested() ? "true" : "false") << "\" ";
-        cout << "restart=\"" << (patch->rebootSuggested() ? "true" : "false") << "\" ";
-
-        Patch::InteractiveFlags ignoreFlags = Patch::NoFlags;
-        if (zypper.globalOpts().reboot_req_non_interactive)
-          ignoreFlags |= Patch::Reboot;
-       if ( zypper.cOpts().count("auto-agree-with-licenses") || zypper.cOpts().count("agree-to-third-party-licenses") )
-         ignoreFlags |= Patch::License;
-
-        cout << "interactive=\"" << (patch->interactiveWhenIgnoring(ignoreFlags) ? "true" : "false") << "\" ";
-        cout << "kind=\"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->repoInfo().alias().empty() )
-        {
-          cout << "  <source url=\"" << xml::escape(patch->repoInfo().url().asString());
-          cout << "\" alias=\"" << xml::escape(patch->repoInfo().alias()) << "\"/>" << endl;
-        }
-
-        cout << " </update>" << endl;
+       xml_print_patch( zypper, pi );
       }
     }
     ++patchcount;
@@ -164,6 +187,28 @@ static bool xml_list_patches (Zypper & zypper)
   if (patchcount == 0)
     cout << "<appletinfo status=\"no-update-repositories\"/>" << endl;
 
+
+  if ( pkg_mgr_available )
+  {
+    // close <update-list> and write <blocked-update-list> if not all
+    cout << "</update-list>" << endl;
+    if ( ! all )
+    {
+    cout << "<blocked-update-list>" << endl;
+    for_( it, pool.byKindBegin(ResKind::patch), pool.byKindEnd(ResKind::patch) )
+    {
+      if ( patchIsApplicable( *it ) )
+      {
+       const PoolItem & pi( *it );
+       Patch::constPtr patch = pi->asKind<Patch>();
+       if ( ! patch->restartSuggested() )
+         xml_print_patch( zypper, pi );
+      }
+    }
+    cout << "</blocked-update-list>" << endl;
+    }
+  }
+
   return pkg_mgr_available;
 }
 
@@ -180,9 +225,20 @@ static void xml_list_updates(const ResKindSet & kinds)
 
     cout << " <update ";
     cout << "name=\"" << res->name () << "\" " ;
-    cout << "edition=\""  << res->edition ().asString() << "\" ";
-    cout << "arch=\""  << res->arch().asString() << "\" ";
+    cout << "edition=\""  << res->edition() << "\" ";
+    cout << "arch=\""  << res->arch() << "\" ";
     cout << "kind=\"" << res->kind() << "\" ";
+    // for packages show also the current installed version (bnc #466599)
+    {
+      ResObject::constPtr ires = ui::Selectable::get(*ci)->installedObj().resolvable();
+      if ( ires )
+      {
+       if ( res->edition() != ires->edition() )
+         cout << "edition-old=\""  << ires->edition() << "\" ";
+       if ( res->arch() != ires->arch() )
+         cout << "arch-old=\""  << ires->arch() << "\" ";
+      }
+    }
     cout << ">" << endl;
     cout << "  <summary>" << xml::escape(res->summary()) << "  </summary>" << endl;
     cout << "  <description>" << xml::escape(res->description()) << "</description>" << endl;
@@ -268,7 +324,7 @@ static bool list_patch_updates(Zypper & zypper)
     ResObject::constPtr res = it->resolvable();
 
     // show only needed and wanted/unlocked (bnc #420606) patches unless --all
-    if (all || (it->isBroken() && !it->isUnwanted()))
+    if ( all || patchIsApplicable( *it ) )
     {
       Patch::constPtr patch = asKind<Patch>(res);
       if (date_limit != Date() && patch->timestamp() > date_limit ) {
@@ -416,7 +472,7 @@ string i18n_kind_updates(const ResKind & kind)
   else if (kind == ResKind::product)
     return _("Product updates");
 
-  return boost::str(format("%s updates") % kind);
+  return boost::str(boost::format("%s updates") % kind);
 }
 
 // ----------------------------------------------------------------------------
@@ -427,6 +483,7 @@ void list_updates(Zypper & zypper, const ResKindSet & kinds, bool best_effort)
 {
   if (zypper.out().type() == Out::TYPE_XML)
   {
+    // TODO: go for XmlNode
     cout << "<update-status version=\"0.6\">" << endl;
     cout << "<update-list>" << endl;
   }
@@ -465,8 +522,10 @@ void list_updates(Zypper & zypper, const ResKindSet & kinds, bool best_effort)
   if (zypper.out().type() == Out::TYPE_XML)
   {
     if (!affects_pkgmgr)
+    {
       xml_list_updates(localkinds);
-    cout << "</update-list>" << endl;
+      cout << "</update-list>" << endl;                // otherwise closed in xml_list_patches
+    }
     cout << "</update-status>" << endl;
     return;
   }
@@ -571,7 +630,7 @@ void list_patches_by_issue(Zypper & zypper)
   // --bz, --cve can't be used together with --issue; this case is ruled out
   // in the initial arguments validation in Zypper.cc
 
-  typedef set<pair<string, string> > Issues;
+  typedef std::set<std::pair<std::string, std::string> > Issues;
   bool only_needed = !zypper.cOpts().count("all");
   bool specific = false; // whether specific issue numbers were given
 
@@ -585,7 +644,7 @@ void list_patches_by_issue(Zypper & zypper)
   if (it != zypper.cOpts().end()) \
     for_(i, it->second.begin(), it->second.end()) \
     { \
-      issues.insert(pair<string, string>(ID, *i)); \
+      issues.insert(std::pair<std::string, std::string>(ID, *i)); \
       if (!i->empty()) \
         specific = true; \
     } \
@@ -652,7 +711,7 @@ void list_patches_by_issue(Zypper & zypper)
     for_(it, q.begin(), q.end())
     {
       PoolItem pi(*it);
-      if (only_needed && (!pi.isBroken() || pi.isUnwanted()))
+      if ( only_needed && ! patchIsApplicable( pi ) )
         continue;
 
       Patch::constPtr patch = asKind<Patch>(pi.resolvable());
@@ -695,7 +754,7 @@ void list_patches_by_issue(Zypper & zypper)
     for_(it, q.begin(), q.end())
     {
       PoolItem pi(*it);
-      if (only_needed && (!pi.isBroken() || pi.isUnwanted()))
+      if ( only_needed && ! patchIsApplicable( pi ) )
         continue;
       Patch::constPtr patch = asKind<Patch>(pi.resolvable());
 
@@ -745,20 +804,20 @@ void list_patches_by_issue(Zypper & zypper)
 
 void mark_updates_by_issue(Zypper & zypper)
 {
-  typedef set<pair<string, string> > Issues;
+  typedef std::set<std::pair<std::string, std::string> > Issues;
   Issues issues;
   parsed_opts::const_iterator it = zypper.cOpts().find("bugzilla");
   if (it != zypper.cOpts().end())
     for_(i, it->second.begin(), it->second.end())
-      issues.insert(pair<string, string>("b", *i));
+      issues.insert(std::pair<std::string, std::string>("b", *i));
   it = zypper.cOpts().find("bz");
   if (it != zypper.cOpts().end())
     for_(i, it->second.begin(), it->second.end())
-      issues.insert(pair<string, string>("b", *i));
+      issues.insert(std::pair<std::string, std::string>("b", *i));
   it = zypper.cOpts().find("cve");
   if (it != zypper.cOpts().end())
     for_(i, it->second.begin(), it->second.end())
-      issues.insert(pair<string, string>("c", *i));
+      issues.insert(std::pair<std::string, std::string>("c", *i));
 
   SolverRequester::Options sropts;
   sropts.skip_interactive = zypper.cOpts().count("skip-interactive");
index 41bcf84..0984ebf 100755 (executable)
@@ -33,5 +33,3 @@ void list_patches_by_issue(Zypper & zypper);
  * in --cve or --bugzilla or --bz.
  */
 void mark_updates_by_issue(Zypper & zypper);
-
-void selectable_update_report(Zypper & zypper, const zypp::ui::Selectable & s);