uggly bool flag.
- dont clear the store each time Target::resolvables is called
- Load target resolvables on demand by kind, keep them cached later
- add Target::resolvablesByKind(kind) to allow query specific kind
without reading all kinds. Used to port TargetProduct, which
was reading the whole rpm database only to displayy base product
name in YaST help.
- commit to pkg-bindings and packager following.
- jsrain will port more stuff, especially inst_source which
startup time should by reduced by half afterwards.
AM_CXXFLAGS =
# gperf: -pg
-LDADD = -L$(top_srcdir)/zypp/.libs -lzypp -lboost_regex -lxml2 -lz
+LDADD = -L$(top_srcdir)/zypp/.libs -L$(top_srcdir)/zypp2/.libs -lzypp -lzypp2 -lboost_regex -lxml2 -lz
## ##################################################
.PHONY: always
-$(noinst_PROGRAMS): $(top_srcdir)/zypp/lib@PACKAGE@.la
+$(noinst_PROGRAMS): $(top_srcdir)/zypp/lib@PACKAGE@.la $(top_srcdir)/zypp2/lib@PACKAGE@2.la
$(top_srcdir)/zypp/lib@PACKAGE@.la: always
$(MAKE) -C $(top_srcdir)/zypp
#include "zypp/KeyRing.h"
#include "zypp/PublicKey.h"
+#include "zypp/ZYppFactory.h"
+
#include "zypp/MediaSetAccess.h"
-#include "zypp/source/yum/YUMSourceCacher.h"
+#include "zypp2/source/yum/YUMSourceCacher.h"
using namespace zypp::detail;
//MIL << local << std::endl;
try
{
- zypp::source::yum::YUMSourceCacher cacher(Pathname("/"));
- cacher.cache( Url("http://ftp-1.gwdg.de/pub/opensuse/distribution/SL-OSS-factory/inst-source/suse"), Pathname("/"));
+ //zypp::source::yum::YUMSourceCacher cacher(Pathname("/"));
+ //cacher.cache( Url("dir:/space/tmp/factory-yum"), Pathname("/"));
+ ZYpp::Ptr z = getZYpp();
+ z->initTarget("/", false);
+
}
catch ( const Exception &e )
{
if (mediaorder) {
cout << endl;
RESULT << "Media Order:" << endl << endl;
- God->initTarget("/", true); // init, but don't populate pool
+ God->initTarget("/"); // init, but don't populate pool
Target::PoolItemList dellist;
Target::PoolItemList inslist;
Target::PoolItemList srclist;
cerr << "Can't aquire ZYPP lock" << endl;
return 1;
}
- God->initTarget("/", false);
+ God->initTarget("/");
int argpos = 1;
while ( argpos < argc - 1 )
int main()
{
- getZYpp()->initTarget("/", false);
+ getZYpp()->initTarget("/");
try
{
//RUN_TEST(armstrong_yum_source_source_read);
const ResStore & Target::resolvables()
{ return _pimpl->resolvables(); }
+ ResStore Target::resolvablesByKind( const Resolvable::Kind kind )
+ { return _pimpl->resolvablesByKind(kind); }
+
target::rpm::RpmDb & Target::rpmDb()
{ return _pimpl->rpm(); }
/** All resolvables provided by the target. */
const ResStore & resolvables();
+ /**
+ * load resolvables of certain kind in the internal store
+ * and return a store with only that kind
+ * successive calls will be faster as resolvables are cached-
+ */
+ ResStore resolvablesByKind( const Resolvable::Kind kind );
+
+
/** Null implementation */
static Target_Ptr nullimpl();
Target_Ptr ZYpp::target() const
{ return _pimpl->target(); }
- void ZYpp::initTarget(const Pathname & root, bool commit_only)
- { _pimpl->initTarget(root, commit_only); }
+ void ZYpp::initTarget(const Pathname & root)
+ { _pimpl->initTarget(root); }
void ZYpp::finishTarget()
{ _pimpl->finishTarget(); }
/**
* \throws Exception
- * if commit_only == true, just init, don't populate store or pool
*/
- void initTarget(const Pathname & root, bool commit_only = false);
+ void initTarget(const Pathname & root);
/**
* \throws Exception
#include "zypp/Resolvable.h"
#include "zypp/ResObject.h"
#include "zypp/Package.h"
+#include "zypp/Pattern.h"
+#include "zypp/Selection.h"
#include "zypp/Script.h"
#include "zypp/Message.h"
#include "zypp/Source.h"
// METHOD TYPE : Ctor
//
TargetImpl::TargetImpl(const Pathname & root_r)
- : _root(root_r)
+ : _root(root_r), _storage_enabled(false)
{
_rpm.initDatabase(root_r);
- _storage_enabled = false;
MIL << "Initialized target on " << _root << endl;
}
return _root;
}
- const ResStore & TargetImpl::resolvables()
+ void TargetImpl::loadKindResolvables( const Resolvable::Kind kind )
{
- _store.clear();
- // RPM objects
- std::list<Package::Ptr> packages = _rpm.getPackages();
- for (std::list<Package::Ptr>::const_iterator it = packages.begin();
- it != packages.end();
- it++)
- {
- _store.insert(*it);
- }
+ if ( _resstore_loaded[kind] )
+ return;
- if ( isStorageEnabled() )
+ if ( kind == ResTraits<zypp::Package>::kind )
{
- // resolvables stored in the zypp storage database
- std::list<ResObject::Ptr> resolvables = _storage.storedObjects();
- for (std::list<ResObject::Ptr>::iterator it = resolvables.begin();
- it != resolvables.end();
+ std::list<Package::Ptr> packages = _rpm.getPackages();
+ for (std::list<Package::Ptr>::const_iterator it = packages.begin();
+ it != packages.end();
it++)
- {
- _store.insert(*it);
- }
+ {
+ _store.insert(*it);
+ }
+ _resstore_loaded[kind] = true;
}
else
{
- WAR << "storage target not enabled" << std::endl;
+ if ( isStorageEnabled() )
+ {
+ // resolvables stored in the zypp storage database
+ std::list<ResObject::Ptr> resolvables = _storage.storedObjects(kind);
+ for (std::list<ResObject::Ptr>::iterator it = resolvables.begin();
+ it != resolvables.end();
+ it++)
+ {
+ _store.insert(*it);
+ }
+ }
+ else
+ {
+ WAR << "storage target not enabled" << std::endl;
+ }
+ _resstore_loaded[kind] = true;
+ } // end switch
+ }
+
+ ResStore TargetImpl::resolvablesByKind( const Resolvable::Kind kind )
+ {
+ ResStore tmp_store;
+
+ // load all resolvables of Kind kind in internal store
+ loadKindResolvables(kind);
+
+ for (ResStore::const_iterator it = _store.begin(); it != _store.end(); ++it)
+ {
+ // insert them in the tmp store we will return
+ if ((*it)->kind() == kind) {
+ tmp_store.insert(*it);
+ }
}
+ return tmp_store;
+ }
+ const ResStore & TargetImpl::resolvables()
+ {
+ loadKindResolvables( ResTraits<zypp::Patch>::kind );
+ loadKindResolvables( ResTraits<zypp::Selection>::kind );
+ loadKindResolvables( ResTraits<zypp::Pattern>::kind );
+ loadKindResolvables( ResTraits<zypp::Product>::kind );
+ loadKindResolvables( ResTraits<zypp::Language>::kind );
+ loadKindResolvables( ResTraits<zypp::Package>::kind );
return _store;
}
-
-
ZYppCommitResult TargetImpl::commit( ResPool pool_r, const ZYppCommitPolicy & policy_rX )
{
// ----------------------------------------------------------------- //
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/NonCopyable.h"
+#include "zypp/base/DefaultFalseBool.h"
#include "zypp/base/PtrTypes.h"
#include "zypp/ResStore.h"
#include "zypp/PoolItem.h"
/** All resolvables in the target. */
const ResStore & resolvables();
+ /**
+ * resolvables of certain kind
+ */
+ ResStore resolvablesByKind( const Resolvable::Kind kind );
+
/** The root set for this target */
Pathname root() const;
Date timestamp() const;
protected:
+ void loadKindResolvables( const Resolvable::Kind kind );
/** All resolvables provided by the target. */
ResStore _store;
/** Path to the target */
#ifndef STORAGE_DISABLED
zypp::storage::PersistentStorage _storage;
bool _storage_enabled;
+ std::map< const Resolvable::Kind, DefaultFalseBool> _resstore_loaded;
#endif
private:
/** Null implementation */
return _target;
}
- void ZYppImpl::initTarget(const Pathname & root, bool commit_only)
+ void ZYppImpl::initTarget(const Pathname & root)
{
- MIL << "initTarget( " << root << ", " << commit_only << ")" << endl;
+ MIL << "initTarget( " << root << endl;
if (_target) {
if (_target->root() == root) {
MIL << "Repeated call to initTarget()" << endl;
removeInstalledResolvables( );
}
_target = new Target( root );
- if (!commit_only)
- {
- _target->enableStorage( root );
- addResolvables( _target->resolvables(), true );
- }
+ _target->enableStorage( root );
}
void ZYppImpl::finishTarget()
* \throws Exception
* if commit_only == true, just init the target, dont populate store or pool
*/
- void initTarget(const Pathname & root, bool commit_only = false);
+ void initTarget(const Pathname & root);
/**
* \throws Exception