ADD_EXECUTABLE(susetags-downloader SUSETagsDownloader_tp.cc)
TARGET_LINK_LIBRARIES(susetags-downloader zypp )
-ADD_EXECUTABLE(cachestore CacheStore.cc)
+ADD_EXECUTABLE(cachestore CacheStore_tp.cc)
TARGET_LINK_LIBRARIES(cachestore zypp )
TARGET_LINK_LIBRARIES(cachestore zypp2 )
TARGET_LINK_LIBRARIES(cachequery zypp )
TARGET_LINK_LIBRARIES(cachequery zypp2 )
-ADD_EXECUTABLE(tagsparser SUSETagsParser.cc)
+ADD_EXECUTABLE(tagsparser SUSETagsParser.cc SUSETagsParser_tp.cc)
TARGET_LINK_LIBRARIES(tagsparser zypp )
TARGET_LINK_LIBRARIES(tagsparser zypp2 )
TARGET_LINK_LIBRARIES(testbed zypp )
TARGET_LINK_LIBRARIES(testbed zypp2 )
-ADD_EXECUTABLE(yum-downloader YUMDownloader.cc YUMDownloader_tp.cc)
+ADD_EXECUTABLE(yum-downloader YUMDownloader_tp.cc)
TARGET_LINK_LIBRARIES(yum-downloader zypp )
TARGET_LINK_LIBRARIES(yum-downloader zypp2 )
#include "zypp/parser/taggedfile/TagCacheRetrieval.h"
#include "zypp/parser/taggedfile/TagCacheRetrievalPtr.h"
+#include "SUSETagsParser.h"
+
using namespace zypp;
using namespace std;
using zypp::debug::Measure;
-typedef Exception ParseException;
-
-struct PackageDataProvider;
-
-typedef shared_ptr<PackageDataProvider> PackageDataProviderPtr;
+namespace zypp {
+typedef Exception ParseException;
+
struct PackageDataProvider
{
TagRetrievalPos _attr_SUMMARY;
PackageDataProviderPtr _fallback_provider;
};
-struct PackagesParser
-{
- // tag ids for the TaggedParser
- enum Tags {
- PACKAGE, // name version release arch
- REQUIRES, // list of requires tags
- PREREQUIRES,// list of pre-requires tags
- PROVIDES, // list of provides tags
- CONFLICTS, // list of conflicts tags
- OBSOLETES, // list of obsoletes tags
- RECOMMENDS, // list of recommends tags
- SUGGESTS, // list of suggests tags
- LOCATION, // file location
- SIZE, // packed and unpacked size
- BUILDTIME, // buildtime
- SOURCERPM, // source package
- GROUP, // rpm group
- LICENSE, // license
- AUTHORS, // list of authors
- SHAREWITH, // package to share data with
- KEYWORDS, // list of keywords
-
- // packages.<locale>
- SUMMARY, // short summary (label)
- DESCRIPTION,// long description
- INSNOTIFY, // install notification
- DELNOTIFY, // delete notification
- LICENSETOCONFIRM, // license to confirm upon install
- // packages.DU
- DU, // disk usage data
- NUM_TAGS
- };
-
- // our parser
- TaggedParser _parser;
- // our set of tags, initialized in constructor
- TaggedFile::TagSet _tagset;
- zypp::Arch _system_arch;
-
- typedef std::map <std::string, PackageDataProviderPtr> pkgmaptype;
- pkgmaptype _pkgmap;
-
- zypp::cache::CacheStore *_consumer;
-
- std::map<std::string, data::RecordId> _idmap;
-
- PackagesParser( zypp::cache::CacheStore *consumer )
- : _consumer(consumer)
+
+ PackagesParser::PackagesParser( const data::RecordId &catalog_id, zypp::cache::CacheStore consumer )
+ : _consumer(consumer), _catalog_id(catalog_id)
{
ZYpp::Ptr z = getZYpp();
_system_arch = z->architecture();
}
}
- void start( const Pathname &path )
+ void PackagesParser::start( const Pathname &path )
{
std::ifstream content_stream((path + "/content").asString().c_str());
std::string buffer;
} // locales iterator
}
- void fromCache ( TagCacheRetrieval_Ptr pkgcache)
+ void PackagesParser::fromCache ( TagCacheRetrieval_Ptr pkgcache)
{
//---------------------------------------------------------------
// PACKAGE
NVRA nvra( splitted[0], Edition( splitted[1], splitted[2] ), Arch(arch) );
- // DEPENDENCIES
+ // DEPENDENCIES
#define GET_TAG(tagname) \
_tagset.getTagByIndex (tagname)
-
+
data::Dependencies deps;
std::list<std::string> pkglist;
//COLLECT_DEPS(SUPPLEMENTS);
COLLECT_DEPS(RECOMMENDS);
- data::RecordId pkgid = _consumer->appendResolvable( ResTraits<Package>::kind, nvra, deps );
+ data::RecordId pkgid = _consumer.appendResolvable( _catalog_id, ResTraits<Package>::kind, nvra, deps );
_idmap[single] = pkgid;
}
- void collectDeps( zypp::Dep deptype, const std::list<std::string> &depstrlist, data::Dependencies &deps )
+ void PackagesParser::collectDeps( zypp::Dep deptype, const std::list<std::string> &depstrlist, data::Dependencies &deps )
{
for ( list<string>::const_iterator it = depstrlist.begin(); it != depstrlist.end(); ++it )
{
}
}
- void fromPathLocale (const Pathname& path)
+ void PackagesParser::fromPathLocale (const Pathname& path)
{
}
- void fromLocale ()
+ void PackagesParser::fromLocale ()
{
//---------------------------------------------------------------
// PACKAGE.<locale>
#undef SET_CACHE
}
-};
-
-int main(int argc, char **argv)
-{
- try
- {
- ZYpp::Ptr z = getZYpp();
- Pathname dbfile = Pathname(getenv("PWD")) + "data.db";
- zypp::cache::CacheStore store(getenv("PWD"));
-
- PackagesParser parser(&store);
- Measure m;
- parser.start(argv[1]);
- m.elapsed();
- }
- catch ( const Exception &e )
- {
- cout << "ups! " << e.msg() << std::endl;
- }
- return 0;
-}
+} // ns zypp
--- /dev/null
+
+#ifndef ZYPP_SOURCE_SUSETAGSPARSER_H
+#define ZYPP_SOURCE_SUSETAGSPARSER_H
+// #include <list>
+// #include <string>
+// #include <fstream>
+#include "zypp/base/PtrTypes.h"
+// #include "zypp/base/Measure.h"
+// #include "zypp/Arch.h"
+// #include "zypp/ZYppFactory.h"
+// #include "zypp/ZYpp.h"
+// #include "zypp/capability/CapabilityImpl.h"
+#include "zypp2/cache/CacheStore.h"
+#include "zypp/data/ResolvableData.h"
+#include "zypp/parser/taggedfile/TaggedParser.h"
+#include "zypp/parser/taggedfile/TaggedFile.h"
+#include "zypp/parser/taggedfile/TagCacheRetrieval.h"
+#include "zypp/parser/taggedfile/TagCacheRetrievalPtr.h"
+
+namespace zypp
+{
+ struct PackageDataProvider;
+ typedef zypp::shared_ptr<PackageDataProvider> PackageDataProviderPtr;
+ struct PackageDataProvider;
+
+ struct PackagesParser
+ {
+ // tag ids for the TaggedParser
+ enum Tags {
+ PACKAGE, // name version release arch
+ REQUIRES, // list of requires tags
+ PREREQUIRES,// list of pre-requires tags
+ PROVIDES, // list of provides tags
+ CONFLICTS, // list of conflicts tags
+ OBSOLETES, // list of obsoletes tags
+ RECOMMENDS, // list of recommends tags
+ SUGGESTS, // list of suggests tags
+ LOCATION, // file location
+ SIZE, // packed and unpacked size
+ BUILDTIME, // buildtime
+ SOURCERPM, // source package
+ GROUP, // rpm group
+ LICENSE, // license
+ AUTHORS, // list of authors
+ SHAREWITH, // package to share data with
+ KEYWORDS, // list of keywords
+
+ // packages.<locale>
+ SUMMARY, // short summary (label)
+ DESCRIPTION,// long description
+ INSNOTIFY, // install notification
+ DELNOTIFY, // delete notification
+ LICENSETOCONFIRM, // license to confirm upon install
+ // packages.DU
+ DU, // disk usage data
+ NUM_TAGS
+ };
+
+ PackagesParser( const data::RecordId &catalog_id, zypp::cache::CacheStore consumer );
+ void start( const zypp::Pathname &path );
+ void fromCache ( TagCacheRetrieval_Ptr pkgcache);
+ void collectDeps( zypp::Dep deptype, const std::list<std::string> &depstrlist, data::Dependencies &deps );
+ void fromPathLocale (const zypp::Pathname& path);
+ void fromLocale ();
+
+ private:
+ // our parser
+ TaggedParser _parser;
+ // our set of tags, initialized in constructor
+ TaggedFile::TagSet _tagset;
+ zypp::Arch _system_arch;
+ typedef std::map <std::string, PackageDataProviderPtr> pkgmaptype;
+ pkgmaptype _pkgmap;
+ zypp::cache::CacheStore _consumer;
+ std::map<std::string, data::RecordId> _idmap;
+ data::RecordId _catalog_id;
+ };
+}
+
+#endif
+
+
--- /dev/null
+
+#include <iostream>
+#include "zypp/base/Measure.h"
+#include "zypp/base/Logger.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/ZYpp.h"
+
+#include "SUSETagsParser.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::debug;
+
+int main(int argc, char **argv)
+{
+ try
+ {
+ ZYpp::Ptr z = getZYpp();
+ Pathname dbfile = Pathname(getenv("PWD")) + "data.db";
+ zypp::cache::CacheStore store(getenv("PWD"));
+ data::RecordId catalog_id = store.lookupOrAppendCatalog( Url(argv[1]), "/");
+ PackagesParser parser( catalog_id, store);
+ Measure m;
+ parser.start(argv[1]);
+ m.elapsed();
+ }
+ catch ( const Exception &e )
+ {
+ cout << "ups! " << e.msg() << std::endl;
+ }
+ return 0;
+}
+
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#include <fstream>
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-#include "zypp/base/Function.h"
-
-#include "zypp/Date.h"
-
-#include "zypp/parser/yum/RepomdFileReader.h"
-#include "zypp/parser/yum/PatchesFileReader.h"
-#include "YUMDownloader.h"
-
-using namespace std;
-using namespace zypp::xml;
-
-namespace zypp
-{
-namespace source
-{
-namespace yum
-{
-
-YUMDownloader::YUMDownloader( const Url &url, const Pathname &path )
- : _url(url), _path(path), _media(url, path)
-{
-}
-
-bool YUMDownloader::patches_Callback( const OnMediaLocation &loc, const string &id )
-{
- MIL << id << " : " << loc << endl;
- _fetcher.enqueue(loc);
- return true;
-}
-
-
-bool YUMDownloader::repomd_Callback( const OnMediaLocation &loc, const string &dtype )
-{
- MIL << dtype << " : " << loc << endl;
- _fetcher.enqueue(loc);
-
- // We got a patches file we need to read, to add patches listed
- // there, so we transfer what we have in the queue, and
- // queue the patches in the patches callback
- if ( dtype == "patches" )
- {
- _fetcher.start( _dest_dir, _media);
- // now the patches.xml file must exists
- PatchesFileReader( _dest_dir + loc.filename(), bind( &YUMDownloader::patches_Callback, this, _1, _2));
- }
- return true;
-}
-
-void YUMDownloader::download( const Pathname &dest_dir )
-{
- _dest_dir = dest_dir;
- _fetcher.enqueue( OnMediaLocation().filename("/repodata/repomd.xml") );
- _fetcher.start( dest_dir, _media);
- _fetcher.reset();
-
- Reader reader( dest_dir + "/repodata/repomd.xml" );
- RepomdFileReader( dest_dir + "/repodata/repomd.xml", bind( &YUMDownloader::repomd_Callback, this, _1, _2));
-
- // ready, go!
- _fetcher.start( dest_dir, _media);
-}
-
-}// ns yum
-}// ns source
-} // ns zypp
-
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef ZYPP_SOURCE_YUM_DOWNLOADER
-#define ZYPP_SOURCE_YUM_DOWNLOADER
-
-#include "zypp/Url.h"
-#include "zypp/Pathname.h"
-#include "zypp/Fetcher.h"
-#include "zypp/OnMediaLocation.h"
-#include "zypp/MediaSetAccess.h"
-#include "zypp/parser/xml/Reader.h"
-
-namespace zypp
-{
- namespace source
- {
- namespace yum
- {
- /**
- * This class allows to retrieve a YUM repository
- * to a local directory
- *
- * \code
- * YUMDownloader yum(url, path);
- * yum.download("localdir");
- * \endcode
- */
- class YUMDownloader
- {
- public:
- /**
- * Create the download object for a repository
- * located in \a url with path \a path
- */
- YUMDownloader( const Url &url, const Pathname &path );
- /**
- * starts the download to local directory \a dest_dir
- */
- void download( const Pathname &dest_dir );
-
- protected:
- bool repomd_Callback( const OnMediaLocation &loc, const std::string &dtype );
- bool patches_Callback( const OnMediaLocation &loc, const std::string &id );
- private:
- Url _url;
- Pathname _path;
- Fetcher _fetcher;
- Pathname _dest_dir;
- std::list<OnMediaLocation> _patches_files;
- MediaSetAccess _media;
- };
-
- } // ns yum
- } // ns source
-} // ns zypp
-
-#endif
#include <list>
#include <set>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/ZYpp.h>
-#include <zypp/ZYppFactory.h>
-#include <zypp/media/MediaAccess.h>
-#include <zypp/media/MediaManager.h>
-#include <zypp/MediaSetAccess.h>
-#include <zypp/source/SUSEMediaVerifier.h>
-#include <zypp/OnMediaLocation.h>
-#include <YUMDownloader.h>
-#include <zypp/Fetcher.h>
+#include "zypp/base/Logger.h"
+#include "zypp/base/String.h"
+#include "zypp/ZYpp.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/media/MediaAccess.h"
+#include "zypp/media/MediaManager.h"
+#include "zypp/MediaSetAccess.h"
+#include "zypp/source/SUSEMediaVerifier.h"
+#include "zypp/OnMediaLocation.h"
+#include "zypp/source/yum/YUMDownloader.h"
+#include "zypp/Fetcher.h"
#include "zypp/Product.h"
#include "zypp/Package.h"
#include "zypp/Product.h"
#include "zypp/detail/PackageImplIf.h"
#include "zypp/Package.h"
-
+#include "zypp/SourceFactory.h"
#include "zypp2/source/cached/CachedSourceImpl.h"
#include "zypp/data/ResolvableData.h"
Pathname dbpath = Pathname(getenv("PWD"));
- CachedSourceImpl source(dbpath);
- //ResStore dbres = src.resolvables();
+ SourceImpl_Ptr sourceImpl(new CachedSourceImpl(dbpath));
+ SourceFactory factory;
+ Source_Ref source = factory.createFrom(sourceImpl);
+ ResStore dbres = source.resolvables();
+
+ MIL << dbres.size() << " resolvables" << endl;
}
catch ( const Exception &e )