From 0be6b6faf88057b5ef2d79ddbf0856626b119055 Mon Sep 17 00:00:00 2001 From: Klaus Kaempf Date: Thu, 19 Jan 2006 21:58:21 +0000 Subject: [PATCH] compiles and links --- zmd/backend/package-writer.cc | 10 +++++- zmd/backend/package-writer.h | 3 +- zmd/backend/query-system.cc | 66 +++++++---------------------------- 3 files changed, 23 insertions(+), 56 deletions(-) diff --git a/zmd/backend/package-writer.cc b/zmd/backend/package-writer.cc index be217ecfa..9efe55b31 100644 --- a/zmd/backend/package-writer.cc +++ b/zmd/backend/package-writer.cc @@ -2,6 +2,7 @@ #include "package-writer.h" #include +#include "zypp/target/rpm/librpmDb.h" #include "zypp/base/Logger.h" #include "zypp/CapSet.h" #include @@ -296,13 +297,20 @@ write_package (RCDB *rcdb, RpmHeader::constPtr pkg) //----------------------------------------------------------------------------- void -write_packages_to_db (const string & db_file, librpmDb::db_const_iterator iter) +write_packages_to_db (const string & db_file) { RCDB *db; db = rc_db_new (db_file); rc_db_begin (db); + librpmDb::db_const_iterator iter; + + if (iter.dbHdrNum() == 0) { + ERR << "Couldn't access the packaging system:" << endl; + return; + } + while (*iter) { sqlite_int64 id = write_package (db, *iter); if (id > 0) { diff --git a/zmd/backend/package-writer.h b/zmd/backend/package-writer.h index 40a0c3f7b..967a84adc 100644 --- a/zmd/backend/package-writer.h +++ b/zmd/backend/package-writer.h @@ -1,6 +1,5 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ #include -#include "zypp/target/rpm/librpmDb.h" -void write_packages_to_db (const std::string & db_file, zypp::target::rpm::librpmDb::db_const_iterator iter); +void write_packages_to_db (const std::string & db_file); diff --git a/zmd/backend/query-system.cc b/zmd/backend/query-system.cc index 86feb5e5e..b36cdbd3f 100644 --- a/zmd/backend/query-system.cc +++ b/zmd/backend/query-system.cc @@ -1,70 +1,30 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -#include -#include -#include "package-writer.h" +#include "zypp/target/rpm/librpmDb.h" +#include "zypp/base/Logger.h" -static void -set_channel (gpointer data, gpointer user_data) -{ - RCPackage *package = data; - RCChannel *channel = user_data; +using namespace zypp::target::rpm; - package->channel = rc_channel_ref (channel); -} +using std::endl; -static void -debug (const char *message, RCDebugLevel level, gpointer user_data) -{ - fprintf (stderr, "%d|%s\n", level, message); -} +#include +#include "package-writer.h" int main (int argc, char **argv) { - RCPackman *packman; - RCPackageSList *packages = NULL; - - rc_debug_add_handler (debug, RC_DEBUG_LEVEL_ALWAYS, NULL); - if (argc != 2) { - rc_debug (RC_DEBUG_LEVEL_ERROR, - "usage: %s ", argv[0]); - return 1; + ERR << "usage: " << argv[0] << " " << endl; + return 1; } - g_type_init (); + librpmDb::unblockAccess(); + librpmDb::dbAccess (librpmDb::defaultRoot(), librpmDb::defaultDbPath()); - packman = rc_distman_new (); - - if (!packman) { - rc_debug (RC_DEBUG_LEVEL_ERROR, - "Couldn't access the packaging system"); - return 1; - } - - if (rc_packman_get_error (packman)) { - rc_debug (RC_DEBUG_LEVEL_ERROR, - "Couldn't access the packaging system: %s", - rc_packman_get_reason (packman)); - return 1; - } - - packages = rc_packman_query_all (packman); - - if (packages) { - RCChannel *channel; - - channel = rc_channel_new ("@system", "foo", "foo", "foo"); - g_slist_foreach (packages, set_channel, channel); - rc_channel_unref (channel); - - write_packages_to_db (argv[1], packages); - rc_package_slist_unref (packages); - g_slist_free (packages); - } + librpmDb::constPtr rpmhandle; + librpmDb::dbAccess (rpmhandle); - g_object_unref (packman); + write_packages_to_db (argv[1]); return 0; } -- 2.34.1