Mailinglist Archive: zypp-commit (266 mails)

< Previous Next >
[zypp-commit] r11719 - in /trunk/libzypp: devel/devel.ma/ package/ tests/lib/ zypp/ zypp/sat/ zypp/sat/detail/
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Wed, 19 Nov 2008 14:24:43 -0000
  • Message-id: <20081119142444.287369E580@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Wed Nov 19 15:24:43 2008
New Revision: 11719

URL: http://svn.opensuse.org/viewcvs/zypp?rev=11719&view=rev
Log:
- Support loading helix files.

Modified:
trunk/libzypp/devel/devel.ma/Test.cc
trunk/libzypp/devel/devel.ma/Tools.h
trunk/libzypp/package/libzypp.changes
trunk/libzypp/tests/lib/TestSetup.h
trunk/libzypp/zypp/Repository.cc
trunk/libzypp/zypp/Repository.h
trunk/libzypp/zypp/sat/Pool.cc
trunk/libzypp/zypp/sat/Pool.h
trunk/libzypp/zypp/sat/detail/PoolImpl.cc
trunk/libzypp/zypp/sat/detail/PoolImpl.h

Modified: trunk/libzypp/devel/devel.ma/Test.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Test.cc?rev=11719&r1=11718&r2=11719&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/Test.cc (original)
+++ trunk/libzypp/devel/devel.ma/Test.cc Wed Nov 19 15:24:43 2008
@@ -1,6 +1,11 @@
#include "Tools.h"
#include <zypp/ResObjects.h>

+#include "zypp/IdString.h"
+#include "zypp/Glob.h"
+
+using filesystem::Glob;
+
/******************************************************************
**
** FUNCTION NAME : main
@@ -10,22 +15,26 @@
{
INT << "===[START]==========================================" << endl;

- // https://bugzilla.novell.com/show_bug.cgi?id=442200
Pathname mroot( "/tmp/Bb" );
TestSetup test( mroot, Arch_x86_64 );
- test.loadRepos();

- ResPool pool( test.pool() );
- for_( it, pool.byKindBegin<Patch>(), pool.byKindEnd<Patch>() )
+ //test.loadRepos();
+ test.loadTestcaseRepos( "/suse/ma/BUGS/153548/YaST2/solverTestcase" );
+
+ sat::Pool satpool( test.satpool() );
+ for_( it, satpool.reposBegin(), satpool.reposEnd() )
{
- Patch::constPtr p( (*it)->asKind<Patch>() );
- MIL << p << endl;
- for_( i, p->referencesBegin(), p->referencesEnd() )
- {
- DBG << i.href() << endl;
- }
+ MIL << *it << endl;
}

+ INT << "===[END]============================================" << endl <<
endl;
+ return 0;
+
+ ResPool pool( test.pool() );
+ for_( it, pool.byKindBegin<Product>(), pool.byKindEnd<Product>() )
+ {
+ MIL << *it << endl;
+ }

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

Modified: trunk/libzypp/devel/devel.ma/Tools.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Tools.h?rev=11719&r1=11718&r2=11719&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/Tools.h (original)
+++ trunk/libzypp/devel/devel.ma/Tools.h Wed Nov 19 15:24:43 2008
@@ -42,6 +42,13 @@

///////////////////////////////////////////////////////////////////

+template<typename T>
+void whichType( T )
+{ INT << __PRETTY_FUNCTION__ << endl; }
+template<typename T>
+void whichType()
+{ INT << __PRETTY_FUNCTION__ << endl; }
+
void waitForInput()
{
int i;

Modified: trunk/libzypp/package/libzypp.changes
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=11719&r1=11718&r2=11719&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Wed Nov 19 15:24:43 2008
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Wed Nov 19 15:15:14 CET 2008 - ma@xxxxxxx
+
+- Support loading helix files.
+- revision 11719
+
+-------------------------------------------------------------------
Tue Nov 18 18:37:30 CET 2008 - ma@xxxxxxx

- Add class filesystem::Glob to find pathnames matching a pattern

Modified: trunk/libzypp/tests/lib/TestSetup.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/lib/TestSetup.h?rev=11719&r1=11718&r2=11719&view=diff
==============================================================================
--- trunk/libzypp/tests/lib/TestSetup.h (original)
+++ trunk/libzypp/tests/lib/TestSetup.h Wed Nov 19 15:24:43 2008
@@ -12,6 +12,7 @@
#include "zypp/ZYppFactory.h"
#include "zypp/ZYpp.h"
#include "zypp/TmpPath.h"
+#include "zypp/Glob.h"
#include "zypp/PathInfo.h"
#include "zypp/RepoManager.h"
#include "zypp/Target.h"
@@ -38,6 +39,9 @@
*
* BOOST_AUTO_TEST_CASE(WhatProvides)
* {
+ * // enabls loging fot the scope of this block:
+ * // base::LogControl::TmpLineWriter shutUp( new log::FileLineWriter(
"/tmp/YLOG" ) );
+ *
* TestSetup test( Arch_x86_64 );
* // test.loadTarget(); // initialize and load target
* test.loadRepo( TESTS_SRC_DIR"/data/openSUSE-11.1" );
@@ -79,7 +83,11 @@
/** Fake @System repo from Path. */
void loadTargetRepo( const Pathname & path_r )
{ loadRepo( path_r, sat::Pool::systemRepoAlias() ); }
+ /** Fake @System repo from helix repo. */
+ void loadTargetHelix( const Pathname & path_r )
+ { loadHelix( path_r, sat::Pool::systemRepoAlias() ); }

+ public:
/** Directly load repoinfo to pool. */
void loadRepo( RepoInfo nrepo )
{
@@ -136,6 +144,39 @@
{ loadRepo( std::string( loc_r ? loc_r : "" ), alias_r ); }

public:
+ /** Directly load a helix repo from some testcase.
+ * An empty alias is guessed.
+ */
+ void loadHelix( const Pathname & path_r, const std::string & alias_r =
std::string() )
+ {
+ // .solv file is loaded directly using a faked RepoInfo
+ RepoInfo nrepo;
+ nrepo.setAlias( alias_r.empty() ? path_r.basename() : alias_r );
+ satpool().addRepoHelix( path_r, nrepo );
+ }
+
+ // Load repos included in a solver testcase.
+ void loadTestcaseRepos( const Pathname & path_r )
+ {
+ if ( ! filesystem::PathInfo( path_r ).isDir() )
+ {
+ ERR << "No dir " << filesystem::PathInfo( path_r ) << endl;
+ return;
+ }
+ filesystem::Glob files( path_r/"*{.xml,.xml.gz}",
filesystem::Glob::_BRACE );
+ for_( it, files.begin(), files.end() )
+ {
+ std::string basename( Pathname::basename( *it ) );
+ if ( str::hasPrefix( basename, "solver-test.xml" ) )
+ continue; // master index currently unevaluated
+ if ( str::hasPrefix( basename, "solver-system.xml" ) )
+ loadTargetHelix( *it );
+ else
+ loadHelix( *it );
+ }
+ }
+
+ public:
/** Load all enabled repos in repos.d to pool. */
void loadRepos()
{

Modified: trunk/libzypp/zypp/Repository.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.cc?rev=11719&r1=11718&r2=11719&view=diff
==============================================================================
--- trunk/libzypp/zypp/Repository.cc (original)
+++ trunk/libzypp/zypp/Repository.cc Wed Nov 19 15:24:43 2008
@@ -258,6 +258,28 @@
MIL << *this << " after adding " << file_r << endl;
}

+ void Repository::addHelix( const Pathname & file_r )
+ {
+ NO_REPOSITORY_THROW( Exception( "Can't add solvables to norepo." ) );
+
+ std::string command( file_r.extension() == ".gz" ? "zcat " : "cat " );
+ command += file_r.asString();
+
+ AutoDispose<FILE*> file( ::popen( command.c_str(), "r" ), ::pclose );
+ if ( file == NULL )
+ {
+ file.resetDispose();
+ ZYPP_THROW( Exception( "Can't open helix-file: "+file_r.asString() ) );
+ }
+
+ if ( myPool()._addHelix( _repo, file ) != 0 )
+ {
+ ZYPP_THROW( Exception( "Error reading helix-file: "+file_r.asString()
) );
+ }
+
+ MIL << *this << " after adding " << file_r << endl;
+ }
+
sat::detail::SolvableIdType Repository::addSolvables( unsigned count_r )
{
NO_REPOSITORY_THROW( Exception( "Can't add solvables to norepo.") );

Modified: trunk/libzypp/zypp/Repository.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.h?rev=11719&r1=11718&r2=11719&view=diff
==============================================================================
--- trunk/libzypp/zypp/Repository.h (original)
+++ trunk/libzypp/zypp/Repository.h Wed Nov 19 15:24:43 2008
@@ -211,7 +211,16 @@
*/
void addSolv( const Pathname & file_r );

- /** Add \c count_r new empty \ref Solvable to this \ref Repository. */
+ /** Load \ref Solvables from a helix-file.
+ * Supports loading of gzip compressed files (.gz). In case of an
exception
+ * the repository remains in the \ref Pool.
+ * \throws Exception if this is \ref noRepository
+ * \throws Exception if loading the helix-file fails.
+ * \see \ref Pool::addRepoHelix and \ref Repository::EraseFromPool
+ */
+ void addHelix( const Pathname & file_r );
+
+ /** Add \c count_r new empty \ref Solvable to this \ref Repository. */
sat::Solvable::IdType addSolvables( unsigned count_r );
/** \overload Add only one new \ref Solvable. */
sat::Solvable::IdType addSolvable()

Modified: trunk/libzypp/zypp/sat/Pool.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Pool.cc?rev=11719&r1=11718&r2=11719&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Pool.cc (original)
+++ trunk/libzypp/zypp/sat/Pool.cc Wed Nov 19 15:24:43 2008
@@ -160,6 +160,30 @@

/////////////////////////////////////////////////////////////////

+ Repository Pool::addRepoHelix( const Pathname & file_r, const std::string
& alias_r )
+ {
+ // Using a temporay repo! (The additional parenthesis are required.)
+ AutoDispose<Repository> tmprepo( (Repository::EraseFromPool()) );
+ *tmprepo = reposInsert( alias_r );
+ tmprepo->addHelix( file_r );
+
+ // no exceptions so we keep it:
+ tmprepo.resetDispose();
+ return tmprepo;
+ }
+
+ Repository Pool::addRepoHelix( const Pathname & file_r )
+ { return addRepoHelix( file_r, file_r.basename() ); }
+
+ Repository Pool::addRepoHelix( const Pathname & file_r, const RepoInfo &
info_r )
+ {
+ Repository ret( addRepoHelix( file_r, info_r.alias() ) );
+ ret.setInfo( info_r );
+ return ret;
+ }
+
+ /////////////////////////////////////////////////////////////////
+
void Pool::setRequestedLocales( const LocaleSet & locales_r )
{ myPool().setRequestedLocales( locales_r ); }


Modified: trunk/libzypp/zypp/sat/Pool.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Pool.h?rev=11719&r1=11718&r2=11719&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Pool.h (original)
+++ trunk/libzypp/zypp/sat/Pool.h Wed Nov 19 15:24:43 2008
@@ -120,6 +120,21 @@
Repository addRepoSolv( const Pathname & file_r, const RepoInfo &
info_r );

public:
+ /** Load \ref Solvables from a helix-file into a \ref Repository named
\c name_r.
+ * Supports loading of gzip compressed files (.gz). In case of an
exception
+ * the \ref Repository is removed from the \ref Pool.
+ * \throws Exception if loading the helix-file fails.
+ * \see \ref Repository::EraseFromPool
+ */
+ Repository addRepoHelix( const Pathname & file_r, const std::string &
name_r );
+ /** \overload Using the files basename as \ref Repository name. */
+ Repository addRepoHelix( const Pathname & file_r );
+ /** \overload Using the \ref RepoInfo::alias \ref Repo name.
+ * Additionally stores the \ref RepoInfo. \See \ref Prool::setInfo.
+ */
+ Repository addRepoHelix( const Pathname & file_r, const RepoInfo &
info_r );
+
+ public:
/** Whether \ref Pool contains solvables. */
bool solvablesEmpty() const;


Modified: trunk/libzypp/zypp/sat/detail/PoolImpl.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/detail/PoolImpl.cc?rev=11719&r1=11718&r2=11719&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/detail/PoolImpl.cc (original)
+++ trunk/libzypp/zypp/sat/detail/PoolImpl.cc Wed Nov 19 15:24:43 2008
@@ -260,17 +260,32 @@
int PoolImpl::_addSolv( ::_Repo * repo_r, FILE * file_r )
{
setDirty(__FUNCTION__, repo_r->name );
- int ret = ::repo_add_solv( repo_r , file_r );
- if ( ret == 0 && ! isSystemRepo( repo_r ) )
+ int ret = ::repo_add_solv( repo_r , file_r );
+ if ( ret == 0 )
+ _postRepoAdd( repo_r );
+ return ret;
+ }
+
+ int PoolImpl::_addHelix( ::_Repo * repo_r, FILE * file_r )
+ {
+ setDirty(__FUNCTION__, repo_r->name );
+ ::repo_add_helix( repo_r , file_r, 0 ); // unfortunately void
+ _postRepoAdd( repo_r );
+ return 0;
+ }
+
+ void PoolImpl::_postRepoAdd( ::_Repo * repo_r )
+ {
+ if ( ! isSystemRepo( repo_r ) )
{
- // Filter out unwanted archs
+ // Filter out unwanted archs
std::set<detail::IdType> sysids;
{
Arch::CompatSet sysarchs( Arch::compatSet(
ZConfig::instance().systemArchitecture() ) );
for_( it, sysarchs.begin(), sysarchs.end() )
- sysids.insert( it->id() );
+ sysids.insert( it->id() );

- // unfortunately satsolver treats src/nosrc as architecture:
+ // unfortunately satsolver treats src/nosrc as architecture:
sysids.insert( ARCH_SRC );
sysids.insert( ARCH_NOSRC );
}
@@ -279,29 +294,28 @@
unsigned blockSize = 0;
for ( detail::IdType i = repo_r->start; i < repo_r->end; ++i )
{
- ::_Solvable * s( _pool->solvables + i );
- if ( s->repo == repo_r && sysids.find( s->arch ) == sysids.end() )
- {
- // Remember an unwanted arch entry:
- if ( ! blockBegin )
- blockBegin = i;
- ++blockSize;
- }
- else if ( blockSize )
- {
- // Free remembered entries
- ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
/*reuseids*/false );
- blockBegin = blockSize = 0;
- }
+ ::_Solvable * s( _pool->solvables + i );
+ if ( s->repo == repo_r && sysids.find( s->arch ) == sysids.end()
)
+ {
+ // Remember an unwanted arch entry:
+ if ( ! blockBegin )
+ blockBegin = i;
+ ++blockSize;
+ }
+ else if ( blockSize )
+ {
+ // Free remembered entries
+ ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
/*reuseids*/false );
+ blockBegin = blockSize = 0;
+ }
}
if ( blockSize )
{
- // Free remembered entries
- ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
/*reuseids*/false );
- blockBegin = blockSize = 0;
+ // Free remembered entries
+ ::repo_free_solvable_block( repo_r, blockBegin, blockSize,
/*reuseids*/false );
+ blockBegin = blockSize = 0;
}
}
- return ret;
}

detail::SolvableIdType PoolImpl::_addSolvables( ::_Repo * repo_r,
unsigned count_r )

Modified: trunk/libzypp/zypp/sat/detail/PoolImpl.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/detail/PoolImpl.h?rev=11719&r1=11718&r2=11719&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/detail/PoolImpl.h (original)
+++ trunk/libzypp/zypp/sat/detail/PoolImpl.h Wed Nov 19 15:24:43 2008
@@ -18,6 +18,7 @@
#include <satsolver/solvable.h>
#include <satsolver/poolarch.h>
#include <satsolver/repo_solv.h>
+#include <satsolver/repo_helix.h>
}
#include <iosfwd>

@@ -109,10 +110,19 @@
*/
int _addSolv( ::_Repo * repo_r, FILE * file_r );

+ /** Adding helix file to a repo.
+ * Except for \c isSystemRepo_r, solvables of incompatible
architecture
+ * are filtered out.
+ */
+ int _addHelix( ::_Repo * repo_r, FILE * file_r );
+
/** Adding Solvables to a repo. */
detail::SolvableIdType _addSolvables( ::_Repo * repo_r, unsigned
count_r );
//@}

+ /** Helper postprocessing the repo aftr adding solv or helix files.
*/
+ void _postRepoAdd( ::_Repo * repo_r );
+
public:
/** a \c valid \ref Solvable has a non NULL repo pointer. */
bool validSolvable( const ::_Solvable & slv_r ) const

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

< Previous Next >
This Thread
  • No further messages