Author: dmacvicar
Date: Fri Apr 20 17:58:02 2007
New Revision: 5429
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5429&view=rev
Log:
backup for today.
- almost working resolvable query, and test
- fix in cached source arch
- skeleton for source manager
Added:
trunk/libzypp/devel/devel.dmacvicar/SourceManager.h
trunk/libzypp/devel/devel.dmacvicar/SourceManager_tp.cc
trunk/libzypp/tests/cache/CacheQuery_test.cc
trunk/libzypp/tests/cache/SimplePackagesParser.cc
trunk/libzypp/tests/cache/SimplePackagesParser.h
Modified:
trunk/libzypp/devel/devel.dmacvicar/CMakeLists.txt
trunk/libzypp/tests/cache/CMakeLists.txt
trunk/libzypp/tests/cache/CacheStore_test.cc
trunk/libzypp/zypp/data/ResolvableData.cc
trunk/libzypp/zypp/data/ResolvableData.h
trunk/libzypp/zypp/detail/ResolvableImpl.cc
trunk/libzypp/zypp2/cache/ResolvableQuery.cc
trunk/libzypp/zypp2/cache/ResolvableQuery.h
trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc
Modified: trunk/libzypp/devel/devel.dmacvicar/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/CMakeLists.txt?rev=5429&r1=5428&r2=5429&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/CMakeLists.txt (original)
+++ trunk/libzypp/devel/devel.dmacvicar/CMakeLists.txt Fri Apr 20 17:58:02 2007
@@ -16,10 +16,6 @@
TARGET_LINK_LIBRARIES(cachestore zypp )
TARGET_LINK_LIBRARIES(cachestore zypp2 )
-ADD_EXECUTABLE(cachequery CacheQuery_test.cc)
-TARGET_LINK_LIBRARIES(cachequery zypp )
-TARGET_LINK_LIBRARIES(cachequery zypp2 )
-
ADD_EXECUTABLE(tagsparser SUSETagsParser.cc SUSETagsParser_tp.cc)
TARGET_LINK_LIBRARIES(tagsparser zypp )
TARGET_LINK_LIBRARIES(tagsparser zypp2 )
Added: trunk/libzypp/devel/devel.dmacvicar/SourceManager.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/SourceManager.h?rev=5429&view=auto
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/SourceManager.h (added)
+++ trunk/libzypp/devel/devel.dmacvicar/SourceManager.h Fri Apr 20 17:58:02 2007
@@ -0,0 +1,3 @@
+
+#ifndef ZYPP_NEW_SOURCEMANAGER_H
+#define ZYPP_NEW_SOURCEMANAGER_H
\ No newline at end of file
Added: trunk/libzypp/devel/devel.dmacvicar/SourceManager_tp.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/SourceManager_tp.cc?rev=5429&view=auto
==============================================================================
(empty)
Modified: trunk/libzypp/tests/cache/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/cache/CMakeLists.txt?rev=5429&r1=5428&r2=5429&view=diff
==============================================================================
--- trunk/libzypp/tests/cache/CMakeLists.txt (original)
+++ trunk/libzypp/tests/cache/CMakeLists.txt Fri Apr 20 17:58:02 2007
@@ -5,11 +5,19 @@
TARGET_LINK_LIBRARIES(CacheInitializer zypp2 )
TARGET_LINK_LIBRARIES(CacheInitializer zypp )
-ADD_EXECUTABLE(CacheStore CacheStore_test.cc)
+ADD_EXECUTABLE(CacheStore CacheStore_test.cc SimplePackagesParser.cc)
TARGET_LINK_LIBRARIES(CacheStore boost_unit_test_framework )
TARGET_LINK_LIBRARIES(CacheStore zypp2 )
TARGET_LINK_LIBRARIES(CacheStore zypp )
+ADD_EXECUTABLE(CacheQuery CacheQuery_test.cc SimplePackagesParser.cc)
+TARGET_LINK_LIBRARIES(CacheQuery boost_unit_test_framework )
+TARGET_LINK_LIBRARIES(CacheQuery zypp2 )
+TARGET_LINK_LIBRARIES(CacheQuery zypp )
+
ADD_TEST(CacheInitializer ${CMAKE_CURRENT_BINARY_DIR}/CacheInitializer ${CMAKE_CURRENT_SOURCE_DIR}/data )
ADD_TEST(CacheStore ${CMAKE_CURRENT_BINARY_DIR}/CacheStore ${CMAKE_CURRENT_SOURCE_DIR}/data )
+ADD_TEST(CacheQuery ${CMAKE_CURRENT_BINARY_DIR}/CacheQuery ${CMAKE_CURRENT_SOURCE_DIR}/data )
+
+
Added: trunk/libzypp/tests/cache/CacheQuery_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/cache/CacheQuery_test.cc?rev=5429&view=auto
==============================================================================
--- trunk/libzypp/tests/cache/CacheQuery_test.cc (added)
+++ trunk/libzypp/tests/cache/CacheQuery_test.cc Fri Apr 20 17:58:02 2007
@@ -0,0 +1,96 @@
+#include
+
+#include <iostream>
+#include <fstream>
+
+#include
+#include
+#include
+
+#include "zypp/base/Measure.h"
+#include "zypp/base/Logger.h"
+#include "zypp/ZYpp.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/TmpPath.h"
+
+#include "zypp2/cache/CacheStore.h"
+#include "zypp2/cache/CapabilityQuery.h"
+#include "zypp/data/ResolvableData.h"
+#include "zypp2/cache/ResolvableQuery.h"
+
+#include "SimplePackagesParser.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::debug;
+using namespace zypp::capability;
+using namespace zypp::filesystem;
+using namespace zypp::cache;
+using namespace boost::unit_test;
+
+bool result(const data::RecordId &id, data::ResObject_Ptr ptr )
+{
+ MIL << "result: " << id << " | " << ptr->name << " | " << ptr->edition << " | " << ptr->arch << endl;
+}
+
+void resolvable_query_test(const string &dir)
+{
+ Pathname nvra_list = Pathname(dir) + "package-set.txt.gz";
+
+ MIL << "parsing " << nvra_list << endl;
+
+ list<MiniResolvable> res_list;
+
+ parse_mini_file( nvra_list, res_list );
+
+ filesystem::TmpDir tmpdir;
+ // let the store go out of scope to drop the connection
+ {
+ cache::CacheStore store(tmpdir.path());
+
+ data::RecordId catalog_id = store.lookupOrAppendCatalog( Url("http://novell.com"), "/");
+
+ zypp::debug::Measure cap_parse_timer("store resolvables");
+ for ( list<MiniResolvable>::iterator it = res_list.begin(); it != res_list.end(); it++)
+ {
+ data::RecordId id = store.appendResolvable( catalog_id,
+ ResTraits<Package>::kind,
+ (*it).nvra,
+ (*it).deps );
+ }
+
+ MIL << "packages writen to store" << endl;
+ }
+
+ ResolvableQuery query(tmpdir.path(), &result);
+ query.query("lib");
+}
+
+test_suite*
+init_unit_test_suite( int argc, char *argv[] )
+{
+ string datadir;
+ if (argc < 2)
+ {
+ datadir = TESTS_SRC_DIR;
+ datadir = (Pathname(datadir) + "/cache/data").asString();
+ cout << "CacheStore_test:"
+ " path to directory with test data required as parameter. Using " << datadir << endl;
+ //return (test_suite *)0;
+
+ }
+ else
+ {
+ datadir = argv[1];
+ }
+
+ test_suite* test= BOOST_TEST_SUITE("CacheStore");
+
+ std::string const params[] = { datadir };
+ test->add(BOOST_PARAM_TEST_CASE(&resolvable_query_test,
+ (std::string const*)params, params+1));
+ return test;
+}
+
+
+
Modified: trunk/libzypp/tests/cache/CacheStore_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/cache/CacheStore_test.cc?rev=5429&r1=5428&r2=5429&view=diff
==============================================================================
--- trunk/libzypp/tests/cache/CacheStore_test.cc (original)
+++ trunk/libzypp/tests/cache/CacheStore_test.cc Fri Apr 20 17:58:02 2007
@@ -9,7 +9,7 @@
#include "zypp/base/Random.h"
#include "zypp/base/Logger.h"
-#include "zypp/base/GzStream.h"
+
#include "zypp/base/Measure.h"
#include "zypp/capability/CapabilityImpl.h"
#include "zypp/data/ResolvableData.h"
@@ -19,91 +19,18 @@
#include "zypp/PathInfo.h"
#include "zypp/TmpPath.h"
+#include "SimplePackagesParser.h"
+
using namespace std;
using namespace zypp;
using namespace boost::unit_test;
-void read_dash( zypp::ifgzstream &ifs, const std::string &s, int &line )
-{
- string buffer;
- // get the "-"
- getline(ifs, buffer);
- line++;
- if ( buffer != s )
- {
- ERR << "line : " << line << endl;
- ZYPP_THROW(Exception("missing " + s ));
- }
-}
-
-void read_deps( zypp::ifgzstream &ifs, data::DependencyList &list, int &line, const string &endchar )
-{
- string buffer;
- while ( ifs && !ifs.eof())
- {
- getline(ifs, buffer);
- line++;
- if ( buffer == endchar )
- break;
- try
- {
- capability::CapabilityImpl::Ptr cap = zypp::capability::parse( ResTraits<Package>::kind, buffer);
- if (cap)
- list.push_back(cap);
- }
- catch( const Exception &e )
- {
- ERR << "line : " << line << endl;
- ZYPP_THROW(Exception("bad capability line"));
- }
- }
-}
-
-struct MiniResolvable
-{
- NVRA nvra;
- data::Dependencies deps;
-};
-
void cache_write_test(const string &dir)
{
- list<MiniResolvable> res_list;
- std::string buffer;
Pathname nvra_list = Pathname(dir) + "package-set.txt.gz";
+ list<MiniResolvable> res_list;
- int line = 0;
- zypp::ifgzstream nvra_stream(nvra_list.c_str());
- MIL << "reading " << nvra_list << endl;
-
- if ( ! nvra_stream )
- ZYPP_THROW(Exception("cant open data file " + nvra_list.asString()));
-
- while ( nvra_stream && !nvra_stream.eof())
- {
- MiniResolvable res;
- getline(nvra_stream, buffer);
- line++;
-
- if ( buffer.empty() )
- break;
-
- std::vectorstd::string words;
- if ( str::split( buffer, std::back_inserter(words) ) != 4 )
- {
- ERR << nvra_list << " : line : " << line << endl;
- ZYPP_THROW(Exception("bad NVRA line"));
- }
-
- res.nvra = NVRA(words[0], Edition(words[1], words[2]), Arch(words[3]));
- // requires
- read_dash( nvra_stream, "+r", line);
- read_deps( nvra_stream, res.deps[Dep::REQUIRES], line, "-r");
- read_dash( nvra_stream, "+p", line);
- read_deps( nvra_stream, res.deps[Dep::PROVIDES], line, "-p");
-
- res_list.push_back(res);
- }
- //MIL << deps.size() << " capabilities read." << endl;
+ parse_mini_file( nvra_list, res_list );
filesystem::TmpDir tmpdir;
cache::CacheStore store(tmpdir.path());
Added: trunk/libzypp/tests/cache/SimplePackagesParser.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/cache/SimplePackagesParser.cc?rev=5429&view=auto
==============================================================================
--- trunk/libzypp/tests/cache/SimplePackagesParser.cc (added)
+++ trunk/libzypp/tests/cache/SimplePackagesParser.cc Fri Apr 20 17:58:02 2007
@@ -0,0 +1,89 @@
+
+#include <string>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/GzStream.h"
+#include "zypp/Url.h"
+#include "zypp/PathInfo.h"
+#include "zypp/TmpPath.h"
+
+#include "SimplePackagesParser.h"
+
+
+using namespace zypp;
+using namespace std;
+
+static void read_dash( ifgzstream &ifs, const std::string &s, int &line )
+{
+ string buffer;
+ // get the "-"
+ getline(ifs, buffer);
+ line++;
+ if ( buffer != s )
+ {
+ ERR << "line : " << line << endl;
+ ZYPP_THROW(Exception("missing " + s ));
+ }
+}
+
+static void read_deps( ifgzstream &ifs, data::DependencyList &list, int &line, const string &endchar )
+{
+ string buffer;
+ while ( ifs && !ifs.eof())
+ {
+ getline(ifs, buffer);
+ line++;
+ if ( buffer == endchar )
+ break;
+ try
+ {
+ capability::CapabilityImpl::Ptr cap = capability::parse( ResTraits<Package>::kind, buffer);
+ if (cap)
+ list.push_back(cap);
+ }
+ catch( const Exception &e )
+ {
+ ERR << "line : " << line << endl;
+ ZYPP_THROW(Exception("bad capability line"));
+ }
+ }
+}
+
+void parse_mini_file(const Pathname &nvra_list, std::list<MiniResolvable> &res_list)
+{
+ std::string buffer;
+ int line = 0;
+ ifgzstream nvra_stream(nvra_list.c_str());
+ MIL << "reading " << nvra_list << endl;
+
+ if ( ! nvra_stream )
+ ZYPP_THROW(Exception("cant open data file " + nvra_list.asString()));
+
+ while ( nvra_stream && !nvra_stream.eof())
+ {
+ MiniResolvable res;
+ getline(nvra_stream, buffer);
+ line++;
+
+ if ( buffer.empty() )
+ break;
+
+ std::vectorstd::string words;
+ if ( str::split( buffer, std::back_inserter(words) ) != 4 )
+ {
+ ERR << nvra_list << " : line : " << line << endl;
+ ZYPP_THROW(Exception("bad NVRA line"));
+ }
+
+ res.nvra = NVRA(words[0], Edition(words[1], words[2]), Arch(words[3]));
+ // requires
+ read_dash( nvra_stream, "+r", line);
+ read_deps( nvra_stream, res.deps[Dep::REQUIRES], line, "-r");
+ read_dash( nvra_stream, "+p", line);
+ read_deps( nvra_stream, res.deps[Dep::PROVIDES], line, "-p");
+
+ res_list.push_back(res);
+ }
+ //MIL << deps.size() << " capabilities read." << endl;
+}
+
Added: trunk/libzypp/tests/cache/SimplePackagesParser.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/cache/SimplePackagesParser.h?rev=5429&view=auto
==============================================================================
--- trunk/libzypp/tests/cache/SimplePackagesParser.h (added)
+++ trunk/libzypp/tests/cache/SimplePackagesParser.h Fri Apr 20 17:58:02 2007
@@ -0,0 +1,18 @@
+
+#ifndef SimplePackagesParser_H
+#define SimplePackagesParser_H
+
+#include <list>
+#include "zypp/NVRA.h"
+#include "zypp/Pathname.h"
+#include "zypp/data/ResolvableData.h"
+
+struct MiniResolvable
+{
+ zypp::NVRA nvra;
+ zypp::data::Dependencies deps;
+};
+
+void parse_mini_file(const zypp::Pathname &nvra_list, std::list<MiniResolvable> &res_list);
+
+#endif
Modified: trunk/libzypp/zypp/data/ResolvableData.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/data/ResolvableData.cc?rev=5429&r1=5428&r2=5429&view=diff
==============================================================================
--- trunk/libzypp/zypp/data/ResolvableData.cc (original)
+++ trunk/libzypp/zypp/data/ResolvableData.cc Fri Apr 20 17:58:02 2007
@@ -16,7 +16,7 @@
namespace data
{
-
+IMPL_PTR_TYPE(Resolvable);
IMPL_PTR_TYPE(ResObject);
IMPL_PTR_TYPE(Script);
IMPL_PTR_TYPE(Message);
Modified: trunk/libzypp/zypp/data/ResolvableData.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/data/ResolvableData.h?rev=5429&r1=5428&r2=5429&view=diff
==============================================================================
--- trunk/libzypp/zypp/data/ResolvableData.h (original)
+++ trunk/libzypp/zypp/data/ResolvableData.h Fri Apr 20 17:58:02 2007
@@ -33,9 +33,12 @@
{
namespace data
{
+
typedef std::list< capability::CapabilityImpl::Ptr > DependencyList;
typedef std::map< zypp::Dep, DependencyList> Dependencies;
+ DEFINE_PTR_TYPE(Resolvable);
+
class Resolvable : public base::ReferenceCounted, private base::NonCopyable
{
public:
@@ -49,34 +52,7 @@
Dependencies deps;
};
- struct ResObjectData
- {
- ResObjectData()
- : source_media_nr(1), install_only(false)
- {}
-
- TranslatedText summary;
- TranslatedText description;
-
- std::string insnotify;
- std::string delnotify;
-
- std::string license_to_confirm;
- std::string vendor;
-
- ByteCount size;
- ByteCount archive_size;
-
- std::string source;
-
- int source_media_nr;
-
- bool install_only;
-
- Date build_time;
- Date install_time;
- };
-
+ DEFINE_PTR_TYPE(ResObject);
class ResObject : public Resolvable
{
Modified: trunk/libzypp/zypp/detail/ResolvableImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/detail/ResolvableImpl.cc?rev=5429&r1=5428&r2=5429&view=diff
==============================================================================
--- trunk/libzypp/zypp/detail/ResolvableImpl.cc (original)
+++ trunk/libzypp/zypp/detail/ResolvableImpl.cc Fri Apr 20 17:58:02 2007
@@ -115,6 +115,7 @@
void filterExtraProvides( const Dependencies & from, Dependencies & to )
{
+ //return;
CapSet provides;
CapSet languages;
@@ -136,6 +137,7 @@
void filterExtraSupplements( const Dependencies & from, Dependencies & to )
{
+ //return;
CapSet supplements;
CapSet dummy;
to[Dep::SUPPLEMENTS].clear();
Modified: trunk/libzypp/zypp2/cache/ResolvableQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/ResolvableQuery.cc?rev=5429&r1=5428&r2=5429&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/ResolvableQuery.cc (original)
+++ trunk/libzypp/zypp2/cache/ResolvableQuery.cc Fri Apr 20 17:58:02 2007
@@ -1,8 +1,10 @@
#include "zypp2/cache/ResolvableQuery.h"
+#include "zypp2/cache/DatabaseTypes.h"
#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
using namespace sqlite3x;
+using namespace std;
namespace zypp { namespace cache {
@@ -11,35 +13,58 @@
{
Impl( const Pathname &dbdir, ProcessResolvable fnc )
: _dbdir(dbdir), _fnc(fnc)
- {}
+ {
+ _fields = "id, name, version, release, epoch, arch, kind, insnotify, delnotify, license_to_confirm, vendor, installed_size, archive_size, install_only, build_time, install_time, catalog_id";
+ }
~Impl()
{
}
+ data::ResObject_Ptr fromRow( sqlite3_reader &reader )
+ {
+ data::ResObject_Ptr ptr (new data::ResObject);
+
+ ptr->name = reader.getstring(1);
+ ptr->edition = Edition( reader.getstring(2), reader.getstring(3), reader.getint(4));
+ ptr->arch = db_arch2zypp_arch( static_castdb::Arch(reader.getint(5)));
+
+ return ptr;
+ }
void query( const data::RecordId &id )
{
sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
//con.executenonquery("PRAGMA cache_size=8000;");
con.executenonquery("BEGIN;");
- sqlite3_command cmd( con, "select * from resolvables where id=:id;");
+ sqlite3_command cmd( con, "select " + _fields + " from resolvables where id=:id;");
cmd.bind(":id", id);
sqlite3_reader reader = cmd.executereader();
while(reader.read())
{
-
+ _fnc( id, fromRow(reader) );
}
con.executenonquery("COMMIT;");
}
void query( const std::string &s )
{
-
+ sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
+ //con.executenonquery("PRAGMA cache_size=8000;");
+ con.executenonquery("BEGIN;");
+ sqlite3_command cmd( con, "select " + _fields + " from resolvables where name like '%:name%';");
+ cmd.bind(":name", s);
+ sqlite3_reader reader = cmd.executereader();
+ while(reader.read())
+ {
+ _fnc( reader.getint64(0), fromRow(reader) );
+ }
+ con.executenonquery("COMMIT;");
}
Pathname _dbdir;
ProcessResolvable _fnc;
+ string _fields;
};
ResolvableQuery::ResolvableQuery( const Pathname &dbdir, ProcessResolvable fnc )
Modified: trunk/libzypp/zypp2/cache/ResolvableQuery.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/ResolvableQuery.h?rev=5429&r1=5428&r2=5429&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/ResolvableQuery.h (original)
+++ trunk/libzypp/zypp2/cache/ResolvableQuery.h Fri Apr 20 17:58:02 2007
@@ -38,9 +38,11 @@
* first parameter is the resolvable id.
* second parameter is a \ref data::ResObjectData object with the resource
*/
- typedef function ProcessResolvable;
+ typedef function ProcessResolvable;
- ResolvableQuery( const Pathname &dbdir, ProcessResolvable fnc );
+ ResolvableQuery( const Pathname &dbdir,
+ ProcessResolvable fnc );
/**
* Query by record id
Modified: trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc?rev=5429&r1=5428&r2=5429&view=diff
==============================================================================
--- trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc (original)
+++ trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc Fri Apr 20 17:58:02 2007
@@ -85,11 +85,8 @@
long long id = reader.getint64(0);
Dependencies deps;
- Arch arch;
- string archstring = reader.getstring(5);
- if (!archstring.empty())
- arch = Arch(archstring);
-
+ Arch arch = db_arch2zypp_arch( static_castdb::Arch(reader.getint(5)));
+
// Collect basic Resolvable data
nvras[id] = NVRAD( reader.getstring(1),
Edition( reader.getstring(2), reader.getstring(3), reader.getint(4) ),
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org