Author: jkupec
Date: Mon May 19 03:11:34 2008
New Revision: 10136
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10136&view=rev
Log:
- delta support backup
- limit delta candidates by package name
- TODO: fix the deltainfo parser in sat (add missing stuff, check
attributes), beautify
Added:
trunk/libzypp/devel/devel.jkupec/deltarpm.cc
Modified:
trunk/libzypp/zypp/repo/DeltaCandidates.cc
trunk/libzypp/zypp/repo/DeltaCandidates.h
trunk/libzypp/zypp/repo/PackageDelta.cc
trunk/libzypp/zypp/repo/PackageDelta.h
trunk/libzypp/zypp/target/TargetImpl.cc
Added: trunk/libzypp/devel/devel.jkupec/deltarpm.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.jkupec/deltarpm.cc?rev=10136&view=auto
==============================================================================
--- trunk/libzypp/devel/devel.jkupec/deltarpm.cc (added)
+++ trunk/libzypp/devel/devel.jkupec/deltarpm.cc Mon May 19 03:11:34 2008
@@ -0,0 +1,183 @@
+#include
+#include <iostream>
+#include <iterator>
+#include <list>
+
+extern "C"
+{
+#include
+}
+
+#include "zypp/ZYppFactory.h"
+#include "zypp/Pathname.h"
+
+#include "zypp/RepoManager.h"
+#include "zypp/repo/DeltaCandidates.h"
+#include "zypp/PoolQuery.h"
+
+using std::cout;
+using std::endl;
+using std::string;
+using namespace zypp;
+
+
+struct PrintAndCount
+{
+ PrintAndCount() : _count(0) {}
+
+ bool operator()( const sat::Solvable & solvable )
+ {
+ zypp::PoolItem pi( zypp::ResPool::instance().find( solvable ) );
+ cout << pi.resolvable() << endl;
+ // name: yast2-sound 2.16.2-9 i586
+ ++_count;
+ return true;
+ }
+
+ unsigned _count;
+};
+
+
+
+int main (int argc, const char ** argv)
+{
+ Pathname rootdir(SRC_DIR "/data/deltarpm");
+ RepoManagerOptions opts(rootdir);
+ opts.repoRawCachePath = rootdir;
+ opts.repoSolvCachePath = rootdir;
+ RepoManager rm(opts);
+
+ RepoInfo updates;
+ updates.setAlias("updates");
+ updates.addBaseUrl(Url(string("dir:") + rootdir.absolutename().asString() + "/updates"));
+
+ RepoInfo updates2;
+ updates2.setAlias("updates2");
+ updates2.addBaseUrl(Url(string("dir:") + rootdir.absolutename().asString() + "/updates2"));
+
+ try
+ {
+ rm.buildCache(updates);
+ rm.buildCache(updates2);
+ rm.loadFromCache(updates);
+ rm.loadFromCache(updates2);
+ }
+ catch (const Exception & e)
+ {
+ cout << "Problem getting the data: " << e.msg() << endl;
+ }
+
+ sat::Pool pool(sat::Pool::instance());
+ for_(repoit, pool.reposBegin(), pool.reposEnd())
+ {
+ Repository repo(*repoit);
+ for (int i = 0; i < repo.get()->nextra; ++i)
+ {
+ cout << endl << "extra " << i << ":" << endl;
+ ::Dataiterator di;
+ ::dataiterator_init(&di, repo.get(), -1 - i, 0, 0, SEARCH_EXTRA | SEARCH_NO_STORAGE_SOLVABLE);
+ while (::dataiterator_step(&di))
+ {
+ const char * keyname;
+ keyname = ::id2str(repo.get()->pool, di.key->name);
+
+ cout << keyname << ": ";
+
+ switch (di.key->name)
+ {
+ case DELTA_PACKAGE_NAME:
+ {
+ cout << IdString(di.kv.id);
+ break;
+ }
+ /*
+ case DELTA_PACKAGE_EVR:
+ {
+ if (di.key->type == REPOKEY_TYPE_STR)
+ cout << di.kv.str;
+ else
+ cout << "...";
+ break;
+ }
+ case DELTA_PACKAGE_ARCH:
+ {
+ break;
+ }
+ */
+ case DELTA_LOCATION_DIR:
+ {
+ cout << IdString(di.kv.id);
+ break;
+ }
+ case DELTA_LOCATION_NAME:
+ {
+ cout << IdString(di.kv.id);
+ break;
+ }
+ case DELTA_LOCATION_EVR:
+ {
+ cout << IdString(di.kv.id);
+ break;
+ }
+ case DELTA_LOCATION_SUFFIX:
+ {
+ cout << IdString(di.kv.id);
+ break;
+ }
+ case DELTA_DOWNLOADSIZE:
+ {
+ cout << di.kv.num;
+ break;
+ }
+ case DELTA_CHECKSUM:
+ {
+ cout << di.kv.str;
+ break;
+ }
+ case DELTA_BASE_EVR:
+ {
+ cout << IdString(di.kv.id);
+ break;
+ }
+ case DELTA_SEQ_NAME:
+ {
+ cout << IdString(di.kv.id);
+ break;
+ }
+ case DELTA_SEQ_EVR:
+ {
+ cout << IdString(di.kv.id);
+ break;
+ }
+ case DELTA_SEQ_NUM:
+ {
+ cout << di.kv.str;
+ break;
+ }
+ default:
+ cout << "ingoring " << IdString(di.key->name) << endl;
+ }
+ cout << endl;
+ }
+ }
+ }
+
+ PoolQuery q;
+ q.addKind(ResKind::package);
+ q.addAttribute(sat::SolvAttr::name, "libzypp");
+ q.setMatchExact();
+
+ std::for_each(q.begin(), q.end(), PrintAndCount());
+
+ PoolItem pi(*q.poolItemBegin());
+ if (pi)
+ {
+ Package::constPtr p = asKind<Package>(pi.resolvable());
+
+ std::list<Repository> repos( pool.reposBegin(), pool.reposEnd() );
+ repo::DeltaCandidates deltas(repos, p->name());
+ deltas.deltaRpms(p);
+ }
+ else
+ cout << "no such package" << endl;
+}
Modified: trunk/libzypp/zypp/repo/DeltaCandidates.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/DeltaCandidates.cc?rev=10136&r1=10135&r2=10136&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/DeltaCandidates.cc (original)
+++ trunk/libzypp/zypp/repo/DeltaCandidates.cc Mon May 19 03:11:34 2008
@@ -12,6 +12,11 @@
#include "zypp/Repository.h"
#include "zypp/repo/DeltaCandidates.h"
+extern "C"
+{
+#include
+}
+
using std::endl;
using namespace zypp::packagedelta;
@@ -28,8 +33,8 @@
public:
- Impl( const std::list<Repository> & repos )
- : repos(repos)
+ Impl( const std::list<Repository> & repos, const std::string & pkgname = "" )
+ : repos(repos), pkgname(pkgname)
{
}
@@ -40,6 +45,7 @@
{ return new Impl( *this ); }
std::list<Repository> repos;
+ std::string pkgname;
};
///////////////////////////////////////////////////////////////////
@@ -49,8 +55,9 @@
return str << "DeltaCandidates::Impl";
}
- DeltaCandidates::DeltaCandidates(const std::list<Repository> & repos)
- : _pimpl( new Impl(repos) )
+ DeltaCandidates::DeltaCandidates(const std::list<Repository> & repos,
+ const std::string & pkgname)
+ : _pimpl( new Impl(repos, pkgname) )
{}
DeltaCandidates::~DeltaCandidates()
@@ -66,7 +73,7 @@
++it )
{
// all delta in repo
- #warning patchRpms are not implemented
+ #warning patchRpms are not implemented
std::list<PatchRpm> candidates_in_repo; // = (*it).patchRpms();
for ( std::list<PatchRpm>::const_iterator dit = candidates_in_repo.begin();
dit != candidates_in_repo.end();
@@ -88,27 +95,36 @@
{
std::list<DeltaRpm> candidates;
+#warning deltaRpms are not completely implemented
+
// query all repos
for ( std::list<Repository>::const_iterator it = _pimpl->repos.begin();
- it != _pimpl->repos.end();
- ++it )
+ it != _pimpl->repos.end(); ++it )
{
- // all delta in repo
- #warning deltaRpms are not implemented
- std::list<DeltaRpm> candidates_in_repo; // = (*it).deltaRpms();
- for ( std::list<DeltaRpm>::const_iterator dit = candidates_in_repo.begin();
- dit != candidates_in_repo.end();
- ++dit )
+ for (int i = 0; i < it->get()->nextra; ++i)
{
- if ( ! package
- || ( package->name() == dit->name()
- && package->edition() == dit->edition()
- && package->arch() == dit->arch() ) )
+ ::Dataiterator di;
+ ::dataiterator_init(&di
+ , it->get() // in this repo
+ , -1 - i // in this extra
+ , DELTA_PACKAGE_NAME // with this attribute
+ , _pimpl->pkgname.empty() ? 0 : _pimpl->pkgname.c_str() // of this value
+ , SEARCH_EXTRA | SEARCH_NO_STORAGE_SOLVABLE | SEARCH_STRING);
+ while (::dataiterator_step(&di))
{
- candidates.push_back( *dit );
+ DeltaRpm delta(*it, di.solvid);
+ std::cout << delta << endl;
+ if ( ! package
+ || ( package->name() == delta.name()
+ && package->edition() == delta.edition()
+ && package->arch() == delta.arch() ) )
+ {
+ candidates.push_back( delta );
+ }
}
}
}
+
return candidates;
}
Modified: trunk/libzypp/zypp/repo/DeltaCandidates.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/DeltaCandidates.h?rev=10136&r1=10135&r2=10136&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/DeltaCandidates.h (original)
+++ trunk/libzypp/zypp/repo/DeltaCandidates.h Mon May 19 03:11:34 2008
@@ -47,7 +47,7 @@
* \param repos Set of repositories providing patch and delta packages
* \param installed_callback Will be used to ask if a package is installed or not
*/
- DeltaCandidates( const std::list<Repository> & repos );
+ DeltaCandidates( const std::list<Repository> & repos, const std::string & pkgname = "" );
/** Dtor */
~DeltaCandidates();
Modified: trunk/libzypp/zypp/repo/PackageDelta.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/PackageDelta.cc?rev=10136&r1=10135&r2=10136&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/PackageDelta.cc (original)
+++ trunk/libzypp/zypp/repo/PackageDelta.cc Mon May 19 03:11:34 2008
@@ -10,12 +10,18 @@
*
*/
#include <iostream>
+extern "C"
+{
+#include
+}
#include "zypp/base/LogTools.h"
#include "zypp/repo/PackageDelta.h"
+
using std::endl;
+using std::string;
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -36,15 +42,119 @@
<< ')';
}
+ DeltaRpm::DeltaRpm(const Repository & repo, sat::detail::IdType extraid)
+ {
+ MIL << "creating deltarpm from repo " << repo.name() << ", id " << extraid << endl;
+ ::Dataiterator di;
+ ::dataiterator_init(&di, repo.get(), extraid, 0, 0, SEARCH_EXTRA | SEARCH_NO_STORAGE_SOLVABLE);
+
+ string locdir;
+ string locname;
+ string locevr;
+ string locsuffix;
+ OnMediaLocation loc;
+ BaseVersion base;
+ string seqname;
+ string seqevr;
+ string seqnum;
+
+ if (::dataiterator_step(&di))
+ {
+ do
+ {
+ switch (di.key->name)
+ {
+ case DELTA_PACKAGE_NAME:
+ {
+ setName(IdString(di.kv.id).asString());
+ break;
+ }
+ /* \todo add this to the deltainfo parser in sat
+ case DELTA_PACKAGE_EVR:
+ {
+ setEdition(Edition(di.kv.str));
+ break;
+ }
+ case DELTA_PACKAGE_ARCH:
+ {
+ setArch(Arch(di.kv.str));
+ break;
+ }
+ */
+ case DELTA_LOCATION_DIR:
+ {
+ locdir = IdString(di.kv.id).asString();
+ break;
+ }
+ case DELTA_LOCATION_NAME:
+ {
+ locname = IdString(di.kv.id).asString();
+ break;
+ }
+ case DELTA_LOCATION_EVR:
+ {
+ locevr = IdString(di.kv.id).asString();
+ break;
+ }
+ case DELTA_LOCATION_SUFFIX:
+ {
+ locsuffix = IdString(di.kv.id).asString();
+ break;
+ }
+ case DELTA_DOWNLOADSIZE:
+ {
+ loc.setDownloadSize(di.kv.num);
+ break;
+ }
+ case DELTA_CHECKSUM:
+ {
+ loc.setChecksum(CheckSum::sha1(di.kv.str));
+ break;
+ }
+ case DELTA_BASE_EVR:
+ {
+ base.setEdition(Edition(IdString(di.kv.id).asString()));
+ break;
+ }
+ case DELTA_SEQ_NAME:
+ {
+ seqname = IdString(di.kv.id).asString();
+ break;
+ }
+ case DELTA_SEQ_EVR:
+ {
+ seqevr = IdString(di.kv.id).asString();
+ break;
+ }
+ case DELTA_SEQ_NUM:
+ {
+ seqnum = di.kv.str;
+ break;
+ }
+ default:
+ WAR << "ingoring unknown attribute: " << IdString(di.key->name) << endl;
+ }
+ } while (::dataiterator_step(&di));
+ }
+ else
+ ERR << "the extra does not exist in the repo" << endl;
+
+ //! \todo FIXME here + in sat tools
+ loc.setLocation(locdir + "/" + locname + "-" + locevr + "." + locsuffix);
+ setLocation(loc);
+ base.setSequenceinfo(seqname + "-" + seqevr + "-" + seqnum);
+ setBaseversion(base);
+ }
+
std::ostream & operator<<( std::ostream & str, const DeltaRpm & obj )
{
return str
<< "DeltaRpm[" << obj.name() << "-" << obj.edition() << "." << obj.arch()
<< "](" << obj.location()
- << '|' << obj.buildtime()
+ //<< '|' << obj.buildtime()
<< '|' << obj.baseversion().edition()
- << ',' << obj.baseversion().buildtime()
- << ',' << obj.baseversion().checksum()
+ //<< ',' << obj.baseversion().buildtime()
+ //<< ',' << obj.baseversion().checksum()
<< ',' << obj.baseversion().sequenceinfo()
<< ')';
}
Modified: trunk/libzypp/zypp/repo/PackageDelta.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/PackageDelta.h?rev=10136&r1=10135&r2=10136&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/PackageDelta.h (original)
+++ trunk/libzypp/zypp/repo/PackageDelta.h Mon May 19 03:11:34 2008
@@ -20,6 +20,9 @@
#include "zypp/Arch.h"
#include "zypp/Date.h"
+#include "zypp/sat/detail/PoolMember.h"
+#include "zypp/Repository.h"
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
@@ -86,28 +89,29 @@
public:
const Edition & edition() const { return _edition; }
- const Date & buildtime() const { return _buildtime; }
- const CheckSum & checksum() const { return _checksum; }
+ //const Date & buildtime() const { return _buildtime; }
+ //const CheckSum & checksum() const { return _checksum; }
const std::string & sequenceinfo() const { return _sequenceinfo; }
public:
BaseVersion & setEdition( const Edition & val_r ) { _edition = val_r; return *this; }
- BaseVersion & setBuildtime( const Date & val_r ) { _buildtime = val_r; return *this; }
- BaseVersion & setChecksum( const CheckSum & val_r ) { _checksum = val_r; return *this; }
+ //BaseVersion & setBuildtime( const Date & val_r ) { _buildtime = val_r; return *this; }
+ //BaseVersion & setChecksum( const CheckSum & val_r ) { _checksum = val_r; return *this; }
BaseVersion & setSequenceinfo( const std::string & val_r ) { _sequenceinfo = val_r; return *this; }
private:
Edition _edition;
- Date _buildtime;
- CheckSum _checksum;
+ //Date _buildtime;
+ //CheckSum _checksum;
std::string _sequenceinfo;
};
- typedef std::list<BaseVersion> BaseVersions;
+ //typedef std::list<BaseVersion> BaseVersions;
public:
DeltaRpm()
{}
+ DeltaRpm(const Repository & repo, sat::detail::IdType id);
public:
/** \name Target package ident. */
@@ -118,7 +122,7 @@
//@}
const OnMediaLocation & location() const { return _location; }
const BaseVersion & baseversion() const { return _baseversion; }
- const Date & buildtime() const { return _buildtime;}
+ //const Date & buildtime() const { return _buildtime;}
public:
DeltaRpm & setName( const std::string & val_r ) { _name = val_r; return *this; }
@@ -126,7 +130,7 @@
DeltaRpm & setArch( const Arch & val_r ) { _arch = val_r; return *this; }
DeltaRpm & setLocation( const OnMediaLocation & val_r ) { _location = val_r; return *this; }
DeltaRpm & setBaseversion( const BaseVersion & val_r ) { _baseversion = val_r; return *this; }
- DeltaRpm & setBuildtime( const Date & val_r ) { _buildtime = val_r; return *this; }
+ //DeltaRpm & setBuildtime( const Date & val_r ) { _buildtime = val_r; return *this; }
private:
std::string _name;
@@ -134,7 +138,7 @@
Arch _arch;
OnMediaLocation _location;
BaseVersion _baseversion;
- Date _buildtime;
+ //Date _buildtime;
};
/** \relates DeltaRpm Stream output. */
Modified: trunk/libzypp/zypp/target/TargetImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=10136&r1=10135&r2=10136&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/TargetImpl.cc (original)
+++ trunk/libzypp/zypp/target/TargetImpl.cc Mon May 19 03:11:34 2008
@@ -254,7 +254,7 @@
// Build a repository list for repos
// contributing to the pool
std::list<Repository> repos( _pool.knownRepositoriesBegin(), _pool.knownRepositoriesEnd() );
- repo::DeltaCandidates deltas(repos);
+ repo::DeltaCandidates deltas(repos, p->name());
repo::PackageProvider pkgProvider( _access, p, deltas, packageProviderPolicy );
return pkgProvider.providePackage();
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org