#include "zypp/ResPoolProxy.h"
#include "zypp/ZYppCallbacks.h"
-#include "zypp/NVRAD.h"
#include "zypp/ResPool.h"
#include "zypp/ResFilters.h"
#include "zypp/ResObjects.h"
#include "zypp/repo/PackageProvider.h"
-#include "zypp/ui/PatchContents.h"
#include "zypp/ResPoolProxy.h"
#include "zypp/sat/Pool.h"
bool install()
{
- SEC << getZYpp()->commit( ZYppCommitPolicy().dryRun() ) << endl;
+ SEC << getZYpp()->commit( ZYppCommitPolicy().dryRun(true) ) << endl;
return true;
}
///////////////////////////////////////////////////////////////////
-struct ConvertDbReceive : public callback::ReceiveReport<target::ScriptResolvableReport>
-{
- virtual void start( const Resolvable::constPtr & script_r,
- const Pathname & path_r,
- Task task_r )
- {
- SEC << __FUNCTION__ << endl
- << " " << script_r << endl
- << " " << path_r << endl
- << " " << task_r << endl;
- }
-
- virtual bool progress( Notify notify_r, const std::string & text_r )
- {
- SEC << __FUNCTION__ << endl
- << " " << notify_r << endl
- << " " << text_r << endl;
- return true;
- }
-
- virtual void problem( const std::string & description_r )
- {
- SEC << __FUNCTION__ << endl
- << " " << description_r << endl;
- }
-
- virtual void finish()
- {
- SEC << __FUNCTION__ << endl;
- }
-
-};
-///////////////////////////////////////////////////////////////////
-
struct DigestReceive : public callback::ReceiveReport<DigestReport>
{
DigestReceive()
//SEC << zypp::getZYpp()->diskUsage() << endl;
//vdumpPoolStats( USR << "Pool:"<< endl, pool.begin(), pool.end() ) << endl;
- //waitForInput();
+
+ sat::WhatProvides prodcap( Capability("product()") );
+ dumpRange( WAR << "Product ", pool.byKindBegin<Product>(), pool.byKindEnd<Product>() ) << endl;
+ dumpRange( WAR << "ProdPac " , prodcap.poolItemBegin(), prodcap.poolItemEnd() ) << endl;
+
+ prodcap.poolItemBegin()->status().setTransact( true, ResStatus::APPL_LOW );
+ dumpRange( WAR << "Product ", pool.byKindBegin<Product>(), pool.byKindEnd<Product>() ) << endl;
+ dumpRange( WAR << "ProdPac " , prodcap.poolItemBegin(), prodcap.poolItemEnd() ) << endl;
+
+ pool.byKindBegin<Product>()->status().setTransact( true, ResStatus::USER );
+ dumpRange( WAR << "Product ", pool.byKindBegin<Product>(), pool.byKindEnd<Product>() ) << endl;
+ dumpRange( WAR << "ProdPac " , prodcap.poolItemBegin(), prodcap.poolItemEnd() ) << endl;
+
+ prodcap.poolItemBegin()->status().setLock( true, ResStatus::USER );
+ dumpRange( WAR << "Product ", pool.byKindBegin<Product>(), pool.byKindEnd<Product>() ) << endl;
+ dumpRange( WAR << "ProdPac " , prodcap.poolItemBegin(), prodcap.poolItemEnd() ) << endl;
+
+
//std::for_each( pool.begin(), pool.end(), Xprint() );
void mksrc( const std::string & url, const std::string & alias, RepoManager & repoManager )
{
RepoInfo nrepo;
- nrepo
- .setAlias( alias )
- .setName( alias )
- .setEnabled( true )
- .setAutorefresh( false )
- .addBaseUrl( Url(url) );
+ nrepo.setAlias( alias );
+ nrepo.setName( alias );
+ nrepo.setEnabled( true );
+ nrepo.setAutorefresh( false );
+ nrepo.addBaseUrl( Url(url) );
if ( ! repoManager.isCached( nrepo ) )
{
-------------------------------------------------------------------
+Mon Aug 4 19:34:27 CEST 2008 ma@suse.de
+
+- Add new product attributes (flavor,referencePackage).
+- Add PoolItem buddies, i.e. two PoolItems sharing the same status
+ object. This is used to keep the product resolvable and the
+ package providing the product metadata in sync.
+- revision 10742
+
+-------------------------------------------------------------------
Sat Aug 2 19:26:52 CEST 2008 - jkupec@suse.cz
- support an optional url attribute in repoindex.xml's <repo>
*/
#include <iostream>
#include "zypp/base/Logger.h"
+#include "zypp/base/DefaultIntegral.h"
#include "zypp/PoolItem.h"
#include "zypp/ResPool.h"
//
// CLASS NAME : PoolItem::Impl
//
- /** PoolItem implementation. */
+ /** PoolItem implementation.
+ * \c _buddy handling:
+ * \li \c ==0 no buddy
+ * \li \c >0 this uses \c _buddy status
+ * \li \c <0 this status used by \c -_buddy
+ */
struct PoolItem::Impl
{
public:
{}
ResStatus & status() const
- { return _status; }
+ { return _buddy > 0 ? PoolItem(buddy()).status() : _status; }
+
+ sat::Solvable buddy() const
+ {
+ if ( !_buddy )
+ return sat::Solvable::noSolvable;
+ if ( _buddy < 0 )
+ return sat::Solvable( -_buddy );
+ return sat::Solvable( _buddy );
+ }
+
+ void setBuddy( sat::Solvable solv_r );
ResObject::constPtr resolvable() const
{ return _resolvable; }
private:
mutable ResStatus _status;
ResObject::constPtr _resolvable;
+ DefaultIntegral<sat::detail::IdType,sat::detail::noId> _buddy;
/** \name Poor man's save/restore state.
* \todo There may be better save/restore state strategies.
//@{
public:
void saveState() const
- { _savedStatus = _status; }
+ { _savedStatus = status(); }
void restoreState() const
- { _status = _savedStatus; }
+ { status() = _savedStatus; }
bool sameState() const
{
- if ( _status.getTransactValue() != _savedStatus.getTransactValue()
- && !_status.isBySolver() )
+ if ( status().getTransactValue() != _savedStatus.getTransactValue()
+ && !status().isBySolver() )
return false;
- if ( _status.isLicenceConfirmed() != _savedStatus.isLicenceConfirmed() )
+ if ( status().isLicenceConfirmed() != _savedStatus.isLicenceConfirmed() )
return false;
return true;
}
return str;
}
+ inline void PoolItem::Impl::setBuddy( sat::Solvable solv_r )
+ {
+ PoolItem myBuddy( solv_r );
+ if ( myBuddy )
+ {
+ myBuddy._pimpl->_buddy = -resolvable()->satSolvable().id();
+ _buddy = myBuddy.satSolvable().id();
+ DBG << *this << " has buddy " << myBuddy << endl;
+ }
+ }
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : PoolItem
// METHOD TYPE : PoolItem
//
PoolItem PoolItem::makePoolItem( const sat::Solvable & solvable_r )
- { return PoolItem( new Impl( makeResObject( solvable_r ), solvable_r.isSystem() ) ); }
+ {
+ return PoolItem( new Impl( makeResObject( solvable_r ), solvable_r.isSystem() ) );
+ }
///////////////////////////////////////////////////////////////////
//
ResStatus & PoolItem::statusReset() const
{ return _pimpl->statusReset(); }
+ sat::Solvable PoolItem::buddy() const
+ { return _pimpl->buddy(); }
+
+ void PoolItem::setBuddy( sat::Solvable solv_r )
+ { _pimpl->setBuddy( solv_r ); }
+
bool PoolItem::isUndetermined() const
{ return _pimpl->isUndetermined(); }
sat::Solvable satSolvable() const
{ return resolvable() ? resolvable()->satSolvable() : sat::Solvable::noSolvable; }
+ /** Return the buddy we share our status object with.
+ * A \ref Product e.g. may share it's status with an associated reference \ref Package.
+ */
+ sat::Solvable buddy() const;
+
public:
/** Returns the ResObject::constPtr.
* \see \ref operator->
{ return resolvable(); }
private:
+ friend class Impl;
friend class pool::PoolImpl;
/** \ref PoolItem generator for \ref pool::PoolImpl. */
static PoolItem makePoolItem( const sat::Solvable & solvable_r );
+ /** Buddies are set by \ref pool::PoolImpl.*/
+ void setBuddy( sat::Solvable solv_r );
/** internal ctor */
explicit PoolItem( Impl * implptr_r );
/** Pointer to implementation */
#include "zypp/Url.h"
#include "zypp/sat/LookupAttr.h"
+#include "zypp/sat/WhatProvides.h"
using std::endl;
//
///////////////////////////////////////////////////////////////////
+ sat::Solvable Product::referencePackage() const
+ {
+ Capability identCap( lookupStrAttribute( sat::SolvAttr::productReferences ) );
+ if ( ! identCap )
+ return sat::Solvable::noSolvable;
+
+ // if there is productReferences defined, we expect
+ // a matching package within the same repo.
+ sat::WhatProvides providers( identCap );
+ for_( it, providers.begin(), providers.end() )
+ {
+ if ( it->repository() == repository() )
+ return *it;
+ }
+
+ WAR << *this << ": no reference package found: " << identCap << endl;
+ return sat::Solvable::noSolvable;
+ }
+
+ std::string Product::flavor() const
+ { return lookupStrAttribute( sat::SolvAttr::productFlavor ); }
+
std::string Product::type() const
{ return lookupStrAttribute( sat::SolvAttr::productType ); }
///////////////////////////////////////////////////////////////////
//
- // CLASS NAME : ResObject
+ // CLASS NAME : Product
//
/** Product interface.
*/
typedef TraitsType::constPtrType constPtr;
public:
+ /** The reference package providing the product metadata,
+ * if such a package exists.
+ */
+ sat::Solvable referencePackage() const;
+
+ public:
+ /** The product flavor (LiveCD Demo, FTP edition,...).*/
+ std::string flavor() const;
+
/** Get the product type (base, add-on) */
std::string type() const;
#include "zypp/PoolQueryResult.h"
#include "zypp/sat/Pool.h"
+#include "zypp/Product.h"
using std::endl;
{
sat::Pool pool( satpool() );
bool addedItems = false;
+ std::list<PoolItem> addedProducts;
if ( pool.capacity() != _store.capacity() )
{
{
// new PoolItem to add
pi = PoolItem::makePoolItem( s ); // the only way to create a new one!
- // and on the fly check for wek locks...
+ // remember products for buddy processing (requires clean store)
+ if ( s.isKind( ResKind::product ) )
+ addedProducts.push_back( pi );
+ // and on the fly check for weak locks...
if ( autoSoftLockAppliesTo( s ) )
{
pi.status().setSoftLock( ResStatus::USER );
}
_storeDirty = false;
- // Now, as the pool is adjusted, we must reapply those query
- // based hard locks...
+ // Now, as the pool is adjusted, ....
+
+ // .... we check for product buddies.
+ if ( ! addedProducts.empty() )
+ {
+ for_( it, addedProducts.begin(), addedProducts.end() )
+ {
+ it->setBuddy( asKind<Product>(*it)->referencePackage() );
+ }
+ }
+
+ // .... we must reapply those query based hard locks.
if ( addedItems )
{
reapplyHardLocks();
const SolvAttr SolvAttr::mediafile ( SOLVABLE_MEDIAFILE );
const SolvAttr SolvAttr::mediadir ( SOLVABLE_MEDIADIR );
const SolvAttr SolvAttr::changelog ( "changelog" );
- const SolvAttr SolvAttr::buildhost ( "buildhost" );
- const SolvAttr SolvAttr::distribution ( "distribution" );
+ const SolvAttr SolvAttr::buildhost ( SOLVABLE_BUILDHOST );
+ const SolvAttr SolvAttr::distribution ( SOLVABLE_DISTRIBUTION );
const SolvAttr SolvAttr::license ( SOLVABLE_LICENSE );
- const SolvAttr SolvAttr::packager ( "packager" );
+ const SolvAttr SolvAttr::packager ( SOLVABLE_PACKAGER );
const SolvAttr SolvAttr::group ( SOLVABLE_GROUP );
const SolvAttr SolvAttr::keywords ( SOLVABLE_KEYWORDS );
const SolvAttr SolvAttr::sourcesize ( "sourcesize" );
const SolvAttr SolvAttr::extends ( SOLVABLE_EXTENDS );
// product
+ const SolvAttr SolvAttr::productReferences ( PRODUCT_REFERENCES );
const SolvAttr SolvAttr::productShortlabel ( PRODUCT_SHORTLABEL );
const SolvAttr SolvAttr::productDistproduct ( PRODUCT_DISTPRODUCT );
const SolvAttr SolvAttr::productDistversion ( PRODUCT_DISTVERSION );
const SolvAttr SolvAttr::productExtraurls ( PRODUCT_EXTRAURLS );
const SolvAttr SolvAttr::productOptionalurls ( PRODUCT_OPTIONALURLS );
const SolvAttr SolvAttr::productFlags ( PRODUCT_FLAGS );
+ const SolvAttr SolvAttr::productFlavor ( PRODUCT_FLAVOR );
// repository
const SolvAttr SolvAttr::repositoryTimestamp ( REPOSITORY_TIMESTAMP );
/** \name product */
//@{
+ static const SolvAttr productReferences; // the package providing the metadata
static const SolvAttr productShortlabel;
static const SolvAttr productDistproduct;
static const SolvAttr productDistversion;
static const SolvAttr productExtraurls;
static const SolvAttr productOptionalurls;
static const SolvAttr productFlags;
+ static const SolvAttr productFlavor;
//@}
/** \name repository */