Author: mlandres
Date: Fri Aug 15 18:50:22 2008
New Revision: 10876
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10876&view=rev
Log:
- Add method Product::replacedProducts to identify installed
Products that would be replaced by installing a new Product.
Added:
trunk/libzypp/zypp/sat/WhatObsoletes.cc
trunk/libzypp/zypp/sat/WhatObsoletes.h
Modified:
trunk/libzypp/devel/devel.ma/NewPool.cc
trunk/libzypp/package/libzypp.changes
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/Product.cc
trunk/libzypp/zypp/Product.h
trunk/libzypp/zypp/sat/WhatProvides.cc
trunk/libzypp/zypp/sat/WhatProvides.h
trunk/libzypp/zypp/ui/Selectable.h
trunk/libzypp/zypp/ui/SelectableTraits.h
Modified: trunk/libzypp/devel/devel.ma/NewPool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=10876&r1=10875&r2=10876&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/NewPool.cc (original)
+++ trunk/libzypp/devel/devel.ma/NewPool.cc Fri Aug 15 18:50:22 2008
@@ -41,6 +41,7 @@
#include "zypp/sat/SolvableSet.h"
#include "zypp/sat/SolvIterMixin.h"
#include "zypp/sat/detail/PoolImpl.h"
+#include "zypp/sat/WhatObsoletes.h"
#include "zypp/PoolQuery.h"
#include "zypp/parser/ProductConfReader.h"
@@ -528,10 +529,42 @@
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- testcase();
- MIL << "FOOO" << endl;
+ // Pool of Selectables
+ ResPoolProxy selectablePool( ResPool::instance().proxy() );
- ///////////////////////////////////////////////////////////////////
+ // Iterate it's Products...
+ for_( it, selectablePool.byKindBegin<Product>(), selectablePool.byKindEnd<Product>() )
+ {
+ // current Product Selectable
+ ui::Selectable::Ptr prodSel( *it );
+ MIL << dump( prodSel ) << endl;
+
+ // It's candiate as Product pointer
+ Product::constPtr prod( prodSel->candidateAsKind<Product>() );
+ if ( prod )
+ {
+ // Not NULL, so there is an available Product.
+ // Get the installed Products it would replace.
+ Product::ReplacedProducts prodReplaces( prod->replacedProducts() );
+
+ // Iterate the replaced Products...
+ for_( it, prodReplaces.begin(), prodReplaces.end() )
+ {
+ // current replaced Product
+ Product::constPtr replacedProduct( *it );
+ DBG << replacedProduct << endl;
+
+ // and this is how you would get the Selectable that contains
+ // this replacedProduct, in case you need it ..
+ ui::Selectable::Ptr replacedProductsSelectable( ui::Selectable::get( replacedProduct ) );
+ DBG << replacedProductsSelectable << endl;
+ }
+ }
+
+ }
+
+
+ ///////////////////////////////////////////////////////////////////
INT << "===[END]============================================" << endl << endl;
zypp::base::LogControl::instance().logNothing();
return 0;
Modified: trunk/libzypp/package/libzypp.changes
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=10876&r1=10875&r2=10876&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Fri Aug 15 18:50:22 2008
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Fri Aug 15 17:42:58 CEST 2008 - ma@suse.de
+
+- Add method Product::replacedProducts to identify installed
+ Products that would be replaced by installing a new Product.
+ (for Fate #301997)
+- revision 10876
+
+-------------------------------------------------------------------
Fri Aug 15 15:30:32 CEST 2008 - ma@suse.de
- Fixes to Selectable doing staus manipulation on non-USER level.
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=10876&r1=10875&r2=10876&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Fri Aug 15 18:50:22 2008
@@ -483,6 +483,7 @@
sat/SolvableSet.cc
sat/SolvIterMixin.cc
sat/WhatProvides.cc
+ sat/WhatObsoletes.cc
sat/LocaleSupport.cc
sat/LookupAttr.cc
sat/SolvAttr.cc
@@ -494,6 +495,7 @@
sat/SolvableSet.h
sat/SolvIterMixin.h
sat/WhatProvides.h
+ sat/WhatObsoletes.h
sat/LocaleSupport.h
sat/LookupAttr.h
sat/SolvAttr.h
Modified: trunk/libzypp/zypp/Product.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Product.cc?rev=10876&r1=10875&r2=10876&view=diff
==============================================================================
--- trunk/libzypp/zypp/Product.cc (original)
+++ trunk/libzypp/zypp/Product.cc Fri Aug 15 18:50:22 2008
@@ -17,6 +17,8 @@
#include "zypp/sat/LookupAttr.h"
#include "zypp/sat/WhatProvides.h"
+#include "zypp/sat/WhatObsoletes.h"
+#include "zypp/PoolItem.h"
using std::endl;
@@ -70,10 +72,6 @@
{}
///////////////////////////////////////////////////////////////////
- //
- // Package interface forwarded to implementation
- //
- ///////////////////////////////////////////////////////////////////
sat::Solvable Product::referencePackage() const
{
@@ -104,6 +102,35 @@
return sat::Solvable::noSolvable;
}
+ Product::ReplacedProducts Product::replacedProducts() const
+ {
+ std::vector<constPtr> ret;
+ // By now we simply collect what is obsoleted by the Product,
+ // or by the products buddy (release-package).
+
+ // Check our own dependencies. We should not have any,
+ // but just to be shure.
+ sat::WhatObsoletes obsoleting( satSolvable() );
+ for_( it, obsoleting.begin(), obsoleting.end() )
+ {
+ if ( it->isKind( ResKind::product ) )
+ ret.push_back( make<Product>( *it ) );
+ }
+
+ // If we have a buddy, we check what product buddies the
+ // buddy replaces.
+ obsoleting = sat::WhatObsoletes( poolItem().buddy() );
+ for_( it, obsoleting.poolItemBegin(), obsoleting.poolItemEnd() )
+ {
+ if ( (*it).buddy().isKind( ResKind::product ) )
+ ret.push_back( make<Product>( (*it).buddy() ) );
+ }
+
+ return ret;
+ }
+
+ ///////////////////////////////////////////////////////////////////
+
std::string Product::shortName() const
{ return lookupStrAttribute( sat::SolvAttr::productShortlabel ); }
Modified: trunk/libzypp/zypp/Product.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Product.h?rev=10876&r1=10875&r2=10876&view=diff
==============================================================================
--- trunk/libzypp/zypp/Product.h (original)
+++ trunk/libzypp/zypp/Product.h Fri Aug 15 18:50:22 2008
@@ -44,6 +44,15 @@
sat::Solvable referencePackage() const;
public:
+ /***/
+ typedef std::vector<constPtr> ReplacedProducts;
+
+ /** Array of \b installed Products that would be replaced by
+ * installing this one.
+ */
+ ReplacedProducts replacedProducts() const;
+
+ public:
/** Untranslated short name like <tt>SLES 10</tt>*/
std::string shortName() const;
Added: trunk/libzypp/zypp/sat/WhatObsoletes.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/WhatObsoletes.cc?rev=10876&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/WhatObsoletes.cc (added)
+++ trunk/libzypp/zypp/sat/WhatObsoletes.cc Fri Aug 15 18:50:22 2008
@@ -0,0 +1,114 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/WhatObsoletes.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/base/LogTools.h"
+#include "zypp/sat/WhatObsoletes.h"
+#include "zypp/sat/detail/PoolImpl.h"
+#include "zypp/PoolItem.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace sat
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ namespace
+ { /////////////////////////////////////////////////////////////////
+
+ /** WhatObsoletes ctor helper collecting obsoleted installed items. */
+ shared_ptr<void> allocatedProviders( sat::Solvable item_r, const sat::detail::IdType *& first_r )
+ {
+ WhatProvides obsoleted( item_r.obsoletes() );
+ if ( obsoleted.empty() )
+ {
+ return shared_ptr<void>();
+ }
+
+ // use allocated private data to store the result (incl. trailing NULL)
+ std::vectorsat::detail::IdType * pdata = 0;
+ shared_ptr<void> ret;
+
+ for_( it, obsoleted.begin(), obsoleted.end() )
+ {
+ if ( it->isSystem() )
+ {
+ if ( ! pdata )
+ {
+ ret.reset( (pdata = new std::vectorsat::detail::IdType) );
+ }
+ pdata->push_back( it->id() );
+ }
+ }
+
+ if ( pdata )
+ {
+ pdata->push_back( sat::detail::noId );
+ first_r = &pdata->front();
+ }
+ return ret;
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace
+ ///////////////////////////////////////////////////////////////////
+
+ WhatObsoletes::WhatObsoletes( Solvable item_r )
+ : _begin( 0 )
+ , _private( allocatedProviders( item_r, _begin ) )
+ {}
+
+ WhatObsoletes::WhatObsoletes( const PoolItem & item_r )
+ : _begin( 0 )
+ , _private( allocatedProviders( item_r.satSolvable(), _begin ) )
+ {}
+
+ WhatObsoletes::WhatObsoletes( const ResObject::constPtr item_r )
+ : _begin( 0 )
+ {
+ if ( item_r )
+ _private = allocatedProviders( item_r->satSolvable(), _begin );
+ }
+
+ WhatObsoletes::size_type WhatObsoletes::size() const
+ {
+ if ( ! _begin )
+ return 0;
+
+ Capabilities::size_type ret = 0;
+ for ( const sat::detail::IdType * end = _begin; *end; ++end )
+ {
+ ++ret;
+ }
+ return ret;
+ }
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const WhatObsoletes & obj )
+ {
+ return dumpRange( str << "(" << obj.size() << ")", obj.begin(), obj.end() );
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace sat
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
Added: trunk/libzypp/zypp/sat/WhatObsoletes.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/WhatObsoletes.h?rev=10876&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/WhatObsoletes.h (added)
+++ trunk/libzypp/zypp/sat/WhatObsoletes.h Fri Aug 15 18:50:22 2008
@@ -0,0 +1,96 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/WhatObsoletes.h
+ *
+*/
+#ifndef ZYPP_SAT_WHATOBSOLETES_H
+#define ZYPP_SAT_WHATOBSOLETES_H
+
+#include <iosfwd>
+#include <vector>
+
+#include "zypp/sat/WhatProvides.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace sat
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : WhatObsoletes
+ //
+ /** Container of \b installed \ref Solvable which would be
+ * obsoleted by the \ref Solvable passed to the ctor.
+ *
+ * \code
+ * \endcode
+ */
+ class WhatObsoletes : public SolvIterMixin