Hello community,
here is the log from the commit of package libzypp-zmd-backend
checked in at Mon Apr 24 00:38:59 CEST 2006.
--------
--- libzypp-zmd-backend/libzypp-zmd-backend.changes 2006-04-20 18:51:35.000000000 +0200
+++ STABLE/libzypp-zmd-backend/libzypp-zmd-backend.changes 2006-04-23 22:41:58.000000000 +0200
@@ -1,0 +2,6 @@
+Sun Apr 23 22:39:07 CEST 2006 - kkaempf@suse.de
+
+- sync Message and Script objects to zmd database (#168607)
+- rev 3183
+
+-------------------------------------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ libzypp-zmd-backend.spec ++++++
--- /var/tmp/diff_new_pack.BQJvxN/_old 2006-04-24 00:38:49.000000000 +0200
+++ /var/tmp/diff_new_pack.BQJvxN/_new 2006-04-24 00:38:49.000000000 +0200
@@ -22,7 +22,7 @@
Obsoletes: zmd-librc-backend
Summary: ZMD backend for Package, Patch, Pattern, and Product Management
Version: 7.1.1.0
-Release: 22
+Release: 24
Source: zmd-backend-%{version}.tar.bz2
Prefix: /usr
@@ -68,6 +68,9 @@
/etc/logrotate.d/zmd-backend
%changelog -n libzypp-zmd-backend
+* Sun Apr 23 2006 - kkaempf@suse.de
+- sync Message and Script objects to zmd database (#168607)
+- rev 3183
* Thu Apr 20 2006 - kkaempf@suse.de
- add 'alias=' parameter with "&" if url already contains "?"
(#168030)
++++++ zmd-backend-7.1.1.0.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/DbAccess.cc new/zmd-backend-7.1.1.0/src/dbsource/DbAccess.cc
--- old/zmd-backend-7.1.1.0/src/dbsource/DbAccess.cc 2006-04-18 21:29:52.000000000 +0200
+++ new/zmd-backend-7.1.1.0/src/dbsource/DbAccess.cc 2006-04-23 22:36:38.000000000 +0200
@@ -11,6 +11,7 @@
*/
#include <iostream>
+#include <fstream>
#include "zypp/base/Logger.h"
#include "zypp/ZYppFactory.h"
@@ -207,6 +208,8 @@
, _db( NULL )
, _insert_res_handle( NULL )
, _insert_pkg_handle( NULL )
+ , _insert_message_handle( NULL )
+ , _insert_script_handle( NULL )
, _insert_patch_handle( NULL )
, _insert_pattern_handle( NULL )
, _insert_product_handle( NULL )
@@ -267,6 +270,36 @@
static sqlite3_stmt *
+prepare_message_insert (sqlite3 *db)
+{
+ string query (
+ // 1
+ "INSERT INTO message_details (resolvable_id, "
+ // 2
+ " content) "
+ "VALUES (?, ?)"
+ "");
+
+ return prepare_handle( db, query );
+}
+
+
+static sqlite3_stmt *
+prepare_script_insert (sqlite3 *db)
+{
+ string query (
+ // 1
+ "INSERT INTO script_details (resolvable_id, "
+ // 2 3
+ " do_script, undo_script) "
+ "VALUES (?, ?, ?)"
+ "");
+
+ return prepare_handle( db, query );
+}
+
+
+static sqlite3_stmt *
prepare_pkg_insert (sqlite3 *db)
{
string query (
@@ -364,6 +397,16 @@
goto cleanup;
}
+ _insert_message_handle = prepare_message_insert (_db);
+ if (_insert_message_handle == NULL) {
+ goto cleanup;
+ }
+
+ _insert_script_handle = prepare_script_insert (_db);
+ if (_insert_script_handle == NULL) {
+ goto cleanup;
+ }
+
_insert_patch_handle = prepare_patch_insert (_db);
if (_insert_patch_handle == NULL) {
goto cleanup;
@@ -449,6 +492,8 @@
close_handle( &_insert_res_handle );
close_handle( &_insert_pkg_handle );
+ close_handle( &_insert_message_handle );
+ close_handle( &_insert_script_handle );
close_handle( &_insert_patch_handle );
close_handle( &_insert_pattern_handle );
close_handle( &_insert_product_handle );
@@ -602,6 +647,79 @@
//----------------------------------------------------------------------------
+// message
+
+sqlite_int64
+DbAccess::writeMessage (sqlite_int64 id, Message::constPtr message )
+{
+ XXX << "DbAccess::writeMessage(" << id << ", " << *message << ")" << endl;
+ int rc;
+ sqlite3_stmt *handle = _insert_message_handle;
+
+ sqlite3_bind_int64( handle, 1, id);
+ sqlite3_bind_text( handle, 2, message->text().asString().c_str(), -1, SQLITE_STATIC );
+
+ rc = sqlite3_step( handle);
+ sqlite3_reset( handle);
+
+ if (rc != SQLITE_DONE) {
+ ERR << "Error adding message to SQL: " << sqlite3_errmsg (_db) << endl;
+ return -1;
+ }
+ sqlite_int64 rowid = sqlite3_last_insert_rowid (_db);
+
+ return rowid;
+}
+
+
+//----------------------------------------------------------------------------
+// script
+
+static string
+readFromPath( const Pathname & p )
+{
+ string result;
+ string line;
+ try {
+ ifstream infile( p.asString().c_str() );
+ while (getline( infile, line )) {
+ result += line;
+ result += "\n";
+ }
+ }
+ catch( const Exception & excpt_r ) {
+ ZYPP_CAUGHT( excpt_r );
+ }
+ return result;
+}
+
+sqlite_int64
+DbAccess::writeScript (sqlite_int64 id, Script::constPtr script)
+{
+ XXX << "DbAccess::writeScript(" << id << ", " << *script << ")" << endl;
+ int rc;
+ sqlite3_stmt *handle = _insert_script_handle;
+
+ sqlite3_bind_int64( handle, 1, id);
+ string do_script( readFromPath( script->do_script() ) );
+ string undo_script( readFromPath( script->undo_script() ) );
+ sqlite3_bind_text( handle, 2, do_script.c_str(), -1, SQLITE_STATIC );
+ sqlite3_bind_text( handle, 3, undo_script.c_str(), -1, SQLITE_STATIC );
+
+ rc = sqlite3_step( handle);
+ sqlite3_reset( handle);
+
+ if (rc != SQLITE_DONE) {
+ ERR << "Error adding message to SQL: " << sqlite3_errmsg (_db) << endl;
+ return -1;
+ }
+ sqlite_int64 rowid = sqlite3_last_insert_rowid (_db);
+
+ return rowid;
+}
+
+
+//----------------------------------------------------------------------------
// patch
sqlite_int64
@@ -705,6 +823,8 @@
Resolvable::constPtr res = obj;
Package::constPtr pkg = asKind<Package>(res);
+ Message::constPtr message = asKind<Message>(res);
+ Script::constPtr script = asKind<Script>(res);
Patch::constPtr patch = asKind<Patch>(res);
Pattern::constPtr pattern = asKind<Pattern>(res);
Product::constPtr product = asKind<Product>(res);
@@ -782,6 +902,8 @@
// now write the respective _details table
if (pkg != NULL) writePackage( rowid, pkg, zmd_owned );
+ else if (message != NULL) writeMessage( rowid, message );
+ else if (script != NULL) writeScript( rowid, script );
else if (patch != NULL) writePatch( rowid, patch );
else if (pattern != NULL) writePattern( rowid, pattern );
else if (product != NULL) writeProduct( rowid, product );
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/DbAccess.h new/zmd-backend-7.1.1.0/src/dbsource/DbAccess.h
--- old/zmd-backend-7.1.1.0/src/dbsource/DbAccess.h 2006-04-18 21:29:52.000000000 +0200
+++ new/zmd-backend-7.1.1.0/src/dbsource/DbAccess.h 2006-04-23 22:23:49.000000000 +0200
@@ -23,6 +23,8 @@
#include
#include
#include
+#include
+#include
#include
#include
#include
@@ -141,6 +143,8 @@
sqlite3 *_db;
sqlite3_stmt *_insert_res_handle;
sqlite3_stmt *_insert_pkg_handle;
+ sqlite3_stmt *_insert_message_handle;
+ sqlite3_stmt *_insert_script_handle;
sqlite3_stmt *_insert_patch_handle;
sqlite3_stmt *_insert_pattern_handle;
sqlite3_stmt *_insert_product_handle;
@@ -151,6 +155,8 @@
sqlite_int64 writeResObject( zypp::ResObject::constPtr obj, zypp::ResStatus status, const char *catalog = NULL, bool zmd_owned = false );
sqlite_int64 writePackage( sqlite_int64 id, zypp::Package::constPtr package, bool zmd_owned = false );
+ sqlite_int64 writeMessage( sqlite_int64 id, zypp::Message::constPtr message );
+ sqlite_int64 writeScript( sqlite_int64 id, zypp::Script::constPtr script );
sqlite_int64 writePatch( sqlite_int64 id, zypp::Patch::constPtr patch );
sqlite_int64 writePattern( sqlite_int64 id, zypp::Pattern::constPtr pattern );
sqlite_int64 writeProduct( sqlite_int64 id, zypp::Product::constPtr product );
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/DbLanguageImpl.cc new/zmd-backend-7.1.1.0/src/dbsource/DbLanguageImpl.cc
--- old/zmd-backend-7.1.1.0/src/dbsource/DbLanguageImpl.cc 1970-01-01 01:00:00.000000000 +0100
+++ new/zmd-backend-7.1.1.0/src/dbsource/DbLanguageImpl.cc 2006-04-23 21:43:00.000000000 +0200
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zmd/backend/dbsource/DbLanguageImpl.h
+ *
+*/
+
+#include "DbLanguageImpl.h"
+#include "zypp/source/SourceImpl.h"
+#include "zypp/TranslatedText.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Logger.h"
+
+using namespace std;
+using namespace zypp::detail;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : DbLanguageImpl
+//
+///////////////////////////////////////////////////////////////////
+
+/** Default ctor
+*/
+DbLanguageImpl::DbLanguageImpl (Source_Ref source_r, ZmdId zmdid)
+ : _source( source_r )
+ , _zmdid( zmdid )
+{
+}
+
+Source_Ref
+DbLanguageImpl::source() const
+{ return _source; }
+
+ZmdId DbLanguageImpl::zmdid() const
+{ return _zmdid; }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/DbLanguageImpl.h new/zmd-backend-7.1.1.0/src/dbsource/DbLanguageImpl.h
--- old/zmd-backend-7.1.1.0/src/dbsource/DbLanguageImpl.h 1970-01-01 01:00:00.000000000 +0100
+++ new/zmd-backend-7.1.1.0/src/dbsource/DbLanguageImpl.h 2006-04-23 21:39:12.000000000 +0200
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zmd/backend/dbsource/DbLanguageImpl.h
+ *
+*/
+#ifndef ZMD_BACKEND_DBSOURCE_DBLANGUAGEIMPL_H
+#define ZMD_BACKEND_DBSOURCE_DBLANGUAGEIMPL_H
+
+#include "zypp/Language.h"
+#include "zypp/Source.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : DbLanguageImpl
+//
+/** Class representing a package
+*/
+class DbLanguageImpl : public detail::LanguageImplIf
+{
+public:
+
+ /** Default ctor
+ */
+ DbLanguageImpl( Source_Ref source_r, ZmdId zmdid );
+
+ /** */
+ virtual Source_Ref source() const;
+ /** */
+ virtual ZmdId zmdid() const;
+
+protected:
+ Source_Ref _source;
+ ZmdId _zmdid;
+
+ };
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZMD_BACKEND_DBSOURCE_DBLANGUAGEIMPL_H
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/DbMessageImpl.cc new/zmd-backend-7.1.1.0/src/dbsource/DbMessageImpl.cc
--- old/zmd-backend-7.1.1.0/src/dbsource/DbMessageImpl.cc 1970-01-01 01:00:00.000000000 +0100
+++ new/zmd-backend-7.1.1.0/src/dbsource/DbMessageImpl.cc 2006-04-23 15:06:53.000000000 +0200
@@ -0,0 +1,57 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zmd/backend/dbsource/DbMessageImpl.h
+ *
+*/
+
+#include "DbMessageImpl.h"
+#include "zypp/source/SourceImpl.h"
+#include "zypp/TranslatedText.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Logger.h"
+
+using namespace std;
+using namespace zypp::detail;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : DbMessageImpl
+//
+///////////////////////////////////////////////////////////////////
+
+/** Default ctor
+*/
+DbMessageImpl::DbMessageImpl (Source_Ref source_r, TranslatedText text, ZmdId zmdid)
+ : _source( source_r )
+ , _text( text )
+ , _zmdid( zmdid )
+{
+}
+
+Source_Ref
+DbMessageImpl::source() const
+{ return _source; }
+
+TranslatedText DbMessageImpl::text() const
+{ return _text; }
+
+ByteCount DbMessageImpl::size() const
+{ return _text.asString().size(); }
+
+
+ZmdId DbMessageImpl::zmdid() const
+{ return _zmdid; }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/DbMessageImpl.h new/zmd-backend-7.1.1.0/src/dbsource/DbMessageImpl.h
--- old/zmd-backend-7.1.1.0/src/dbsource/DbMessageImpl.h 1970-01-01 01:00:00.000000000 +0100
+++ new/zmd-backend-7.1.1.0/src/dbsource/DbMessageImpl.h 2006-04-23 15:07:12.000000000 +0200
@@ -0,0 +1,52 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zmd/backend/dbsource/DbMessageImpl.h
+ *
+*/
+#ifndef ZMD_BACKEND_DBSOURCE_DBMESSAGEIMPL_H
+#define ZMD_BACKEND_DBSOURCE_DBMESSAGEIMPL_H
+
+#include "zypp/detail/MessageImpl.h"
+#include "zypp/Source.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : DbMessageImpl
+//
+/** Class representing a package
+*/
+class DbMessageImpl : public detail::MessageImplIf
+{
+public:
+
+ /** Default ctor
+ */
+ DbMessageImpl( Source_Ref source_r, TranslatedText text, ZmdId zmdid );
+
+ /** */
+ virtual Source_Ref source() const;
+ virtual TranslatedText text() const;
+ virtual ByteCount size() const;
+ /** */
+ virtual ZmdId zmdid() const;
+
+protected:
+ Source_Ref _source;
+ TranslatedText _text;
+ ZmdId _zmdid;
+
+ };
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZMD_BACKEND_DBSOURCE_DBMESSAGEIMPL_H
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/DbScriptImpl.cc new/zmd-backend-7.1.1.0/src/dbsource/DbScriptImpl.cc
--- old/zmd-backend-7.1.1.0/src/dbsource/DbScriptImpl.cc 1970-01-01 01:00:00.000000000 +0100
+++ new/zmd-backend-7.1.1.0/src/dbsource/DbScriptImpl.cc 2006-04-23 21:45:27.000000000 +0200
@@ -0,0 +1,85 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zmd/backend/dbsource/DbScriptImpl.h
+ *
+*/
+
+#include <fstream>
+
+#include "DbScriptImpl.h"
+#include "zypp/source/SourceImpl.h"
+#include "zypp/TranslatedText.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Logger.h"
+
+using namespace std;
+using namespace zypp::detail;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : DbScriptImpl
+//
+///////////////////////////////////////////////////////////////////
+
+/** Default ctor
+*/
+DbScriptImpl::DbScriptImpl (Source_Ref source_r, std::string do_script, std::string undo_script, ZmdId zmdid)
+ : _source( source_r )
+ , _do_script( do_script )
+ , _undo_script( undo_script )
+ , _zmdid( zmdid )
+{
+}
+
+Source_Ref
+DbScriptImpl::source() const
+{ return _source; }
+
+Pathname
+DbScriptImpl::do_script() const
+{
+ if (_do_script.empty()) {
+ return Pathname();
+ }
+ _tmp_file = filesystem::TmpFile();
+ Pathname path = _tmp_file.path();
+ ofstream st( path.asString().c_str() );
+ st << _do_script << endl;
+ return path;
+}
+
+Pathname
+DbScriptImpl::undo_script() const
+{
+ if (_undo_script.empty()) {
+ return Pathname();
+ }
+ _tmp_file = filesystem::TmpFile();
+ Pathname path = _tmp_file.path();
+ ofstream st( path.asString().c_str() );
+ st << _undo_script << endl;
+ return path;
+}
+
+bool
+DbScriptImpl::undo_available() const
+{
+ return !_undo_script.empty();
+}
+
+ZmdId DbScriptImpl::zmdid() const
+{ return _zmdid; }
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/DbScriptImpl.h new/zmd-backend-7.1.1.0/src/dbsource/DbScriptImpl.h
--- old/zmd-backend-7.1.1.0/src/dbsource/DbScriptImpl.h 1970-01-01 01:00:00.000000000 +0100
+++ new/zmd-backend-7.1.1.0/src/dbsource/DbScriptImpl.h 2006-04-23 21:45:37.000000000 +0200
@@ -0,0 +1,57 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zmd/backend/dbsource/DbScriptImpl.h
+ *
+*/
+#ifndef ZMD_BACKEND_DBSOURCE_DBSCRIPTIMPL_H
+#define ZMD_BACKEND_DBSOURCE_DBSCRIPTIMPL_H
+
+#include "zypp/detail/ScriptImpl.h"
+#include "zypp/TmpPath.h"
+#include "zypp/Source.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : DbScriptImpl
+//
+/** Class representing a package
+*/
+class DbScriptImpl : public detail::ScriptImplIf
+{
+public:
+
+ /** Default ctor
+ */
+ DbScriptImpl( Source_Ref source_r, std::string do_script, std::string undo_script, ZmdId zmdid );
+
+ /** */
+ virtual Source_Ref source() const;
+ virtual Pathname do_script() const;
+ virtual Pathname undo_script() const;
+ virtual bool undo_available() const;
+
+ /** */
+ virtual ZmdId zmdid() const;
+
+protected:
+ Source_Ref _source;
+ std::string _do_script;
+ std::string _undo_script;
+ ZmdId _zmdid;
+
+ mutable filesystem::TmpFile _tmp_file;
+ };
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZMD_BACKEND_DBSOURCE_DBSCRIPTIMPL_H
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/DbSourceImpl.cc new/zmd-backend-7.1.1.0/src/dbsource/DbSourceImpl.cc
--- old/zmd-backend-7.1.1.0/src/dbsource/DbSourceImpl.cc 2006-04-20 11:27:23.000000000 +0200
+++ new/zmd-backend-7.1.1.0/src/dbsource/DbSourceImpl.cc 2006-04-23 21:40:18.000000000 +0200
@@ -23,13 +23,12 @@
#include "DbPackageImpl.h"
#include "DbAtomImpl.h"
+#include "DbMessageImpl.h"
+#include "DbScriptImpl.h"
+#include "DbLanguageImpl.h"
#include "DbPatchImpl.h"
#include "DbPatternImpl.h"
#include "DbProductImpl.h"
-#if 0
-#include "DbScriptImpl.h"
-#include "DbMessageImpl.h"
-#endif
#include "zypp/source/SourceImpl.h"
#include "zypp/base/Logger.h"
@@ -140,6 +139,62 @@
static sqlite3_stmt *
+create_message_handle (sqlite3 *db)
+{
+ const char *query;
+ int rc;
+ sqlite3_stmt *handle = NULL;
+
+ query =
+ // 0 1 2 3 4 5
+ "SELECT id, name, version, release, epoch, arch, "
+ // 6 7
+ " installed_size, catalog,"
+ // 8 9 10
+ " installed, local, content "
+ "FROM messages "
+ "WHERE catalog = ?";
+
+ rc = sqlite3_prepare ( db, query, -1, &handle, NULL);
+ if (rc != SQLITE_OK) {
+ ERR << "Can not prepare messages selection clause: " << sqlite3_errmsg ( db) << endl;
+ sqlite3_finalize (handle);
+ return NULL;
+ }
+
+ return handle;
+}
+
+
+static sqlite3_stmt *
+create_script_handle (sqlite3 *db)
+{
+ const char *query;
+ int rc;
+ sqlite3_stmt *handle = NULL;
+
+ query =
+ // 0 1 2 3 4 5
+ "SELECT id, name, version, release, epoch, arch, "
+ // 6 7
+ " installed_size, catalog,"
+ // 8 9 10 11
+ " installed, local, do_script, undo_script "
+ "FROM scripts "
+ "WHERE catalog = ?";
+
+ rc = sqlite3_prepare ( db, query, -1, &handle, NULL);
+ if (rc != SQLITE_OK) {
+ ERR << "Can not prepare scripts selection clause: " << sqlite3_errmsg ( db) << endl;
+ sqlite3_finalize (handle);
+ return NULL;
+ }
+
+ return handle;
+}
+
+
+static sqlite3_stmt *
create_package_handle (sqlite3 *db)
{
const char *query;
@@ -216,7 +271,7 @@
"SELECT id, name, version, release, epoch, arch, "
// 6 7
" installed_size, catalog,"
- // 8 9 11
+ // 8 9 10
" installed, local, status "
"FROM patterns "
"WHERE catalog = ?";
@@ -279,6 +334,9 @@
createPackages();
createAtoms();
+ createMessages();
+ createScripts();
+// createLanguages();
createPatches();
createPatterns();
createProducts();
@@ -288,12 +346,13 @@
void
-DbSourceImpl::createPackages(void)
+DbSourceImpl::createAtoms(void)
{
- sqlite3_stmt *handle = create_package_handle ( _db);
+ sqlite3_stmt *handle = create_resolvables_handle( _db );
if (handle == NULL) return;
sqlite3_bind_text (handle, 1, _source.id().c_str(), -1, SQLITE_STATIC);
+ sqlite3_bind_int (handle, 2, RC_DEP_TARGET_ATOM);
int rc;
while ((rc = sqlite3_step (handle)) == SQLITE_ROW) {
@@ -302,8 +361,106 @@
try
{
- detail::ResImplTraits<DbPackageImpl>::Ptr impl( new DbPackageImpl( _zyppsource ? _zyppsource :_source ) );
+ sqlite_int64 id = sqlite3_column_int64( handle, 0 );
+ name = (const char *) sqlite3_column_text( handle, 1 );
+ string version ((const char *) sqlite3_column_text( handle, 2 ));
+ string release ((const char *) sqlite3_column_text( handle, 3 ));
+ unsigned epoch = sqlite3_column_int( handle, 4 );
+ Arch arch( DbAccess::Rc2Arch( (RCArch)(sqlite3_column_int( handle, 5 )) ) );
+
+ detail::ResImplTraits<DbAtomImpl>::Ptr impl( new DbAtomImpl( _source, id ) );
+
+ // Collect basic Resolvable data
+ NVRAD dataCollect( name,
+ Edition( version, release, epoch ),
+ arch,
+ createDependencies (id ) );
+
+ Atom::Ptr atom = detail::makeResolvableFromImpl( dataCollect, impl );
+ _store.insert( atom );
+ XXX << "Atom[" << id << "] " << *atom << endl;
+ if ( _idmap != 0)
+ (*_idmap)[id] = atom;
+ }
+ catch (const Exception & excpt_r)
+ {
+ ERR << "Cannot create atom object '" << name << "' from catalog '" << _source.id() << "'" << endl;
+ sqlite3_reset (handle);
+ ZYPP_RETHROW (excpt_r);
+ }
+ }
+ sqlite3_reset (handle);
+ return;
+}
+
+
+void
+DbSourceImpl::createMessages(void)
+{
+ sqlite3_stmt *handle = create_message_handle( _db );
+ if (handle == NULL) return;
+
+ sqlite3_bind_text( handle, 1, _source.id().c_str(), -1, SQLITE_STATIC );
+
+ int rc;
+ while ((rc = sqlite3_step (handle)) == SQLITE_ROW) {
+
+ string name;
+
+ try
+ {
+ sqlite_int64 id = sqlite3_column_int64( handle, 0 );
+ name = (const char *) sqlite3_column_text( handle, 1 );
+ string version( (const char *)sqlite3_column_text( handle, 2 ) );
+ string release( (const char *)sqlite3_column_text( handle, 3 ) );
+ unsigned epoch = sqlite3_column_int( handle, 4 );
+ Arch arch( DbAccess::Rc2Arch( (RCArch)(sqlite3_column_int( handle, 5 )) ) );
+
+ string content( (const char *)sqlite3_column_text( handle, 10 ) );
+
+ detail::ResImplTraits<DbMessageImpl>::Ptr impl( new DbMessageImpl( _source, TranslatedText( content ), id ) );
+
+ // Collect basic Resolvable data
+ NVRAD dataCollect( name,
+ Edition( version, release, epoch ),
+ arch,
+ createDependencies (id ) );
+
+ Message::Ptr message = detail::makeResolvableFromImpl( dataCollect, impl );
+ _store.insert( message );
+ XXX << "Message[" << id << "] " << *message << endl;
+ if (_idmap != 0)
+ (*_idmap)[id] = message;
+ }
+ catch (const Exception & excpt_r)
+ {
+ ERR << "Cannot create message object '" << name << "' from catalog '" << _source.id() << "'" << endl;
+ sqlite3_reset (handle);
+ ZYPP_RETHROW (excpt_r);
+ }
+ }
+
+ sqlite3_reset (handle);
+ return;
+}
+
+
+void
+DbSourceImpl::createScripts(void)
+{
+ sqlite3_stmt *handle = create_script_handle( _db );
+ if (handle == NULL) return;
+
+ sqlite3_bind_text( handle, 1, _source.id().c_str(), -1, SQLITE_STATIC );
+
+ int rc;
+ while ((rc = sqlite3_step (handle)) == SQLITE_ROW) {
+
+ string name;
+
+ try
+ {
sqlite_int64 id = sqlite3_column_int64( handle, 0 );
name = (const char *) sqlite3_column_text( handle, 1 );
string version ((const char *) sqlite3_column_text( handle, 2 ));
@@ -311,7 +468,10 @@
unsigned epoch = sqlite3_column_int( handle, 4 );
Arch arch( DbAccess::Rc2Arch( (RCArch)(sqlite3_column_int( handle, 5 )) ) );
- impl->readHandle( id, handle );
+ string do_script( (const char *)sqlite3_column_text( handle, 10 ) );
+ string undo_script( (const char *)sqlite3_column_text( handle, 11 ) );
+
+ detail::ResImplTraits<DbScriptImpl>::Ptr impl( new DbScriptImpl( _source, do_script, undo_script, id ) );
// Collect basic Resolvable data
NVRAD dataCollect( name,
@@ -319,14 +479,15 @@
arch,
createDependencies (id ) );
- Package::Ptr package = detail::makeResolvableFromImpl( dataCollect, impl );
- _store.insert( package );
+ Script::Ptr script = detail::makeResolvableFromImpl( dataCollect, impl );
+ _store.insert( script );
+ XXX << "Script[" << id << "] " << *script << endl;
if ( _idmap != 0)
- (*_idmap)[id] = package;
+ (*_idmap)[id] = script;
}
catch (const Exception & excpt_r)
{
- ERR << "Cannot create package object '"+name+"' from catalog '"+_source.id()+"'" << endl;
+ ERR << "Cannot create script object '" << name << "' from catalog '" << _source.id() << "'" << endl;
sqlite3_reset (handle);
ZYPP_RETHROW (excpt_r);
}
@@ -338,13 +499,13 @@
void
-DbSourceImpl::createAtoms(void)
+DbSourceImpl::createLanguages(void)
{
sqlite3_stmt *handle = create_resolvables_handle( _db );
if (handle == NULL) return;
sqlite3_bind_text (handle, 1, _source.id().c_str(), -1, SQLITE_STATIC);
- sqlite3_bind_int (handle, 2, RC_DEP_TARGET_ATOM);
+ sqlite3_bind_int (handle, 2, RC_DEP_TARGET_LANGUAGE);
int rc;
while ((rc = sqlite3_step (handle)) == SQLITE_ROW) {
@@ -360,7 +521,7 @@
unsigned epoch = sqlite3_column_int( handle, 4 );
Arch arch( DbAccess::Rc2Arch( (RCArch)(sqlite3_column_int( handle, 5 )) ) );
- detail::ResImplTraits<DbAtomImpl>::Ptr impl( new DbAtomImpl( _source, id ) );
+ detail::ResImplTraits<DbLanguageImpl>::Ptr impl( new DbLanguageImpl( _source, id ) );
// Collect basic Resolvable data
NVRAD dataCollect( name,
@@ -368,15 +529,65 @@
arch,
createDependencies (id ) );
- Atom::Ptr atom = detail::makeResolvableFromImpl( dataCollect, impl );
- _store.insert( atom );
- XXX << "Atom[" << id << "] " << *atom << endl;
+ Language::Ptr language = detail::makeResolvableFromImpl( dataCollect, impl );
+ _store.insert( language );
+ XXX << "Language[" << id << "] " << *language << endl;
if ( _idmap != 0)
- (*_idmap)[id] = atom;
+ (*_idmap)[id] = language;
+ }
+ catch (const Exception & excpt_r)
+ {
+ ERR << "Cannot create language object '" << name << "' from catalog '" << _source.id() << "'" << endl;
+ sqlite3_reset (handle);
+ ZYPP_RETHROW (excpt_r);
+ }
+ }
+
+ sqlite3_reset (handle);
+ return;
+}
+
+
+void
+DbSourceImpl::createPackages(void)
+{
+ sqlite3_stmt *handle = create_package_handle ( _db);
+ if (handle == NULL) return;
+
+ sqlite3_bind_text (handle, 1, _source.id().c_str(), -1, SQLITE_STATIC);
+
+ int rc;
+ while ((rc = sqlite3_step (handle)) == SQLITE_ROW) {
+
+ string name;
+
+ try
+ {
+ detail::ResImplTraits<DbPackageImpl>::Ptr impl( new DbPackageImpl( _zyppsource ? _zyppsource :_source ) );
+
+ sqlite_int64 id = sqlite3_column_int64( handle, 0 );
+ name = (const char *) sqlite3_column_text( handle, 1 );
+ string version ((const char *) sqlite3_column_text( handle, 2 ));
+ string release ((const char *) sqlite3_column_text( handle, 3 ));
+ unsigned epoch = sqlite3_column_int( handle, 4 );
+ Arch arch( DbAccess::Rc2Arch( (RCArch)(sqlite3_column_int( handle, 5 )) ) );
+
+ impl->readHandle( id, handle );
+
+ // Collect basic Resolvable data
+ NVRAD dataCollect( name,
+ Edition( version, release, epoch ),
+ arch,
+ createDependencies (id ) );
+
+ Package::Ptr package = detail::makeResolvableFromImpl( dataCollect, impl );
+ _store.insert( package );
+ if ( _idmap != 0)
+ (*_idmap)[id] = package;
}
catch (const Exception & excpt_r)
{
- ERR << "Cannot create atom object '"+name+"' from catalog '"+_source.id()+"'" << endl;
+ ERR << "Cannot create package object '" << name << "' from catalog '" << _source.id() << "'" << endl;
sqlite3_reset (handle);
ZYPP_RETHROW (excpt_r);
}
@@ -427,7 +638,7 @@
}
catch (const Exception & excpt_r)
{
- ERR << "Cannot create patch object '"+name+"' from catalog '"+_source.id()+"'" << endl;
+ ERR << "Cannot create patch object '" << name << "' from catalog '" << _source.id() << "'" << endl;
sqlite3_reset (handle);
ZYPP_RETHROW (excpt_r);
}
@@ -478,7 +689,7 @@
}
catch (const Exception & excpt_r)
{
- ERR << "Cannot create pattern object '"+name+"' from catalog '"+_source.id()+"'" << endl;
+ ERR << "Cannot create pattern object '" << name << "' from catalog '" << _source.id() << "'" << endl;
sqlite3_reset (handle);
ZYPP_RETHROW (excpt_r);
}
@@ -529,7 +740,7 @@
}
catch (const Exception & excpt_r)
{
- ERR << "Cannot create product object '"+name+"' from catalog '"+_source.id()+"'" << endl;
+ ERR << "Cannot create product object '" << name << "' from catalog '" << _source.id() << "'" << endl;
sqlite3_reset (handle);
ZYPP_RETHROW (excpt_r);
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/DbSourceImpl.h new/zmd-backend-7.1.1.0/src/dbsource/DbSourceImpl.h
--- old/zmd-backend-7.1.1.0/src/dbsource/DbSourceImpl.h 2006-04-18 23:08:54.000000000 +0200
+++ new/zmd-backend-7.1.1.0/src/dbsource/DbSourceImpl.h 2006-04-23 21:35:44.000000000 +0200
@@ -34,6 +34,7 @@
#include "zypp/Atom.h"
#include "zypp/Message.h"
#include "zypp/Script.h"
+#include "zypp/Language.h"
#include "zypp/Patch.h"
#include "zypp/Product.h"
#include "zypp/Pattern.h"
@@ -57,12 +58,17 @@
sqlite3 *_db;
sqlite3_stmt *_dependency_handle;
+ sqlite3_stmt *_message_handle;
+ sqlite3_stmt *_script_handle;
sqlite3_stmt *_patch_handle;
sqlite3_stmt *_pattern_handle;
sqlite3_stmt *_product_handle;
void createPackages(void);
void createAtoms(void);
+ void createMessages(void);
+ void createScripts(void);
+ void createLanguages(void);
void createPatches(void);
void createPatterns(void);
void createProducts(void);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/Makefile.am new/zmd-backend-7.1.1.0/src/dbsource/Makefile.am
--- old/zmd-backend-7.1.1.0/src/dbsource/Makefile.am 2006-03-23 16:30:19.000000000 +0100
+++ new/zmd-backend-7.1.1.0/src/dbsource/Makefile.am 2006-04-23 21:39:49.000000000 +0200
@@ -15,16 +15,22 @@
DbSourceImpl.h \
DbPackageImpl.h \
DbAtomImpl.h \
+ DbScriptImpl.h \
+ DbMessageImpl.h \
+ DbLanguageImpl.h \
DbPatchImpl.h \
DbPatternImpl.h \
DbProductImpl.h
lib_LTLIBRARIES = lib@PACKAGE@.la
-lib@PACKAGE@_la_SOURCES = \
+lib@PACKAGE@_la_SOURCES = \
DbSourceImpl.cc \
DbPackageImpl.cc \
DbAtomImpl.cc \
+ DbScriptImpl.cc \
+ DbMessageImpl.cc \
+ DbLanguageImpl.cc \
DbPatchImpl.cc \
DbPatternImpl.cc \
DbProductImpl.cc \
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-backend-7.1.1.0/src/dbsource/Makefile.in new/zmd-backend-7.1.1.0/src/dbsource/Makefile.in
--- old/zmd-backend-7.1.1.0/src/dbsource/Makefile.in 2006-04-05 10:40:20.000000000 +0200
+++ new/zmd-backend-7.1.1.0/src/dbsource/Makefile.in 2006-04-23 21:39:52.000000000 +0200
@@ -63,8 +63,9 @@
LTLIBRARIES = $(lib_LTLIBRARIES)
lib@PACKAGE@_la_LIBADD =
am_lib@PACKAGE@_la_OBJECTS = DbSourceImpl.lo DbPackageImpl.lo \
- DbAtomImpl.lo DbPatchImpl.lo DbPatternImpl.lo DbProductImpl.lo \
- DbSources.lo DbAccess.lo
+ DbAtomImpl.lo DbScriptImpl.lo DbMessageImpl.lo \
+ DbLanguageImpl.lo DbPatchImpl.lo DbPatternImpl.lo \
+ DbProductImpl.lo DbSources.lo DbAccess.lo
lib@PACKAGE@_la_OBJECTS = $(am_lib@PACKAGE@_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -240,6 +241,9 @@
DbSourceImpl.h \
DbPackageImpl.h \
DbAtomImpl.h \
+ DbScriptImpl.h \
+ DbMessageImpl.h \
+ DbLanguageImpl.h \
DbPatchImpl.h \
DbPatternImpl.h \
DbProductImpl.h
@@ -249,6 +253,9 @@
DbSourceImpl.cc \
DbPackageImpl.cc \
DbAtomImpl.cc \
+ DbScriptImpl.cc \
+ DbMessageImpl.cc \
+ DbLanguageImpl.cc \
DbPatchImpl.cc \
DbPatternImpl.cc \
DbProductImpl.cc \
@@ -327,10 +334,13 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbAccess.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbAtomImpl.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbLanguageImpl.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbMessageImpl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbPackageImpl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbPatchImpl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbPatternImpl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbProductImpl.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbScriptImpl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbSourceImpl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DbSources.Plo@am__quote@
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...