Mailinglist Archive: zypp-commit (266 mails)

< Previous Next >
[zypp-commit] r11754 - in /trunk/libzypp: devel/devel.ma/Iorder.cc devel/devel.ma/Test.cc package/libzypp.changes zypp/sat/LookupAttr.cc zypp/sat/LookupAttr.h zypp/sat/SolvAttr.cc zypp/sat/SolvAttr.h
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Thu, 20 Nov 2008 18:34:39 -0000
  • Message-id: <20081120183439.E2903E02B1@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Thu Nov 20 19:34:39 2008
New Revision: 11754

URL: http://svn.opensuse.org/viewcvs/zypp?rev=11754&view=rev
Log:
- Enhance class LookupAttr and add convenience class LookupRepoAttr to
iterate those solv file attributes which are not acssociated with a
solvable. E.g. product or deltarpm info.

Modified:
trunk/libzypp/devel/devel.ma/Iorder.cc
trunk/libzypp/devel/devel.ma/Test.cc
trunk/libzypp/package/libzypp.changes
trunk/libzypp/zypp/sat/LookupAttr.cc
trunk/libzypp/zypp/sat/LookupAttr.h
trunk/libzypp/zypp/sat/SolvAttr.cc
trunk/libzypp/zypp/sat/SolvAttr.h

Modified: trunk/libzypp/devel/devel.ma/Iorder.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Iorder.cc?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/Iorder.cc (original)
+++ trunk/libzypp/devel/devel.ma/Iorder.cc Thu Nov 20 19:34:39 2008
@@ -14,6 +14,7 @@
if ( ! rres )
{
ERR << "upgrade " << rres << endl;
+ getZYpp()->resolver()->problems();
return false;
}
MIL << "upgrade " << rres << endl;
@@ -30,6 +31,7 @@
if ( ! rres )
{
ERR << "resolve " << rres << endl;
+ getZYpp()->resolver()->problems();
return false;
}
MIL << "resolve " << rres << endl;

Modified: trunk/libzypp/devel/devel.ma/Test.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Test.cc?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/Test.cc (original)
+++ trunk/libzypp/devel/devel.ma/Test.cc Thu Nov 20 19:34:39 2008
@@ -1,40 +1,7 @@
#include "Tools.h"
#include <zypp/ResObjects.h>

-#include "zypp/pool/GetResolvablesToInsDel.h"
-
-bool upgrade()
-{
- bool rres = false;
- {
- zypp::base::LogControl::TmpLineWriter shutUp;
- UpgradeStatistics u;
- rres = getZYpp()->resolver()->doUpgrade( u );
- }
- if ( ! rres )
- {
- ERR << "upgrade " << rres << endl;
- return false;
- }
- MIL << "upgrade " << rres << endl;
- return true;
-}
-
-bool solve()
-{
- bool rres = false;
- {
- //zypp::base::LogControl::TmpLineWriter shutUp;
- rres = getZYpp()->resolver()->resolvePool();
- }
- if ( ! rres )
- {
- ERR << "resolve " << rres << endl;
- return false;
- }
- MIL << "resolve " << rres << endl;
- return true;
-}
+#include <zypp/sat/LookupAttr.h>

/******************************************************************
**
@@ -46,60 +13,16 @@
INT << "===[START]==========================================" << endl;

Pathname mroot( "/tmp/Bb" );
- TestSetup test( mroot, Arch_ppc64 );
- test.loadTarget();
- test.loadTestcaseRepos(
"/suse/ma/BUGS/439802/bug439802/YaST2/solverTestcase" );
-
- //getPi<>( "", "", Edition(""), Arch("") );
- getPi<Product>( "SUSE_SLES", Edition("11"), Arch("ppc64")
).status().setTransact( true, ResStatus::USER );
- getPi<Package>( "sles-release", Edition("11-54.3"), Arch("ppc64")
).status().setTransact( true, ResStatus::USER );
-
- ResPool pool( test.pool() );
- vdumpPoolStats( USR << "Transacting:"<< endl,
- make_filter_begin<resfilter::ByTransact>(pool),
- make_filter_end<resfilter::ByTransact>(pool) ) << endl;
- upgrade();
- vdumpPoolStats( USR << "Transacting:"<< endl,
- make_filter_begin<resfilter::ByTransact>(pool),
- make_filter_end<resfilter::ByTransact>(pool) ) << endl;
-
- pool::GetResolvablesToInsDel collect( pool,
pool::GetResolvablesToInsDel::ORDER_BY_MEDIANR );
- MIL << "GetResolvablesToInsDel:" << endl << collect << endl;
- if ( 1 )
- {
- // Collect until the 1st package from an unwanted media occurs.
- // Further collection could violate install order.
- bool hitUnwantedMedia = false;
- typedef pool::GetResolvablesToInsDel::PoolItemList PoolItemList;
- PoolItemList::iterator fst=collect._toInstall.end();
- for ( PoolItemList::iterator it = collect._toInstall.begin(); it !=
collect._toInstall.end(); ++it)
- {
- ResObject::constPtr res( it->resolvable() );
-
- if ( hitUnwantedMedia
- || ( res->mediaNr() && res->mediaNr() != 1 ) )
- {
- if ( !hitUnwantedMedia )
- fst=it;
- hitUnwantedMedia = true;
- }
- else
- {
- }
- }
- dumpRange( WAR << "toInstall1: " << endl,
- collect._toInstall.begin(), fst ) << endl;
- dumpRange( WAR << "toInstall2: " << endl,
- fst, collect._toInstall.end() ) << endl;
- dumpRange( ERR << "toDelete: " << endl,
- collect._toDelete.begin(), collect._toDelete.end() ) << endl;
- }
- else
+ TestSetup test( mroot, Arch_x86_64 );
+ test.loadRepo( "/Local/ROOT/cache/raw/11.1-update" );
+ test.loadRepo( "/Local/ROOT/cache/raw/11.0-update" );
+
+ sat::LookupRepoAttr q( sat::SolvAttr::repositoryAddedFileProvides );
+ USR << q << endl;
+ USR << dump(q) << endl;
+ for_( it, q.begin(), q.end() )
{
- dumpRange( WAR << "toInstall: " << endl,
- collect._toInstall.begin(), collect._toInstall.end() ) << endl;
- dumpRange( ERR << "toDelete: " << endl,
- collect._toDelete.begin(), collect._toDelete.end() ) << endl;
+ MIL << it << endl;
}

INT << "===[END]============================================" << endl <<
endl;

Modified: trunk/libzypp/package/libzypp.changes
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Thu Nov 20 19:34:39 2008
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Thu Nov 20 19:30:05 CET 2008 - ma@xxxxxxx
+
+- Enhance class LookupAttr and add convenience class LookupRepoAttr to
+ iterate those solv file attributes which are not acssociated with a
+ solvable. E.g. product or deltarpm info.
+- revision 11754
+
+-------------------------------------------------------------------
Wed Nov 19 15:49:38 CET 2008 - jkupec@xxxxxxx

- encode user-supplied URL strings before using them in the Url object

Modified: trunk/libzypp/zypp/sat/LookupAttr.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.cc?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttr.cc (original)
+++ trunk/libzypp/zypp/sat/LookupAttr.cc Thu Nov 20 19:34:39 2008
@@ -30,22 +30,36 @@
namespace sat
{ /////////////////////////////////////////////////////////////////

+ using detail::noSolvableId;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : LookupAttr::Impl
//
///////////////////////////////////////////////////////////////////
-
+ /**
+ * LookupAttr implememtation.
+ *
+ * Repository and Solvable must not be set at the same time!
+ *
+ * \note When looking in pool or repo, \ref Solvable \c _solv is
+ * somewhat abused to store eiter \c Id \c 0 or \c SOLVID_META, which
+ * indicates whether the dataiterator should look into solvable or
+ * repository metadata. Remember that all \ref Solvables with an
+ * \e invalid \c Id, are treated as <tt>== Solvable::noSolvable</tt>,
+ * and in a boolean context evaluate to \c false. Thus \c noSolvable
+ * may have different \c Ids.
+ */
class LookupAttr::Impl
{
public:
Impl()
{}
- Impl( SolvAttr attr_r )
- : _attr( attr_r )
+ Impl( SolvAttr attr_r, Location loc_r )
+ : _attr( attr_r ), _solv( loc_r == REPO_ATTR ? SOLVID_META :
noSolvableId )
{}
- Impl( SolvAttr attr_r, Repository repo_r )
- : _attr( attr_r ), _repo( repo_r )
+ Impl( SolvAttr attr_r, Repository repo_r, Location loc_r )
+ : _attr( attr_r ), _repo( repo_r ), _solv( loc_r == REPO_ATTR ?
SOLVID_META : noSolvableId )
{}
Impl( SolvAttr attr_r, Solvable solv_r )
: _attr( attr_r ), _solv( solv_r )
@@ -62,19 +76,19 @@
bool pool() const
{ return ! (_repo || _solv); }

- void setPool()
+ void setPool( Location loc_r )
{
_repo = Repository::noRepository;
- _solv = Solvable::noSolvable;
+ _solv = Solvable( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId );
}

Repository repo() const
{ return _repo; }

- void setRepo( Repository repo_r )
+ void setRepo( Repository repo_r, Location loc_r )
{
_repo = repo_r;
- _solv = Solvable::noSolvable;
+ _solv = Solvable( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId );
}

Solvable solvable() const
@@ -102,11 +116,11 @@
}
else if ( _repo )
{
- ::dataiterator_init( dip.get(), sat::Pool::instance().get(),
_repo.id(), 0, _attr.id(), 0, 0 );
+ ::dataiterator_init( dip.get(), sat::Pool::instance().get(),
_repo.id(), _solv.id(), _attr.id(), 0, 0 );
}
else if ( ! sat::Pool::instance().reposEmpty() )
{
- ::dataiterator_init( dip.get(), sat::Pool::instance().get(),
0, 0, _attr.id(), 0, 0 );
+ ::dataiterator_init( dip.get(), sat::Pool::instance().get(),
0, _solv.id(), _attr.id(), 0, 0 );
}
else
return end();
@@ -139,12 +153,12 @@
: _pimpl( new Impl )
{}

- LookupAttr::LookupAttr( SolvAttr attr_r )
- : _pimpl( new Impl( attr_r ) )
+ LookupAttr::LookupAttr( SolvAttr attr_r, Location loc_r )
+ : _pimpl( new Impl( attr_r, loc_r ) )
{}

- LookupAttr::LookupAttr( SolvAttr attr_r, Repository repo_r )
- : _pimpl( new Impl( attr_r, repo_r ) )
+ LookupAttr::LookupAttr( SolvAttr attr_r, Repository repo_r, Location loc_r
)
+ : _pimpl( new Impl( attr_r, repo_r, loc_r ) )
{}

LookupAttr::LookupAttr( SolvAttr attr_r, Solvable solv_r )
@@ -164,14 +178,14 @@
bool LookupAttr::pool() const
{ return _pimpl->pool(); }

- void LookupAttr::setPool()
- { _pimpl->setPool(); }
+ void LookupAttr::setPool( Location loc_r )
+ { _pimpl->setPool( loc_r ); }

Repository LookupAttr::repo() const
{ return _pimpl->repo(); }

- void LookupAttr::setRepo( Repository repo_r )
- { _pimpl->setRepo( repo_r ); }
+ void LookupAttr::setRepo( Repository repo_r, Location loc_r )
+ { _pimpl->setRepo( repo_r, loc_r ); }

Solvable LookupAttr::solvable() const
{ return _pimpl->solvable(); }
@@ -224,6 +238,19 @@

///////////////////////////////////////////////////////////////////
//
+ // CLASS NAME : LookupRepoAttr
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ LookupRepoAttr::LookupRepoAttr( SolvAttr attr_r, Repository repo_r )
+ : LookupAttr( attr_r, repo_r, REPO_ATTR )
+ {}
+
+ void LookupRepoAttr::setRepo( Repository repo_r )
+ { LookupAttr::setRepo( repo_r, REPO_ATTR ); }
+
+ ///////////////////////////////////////////////////////////////////
+ //
// CLASS NAME : LookupAttr::iterator
//
///////////////////////////////////////////////////////////////////

Modified: trunk/libzypp/zypp/sat/LookupAttr.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.h?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttr.h (original)
+++ trunk/libzypp/zypp/sat/LookupAttr.h Thu Nov 20 19:34:39 2008
@@ -44,6 +44,13 @@
* or one \ref Solvable. \ref LookupAttr builds the query,
* \ref LookupAttr::iterator iterates over the result.
*
+ * Per default \ref LookupAttr looks for attributes associated with
+ * a \ref Solvable. But you may also pass \ref REPO_ATTR as
+ * \ref Location argument, to lookup attributes associated with
+ * the \ref Repository (e.g. DeltaRpm information).
+ *
+ * For convenience \see \ref LookupRepoAttr.
+ *
* Modifying the query will not affect any running
* iterator.
*
@@ -71,21 +78,37 @@
* MIL << " " << it << endl;
* }
* \endcode
+ *
+ * \code
+ * // look for a repo attribute in the pool.
+ * sat::LookupRepoAttr q( sat::SolvAttr::repositoryAddedFileProvides );
+ * MIL << q << ": " << endl;
+ * for_( it, q.begin(), q.end() )
+ * {
+ * MIL << " " << it << endl;
+ * }
+ * \endcode
*/
class LookupAttr
{
public:
typedef unsigned size_type;

+ /** Specify the where to look for the attribule. */
+ enum Location {
+ SOLV_ATTR = 0, //!< Search for solvable attributes (default)
+ REPO_ATTR = -1 //!< Search for repository attributes
+ };
+
public:
/** Default ctor finds nothing. */
LookupAttr();

/** Lookup \ref SolvAttr in \ref Pool (all repositories). */
- explicit LookupAttr( SolvAttr attr_r );
+ explicit LookupAttr( SolvAttr attr_r, Location = SOLV_ATTR );

/** Lookup \ref SolvAttr in one\ref Repository. */
- explicit LookupAttr( SolvAttr attr_r, Repository repo_r );
+ explicit LookupAttr( SolvAttr attr_r, Repository repo_r, Location =
SOLV_ATTR );

/** Lookup \ref SolvAttr in one \ref Solvable. */
LookupAttr( SolvAttr attr_r, Solvable solv_r );
@@ -131,13 +154,13 @@
bool pool() const;

/** Set search in \ref Pool (all repositories). */
- void setPool();
+ void setPool( Location = SOLV_ATTR );

/** Wheter to search in one \ref Repository. */
Repository repo() const;

/** Set search in one \ref Repository. */
- void setRepo( Repository repo_r );
+ void setRepo( Repository repo_r, Location = SOLV_ATTR );

/** Wheter to search in one \ref Solvable. */
Solvable solvable() const;
@@ -160,6 +183,52 @@

///////////////////////////////////////////////////////////////////
//
+ // CLASS NAME : LookupRepoAttr
+ //
+ /** Lightweight repositor attribute value lookup.
+ *
+ * This is just a convenience class that overloads all
+ * \ref LookupAttr methods which take a \ref LookupAttr::Location
+ * argument and sets it to \ref REPO_ATTR.
+ *
+ * \code
+ * // look for a repo attribute in the pool:
+ * sat::LookupAttr p( sat::SolvAttr::repositoryAddedFileProvides,
sat::LookupAttr::REPO_ATTR );
+ *
+ * // Equivalent but using LookupRepoAttr:
+ * sat::LookupRepoAttr q( sat::SolvAttr::repositoryAddedFileProvides );
+ * \endcode
+ *
+ * \see \ref LookupAttr
+ */
+ class LookupRepoAttr : public LookupAttr
+ {
+ public:
+ /** \copydoc LookupAttr::LookupAttr() */
+ LookupRepoAttr()
+ {}
+ /** \copydoc LookupAttr::LookupAttr(SolvAttr) */
+ explicit LookupRepoAttr( SolvAttr attr_r )
+ : LookupAttr( attr_r, REPO_ATTR )
+ {}
+ /** \copydoc LookupAttr::LookupAttr(SolvAttr,Repository) */
+ explicit LookupRepoAttr( SolvAttr attr_r, Repository repo_r );
+
+ public:
+ /** \copydoc LookupAttr::setPool */
+ void setPool()
+ { LookupAttr::setPool( REPO_ATTR ); }
+ /** \copydoc LookupAttr::setRepo */
+ void setRepo( Repository repo_r );
+ private:
+ // Hide. You can't look inside and outside Solvables at the same time.
+ using LookupAttr::solvable;
+ using LookupAttr::setSolvable;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
// CLASS NAME : LookupAttr::iterator
//
/** Result iterator.

Modified: trunk/libzypp/zypp/sat/SolvAttr.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvAttr.cc?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/SolvAttr.cc (original)
+++ trunk/libzypp/zypp/sat/SolvAttr.cc Thu Nov 20 19:34:39 2008
@@ -124,6 +124,10 @@
const SolvAttr SolvAttr::repositoryProductCpeid( REPOSITORY_PRODUCT_CPEID );
const SolvAttr SolvAttr::repositoryKeywords ( REPOSITORY_KEYWORDS );

+ const SolvAttr SolvAttr::repositoryAddedFileProvides(
REPOSITORY_ADDEDFILEPROVIDES );
+ const SolvAttr SolvAttr::repositoryRpmDbCookie ( REPOSITORY_RPMDBCOOKIE
);
+
+
} // namespace sat
/////////////////////////////////////////////////////////////////
} // namespace zypp

Modified: trunk/libzypp/zypp/sat/SolvAttr.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvAttr.h?rev=11754&r1=11753&r2=11754&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/SolvAttr.h (original)
+++ trunk/libzypp/zypp/sat/SolvAttr.h Thu Nov 20 19:34:39 2008
@@ -154,6 +154,8 @@
static const SolvAttr repositoryProductLabel;
static const SolvAttr repositoryProductCpeid;
static const SolvAttr repositoryRevision;
+ static const SolvAttr repositoryAddedFileProvides;
+ static const SolvAttr repositoryRpmDbCookie;
//@}

//@}

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages