Enable use of name-version.arch all together (bnc #519312).
authorJán Kupec <jkupec@suse.cz>
Thu, 9 Jul 2009 10:18:32 +0000 (12:18 +0200)
committerJán Kupec <jkupec@suse.cz>
Thu, 9 Jul 2009 10:18:32 +0000 (12:18 +0200)
src/install.cc
src/utils/misc.cc
src/utils/misc.h

index 8b72666..d63cd6d 100755 (executable)
@@ -570,7 +570,6 @@ void install_remove(Zypper & zypper,
     if ((pos = str.rfind('.')) != string::npos)
     {
       arch = str.substr(pos + 1);
-      //str = str.substr(0, pos);
       if (Arch(arch).isBuiltIn())
       {
         if (force_by_name)
@@ -584,6 +583,7 @@ void install_remove(Zypper & zypper,
 
         // name.arch is a valid capability since libzypp-4.15.0 (bnc #305445)
         by_capability = true;
+        str = str.substr(0, pos);
       }
       else
       {
@@ -640,7 +640,7 @@ void install_remove(Zypper & zypper,
 
           DBG << "trying: " << trythis << " edition: " << tryver << endl;
 
-          Capability cap = safe_parse_cap (zypper, trythis, kind);
+          Capability cap = safe_parse_cap (zypper, trythis, kind, arch);
           sat::WhatProvides q(cap);
           for_(sit, q.begin(), q.end())
           {
@@ -679,7 +679,7 @@ void install_remove(Zypper & zypper,
 
     // try by capability
 
-    Capability cap = safe_parse_cap (zypper, str, kind);
+    Capability cap = safe_parse_cap (zypper, str, kind, arch);
     sat::WhatProvides q(cap);
 
     // is there a provider for the requested capability?
index 6c44e8a..618dcd0 100644 (file)
@@ -304,7 +304,7 @@ std::string & indent(std::string & text, int columns)
   return text;
 }
 
-static string preparse_cap_str(const string & capstr)
+static string preparse_cap_str(const string & capstr, const string & arch)
 {
   // expect versioned caps as NAME[OP<EDITION>]
   // transform to NAME[ OP <EDITION>] (add spaces)
@@ -315,12 +315,15 @@ static string preparse_cap_str(const string & capstr)
   {
     new_capstr.insert(op_pos, " ");
     DBG << "new capstr: " << new_capstr << endl;
-    op_pos = new_capstr.find_first_not_of("<>=", op_pos + 1);
-    if (op_pos != string::npos && new_capstr.size() > op_pos)
+    string::size_type post_op_pos =
+      new_capstr.find_first_not_of("<>=", op_pos + 1);
+    if (post_op_pos != string::npos && new_capstr.size() > post_op_pos)
     {
-      new_capstr.insert(op_pos, " ");
-      DBG << "new capstr: " << new_capstr << endl;
+      new_capstr.insert(post_op_pos, " ");
     }
+    if (!arch.empty())
+      new_capstr.insert(op_pos, "." + arch);
+    DBG << "new capstr: " << new_capstr << endl;
   }
 
   return new_capstr;
@@ -328,14 +331,15 @@ static string preparse_cap_str(const string & capstr)
 
 Capability safe_parse_cap (Zypper & zypper,
                            const string & capstr,
-                           const ResKind & kind)
+                           const ResKind & kind,
+                           const string & arch)
 {
   try
   {
     if (kind == ResKind::nokind)
-      return Capability(preparse_cap_str(capstr));
+      return Capability(preparse_cap_str(capstr, arch));
     else
-      return Capability(preparse_cap_str(capstr), kind);
+      return Capability(preparse_cap_str(capstr, arch), kind);
   }
   catch (const Exception& e)
   {
index 67f9b7f..f8888c2 100644 (file)
@@ -86,7 +86,8 @@ std::string & indent(std::string & text, int columns);
 
 zypp::Capability safe_parse_cap (Zypper & zypper,
                                  const std::string & capstr,
-                                 const zypp::ResKind & kind = zypp::ResKind::nokind);
+                                 const zypp::ResKind & kind = zypp::ResKind::nokind,
+                                 const std::string & arch = "");
 
 
 // comparator for RepoInfo set