From 0cba44f8dbcd970bd2e09acea5e3cd80228a9ac6 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Thu, 7 Dec 2006 09:25:10 +0000 Subject: [PATCH] fixed error output when trying to install an already installed package (#224129) --- src/zmart-misc.cc | 22 ++++++++++++++++++---- src/zmart-misc.h | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/zmart-misc.cc b/src/zmart-misc.cc index d750757..7362255 100644 --- a/src/zmart-misc.cc +++ b/src/zmart-misc.cc @@ -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; + } } } diff --git a/src/zmart-misc.h b/src/zmart-misc.h index d6123ac..ac46cc3 100644 --- a/src/zmart-misc.h +++ b/src/zmart-misc.h @@ -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; -- 2.7.4