Skip locked patches in lp and patch (bnc #420606)
authorJán Kupec <jkupec@suse.cz>
Tue, 12 Oct 2010 14:19:20 +0000 (16:19 +0200)
committerJán Kupec <jkupec@suse.cz>
Tue, 12 Oct 2010 14:19:20 +0000 (16:19 +0200)
src/RequestFeedback.cc
src/SolverRequester.cc
src/SolverRequester.h
src/update.cc

index 53f7e1f..54f4cf8 100644 (file)
@@ -186,6 +186,15 @@ string SolverRequester::Feedback::asUserString(
     return str::form(_("Patch '%s' is not needed."), pname.str().c_str());
   }
 
+  case PATCH_UNWANTED:
+  {
+    ostringstream pname;
+    pname << _objsel->name() << "-" << _objsel->edition();
+    string cmd = "zypper rl patch:" + _objsel->name();
+    return str::form(_("Patch '%s' is locked. Use '%s' to install it, or unlock it using '%s'."),
+        pname.str().c_str(), "--force", cmd.c_str());
+  }
+
   case SET_TO_INSTALL:
     return str::form(
         _("Selecting '%s' from repository '%s' for installation."),
@@ -240,6 +249,7 @@ void SolverRequester::Feedback::print(
   case UPD_CANDIDATE_IS_LOCKED:
   case SELECTED_IS_OLDER:
   case PATCH_NOT_NEEDED:
+  case PATCH_UNWANTED:
   case FORCED_INSTALL:
     out.info(asUserString(opts));
     break;
index 43526b3..5359c52 100644 (file)
@@ -380,6 +380,14 @@ bool SolverRequester::installPatch(
         addFeedback(Feedback::PATCH_INTERACTIVE_SKIPPED, patchspec, selected);
         return false;
       }
+      else if (selected.isUnwanted())
+      {
+        if (_command == ZypperCommand::INSTALL || _command == ZypperCommand::UPDATE)
+        {
+          DBG << "candidate patch " << patch << " is locked" << endl;
+          addFeedback(Feedback::PATCH_UNWANTED, patchspec, selected, selected);
+        }
+      }
       else
       {
         // TODO use _opts.force
index c269ca7..45a01f3 100644 (file)
@@ -145,6 +145,15 @@ public:
        */
       PATCH_INTERACTIVE_SKIPPED,
 
+      /**
+       * Patch was requested (install/update command), but it's locked
+       * (set to ignore). Its installation can be forced with --force.
+       *
+       * In the 'patch' command, do not issue this feedback, silently skip
+       * the unwanted patch.
+       */
+      PATCH_UNWANTED,
+
       // ********** zypp requests *********************************************
 
       SET_TO_INSTALL,
index 036769d..0b9978d 100755 (executable)
@@ -200,7 +200,8 @@ static bool list_patch_updates(Zypper & zypper)
   {
     ResObject::constPtr res = it->resolvable();
 
-    if (all || it->isBroken())
+    // show only needed and wanted/unlocked (bnc #420606) patches unless --all
+    if (all || (it->isBroken() && !it->isUnwanted()))
     {
       Patch::constPtr patch = asKind<Patch>(res);
 
@@ -618,12 +619,12 @@ mark_patch_updates( Zypper & zypper, bool skip_interactive )
 
 void list_patches_by_issue(Zypper & zypper)
 {
-  // lu --issues               - list all issues which need to be fixed
-  // lu --issues=foo           - look for foo in issue # or description
-  // lu --bz                   - list all bugzilla issues
-  // lu --cve                  - list all CVE issues
-  // lu --bz=foo --cve=foo     - look for foo in bugzillas or CVEs
-  // --all                     - list all, not only needed patches
+  // lp --issues               - list all issues which need to be fixed
+  // lp --issues=foo           - look for foo in issue # or description
+  // lp --bz, --bugzilla       - list all bugzilla issues
+  // lp --cve                  - list all CVE issues
+  // lp --bz=foo --cve=foo     - look for foo in bugzillas or CVEs
+  // lp --all                  - list all, not only needed patches
 
   // --bz, --cve can't be used together with --issue; this case is ruled out
   // in the initial arguments validation in Zypper.cc
@@ -709,7 +710,7 @@ void list_patches_by_issue(Zypper & zypper)
     for_(it, q.begin(), q.end())
     {
       PoolItem pi(*it);
-      if (only_needed && !pi.status().isBroken())
+      if (only_needed && (!pi.isBroken() || pi.isUnwanted()))
         continue;
 
       Patch::constPtr patch = asKind<Patch>(pi.resolvable());
@@ -750,7 +751,7 @@ void list_patches_by_issue(Zypper & zypper)
     for_(it, q.begin(), q.end())
     {
       PoolItem pi(*it);
-      if (only_needed && !pi.status().isBroken())
+      if (only_needed && (!pi.isBroken() || pi.isUnwanted()))
         continue;
       Patch::constPtr patch = asKind<Patch>(pi.resolvable());