Author: mlandres Date: Mon Aug 4 19:41:32 2008 New Revision: 10742 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10742&view=rev Log: - 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. Modified: trunk/libzypp/devel/devel.ma/NewPool.cc trunk/libzypp/devel/devel.ma/Tools.h trunk/libzypp/package/libzypp.changes trunk/libzypp/zypp/PoolItem.cc trunk/libzypp/zypp/PoolItem.h trunk/libzypp/zypp/Product.cc trunk/libzypp/zypp/Product.h trunk/libzypp/zypp/pool/PoolImpl.h trunk/libzypp/zypp/sat/SolvAttr.cc trunk/libzypp/zypp/sat/SolvAttr.h Modified: trunk/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=10742&r1=10741&r2=10742&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/NewPool.cc (original) +++ trunk/libzypp/devel/devel.ma/NewPool.cc Mon Aug 4 19:41:32 2008 @@ -16,7 +16,6 @@ #include "zypp/ResPoolProxy.h" #include "zypp/ZYppCallbacks.h" -#include "zypp/NVRAD.h" #include "zypp/ResPool.h" #include "zypp/ResFilters.h" #include "zypp/ResObjects.h" @@ -33,7 +32,6 @@ #include "zypp/repo/PackageProvider.h" -#include "zypp/ui/PatchContents.h" #include "zypp/ResPoolProxy.h" #include "zypp/sat/Pool.h" @@ -262,46 +260,12 @@ bool install() { - SEC << getZYpp()->commit( ZYppCommitPolicy().dryRun() ) << endl; + SEC << getZYpp()->commit( ZYppCommitPolicy().dryRun(true) ) << endl; return true; } /////////////////////////////////////////////////////////////////// -struct ConvertDbReceive : public callback::ReceiveReporttarget::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() @@ -576,7 +540,24 @@ //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() ); Modified: trunk/libzypp/devel/devel.ma/Tools.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Tools.h?rev=10742&r1=10741&r2=10742&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/Tools.h (original) +++ trunk/libzypp/devel/devel.ma/Tools.h Mon Aug 4 19:41:32 2008 @@ -49,12 +49,11 @@ 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 ) ) { Modified: trunk/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=10742&r1=10741&r2=10742&view=diff ============================================================================== --- trunk/libzypp/package/libzypp.changes (original) +++ trunk/libzypp/package/libzypp.changes Mon Aug 4 19:41:32 2008 @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +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> Modified: trunk/libzypp/zypp/PoolItem.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolItem.cc?rev=10742&r1=10741&r2=10742&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolItem.cc (original) +++ trunk/libzypp/zypp/PoolItem.cc Mon Aug 4 19:41:32 2008 @@ -11,6 +11,7 @@ */ #include <iostream> #include "zypp/base/Logger.h" +#include "zypp/base/DefaultIntegral.h" #include "zypp/PoolItem.h" #include "zypp/ResPool.h" @@ -27,7 +28,12 @@ // // 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: @@ -40,7 +46,18 @@ {} 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; } @@ -76,6 +93,7 @@ private: mutable ResStatus _status; ResObject::constPtr _resolvable; + DefaultIntegralsat::detail::IdType,sat::detail::noId _buddy; /** \name Poor man's save/restore state. * \todo There may be better save/restore state strategies. @@ -83,15 +101,15 @@ //@{ 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; } @@ -120,6 +138,17 @@ 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 @@ -168,7 +197,9 @@ // 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() ) ); + } /////////////////////////////////////////////////////////////////// // @@ -198,6 +229,12 @@ 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(); } Modified: trunk/libzypp/zypp/PoolItem.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolItem.h?rev=10742&r1=10741&r2=10742&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolItem.h (original) +++ trunk/libzypp/zypp/PoolItem.h Mon Aug 4 19:41:32 2008 @@ -106,6 +106,11 @@ 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-> @@ -128,9 +133,12 @@ { 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 */ Modified: trunk/libzypp/zypp/Product.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Product.cc?rev=10742&r1=10741&r2=10742&view=diff ============================================================================== --- trunk/libzypp/zypp/Product.cc (original) +++ trunk/libzypp/zypp/Product.cc Mon Aug 4 19:41:32 2008 @@ -16,6 +16,7 @@ #include "zypp/Url.h" #include "zypp/sat/LookupAttr.h" +#include "zypp/sat/WhatProvides.h" using std::endl; @@ -74,6 +75,28 @@ // /////////////////////////////////////////////////////////////////// + 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 ); } Modified: trunk/libzypp/zypp/Product.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Product.h?rev=10742&r1=10741&r2=10742&view=diff ============================================================================== --- trunk/libzypp/zypp/Product.h (original) +++ trunk/libzypp/zypp/Product.h Mon Aug 4 19:41:32 2008 @@ -25,7 +25,7 @@ /////////////////////////////////////////////////////////////////// // - // CLASS NAME : ResObject + // CLASS NAME : Product // /** Product interface. */ @@ -38,6 +38,15 @@ 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; Modified: trunk/libzypp/zypp/pool/PoolImpl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/pool/PoolImpl.h?rev=10742&r1=10741&r2=10742&view=diff ============================================================================== --- trunk/libzypp/zypp/pool/PoolImpl.h (original) +++ trunk/libzypp/zypp/pool/PoolImpl.h Mon Aug 4 19:41:32 2008 @@ -24,6 +24,7 @@ #include "zypp/PoolQueryResult.h" #include "zypp/sat/Pool.h" +#include "zypp/Product.h" using std::endl; @@ -364,6 +365,7 @@ { sat::Pool pool( satpool() ); bool addedItems = false; + std::list<PoolItem> addedProducts; if ( pool.capacity() != _store.capacity() ) { @@ -385,7 +387,10 @@ { // 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 ); @@ -397,8 +402,18 @@ } _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(); Modified: trunk/libzypp/zypp/sat/SolvAttr.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvAttr.cc?rev=10742&r1=10741&r2=10742&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/SolvAttr.cc (original) +++ trunk/libzypp/zypp/sat/SolvAttr.cc Mon Aug 4 19:41:32 2008 @@ -54,10 +54,10 @@ 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" ); @@ -96,6 +96,7 @@ 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 ); @@ -105,6 +106,7 @@ 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 ); Modified: trunk/libzypp/zypp/sat/SolvAttr.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvAttr.h?rev=10742&r1=10741&r2=10742&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/SolvAttr.h (original) +++ trunk/libzypp/zypp/sat/SolvAttr.h Mon Aug 4 19:41:32 2008 @@ -121,6 +121,7 @@ /** \name product */ //@{ + static const SolvAttr productReferences; // the package providing the metadata static const SolvAttr productShortlabel; static const SolvAttr productDistproduct; static const SolvAttr productDistversion; @@ -130,6 +131,7 @@ static const SolvAttr productExtraurls; static const SolvAttr productOptionalurls; static const SolvAttr productFlags; + static const SolvAttr productFlavor; //@} /** \name repository */ -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org