fixed error output when trying to install an already installed package (#224129)
authorJan Kupec <jkupec@suse.cz>
Thu, 7 Dec 2006 09:25:10 +0000 (09:25 +0000)
committerJan Kupec <jkupec@suse.cz>
Thu, 7 Dec 2006 09:25:10 +0000 (09:25 +0000)
src/zmart-misc.cc
src/zmart-misc.h

index d750757..7362255 100644 (file)
@@ -130,6 +130,11 @@ bool ProvideProcess::operator()( const PoolItem& provider )
       item = provider;
     }
   }
+  else {
+    // store encountered target item (installed)
+    installed_item = provider;
+    if (!item) item = provider;
+  }
 
   return true;
 }
@@ -156,10 +161,19 @@ void mark_for_install( const ResObject::Kind &kind,
     cerr << kind << " '" << name << "' not found" << endl;
     return; //error?
   }
-  
-  bool result = installer.item.status().setToBeInstalled( zypp::ResStatus::USER );
-  if (!result) {
-    cerr << "Failed" << endl;
+
+  if (installer.installed_item &&
+      installer.installed_item.resolvable()->edition() == installer.item.resolvable()->edition() &&
+      installer.installed_item.resolvable()->arch() == installer.item.resolvable()->arch()) {
+    cout << "skipping " << kind.asString() << " '" << name << "' (already installed)" << endl;
+  }
+  else {
+    // TODO don't use setToBeInstalled for this purpose but higher level solver API
+    bool result = installer.item.status().setToBeInstalled( zypp::ResStatus::USER );
+    if (!result) {
+      cerr << "Failed to add '" << name <<
+        "' to the list of packages to be installed." << endl;
+    }
   }
 }
 
index d6123ac..ac46cc3 100644 (file)
@@ -45,6 +45,7 @@ bool confirm_licenses(bool non_interactive = false);
 struct ProvideProcess
 {
   zypp::PoolItem_Ref item;
+  zypp::PoolItem_Ref installed_item;
   zypp::ResStatus::TransactByValue whoWantsIt;
   std::string version;
   zypp::Arch _architecture;