Author: lslezak
Date: Wed Mar 5 17:31:09 2008
New Revision: 45233
URL: http://svn.opensuse.org/viewcvs/yast?rev=45233&view=rev
Log:
- use zypp::sat::WhatProvides instead of obsoleted byCapability
iterators
- 2.16.16
Modified:
trunk/pkg-bindings/VERSION
trunk/pkg-bindings/package/yast2-pkg-bindings.changes
trunk/pkg-bindings/src/Package.cc
Modified: trunk/pkg-bindings/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/VERSION?rev=45233&r1=45232&r2=45233&view=diff
==============================================================================
--- trunk/pkg-bindings/VERSION (original)
+++ trunk/pkg-bindings/VERSION Wed Mar 5 17:31:09 2008
@@ -1 +1 @@
-2.16.15
+2.16.16
Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=45233&r1=45232&r2=45233&view=diff
==============================================================================
--- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original)
+++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Wed Mar 5 17:31:09 2008
@@ -4,6 +4,9 @@
- added Pkg::CallbackStartRefresh() and Pkg::CallbackDoneRefresh()
callbacks, added Pkg::SkipRefresh() call to abort and skip
running source refresh (FATE #30962, bnc #231745)
+- use zypp::sat::WhatProvides instead of obsoleted byCapability
+ iterators
+- 2.16.16
-------------------------------------------------------------------
Wed Feb 27 09:04:14 CET 2008 - lslezak@suse.cz
Modified: trunk/pkg-bindings/src/Package.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Package.cc?rev=45233&r1=45232&r2=45233&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Package.cc (original)
+++ trunk/pkg-bindings/src/Package.cc Wed Mar 5 17:31:09 2008
@@ -47,6 +47,8 @@
#include
#include
+#include
+
#include <fstream>
#include <sstream>
@@ -96,60 +98,64 @@
YCPList ret;
std::string name = tag->value();
- // 'it' is 'const struct std::pair >'
- for (zypp::ResPool::byCapabilityIndex_iterator it = zypp_ptr()->pool().byCapabilityIndexBegin(name, zypp::Dep::PROVIDES);
- it != zypp_ptr()->pool().byCapabilityIndexEnd(name, zypp::Dep::PROVIDES);
- ++it)
- {
- // is it a package?
- if (zypp::isKindzypp::Package(it->item.resolvable()))
- {
-
- // cast to Package object
- zypp::Package::constPtr package = zypp::dynamic_pointer_cast<const zypp::Package>(it->item.resolvable());
- std::string pkgname = package->name();
-
- // get instance status
- bool installed = it->item.status().staysInstalled();
- std::string instance;
+ zypp::Capability cap(name, zypp::ResKind::package);
+ zypp::sat::WhatProvides possibleProviders(cap);
-# warning Status `NONE and `INST is not supported
- // TODO FIXME the other values??
- if (installed)
- {
- instance = "BOTH";
- }
- else
- {
- instance = "CAND";
- }
+ for_(iter, possibleProviders.begin(), possibleProviders.end())
+ {
+ zypp::PoolItem provider = zypp::ResPool::instance().find(*iter);
- // get status on the system
- bool uninstalled = it->item.status().staysUninstalled() || it->item.status().isToBeUninstalled();
- std::string onSystem;
+ // cast to Package object
+ zypp::Package::constPtr package = zypp::dynamic_pointer_cast<const zypp::Package>(provider.resolvable());
- if (uninstalled)
- {
- onSystem = "NONE";
- }
- else if (installed)
- {
- onSystem = "INST";
- }
- else
- {
- onSystem = "CAND";
- }
+ if (!package)
+ {
+ y2internal("Casting to Package failed!");
+ continue;
+ }
- // create list item
- YCPList item;
- item->add(YCPString(pkgname));
- item->add(YCPSymbol(instance));
- item->add(YCPSymbol(onSystem));
+ std::string pkgname = package->name();
- // add the item to the result
- ret->add(item);
+ // get instance status
+ bool installed = provider.status().staysInstalled();
+ std::string instance;
+
+# warning Status `NONE and `INST is not supported
+ // TODO FIXME the other values??
+ if (installed)
+ {
+ instance = "BOTH";
+ }
+ else
+ {
+ instance = "CAND";
+ }
+
+ // get status on the system
+ bool uninstalled = provider.status().staysUninstalled() || provider.status().isToBeUninstalled();
+ std::string onSystem;
+
+ if (uninstalled)
+ {
+ onSystem = "NONE";
+ }
+ else if (installed)
+ {
+ onSystem = "INST";
}
+ else
+ {
+ onSystem = "CAND";
+ }
+
+ // create list item
+ YCPList item;
+ item->add(YCPString(pkgname));
+ item->add(YCPSymbol(instance));
+ item->add(YCPSymbol(onSystem));
+
+ // add the item to the result
+ ret->add(item);
}
return ret;
@@ -421,26 +427,25 @@
if (name.empty())
return YCPBoolean (false);
- y2milestone("IsProvided called");
+ // look for packages
+ zypp::Capability cap(name, zypp::ResKind::package);
+ zypp::sat::WhatProvides possibleProviders(cap);
- zypp::Dep dep( zypp::Dep::PROVIDES );
- CaIMatch match;
-
- // look for installed packages
-
- try
- {
- invokeOnEach( zypp_ptr()->pool().byCapabilityIndexBegin( name, dep ),
- zypp_ptr()->pool().byCapabilityIndexEnd( name, dep ),
- zypp::functor::chain( zypp::resfilter::ByCaIInstalled (),
- zypp::resfilter::ByCaIKind( zypp::ResTraitszypp::Package::kind ) ),
- zypp::functor::functorRef( match ) );
- }
- catch (...)
+ for_(iter, possibleProviders.begin(), possibleProviders.end())
{
+ zypp::PoolItem provider = zypp::ResPool::instance().find(*iter);
+
+ // is it installed?
+ if (provider.status().isInstalled())
+ {
+ y2milestone("Tag %s is provided by %s", name.c_str(), provider->name().c_str());
+ return YCPBoolean(true);
+ }
}
- return YCPBoolean( match.item );
+ y2milestone("Tag %s is not provided", name.c_str());
+
+ return YCPBoolean(false);
}
@@ -463,24 +468,25 @@
if (name.empty())
return YCPBoolean (false);
- zypp::Dep dep( zypp::Dep::PROVIDES );
- CaIMatch match;
+ // look for packages
+ zypp::Capability cap(name, zypp::ResKind::package);
+ zypp::sat::WhatProvides possibleProviders(cap);
- try
- {
- // look for to-be-installed packages
- invokeOnEach( zypp_ptr()->pool().byCapabilityIndexBegin( name, dep ),
- zypp_ptr()->pool().byCapabilityIndexEnd( name, dep ),
- zypp::functor::chain( zypp::resfilter::ByCaIUninstalled(),
- zypp::functor::chain( zypp::resfilter::ByCaITransact(),
- zypp::resfilter::ByCaIKind( zypp::ResTraitszypp::Package::kind ) ) ),
- zypp::functor::functorRef( match ) );
- }
- catch (...)
+ for_(iter, possibleProviders.begin(), possibleProviders.end())
{
+ zypp::PoolItem provider = zypp::ResPool::instance().find(*iter);
+
+ // is it installed?
+ if (provider.status().isToBeInstalled())
+ {
+ y2milestone("Tag %s provided by %s is selected to install", name.c_str(), provider->name().c_str());
+ return YCPBoolean(true);
+ }
}
- return YCPBoolean( match.item );
+ y2milestone("Tag %s is not selected to install", name.c_str());
+
+ return YCPBoolean(false);
}
// ------------------------
@@ -501,28 +507,29 @@
YCPValue
PkgFunctions::IsAvailable (const YCPString& tag)
{
- y2milestone("IsAvailable called");
std::string name = tag->value ();
if (name.empty())
return YCPBoolean (false);
- zypp::Dep dep( zypp::Dep::PROVIDES );
- CaIMatch match;
+ // look for packages
+ zypp::Capability cap(name, zypp::ResKind::package);
+ zypp::sat::WhatProvides possibleProviders(cap);
- try
- {
- // look for uninstalled packages
- invokeOnEach( zypp_ptr()->pool().byCapabilityIndexBegin( name, dep ),
- zypp_ptr()->pool().byCapabilityIndexEnd( name, dep ),
- zypp::functor::chain( zypp::resfilter::ByCaIUninstalled(),
- zypp::resfilter::ByCaIKind( zypp::ResTraitszypp::Package::kind ) ),
- zypp::functor::functorRef( match ) );
- }
- catch (...)
+ for_(iter, possibleProviders.begin(), possibleProviders.end())
{
+ zypp::PoolItem provider = zypp::ResPool::instance().find(*iter);
+
+ // is it installed?
+ if (!provider.status().isInstalled())
+ {
+ y2milestone("Tag %s provided by %s is available to install", name.c_str(), provider->name().c_str());
+ return YCPBoolean(true);
+ }
}
- return YCPBoolean( match.item );
+ y2milestone("Tag %s is not available to install", name.c_str());
+
+ return YCPBoolean(false);
}
YCPValue
@@ -692,30 +699,27 @@
bool
PkgFunctions::DoRemoveNameKind( const std::string & name, zypp::Resolvable::Kind kind)
{
- zypp::Dep dep( zypp::Dep::PROVIDES );
- CaIMatch match;
+ zypp::Capability cap(name, kind);
+ zypp::sat::WhatProvides possibleProviders(cap);
- try
- {
- // look for installed packages
- invokeOnEach( zypp_ptr()->pool().byCapabilityIndexBegin( name, dep ),
- zypp_ptr()->pool().byCapabilityIndexEnd( name, dep ),
- zypp::functor::chain( zypp::resfilter::ByCaIInstalled(),
- zypp::resfilter::ByCaIKind( kind ) ),
- zypp::functor::functorRef( match ) );
- }
- catch (...)
+ bool ret = false;
+
+ for_(iter, possibleProviders.begin(), possibleProviders.end())
{
- return false;
- }
+ zypp::PoolItem provider = zypp::ResPool::instance().find(*iter);
- if (!match.item)
- return false;
+ // get instance status
+ bool installed = provider.status().isInstalled();
- bool result = match.item.status().setToBeUninstalled( whoWantsIt );
- y2milestone ("DoRemoveNameKind %s -> %s\n", name.c_str(), (result ? "Ok" : "Bad"));
+ if (installed)
+ {
+ bool result = provider.status().setToBeUninstalled(whoWantsIt);
+ y2milestone("DoRemoveNameKind %s -> %s\n", name.c_str(), (result ? "Ok" : "Bad"));
+ ret = true;
+ }
+ }
- return true;
+ return ret;
}
// ------------------------
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org