#include "zypp/Arch.h"
#include "zypp/TmpPath.h"
#include "zypp2/cache/CacheInitializer.h"
+#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
// Boost.Test
#include <boost/test/floating_point_comparison.hpp>
#include <boost/test/unit_test.hpp>
-
-#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
+#include <boost/test/unit_test_log.hpp>
using boost::unit_test::test_suite;
using boost::unit_test::test_case;
using boost::test_tools::close_at_tolerance;
-
+using namespace boost::unit_test;
+using namespace boost::unit_test::log;
+using namespace boost::unit_test_framework;
using namespace std;
using namespace zypp;
using namespace sqlite3x;
-/******************************************************************
-**
-**
-** FUNCTION NAME : main
-** FUNCTION TYPE : int
-**
-** DESCRIPTION :
-*/
+// control output with BOOST_TEST_LOG_LEVEL="all"
+
void cacheinit_test()
{
+ //unit_test_log::instance().set_log_threshold_level(log_messages);
filesystem::TmpDir tmpdir;
cache::CacheInitializer initializer(tmpdir.path(), "test.db");
//con.executenonquery(SOURCES_TABLE_SCHEMA);
int count = con.executeint("select count(*) from sqlite_master where type='table';");
BOOST_CHECK( initializer.justInitialized() );
- BOOST_CHECK_EQUAL( count, 3);
+ // 14 tables need to be created
+ BOOST_CHECK_EQUAL( count, 14);
}
test_suite*
## ##################################################
-TESTS = SourceCacheInitializer
+TESTS = CacheInitializerTest
-check_PROGRAMS = SourceCacheInitializer
+check_PROGRAMS = CacheInitializerTest
## ##################################################
## ##################################################
-SourceCacheInitializer_SOURCES = SourceCacheInitializer.cc
-SourceCacheInitializer_LDADD = $(LDADD) -lboost_unit_test_framework
+CacheInitializerTest_SOURCES = CacheInitializer.cc
+CacheInitializerTest_LDADD = $(LDADD) -lboost_unit_test_framework
## ##################################################
class ResObject : public base::ReferenceCounted, private base::NonCopyable
{
public:
+ ResObject()
+ : source_media_nr(1), install_only(false)
+ {}
+
std::string name;
Edition edition;
Arch arch;
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;
+
DependencyList provides;
DependencyList conflicts;
DependencyList obsoletes;
std::string type;
CheckSum checksum;
- std::string packager;
- Url url;
- ByteCount archive_size;
- ByteCount installed_size;
- Date build_time;
- Pathname location;
+ // changlelog?
+ std::string buildhost;
+ std::string distribution;
std::string license;
- std::string vendor;
+ std::string packager;
std::string group;
- std::string buildhost;
+ Url url;
+ std::string os;
+
+ std::string prein;
+ std::string postin;
+ std::string preun;
+ std::string postun;
+
+ ByteCount source_size;
- //std::list<FileData> files;
-
- // SuSE specific data
std::list<std::string> authors;
std::list<std::string> keywords;
- //std::string media;
- //std::list<YUMDirSize> dirSizes;
- //bool installOnly;
- //TranslatedText license_to_confirm;
+
+ Pathname location;
};
/* Easy output */
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef CACHE_COMMON_H
+#define CACHE_COMMON_H
+
+//-----------------------------------------------------------------------------
+// relations
+
+#define RELATION_ANY 0
+#define RELATION_EQUAL (1 << 0)
+#define RELATION_LESS (1 << 1)
+#define RELATION_GREATER (1 << 2)
+#define RELATION_NONE (1 << 3)
+
+namespace zypp
+{
+namespace cache
+{
+
+namespace db
+{
+
+typedef enum {
+ REL_INVALID = -1,
+ REL_ANY = RELATION_ANY,
+ REL_EQUAL = RELATION_EQUAL,
+ REL_LESS = RELATION_LESS,
+ REL_LESS_EQUAL = RELATION_LESS | RELATION_EQUAL,
+ REL_GREATER = RELATION_GREATER,
+ REL_GREATER_EQUAL = RELATION_GREATER | RELATION_EQUAL,
+ REL_NOT_EQUAL = RELATION_LESS | RELATION_GREATER,
+ REL_NONE = RELATION_NONE,
+} Rel;
+
+//-----------------------------------------------------------------------------
+// architectures
+
+typedef enum {
+ ARCH_UNKNOWN = -1,
+ ARCH_NOARCH = 0,
+ ARCH_I386,
+ ARCH_I486,
+ ARCH_I586,
+ ARCH_I686,
+ ARCH_X86_64,
+ ARCH_IA32E,
+ ARCH_ATHLON,
+ ARCH_PPC,
+ ARCH_PPC64,
+ ARCH_S390,
+ ARCH_S390X,
+ ARCH_IA64,
+ ARCH_SPARC,
+ ARCH_SPARC64,
+} Arch;
+
+//-----------------------------------------------------------------------------
+// dependencies
+
+typedef enum {
+ DEP_TYPE_REQUIRE = 0,
+ DEP_TYPE_PROVIDE, // 1
+ DEP_TYPE_CONFLICT, // 2
+ DEP_TYPE_OBSOLETE, // 3
+ DEP_TYPE_PREREQUIRE, // 4
+ DEP_TYPE_FRESHEN, // 5
+ DEP_TYPE_RECOMMEND, // 6
+ DEP_TYPE_SUGGEST, // 7
+ DEP_TYPE_SUPPLEMENT, // 8
+ DEP_TYPE_ENHANCE // 9
+} DependencyType;
+
+//-----------------------------------------------------------------------------
+// kinds (dependencies.dep_target
+
+typedef enum {
+ KIND_PACKAGE = 0,
+ KIND_SCRIPT, // 1
+ KIND_MESSAGE, // 2
+ KIND_PATCH, // 3
+ KIND_PATTERN, // 4
+ KIND_PRODUCT, // 5
+ KIND_SELECTION, // 6
+ KIND_LANGUAGE, // 7
+ KIND_ATOM, // 8
+ KIND_SRC, // 9
+ KIND_SYSTEM, // 10 SystemResObject
+ KIND_UNKNOWN=42 // 42
+} Kind;
+
+
+} // namespace db
+} //namespace cache
+} //namespace zypp
+
+#endif // CACHE_COMMON_H
#include "zypp/base/Logger.h"
#include "zypp/base/String.h"
#include "zypp2/cache/CacheInitializer.h"
+#include "zypp2/cache/schema/schema.h"
#include "zypp/target/store/PersistentStorage.h"
#include "zypp2/cache/Utils.h"
{ /////////////////////////////////////////////////////////////////
-static const char * SOURCES_TABLE_SCHEMA = "create table sources ( id integer primary key autoincrement, alias varchar unique, type varchar, description varchar, url varchar, path varchar, enabled integer, autorefresh integer, timestamp integer, checksum varchar);";
-
-static const char * RESOLVABLES_TABLE_SCHEMA = "\
- CREATE TABLE resolvables ( id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR, version VARCHAR, release VARCHAR, epoch INTEGER, arch INTEGER, installed_size INTEGER, catalog VARCHAR, installed INTEGER, local INTEGER, status INTEGER, category VARCHAR, license VARCHAR, kind INTEGER); \
- CREATE INDEX resolvable_sources ON resolvables (sources); \
- CREATE INDEX resolvable_name ON resolvables (name); \
- CREATE INDEX resolvable_spec ON resolvables (name, version, release, epoch, arch); \
- CREATE TRIGGER remove_resolvables AFTER DELETE ON resolvables BEGIN DELETE FROM package_details WHERE resolvable_id = old.id; \
- DELETE FROM patch_details WHERE resolvable_id = old.id; \
- DELETE FROM pattern_details WHERE resolvable_id = old.id; \
- DELETE FROM product_details WHERE resolvable_id = old.id; \
- DELETE FROM message_details WHERE resolvable_id = old.id; \
- DELETE FROM script_details WHERE resolvable_id = old.id; \
- DELETE FROM dependencies WHERE resolvable_id = old.id; \
- DELETE FROM files WHERE resolvable_id = old.id; END;";
-
-static const char * PACKAGE_DETAILS_TABLE_SCHEMA = "\
- CREATE TABLE package_details ( resolvable_id INTEGER NOT NULL, rpm_group VARCHAR, summary VARCHAR, description VARCHAR, package_url VARCHAR, package_filename VARCHAR, signature_filename VARCHAR, file_size INTEGER, install_only INTEGER, media_nr INTEGER); \
- CREATE INDEX package_details_resolvable_id ON package_details (resolvable_id);\
- CREATE VIEW packages AS SELECT * FROM resolvables, package_details WHERE resolvables.id = package_details.resolvable_id;";
-
-static const char * MESSAGE_DETAILS_TABLE_SCHEMA = "\
-CREATE TABLE message_details (resolvable_id INTEGER NOT NULL, content VARCHAR);";
-
-static const char * PATTERN_DETAILS_TABLE_SCHEMA = "\
-CREATE TABLE pattern_details (resolvable_id INTEGER NOT NULL, summary VARCHAR, description VARCHAR);";
-
-static const char * PRODUCT_DETAILS_TABLE_SCHEMA = "\
-CREATE TABLE product_details (resolvable_id INTEGER NOT NULL, summary VARCHAR, description VARCHAR );";
-
-static const char * SCRIPT_DETAILS_TABLE_SCHEMA = "\
-CREATE TABLE script_details (resolvable_id INTEGER NOT NULL, do_script VARCHAR, undo_script VARCHAR);";
-
-static const char * PATCH_DETAILS_TABLE_SCHEMA = "\
-CREATE TABLE patch_details (resolvable_id INTEGER NOT NULL, patch_id VARCHAR, creation_time INTEGER, reboot INTEGER, restart INTEGER, interactive INTEGER, summary VARCHAR, description VARCHAR);";
-
-static const char * DEPENDENCIES_TABLE_SCHEMA = "\
- CREATE TABLE dependencies ( resolvable_id INTEGER NOT NULL, dep_type INTEGER NOT NULL, name VARCHAR, version VARCHAR, release VARCHAR, epoch INTEGER, arch INTEGER, relation INTEGER, dep_target INTEGER);";
-
-
-
-// id 0, alias 1 , type 2, desc 3, url 4, path 5, enabled 6, autorefresh 7, timestamp 8, checksum 9
CacheInitializer::CacheInitializer( const Pathname &root_r, const Pathname &db_file )
: _root(root_r), _just_initialized(false)
{
sqlite3_transaction trans(*_con);
{
- _con->executenonquery(SOURCES_TABLE_SCHEMA);
- _con->executenonquery(RESOLVABLES_TABLE_SCHEMA);
- _con->executenonquery(PACKAGE_DETAILS_TABLE_SCHEMA);
- _con->executenonquery(PRODUCT_DETAILS_TABLE_SCHEMA);
- _con->executenonquery(PATCH_DETAILS_TABLE_SCHEMA);
- _con->executenonquery(SCRIPT_DETAILS_TABLE_SCHEMA);
- _con->executenonquery(MESSAGE_DETAILS_TABLE_SCHEMA);
- _con->executenonquery(PATTERN_DETAILS_TABLE_SCHEMA);
- _con->executenonquery(DEPENDENCIES_TABLE_SCHEMA);
+ char ** statements = getsql();
+ int i = 0;
+ while ( statements[i] != 0 )
+ {
+ ERR << "Executing " << statements[i] << endl;
+ _con->executenonquery(statements[i]);
+ i++;
+ }
}
-
trans.commit();
}
--- /dev/null
+
+#include "zypp/ZYppFactory.h"
+#include "zypp/ZYpp.h"
+
+#include "zypp2/cache/CacheInitializer.h"
+#include "zypp2/cache/CacheStore.h"
+#include "zypp2/cache/DatabaseTypes.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::cache;
+using namespace sqlite3x;
+
+#define INSERT_RESOLVABLE_QUERY \
+ "insert into resolvables (" \
+ "name, version, release" \
+ ", epoch, arch, kind" \
+ ", summary, description" \
+ ", insnotify, delnotify" \
+ ", license_to_confirm, vendor, size, archive_size" \
+ ", catalog, catalog_media_nr, install_only" \
+ ", build_time, install_time )" \
+ " values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );"
+
+#define INSERT_PACKAGE_QUERY \
+ "insert into package_details (" \
+ " resolvable_id, checksum, changelog, buildhost, distribution, license" \
+ " , packager, package_group, url, os, prein, postin, preun, postun, source_size" \
+ " , authors, filenames, location ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace cache
+{ /////////////////////////////////////////////////////////////////
+
+CacheStore::CacheStore( const Pathname &dbdir )
+{
+ cache::CacheInitializer initializer(dbdir, "zypp.db");
+ if ( initializer.justInitialized() )
+ {
+ MIL << "database " << (dbdir + "zypp.db") << " was just created" << endl;
+ }
+
+ try
+ {
+ _con.reset( new sqlite3_connection( (dbdir + "zypp.db").asString().c_str()) );
+ _insert_resolvable_cmd = new sqlite3_command( *_con, INSERT_RESOLVABLE_QUERY );
+ _insert_package_cmd = new sqlite3_command( *_con, INSERT_PACKAGE_QUERY );
+ }
+ catch(exception &ex)
+ {
+ //ZYPP_CAUGHT(ex);
+ ZYPP_THROW(Exception(ex.what()));
+ }
+
+ // disable autocommit
+ _con->executenonquery("BEGIN;");
+}
+
+CacheStore::CacheStore()
+{
+ CacheStore( getZYpp()->homePath() );
+}
+
+CacheStore::~CacheStore()
+{
+ _con->executenonquery("COMMIT;");
+}
+
+void CacheStore::consumePackage( const data::Package &package )
+{
+ long long id = insertResObject( ResTraits<Package>::kind, package );
+
+}
+
+long long CacheStore::insertResObject( const Resolvable::Kind &kind, const data::ResObject &res )
+{
+ _insert_resolvable_cmd->bind(1, res.name.c_str(), -1);
+ _insert_resolvable_cmd->bind(2, res.edition.version().c_str(), -1);
+ _insert_resolvable_cmd->bind(3, res.edition.release().c_str(), -1);
+ _insert_resolvable_cmd->bind(4, static_cast<int>( res.edition.epoch() ));
+ _insert_resolvable_cmd->bind(5, zypp_arch2db_arch(res.arch));
+ _insert_resolvable_cmd->bind(6, db_kind2zypp_kind(kind));
+ _insert_resolvable_cmd->bind(7, res.summary.text().c_str(), -1);
+ _insert_resolvable_cmd->bind(8, res.description.text().c_str(), -1);
+ _insert_resolvable_cmd->bind(9, res.insnotify.c_str(), -1);
+ _insert_resolvable_cmd->bind(10, res.delnotify.c_str(), -1);
+ _insert_resolvable_cmd->bind(11, res.license_to_confirm.c_str(), -1);
+ _insert_resolvable_cmd->bind(12, res.vendor.c_str(), -1);
+ _insert_resolvable_cmd->bind(13, res.size ); // FIX cast?
+ _insert_resolvable_cmd->bind(14, res.archive_size ); // FIX cast?
+ _insert_resolvable_cmd->bind(15, res.source.c_str(), -1);
+
+ _insert_resolvable_cmd->bind(16, res.source_media_nr);
+ _insert_resolvable_cmd->bind(17, static_cast<int>(res.install_only));
+ _insert_resolvable_cmd->bind(18, static_cast<int>(res.build_time) ); // FIX cast?
+ _insert_resolvable_cmd->bind(19, static_cast<int>(res.install_time) ); // FIX cast?
+ _insert_resolvable_cmd->executenonquery();
+ return _con->insertid();
+
+}
+
+void CacheStore::insertPackage( long long id, const data::Package &pkg )
+{
+ /*
+ " resolvable_id, checksum, changelog, buildhost, distribution, license" \
+ " , packager, package_group, url, os, prein, postin, preun, postun, source_size" \
+ " , authors, filenames, location ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );"
+ */
+ _insert_package_cmd->bind( 1, id );
+ _insert_package_cmd->bind( 2 );
+ //_insert_package_cmd->bind( 2, pkg.checksum.asString().c_str() );
+ _insert_package_cmd->bind( 3 );
+ _insert_package_cmd->bind( 4, pkg.buildhost.c_str() );
+}
+
+
+
+}
+}
\ No newline at end of file
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef ZYPP_CacheStore_H
+#define ZYPP_CacheStore_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+#include "zypp/base/PtrTypes.h"
+#include "zypp/Pathname.h"
+#include "zypp/data/ResolvableDataConsumer.h"
+#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace cache
+ { /////////////////////////////////////////////////////////////////
+
+ class CacheStore : public data::ResolvableDataConsumer
+ {
+ public:
+
+ CacheStore();
+ ~CacheStore();
+ CacheStore( const Pathname &dbdir );
+
+ void consumePackage( const data::Package &package );
+
+ protected:
+ long long insertResObject( const Resolvable::Kind &kind, const data::ResObject &res );
+ void insertPackage( long long id, const data::Package &package );
+
+ private:
+ shared_ptr<sqlite3x::sqlite3_connection> _con;
+
+ sqlite3x::sqlite3_command *_insert_package_cmd;
+ sqlite3x::sqlite3_command *_insert_resolvable_cmd;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+#include "zypp2/cache/CacheCommon.h"
+#include "zypp/NeedAType.h"
+#include "zypp/Resolvable.h"
+#include "zypp/base/Logger.h"
+#include "zypp/Arch.h"
+#include "zypp/Rel.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::cache;
+
+static struct archrc
+{
+ char *arch;
+ db::Arch rc;
+}
+archtable[] = {
+ { "noarch", db::ARCH_NOARCH },
+ { "i386", db::ARCH_I386 },
+ { "i486", db::ARCH_I486 },
+ { "i586", db::ARCH_I586 },
+ { "i686", db::ARCH_I686 },
+ { "x86_64", db::ARCH_X86_64 },
+ { "ia32e", db::ARCH_IA32E },
+ { "athlon", db::ARCH_ATHLON },
+ { "ppc", db::ARCH_PPC },
+ { "ppc64", db::ARCH_PPC64 },
+ { "s390", db::ARCH_S390 },
+ { "s390x", db::ARCH_S390X },
+ { "ia64", db::ARCH_IA64 },
+ { "sparc", db::ARCH_SPARC },
+ { "sparc64", db::ARCH_SPARC64 },
+ { NULL, db::ARCH_UNKNOWN }
+ };
+
+//----------------------------------------------------------------------------
+
+// Convert ZYPP relation operator to ZMD RCResolvableRelation
+
+db::Rel
+zypp_rel2db_rel( zypp::Rel op)
+{
+
+ /* This enum is here so that gdb can give us pretty strings */
+
+ switch (op.inSwitch())
+ {
+ case Rel::EQ_e:
+ return db::REL_EQUAL;
+ break;
+ case Rel::NE_e:
+ return db::REL_NOT_EQUAL;
+ break;
+ case Rel::LT_e:
+ return db::REL_LESS;
+ break;
+ case Rel::LE_e:
+ return db::REL_LESS_EQUAL;
+ break;
+ case Rel::GT_e:
+ return db::REL_GREATER;
+ break;
+ case Rel::GE_e:
+ return db::REL_GREATER_EQUAL;
+ break;
+ case Rel::ANY_e:
+ return db::REL_ANY;
+ break;
+ case Rel::NONE_e:
+ return db::REL_NONE;
+ break;
+ }
+ return db::REL_INVALID;
+}
+
+
+Rel
+db_rel2zypp_rel (db::Rel rel)
+{
+ switch (rel)
+ {
+ case db::REL_INVALID:
+ return Rel::NONE;
+ break;
+ case db::REL_ANY:
+ return Rel::ANY;
+ break;
+ case db::REL_EQUAL:
+ return Rel::EQ;
+ break;
+ case db::REL_LESS:
+ return Rel::LT;
+ break;
+ case db::REL_LESS_EQUAL:
+ return Rel::LE;
+ break;
+ case db::REL_GREATER:
+ return Rel::GT;
+ break;
+ case db::REL_GREATER_EQUAL:
+ return Rel::GE;
+ break;
+ case db::REL_NOT_EQUAL:
+ return Rel::NE;
+ break;
+ case db::REL_NONE:
+ return Rel::ANY;
+ break;
+ }
+ return Rel::NONE;
+}
+
+//----------------------------------------------------------------------------
+
+// convert ZYPP architecture string to ZMD int
+
+db::Arch
+zypp_arch2db_arch(const Arch & arch)
+{
+ string arch_str = arch.asString();
+ struct archrc *aptr = archtable;
+ while (aptr->arch != NULL)
+ {
+ if (arch_str == aptr->arch)
+ break;
+ aptr++;
+ }
+
+ return aptr->rc;
+}
+
+Arch
+db_arch2zypp_arch (db::Arch rc)
+{
+ if (rc == db::ARCH_UNKNOWN)
+ return Arch();
+
+ struct archrc *aptr = archtable;
+ while (aptr->arch != NULL)
+ {
+ if (aptr->rc == rc)
+ {
+ return Arch (aptr->arch);
+ }
+ aptr++;
+ }
+ WAR << "DbAccess::Rc2Arch(" << rc << ") unknown" << endl;
+ return Arch ();
+}
+
+
+// remove Authors from description Text
+string desc2str (const Text t)
+{
+ static string s; // static so we can use sqlite STATIC below
+ s.clear();
+ string::size_type authors = t.find ("Authors:"); // strip off 'Authors:'
+
+ if (authors == string::npos)
+ { // if no "Authors", point to end of string
+ authors = t.size();
+ }
+
+ // now remove trailing whitespace
+
+ do
+ {
+ --authors;
+ }
+ while (t[authors] == ' ' || t[authors] == '\n');
+ s = string( t, 0, authors+1 );
+
+ return s;
+}
+
+//----------------------------------------------------------------------------
+// convert ZYPP Resolvable kind to ZMD db::Kind
+
+db::Kind
+db_kind2zypp_kind( Resolvable::Kind kind )
+{
+ if (kind == ResTraits<Package>::kind) return db::KIND_PACKAGE;
+ else if (kind == ResTraits<Script>::kind) return db::KIND_SCRIPT;
+ else if (kind == ResTraits<Message>::kind) return db::KIND_MESSAGE;
+ else if (kind == ResTraits<Patch>::kind) return db::KIND_PATCH;
+ else if (kind == ResTraits<Selection>::kind) return db::KIND_SELECTION;
+ else if (kind == ResTraits<Pattern>::kind) return db::KIND_PATTERN;
+ else if (kind == ResTraits<Product>::kind) return db::KIND_PRODUCT;
+ else if (kind == ResTraits<Language>::kind) return db::KIND_LANGUAGE;
+ else if (kind == ResTraits<Atom>::kind) return db::KIND_ATOM;
+ else if (kind == ResTraits<SrcPackage>::kind) return db::KIND_SRC;
+ else if (kind == ResTraits<SystemResObject>::kind) return db::KIND_SYSTEM;
+
+ WAR << "Unknown resolvable kind " << kind << endl;
+ return db::KIND_UNKNOWN;
+}
+
+
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#include "zypp/base/Logger.h"
-#include "zypp2/cache/KnownSourcesCache.h"
-#include "zypp2/cache/CacheInitializer.h"
-#include "zypp/target/store/PersistentStorage.h"
-
-#define ZYPP_DB_FILE "/var/lib/zypp/zypp.db"
-
-using namespace sqlite3x;
-using namespace std;
-
-//////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace cache
-{ /////////////////////////////////////////////////////////////////
-
-KnownSourcesCache::KnownSourcesCache( const Pathname &root_r ) : _root(root_r)
-{
- try
- {
- CacheInitializer init(_root, ZYPP_DB_FILE);
- if (init.justInitialized())
- importOldSources();
- }
- catch(exception &ex)
- {
- ERR << "Exception Occured: " << ex.what() << endl;
- }
-
- try
- {
- _con.reset( new sqlite3_connection(ZYPP_DB_FILE) );
- }
- catch(exception &ex)
- {
- ERR << "Exception Occured: " << ex.what() << endl;
- }
-
-
-}
-
-KnownSourcesCache::~KnownSourcesCache()
-{
- _con->close();
-}
-
-void KnownSourcesCache::importOldSources()
-{
- // import old sources
- storage::PersistentStorage store;
- store.init( _root );
- source::SourceInfoList old_sources = store.storedSources();
- for ( source::SourceInfoList::const_iterator it = old_sources.begin(); it != old_sources.end(); it++ )
- {
- storeSource( *it );
- }
-}
-
-source::SourceInfoList KnownSourcesCache::knownSources() const
-{
- source::SourceInfoList sources;
- try
- {
- sqlite3_command cmd( *_con , "select * from sources;");
- sqlite3_reader reader = cmd.executereader();
-
- while(reader.read())
- {
- source::SourceInfo info;
- info.setAlias(reader.getstring(1));
- info.setUrl(reader.getstring(2));
- info.setEnabled( (reader.getint(4) == 1 ) ? true : false );
- info.setAutorefresh( (reader.getint(5) == 1 ) ? true : false );
- info.setType(reader.getstring(6));
- info.setCacheDir(reader.getstring(7));
- info.setPath(reader.getstring(8));
- sources.push_back(info);
- }
- }
- catch(exception &ex)
- {
- ERR << "Exception Occured: " << ex.what() << endl;
- }
- return sources;
-}
-
-void KnownSourcesCache::storeSource( const source::SourceInfo &info )
-{
- try
- {
- sqlite3_command cmd( *_con, "insert into sources ( alias, url, description, enabled, autorefresh, type, cachedir, path) values ( ?, ?, ?, ? , ?, ?, ?, ?);");
- cmd.bind(1, info.alias());
- cmd.bind(2, info.url().asCompleteString());
- // FIXME no description
- cmd.bind(4, info.enabled() ? 1 : 0 );
- cmd.bind(5, info.autorefresh() ? 1 : 0 );
- cmd.bind(6, info.type());
- cmd.bind(7, info.cacheDir().asString());
- cmd.bind(8, info.path().asString());
-
- cmd.executenonquery();
- }
- catch(exception &ex)
- {
- ERR << "Exception Occured: " << ex.what() << endl;
- }
-}
-
-std::ostream & KnownSourcesCache::dumpOn( std::ostream & str ) const
-{
- return str;
-}
-
-}
-}
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/KnownSourcesCache.h
- *
-*/
-#ifndef ZYPP_KnownSourcesCache_H
-#define ZYPP_KnownSourcesCache_H
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/base/PtrTypes.h"
-#include "zypp/source/SourceInfo.h"
-#include "zypp/Pathname.h"
-#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- DEFINE_PTR_TYPE(KnownSourcesCache);
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : KnownSourcesCache
- //
- class KnownSourcesCache : public base::ReferenceCounted, private base::NonCopyable
- {
- friend std::ostream & operator<<( std::ostream & str, const KnownSourcesCache & obj );
-
- public:
- /** root path */
- KnownSourcesCache( const Pathname &root_r );
- ~KnownSourcesCache();
- source::SourceInfoList knownSources() const;
- void storeSource( const source::SourceInfo &info );
- void importOldSources();
- protected:
- /** Overload to realize stream output. */
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- //typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap
- shared_ptr<sqlite3x::sqlite3_connection> _con;
- Pathname _root;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates KnownSourcesCache Stream output */
- inline std::ostream & operator<<( std::ostream & str, const KnownSourcesCache & obj )
- { return obj.dumpOn( str ); }
-
-
- /////////////////////////////////////////////////////////////////
- } // namespace cache
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOURCE_KnownSourcesCache_H
cacheincludedir = $(pkgincludedir)/cache
-cacheinclude_HEADERS = SourceCache.h CacheInitializer.h SourceCacher.h KnownSourcesCache.h Utils.h
+cacheinclude_HEADERS = CacheStore.h CacheInitializer.h Utils.h
## ##################################################
## ##################################################
-lib@PACKAGE@2_cache_la_SOURCES = SourceCache.cpp CacheInitializer.cpp SourceCacher.cpp KnownSourcesCache.cpp Utils.cpp
+lib@PACKAGE@2_cache_la_SOURCES = CacheStore.cpp CacheInitializer.cpp Utils.cpp
lib@PACKAGE@2_cache_la_LDFLAGS = @LIBZYPP_VERSION_INFO@
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#include <vector>
-
-#include "zypp/base/Logger.h"
-#include "zypp/base/String.h"
-#include "zypp2/cache/SourceCache.h"
-#include "zypp/target/store/PersistentStorage.h"
-#include "zypp2/cache/CacheInitializer.h"
-#include "zypp2/cache/Utils.h"
-
-#define ZYPP_DB_FILE "/var/lib/zypp/zypp.db"
-
-using namespace sqlite3x;
-using namespace std;
-
-//////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace cache
-{ /////////////////////////////////////////////////////////////////
-
-
-
-// alias 0 , type 1, desc 2, url 3, path 4, enabled 5, autorefresh 6, timestamp 7, checksum 8
-
-SourceCache::SourceCache( const Pathname &root_r, const std::string alias )
-{
- try
- {
- CacheInitializer init( root_r, ZYPP_DB_FILE);
- _con.reset( new sqlite3_connection(ZYPP_DB_FILE) );
- }
- catch(exception &ex) {
- ERR << "Exception Occured: " << ex.what() << endl;
- }
-}
-
-SourceCache::~SourceCache()
-{
- _con->close();
-}
-
-void SourceCache::cachePackage( const data::Package package )
-{
- MIL << "caching: " << package << std::endl;
-}
-
-void SourceCache::cachePattern( const data::Pattern pattern )
-{
-
-}
-
-void SourceCache::cacheResolvable( const data::ResObject )
-{
-
-}
-
-std::ostream & SourceCache::dumpOn( std::ostream & str ) const
-{
- return str;
-}
-
-}
-}
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/SourceCache.h
- *
-*/
-#ifndef ZYPP_SourceCache_H
-#define ZYPP_SourceCache_H
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/base/PtrTypes.h"
-#include "zypp/source/SourceInfo.h"
-#include "zypp/data/ResolvableData.h"
-#include "zypp/Pathname.h"
-#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- DEFINE_PTR_TYPE(SourceCache);
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : SourceCache
- //
- class SourceCache : public base::ReferenceCounted, private base::NonCopyable
- {
- friend std::ostream & operator<<( std::ostream & str, const SourceCache & obj );
-
- public:
- /** Creates a source cache */
- SourceCache( const Pathname &root_r, const std::string alias );
- ~SourceCache();
-
- void cachePattern( const data::Pattern pattern );
- void cachePackage( const data::Package package );
- protected:
- void cacheResolvable( const data::ResObject );
- /** Overload to realize stream output. */
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- //typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap
- shared_ptr<sqlite3x::sqlite3_connection> _con;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates SourceCache Stream output */
- inline std::ostream & operator<<( std::ostream & str, const SourceCache & obj )
- { return obj.dumpOn( str ); }
-
-
- /////////////////////////////////////////////////////////////////
- } // namespace cache
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOURCE_SourceCache_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#include "zypp/base/Logger.h"
-#include "zypp2/cache/SourceCacher.h"
-
-using namespace std;
-
-//////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace cache
-{ /////////////////////////////////////////////////////////////////
-
-SourceCacher::SourceCacher( const Pathname &root_r )
-{
-
-}
-
-SourceCacher::~SourceCacher()
-{
-}
-
-std::ostream & SourceCacher::dumpOn( std::ostream & str ) const
-{
- return str;
-}
-
-}
-}
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/SourceCacher.h
- *
-*/
-#ifndef ZYPP_SourceCacher_H
-#define ZYPP_SourceCacher_H
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/base/PtrTypes.h"
-#include "zypp/source/SourceInfo.h"
-#include "zypp/Pathname.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- DEFINE_PTR_TYPE(SourceCacher);
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : SourceCacher
- //
- class SourceCacher : public base::ReferenceCounted, private base::NonCopyable
- {
- friend std::ostream & operator<<( std::ostream & str, const SourceCacher & obj );
-
- public:
- /** root path */
- SourceCacher( const Pathname &root_r );
- ~SourceCacher();
- protected:
-
- /** Overload to realize stream output. */
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- //typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates SourceCacher Stream output */
- inline std::ostream & operator<<( std::ostream & str, const SourceCacher & obj )
- { return obj.dumpOn( str ); }
-
-
- /////////////////////////////////////////////////////////////////
- } // namespace cache
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOURCE_SourceCacher_H
char** getsql() {
static char *sql[] = {
- "DROP TABLE IF EXISTS db_info;",
-
- "DROP TABLE IF EXISTS patch_packages_baseversions;",
-
- "DROP TABLE IF EXISTS patch_packages;",
-
- "DROP TABLE IF EXISTS delta_packages;",
-
- "DROP TABLE IF EXISTS package_details;",
-
- "DROP VIEW IF EXISTS packages;",
-
- "DROP TABLE IF EXISTS patch_details;",
-
- "DROP VIEW IF EXISTS patches;",
-
- "DROP TABLE IF EXISTS pattern_details;",
-
- "DROP VIEW IF EXISTS patterns;",
-
- "DROP TABLE IF EXISTS product_details;",
-
- "DROP VIEW IF EXISTS products;",
-
- "DROP TABLE IF EXISTS message_details;",
-
- "DROP VIEW IF EXISTS messages;",
-
- "DROP TABLE IF EXISTS script_details;",
-
- "DROP VIEW IF EXISTS scripts;",
-
- "DROP TABLE IF EXISTS dependencies;",
-
- "DROP TABLE IF EXISTS sources;",
-
- "DROP TABLE IF EXISTS locks;",
-
- "DROP TABLE IF EXISTS resolvables;",
-
"CREATE TABLE db_info ("
" version INTEGER"
");",
"CREATE TRIGGER remove_catalogs"
" AFTER DELETE ON catalogs"
" BEGIN"
- " DELETE FROM resolvables WHERE catalog = old.id;",
-
+ " DELETE FROM resolvables WHERE catalog = old.id;"
" END;",
"CREATE TRIGGER remove_patch_packages_baseversions"
" AFTER DELETE ON patch_packages"
" BEGIN"
- " DELETE FROM patch_packages_baseversions WHERE patch_package_id = old.id;",
-
+ " DELETE FROM patch_packages_baseversions WHERE patch_package_id = old.id;"
" END;",
"CREATE TRIGGER remove_resolvables"
" AFTER DELETE ON resolvables"
" BEGIN"
- " DELETE FROM package_details WHERE resolvable_id = old.id;",
-
- " DELETE FROM patch_details WHERE resolvable_id = old.id;",
-
- " DELETE FROM pattern_details WHERE resolvable_id = old.id;",
-
- " DELETE FROM product_details WHERE resolvable_id = old.id;",
-
- " DELETE FROM message_details WHERE resolvable_id = old.id;",
-
- " DELETE FROM script_details WHERE resolvable_id = old.id;",
-
- " DELETE FROM dependencies WHERE resolvable_id = old.id;",
-
- " DELETE FROM files WHERE resolvable_id = old.id;",
-
- " DELETE FROM delta_packages WHERE package_id = old.id;",
-
- " DELETE FROM patch_packages WHERE package_id = old.id;",
-
+ " DELETE FROM package_details WHERE resolvable_id = old.id;"
+ " DELETE FROM patch_details WHERE resolvable_id = old.id;"
+ " DELETE FROM pattern_details WHERE resolvable_id = old.id;"
+ " DELETE FROM product_details WHERE resolvable_id = old.id;"
+ " DELETE FROM message_details WHERE resolvable_id = old.id;"
+ " DELETE FROM script_details WHERE resolvable_id = old.id;"
+ " DELETE FROM dependencies WHERE resolvable_id = old.id;"
+ " DELETE FROM files WHERE resolvable_id = old.id;"
+ " DELETE FROM delta_packages WHERE package_id = old.id;"
+ " DELETE FROM patch_packages WHERE package_id = old.id;"
" END;",
0};
## Process this file with automake to produce Makefile.in
## ##################################################
-SUBDIRS = yum sqlite-source
+SUBDIRS = sqlite-source
INCLUDES = \
-DZYPP_BASE_LOGGER_LOGGROUP=\"source2\"
+++ /dev/null
-## Process this file with automake to produce Makefile.in
-## ##################################################
-
-SUBDIRS =
-
-INCLUDES = \
- -DZYPP_BASE_LOGGER_LOGGROUP=\"yum\"
-
-## ##################################################
-
-sourceyumincludedir = $(pkgincludedir)/source/yum
-
-sourceyuminclude_HEADERS = \
- YUMSourceCacher.h
-
-
-noinst_LTLIBRARIES = lib@PACKAGE@2_source_yum.la
-
-## ##################################################
-
-lib@PACKAGE@2_source_yum_la_SOURCES = \
- YUMSourceCacher.cc
-
-## ##################################################
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#include <fstream>
-
-#include "zypp/base/Logger.h"
-#include "zypp/MediaSetAccess.h"
-#include "zypp2/cache/SourceCacher.h"
-
-#include "zypp/base/GzStream.h"
-#include "zypp/parser/yum/YUMParser.h"
-
-#include "zypp/parser/SAXParser.h"
-#include "zypp/parser/yum/YUMParser.h"
-#include "zypp/parser/yum2/YUMPrimaryParser.h"
-#include "zypp2/source/yum/YUMSourceCacher.h"
-
-using namespace std;
-
-//////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-namespace source
-{ /////////////////////////////////////////////////////////////////
-namespace yum
-{ /////////////////////////////////////////////////////////////////
-
-
-YUMSourceCacher::YUMSourceCacher( const Pathname &root_r ) : zypp::cache::SourceCacher(root_r)
-{
-
-}
-
-YUMSourceCacher::~YUMSourceCacher()
-{
-}
-
-void YUMSourceCacher::consumePackage( const data::Package &package)
-{
- MIL << "caching " << package.name << " " << package.arch << std::endl;
-}
-
-void YUMSourceCacher::cache( const Url &url, const Pathname &path )
-{
- filesystem::TmpDir tmpdir = downloadMetadata(url, path);
- parser::yum2::YUMPrimaryParser reader(*this);
- reader.parseFile( tmpdir.path() + "/repodata/primary.xml.gz");
-
-}
-
-filesystem::TmpDir YUMSourceCacher::downloadMetadata(const Url &url, const Pathname &path)
-{
- filesystem::TmpDir tmpdir;
- filesystem::TmpDir _cache_dir;
-
- MediaSetAccess media(url, path);
-
- int copy_result;
- MIL << "Downloading metadata to " << tmpdir.path() << std::endl;
-
- Pathname local_dir = tmpdir.path();
- if (0 != assert_dir(local_dir + "/repodata" , 0755))
- ZYPP_THROW(Exception("Cannot create /repodata in download directory"));
-
- MIL << "Storing data to tmp dir " << local_dir << endl;
-
- // first read list of all files in the repository
- Pathname remote_repomd;
- try
- {
- remote_repomd = media.provideFile( path + "/repodata/repomd.xml");
- }
- catch(Exception &e)
- {
- ZYPP_THROW(Exception("Can't provide " + path.asString() + "/repodata/repomd.xml from " + url.asString() ));
- }
-
- // provide optional files
- //Pathname remote_repomd_key;
- //Pathname remote_repomd_signature;
- //try {
- // remote_repomd_key = tryToProvideFile( _path + "/repodata/repomd.xml.key");
- //}
- //catch( const Exception &e ) {
- // WAR << "Repository does not contain repomd signing key" << std::endl;
- //}
-
- //try {
- // remote_repomd_signature = tryToProvideFile( _path + "/repodata/repomd.xml.asc");
- //}
- //catch( const Exception &e ) {
- // WAR << "Repository does not contain repomd signature" << std::endl;
- //}
-
- copy_result = filesystem::copy( remote_repomd, local_dir + "/repodata/repomd.xml");
- if ( copy_result != 0 )
- ZYPP_THROW(Exception("Can't copy " + remote_repomd.asString() + " to " + local_dir.asString() + "/repodata/repomd.xml"));
-
- // if (PathInfo(remote_repomd_key).isExist())
- // {
- // copy_result = filesystem::copy( remote_repomd_key, local_dir + "/repodata/repomd.xml.key");
- // if ( copy_result != 0 )
- // ZYPP_THROW(Exception("Can't copy " + remote_repomd_key.asString() + " to " + local_dir.asString() + "/repodata/repomd.xml.key"));
- // getZYpp()->keyRing()->importKey(local_dir + "/repodata/repomd.xml.key" , false);
- // }
- //
- // if (PathInfo(remote_repomd_signature).isExist())
- // {
- // copy_result = filesystem::copy( remote_repomd_signature, local_dir + "/repodata/repomd.xml.asc");
- // if ( copy_result != 0 )
- // ZYPP_THROW(Exception("Can't copy " + remote_repomd_signature.asString() + " to " + local_dir.asString() + "/repodata/repomd.xml.asc"));
- // }
-
- DBG << "Reading file " << remote_repomd << endl;
- ifstream repo_st(remote_repomd.asString().c_str());
- parser::yum::YUMRepomdParser repomd(repo_st, "");
-
- for(; ! repomd.atEnd(); ++repomd)
- {
- if ((*repomd)->type == "other") // don't parse 'other.xml' (#159316)
- continue;
-
- if ((*repomd)->type == "filelists")
- continue;
-
- media.providePossiblyCachedMetadataFile( path + (*repomd)->location, 1, local_dir + (*repomd)->location, _cache_dir + (*repomd)->location, CheckSum((*repomd)->checksumType, (*repomd)->checksum) );
-
- // if it is a patch, we read the patches individually
- if ((*repomd)->type == "patches")
- {
- // use the local copy now
- Pathname patches_list = local_dir + (*repomd)->location;
- MIL << "Reading patches file " << patches_list << std::endl;
- ifgzstream st ( patches_list.asString().c_str() );
- parser::yum::YUMPatchesParser patch(st, "");
- for (; !patch.atEnd(); ++patch)
- {
-
- media.providePossiblyCachedMetadataFile( path + (*patch)->location, 1, local_dir + (*patch)->location, _cache_dir + (*patch)->location, CheckSum((*patch)->checksumType, (*patch)->checksum) );
- } // end of single patch parsing
- }// end of patches file parsing
- } // end of copying
-
- // check signature
- // MIL << "Checking [" << (local_dir + "/repodata/repomd.xml") << "] signature" << endl;
- // if (! getZYpp()->keyRing()->verifyFileSignatureWorkflow(local_dir + "/repodata/repomd.xml", (_path + "/repodata/repomd.xml").asString()+ " (" + url().asString() + ")", local_dir + "/repodata/repomd.xml.asc"))
- // ZYPP_THROW(Exception(N_("Signed repomd.xml file fails signature check")));
-
- // ok, now we have a consistent repo in the tmpdir.
- return tmpdir;
-}
-
-
-std::ostream & YUMSourceCacher::dumpOn( std::ostream & str ) const
-{
- return str;
-}
-
-}
-}
-}
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef ZYPP_YUMSourceCacher_H
-#define ZYPP_YUMSourceCacher_H
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp2/cache/SourceCacher.h"
-#include "zypp/data/ResolvableData.h"
-#include "zypp/data/ResolvableDataConsumer.h"
-#include "zypp/Pathname.h"
-#include "zypp/TmpPath.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace source
- { /////////////////////////////////////////////////////////////////
-
- namespace yum
- { /////////////////////////////////////////////////////////////////
-
- DEFINE_PTR_TYPE(YUMSourceCacher);
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : SourceCacher
- //
- class YUMSourceCacher : public cache::SourceCacher, public data::ResolvableDataConsumer
- {
- friend std::ostream & operator<<( std::ostream & str, const YUMSourceCacher & obj );
-
- public:
- /** root path */
- YUMSourceCacher( const Pathname &root_r );
- ~YUMSourceCacher();
- void cache( const Url &url, const Pathname &path );
-
- void consumePackage( const data::Package &package);
- protected:
- filesystem::TmpDir downloadMetadata(const Url &url, const Pathname &path);
-
- /** Overload to realize stream output. */
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- //typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates SourceCacher Stream output */
- inline std::ostream & operator<<( std::ostream & str, const YUMSourceCacher & obj )
- { return obj.dumpOn( str ); }
-
-
- /////////////////////////////////////////////////////////////////
- } // namespace cache
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-}
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOURCE_SourceCacher_H