[packagekit] packagekit: Branch 'master'
Richard Hughes
hughsient at kemper.freedesktop.org
Wed Oct 17 08:55:57 PDT 2007
backends/apt/Makefile.am | 10 -
backends/apt/apt-build-db.cpp | 283 --------------------------------
backends/apt/pk-apt-build-db.cpp | 283 ++++++++++++++++++++++++++++++++
backends/apt/pk-python-backend-common.c | 39 ++++
backends/apt/pk-python-backend-common.h | 28 +++
backends/apt/pk-sqlite-pkg-cache.c | 228 +++++++++++++++++++++++++
backends/apt/pk-sqlite-pkg-cache.h | 39 ++++
backends/apt/python-backend-common.c | 39 ----
backends/apt/python-backend-common.h | 28 ---
backends/apt/sqlite-pkg-cache.c | 228 -------------------------
backends/apt/sqlite-pkg-cache.h | 39 ----
11 files changed, 622 insertions(+), 622 deletions(-)
New commits:
commit 634feae397048e973d4dccb542a5898a9d394b48
Author: Tom Parker <palfrey at tevp.net>
Date: Wed Oct 17 12:25:18 2007 +0200
Rename all the apt backend files to pk-*
diff --git a/backends/apt/Makefile.am b/backends/apt/Makefile.am
index be27e19..a4126a0 100644
--- a/backends/apt/Makefile.am
+++ b/backends/apt/Makefile.am
@@ -5,11 +5,11 @@ libpk_backend_apt_la_INCLUDES = $(APT_CFLAGS) $(SQLITE_CFLAGS)
libpk_backend_apt_la_SOURCES = \
pk-backend-apt.h \
pk-backend-apt.cpp \
- sqlite-pkg-cache.h \
- sqlite-pkg-cache.c \
- apt-build-db.cpp \
- python-backend-common.h \
- python-backend-common.c
+ pk-sqlite-pkg-cache.h \
+ pk-sqlite-pkg-cache.c \
+ pk-apt-build-db.cpp \
+ pk-python-backend-common.h \
+ pk-python-backend-common.c
libpk_backend_apt_la_LIBADD = @PK_PLUGIN_LIBS@ $(APT_LIBS) $(SQLITE_LIBS)
libpk_backend_apt_la_LDFLAGS = -module -avoid-version
libpk_backend_apt_la_CFLAGS = @PK_PLUGIN_CFLAGS@ -DDATABASEDIR=\""$(PK_DB_DIR)"\"
diff --git a/backends/apt/apt-build-db.cpp b/backends/apt/apt-build-db.cpp
deleted file mode 100644
index 894b70b..0000000
--- a/backends/apt/apt-build-db.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "pk-backend-apt.h"
-#include <apt-pkg/configuration.h>
-#include <sqlite3.h>
-
-typedef enum {FIELD_PKG=1,FIELD_VER,FIELD_DEPS,FIELD_ARCH,FIELD_SHORT,FIELD_LONG,FIELD_REPO} Fields;
-
-void apt_build_db(PkBackend * backend, sqlite3 *db)
-{
- GMatchInfo *match_info;
- GError *error = NULL;
- gchar *contents = NULL;
- gchar *sdir;
- const gchar *fname;
- GRegex *origin, *suite;
- GDir *dir;
- GHashTable *releases;
- int res;
- sqlite3_stmt *package = NULL;
-
- pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
- pk_backend_no_percentage_updates(backend);
-
- sdir = g_build_filename(_config->Find("Dir").c_str(),_config->Find("Dir::State").c_str(),_config->Find("Dir::State::lists").c_str(), NULL);
- dir = g_dir_open(sdir,0,&error);
- if (error!=NULL)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "can't open %s",dir);
- g_error_free(error);
- goto search_task_cleanup;
- }
-
- origin = g_regex_new("^Origin: (\\S+)",(GRegexCompileFlags)(G_REGEX_CASELESS|G_REGEX_OPTIMIZE|G_REGEX_MULTILINE),(GRegexMatchFlags)0,NULL);
- suite = g_regex_new("^Suite: (\\S+)",(GRegexCompileFlags)(G_REGEX_CASELESS|G_REGEX_OPTIMIZE|G_REGEX_MULTILINE),(GRegexMatchFlags)0,NULL);
-
- releases = g_hash_table_new_full(g_str_hash,g_str_equal,g_free,g_free);
- while ((fname = g_dir_read_name(dir))!=NULL)
- {
- gchar *temp, *parsed_name;
- gchar** items = g_strsplit(fname,"_",-1);
- guint len = g_strv_length(items);
- if(len<=3) // minimum is <source>_<type>_<group>
- {
- g_strfreev(items);
- continue;
- }
-
- /* warning: nasty hack with g_strjoinv */
- temp = items[len-2];
- items[len-2] = NULL;
- parsed_name = g_strjoinv("_",items);
- items[len-2] = temp;
-
- if (g_ascii_strcasecmp(items[len-1],"Release")==0 && g_ascii_strcasecmp(items[len-2],"source")!=0)
- {
- gchar * repo = NULL, *fullname;
- fullname = g_build_filename(sdir,fname,NULL);
- if (g_file_get_contents(fullname,&contents,NULL,NULL) == FALSE)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "error loading %s",fullname);
- goto search_task_cleanup;
- }
- g_free(fullname);
-
- g_regex_match (origin, contents, (GRegexMatchFlags)0, &match_info);
- if (!g_match_info_matches(match_info))
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "origin regex failure in %s",fname);
- goto search_task_cleanup;
- }
- repo = g_match_info_fetch (match_info, 1);
-
- g_regex_match (suite, contents, (GRegexMatchFlags)0, &match_info);
- if (g_match_info_matches(match_info))
- {
- temp = g_strconcat(repo,"/",g_match_info_fetch (match_info, 1),NULL);
- g_free(repo);
- repo = temp;
- }
-
- temp = parsed_name;
- parsed_name = g_strconcat(temp,"_",items[len-2],NULL);
- g_free(temp);
-
- pk_debug("type is %s, group is %s, parsed_name is %s",items[len-2],items[len-1],parsed_name);
-
- g_hash_table_insert(releases, parsed_name, repo);
- g_free(contents);
- contents = NULL;
- }
- else
- g_free(parsed_name);
- g_strfreev(items);
- }
- g_dir_close(dir);
-
- /* and then we need to do this again, but this time we're looking for the packages */
- dir = g_dir_open(sdir,0,&error);
- res = sqlite3_prepare_v2(db, "insert or replace into packages values (?,?,?,?,?,?,?)", -1, &package, NULL);
- if (res!=SQLITE_OK)
- pk_error("sqlite error during insert prepare: %s", sqlite3_errmsg(db));
- else
- pk_debug("insert prepare ok for %p",package);
- while ((fname = g_dir_read_name(dir))!=NULL)
- {
- gchar** items = g_strsplit(fname,"_",-1);
- guint len = g_strv_length(items);
- if(len<=3) // minimum is <source>_<type>_<group>
- {
- g_strfreev(items);
- continue;
- }
-
- if (g_ascii_strcasecmp(items[len-1],"Packages")==0)
- {
- const gchar *repo;
- gchar *temp=NULL, *parsed_name=NULL;
- gchar *fullname= NULL;
- gchar *begin=NULL, *next=NULL, *description = NULL;
- glong count = 0;
- gboolean haspk = FALSE;
-
- /* warning: nasty hack with g_strjoinv */
- if (g_str_has_prefix(items[len-2],"binary-"))
- {
- temp = items[len-3];
- items[len-3] = NULL;
- parsed_name = g_strjoinv("_",items);
- items[len-3] = temp;
- }
- else
- {
- temp = items[len-1];
- items[len-1] = NULL;
- parsed_name = g_strjoinv("_",items);
- items[len-1] = temp;
- }
-
- pk_debug("type is %s, group is %s, parsed_name is %s",items[len-2],items[len-1],parsed_name);
-
- repo = (const gchar *)g_hash_table_lookup(releases,parsed_name);
- if (repo == NULL)
- {
- pk_debug("Can't find repo for %s, marking as \"unknown\"",parsed_name);
- repo = g_strdup("unknown");
- //g_assert(0);
- }
- else
- pk_debug("repo for %s is %s",parsed_name,repo);
- g_free(parsed_name);
-
- fullname = g_build_filename(sdir,fname,NULL);
- pk_debug("loading %s",fullname);
- if (g_file_get_contents(fullname,&contents,NULL,NULL) == FALSE)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "error loading %s",fullname);
- goto search_task_cleanup;
- }
- /*else
- pk_debug("loaded");*/
-
- res = sqlite3_bind_text(package,FIELD_REPO,repo,-1,SQLITE_TRANSIENT);
- if (res!=SQLITE_OK)
- pk_error("sqlite error during repo bind: %s", sqlite3_errmsg(db));
- /*else
- pk_debug("repo bind ok");*/
-
- res = sqlite3_exec(db,"begin",NULL,NULL,NULL);
- g_assert(res == SQLITE_OK);
-
- begin = contents;
-
- while (true)
- {
- next = strstr(begin,"\n");
- if (next!=NULL)
- {
- next[0] = '\0';
- next++;
- }
-
- if (begin[0]=='\0')
- {
- if (haspk)
- {
- if (description!=NULL)
- {
- res=sqlite3_bind_text(package,FIELD_LONG,description,-1,SQLITE_TRANSIENT);
- if (res!=SQLITE_OK)
- pk_error("sqlite error during description bind: %s", sqlite3_errmsg(db));
- g_free(description);
- description = NULL;
- }
- res = sqlite3_step(package);
- if (res!=SQLITE_DONE)
- pk_error("sqlite error during step: %s", sqlite3_errmsg(db));
- sqlite3_reset(package);
- //pk_debug("added package");
- haspk = FALSE;
- }
- //g_assert(0);
- }
- else if (begin[0]==' ')
- {
- if (description == NULL)
- description = g_strdup(&begin[1]);
- else
- {
- gchar *oldval = description;
- description = g_strconcat(oldval, "\n",&begin[1],NULL);
- g_free(oldval);
- }
- }
- else
- {
- gchar *colon = strchr(begin,':');
- g_assert(colon!=NULL);
- colon[0] = '\0';
- colon+=2;
- /*if (strlen(colon)>3000)
- pk_error("strlen(colon) = %d\ncolon = %s",strlen(colon),colon);*/
- //pk_debug("entry = '%s','%s'",begin,colon);
- if (begin[0] == 'P' && g_strcasecmp("Package",begin)==0)
- {
- res=sqlite3_bind_text(package,FIELD_PKG,colon,-1,SQLITE_STATIC);
- haspk = TRUE;
- count++;
- if (count%1000==0)
- pk_debug("Package %ld (%s)",count,colon);
- }
- else if (begin[0] == 'V' && g_strcasecmp("Version",begin)==0)
- res=sqlite3_bind_text(package,FIELD_VER,colon,-1,SQLITE_STATIC);
- else if (begin[0] == 'D' && g_strcasecmp("Depends",begin)==0)
- res=sqlite3_bind_text(package,FIELD_DEPS,colon,-1,SQLITE_STATIC);
- else if (begin[0] == 'A' && g_strcasecmp("Architecture",begin)==0)
- res=sqlite3_bind_text(package,FIELD_ARCH,colon,-1,SQLITE_STATIC);
- else if (begin[0] == 'D' && g_strcasecmp("Description",begin)==0)
- res=sqlite3_bind_text(package,FIELD_SHORT,colon,-1,SQLITE_STATIC);
- if (res!=SQLITE_OK)
- pk_error("sqlite error during %s bind: %s", begin, sqlite3_errmsg(db));
- }
- if (next == NULL)
- break;
- begin = next;
- }
- res = sqlite3_exec(db,"commit",NULL,NULL,NULL);
- if (res!=SQLITE_OK)
- pk_error("sqlite error during commit: %s", sqlite3_errmsg(db));
- res = sqlite3_clear_bindings(package);
- if (res!=SQLITE_OK)
- pk_error("sqlite error during clear: %s", sqlite3_errmsg(db));
- g_free(contents);
- contents = NULL;
- }
- }
- sqlite3_finalize(package);
-
-search_task_cleanup:
- g_dir_close(dir);
- g_free(sdir);
- g_free(contents);
-}
-
diff --git a/backends/apt/pk-apt-build-db.cpp b/backends/apt/pk-apt-build-db.cpp
new file mode 100644
index 0000000..894b70b
--- /dev/null
+++ b/backends/apt/pk-apt-build-db.cpp
@@ -0,0 +1,283 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "pk-backend-apt.h"
+#include <apt-pkg/configuration.h>
+#include <sqlite3.h>
+
+typedef enum {FIELD_PKG=1,FIELD_VER,FIELD_DEPS,FIELD_ARCH,FIELD_SHORT,FIELD_LONG,FIELD_REPO} Fields;
+
+void apt_build_db(PkBackend * backend, sqlite3 *db)
+{
+ GMatchInfo *match_info;
+ GError *error = NULL;
+ gchar *contents = NULL;
+ gchar *sdir;
+ const gchar *fname;
+ GRegex *origin, *suite;
+ GDir *dir;
+ GHashTable *releases;
+ int res;
+ sqlite3_stmt *package = NULL;
+
+ pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_no_percentage_updates(backend);
+
+ sdir = g_build_filename(_config->Find("Dir").c_str(),_config->Find("Dir::State").c_str(),_config->Find("Dir::State::lists").c_str(), NULL);
+ dir = g_dir_open(sdir,0,&error);
+ if (error!=NULL)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "can't open %s",dir);
+ g_error_free(error);
+ goto search_task_cleanup;
+ }
+
+ origin = g_regex_new("^Origin: (\\S+)",(GRegexCompileFlags)(G_REGEX_CASELESS|G_REGEX_OPTIMIZE|G_REGEX_MULTILINE),(GRegexMatchFlags)0,NULL);
+ suite = g_regex_new("^Suite: (\\S+)",(GRegexCompileFlags)(G_REGEX_CASELESS|G_REGEX_OPTIMIZE|G_REGEX_MULTILINE),(GRegexMatchFlags)0,NULL);
+
+ releases = g_hash_table_new_full(g_str_hash,g_str_equal,g_free,g_free);
+ while ((fname = g_dir_read_name(dir))!=NULL)
+ {
+ gchar *temp, *parsed_name;
+ gchar** items = g_strsplit(fname,"_",-1);
+ guint len = g_strv_length(items);
+ if(len<=3) // minimum is <source>_<type>_<group>
+ {
+ g_strfreev(items);
+ continue;
+ }
+
+ /* warning: nasty hack with g_strjoinv */
+ temp = items[len-2];
+ items[len-2] = NULL;
+ parsed_name = g_strjoinv("_",items);
+ items[len-2] = temp;
+
+ if (g_ascii_strcasecmp(items[len-1],"Release")==0 && g_ascii_strcasecmp(items[len-2],"source")!=0)
+ {
+ gchar * repo = NULL, *fullname;
+ fullname = g_build_filename(sdir,fname,NULL);
+ if (g_file_get_contents(fullname,&contents,NULL,NULL) == FALSE)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "error loading %s",fullname);
+ goto search_task_cleanup;
+ }
+ g_free(fullname);
+
+ g_regex_match (origin, contents, (GRegexMatchFlags)0, &match_info);
+ if (!g_match_info_matches(match_info))
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "origin regex failure in %s",fname);
+ goto search_task_cleanup;
+ }
+ repo = g_match_info_fetch (match_info, 1);
+
+ g_regex_match (suite, contents, (GRegexMatchFlags)0, &match_info);
+ if (g_match_info_matches(match_info))
+ {
+ temp = g_strconcat(repo,"/",g_match_info_fetch (match_info, 1),NULL);
+ g_free(repo);
+ repo = temp;
+ }
+
+ temp = parsed_name;
+ parsed_name = g_strconcat(temp,"_",items[len-2],NULL);
+ g_free(temp);
+
+ pk_debug("type is %s, group is %s, parsed_name is %s",items[len-2],items[len-1],parsed_name);
+
+ g_hash_table_insert(releases, parsed_name, repo);
+ g_free(contents);
+ contents = NULL;
+ }
+ else
+ g_free(parsed_name);
+ g_strfreev(items);
+ }
+ g_dir_close(dir);
+
+ /* and then we need to do this again, but this time we're looking for the packages */
+ dir = g_dir_open(sdir,0,&error);
+ res = sqlite3_prepare_v2(db, "insert or replace into packages values (?,?,?,?,?,?,?)", -1, &package, NULL);
+ if (res!=SQLITE_OK)
+ pk_error("sqlite error during insert prepare: %s", sqlite3_errmsg(db));
+ else
+ pk_debug("insert prepare ok for %p",package);
+ while ((fname = g_dir_read_name(dir))!=NULL)
+ {
+ gchar** items = g_strsplit(fname,"_",-1);
+ guint len = g_strv_length(items);
+ if(len<=3) // minimum is <source>_<type>_<group>
+ {
+ g_strfreev(items);
+ continue;
+ }
+
+ if (g_ascii_strcasecmp(items[len-1],"Packages")==0)
+ {
+ const gchar *repo;
+ gchar *temp=NULL, *parsed_name=NULL;
+ gchar *fullname= NULL;
+ gchar *begin=NULL, *next=NULL, *description = NULL;
+ glong count = 0;
+ gboolean haspk = FALSE;
+
+ /* warning: nasty hack with g_strjoinv */
+ if (g_str_has_prefix(items[len-2],"binary-"))
+ {
+ temp = items[len-3];
+ items[len-3] = NULL;
+ parsed_name = g_strjoinv("_",items);
+ items[len-3] = temp;
+ }
+ else
+ {
+ temp = items[len-1];
+ items[len-1] = NULL;
+ parsed_name = g_strjoinv("_",items);
+ items[len-1] = temp;
+ }
+
+ pk_debug("type is %s, group is %s, parsed_name is %s",items[len-2],items[len-1],parsed_name);
+
+ repo = (const gchar *)g_hash_table_lookup(releases,parsed_name);
+ if (repo == NULL)
+ {
+ pk_debug("Can't find repo for %s, marking as \"unknown\"",parsed_name);
+ repo = g_strdup("unknown");
+ //g_assert(0);
+ }
+ else
+ pk_debug("repo for %s is %s",parsed_name,repo);
+ g_free(parsed_name);
+
+ fullname = g_build_filename(sdir,fname,NULL);
+ pk_debug("loading %s",fullname);
+ if (g_file_get_contents(fullname,&contents,NULL,NULL) == FALSE)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "error loading %s",fullname);
+ goto search_task_cleanup;
+ }
+ /*else
+ pk_debug("loaded");*/
+
+ res = sqlite3_bind_text(package,FIELD_REPO,repo,-1,SQLITE_TRANSIENT);
+ if (res!=SQLITE_OK)
+ pk_error("sqlite error during repo bind: %s", sqlite3_errmsg(db));
+ /*else
+ pk_debug("repo bind ok");*/
+
+ res = sqlite3_exec(db,"begin",NULL,NULL,NULL);
+ g_assert(res == SQLITE_OK);
+
+ begin = contents;
+
+ while (true)
+ {
+ next = strstr(begin,"\n");
+ if (next!=NULL)
+ {
+ next[0] = '\0';
+ next++;
+ }
+
+ if (begin[0]=='\0')
+ {
+ if (haspk)
+ {
+ if (description!=NULL)
+ {
+ res=sqlite3_bind_text(package,FIELD_LONG,description,-1,SQLITE_TRANSIENT);
+ if (res!=SQLITE_OK)
+ pk_error("sqlite error during description bind: %s", sqlite3_errmsg(db));
+ g_free(description);
+ description = NULL;
+ }
+ res = sqlite3_step(package);
+ if (res!=SQLITE_DONE)
+ pk_error("sqlite error during step: %s", sqlite3_errmsg(db));
+ sqlite3_reset(package);
+ //pk_debug("added package");
+ haspk = FALSE;
+ }
+ //g_assert(0);
+ }
+ else if (begin[0]==' ')
+ {
+ if (description == NULL)
+ description = g_strdup(&begin[1]);
+ else
+ {
+ gchar *oldval = description;
+ description = g_strconcat(oldval, "\n",&begin[1],NULL);
+ g_free(oldval);
+ }
+ }
+ else
+ {
+ gchar *colon = strchr(begin,':');
+ g_assert(colon!=NULL);
+ colon[0] = '\0';
+ colon+=2;
+ /*if (strlen(colon)>3000)
+ pk_error("strlen(colon) = %d\ncolon = %s",strlen(colon),colon);*/
+ //pk_debug("entry = '%s','%s'",begin,colon);
+ if (begin[0] == 'P' && g_strcasecmp("Package",begin)==0)
+ {
+ res=sqlite3_bind_text(package,FIELD_PKG,colon,-1,SQLITE_STATIC);
+ haspk = TRUE;
+ count++;
+ if (count%1000==0)
+ pk_debug("Package %ld (%s)",count,colon);
+ }
+ else if (begin[0] == 'V' && g_strcasecmp("Version",begin)==0)
+ res=sqlite3_bind_text(package,FIELD_VER,colon,-1,SQLITE_STATIC);
+ else if (begin[0] == 'D' && g_strcasecmp("Depends",begin)==0)
+ res=sqlite3_bind_text(package,FIELD_DEPS,colon,-1,SQLITE_STATIC);
+ else if (begin[0] == 'A' && g_strcasecmp("Architecture",begin)==0)
+ res=sqlite3_bind_text(package,FIELD_ARCH,colon,-1,SQLITE_STATIC);
+ else if (begin[0] == 'D' && g_strcasecmp("Description",begin)==0)
+ res=sqlite3_bind_text(package,FIELD_SHORT,colon,-1,SQLITE_STATIC);
+ if (res!=SQLITE_OK)
+ pk_error("sqlite error during %s bind: %s", begin, sqlite3_errmsg(db));
+ }
+ if (next == NULL)
+ break;
+ begin = next;
+ }
+ res = sqlite3_exec(db,"commit",NULL,NULL,NULL);
+ if (res!=SQLITE_OK)
+ pk_error("sqlite error during commit: %s", sqlite3_errmsg(db));
+ res = sqlite3_clear_bindings(package);
+ if (res!=SQLITE_OK)
+ pk_error("sqlite error during clear: %s", sqlite3_errmsg(db));
+ g_free(contents);
+ contents = NULL;
+ }
+ }
+ sqlite3_finalize(package);
+
+search_task_cleanup:
+ g_dir_close(dir);
+ g_free(sdir);
+ g_free(contents);
+}
+
diff --git a/backends/apt/pk-python-backend-common.c b/backends/apt/pk-python-backend-common.c
new file mode 100644
index 0000000..41b3788
--- /dev/null
+++ b/backends/apt/pk-python-backend-common.c
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <pk-backend.h>
+
+/**
+ * python_refresh_cache:
+ **/
+void python_refresh_cache(PkBackend * backend, gboolean force)
+{
+ /* check network state */
+ if (pk_backend_network_is_online(backend) == FALSE)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+ pk_backend_finished(backend);
+ return;
+ }
+
+ pk_backend_spawn_helper (backend, "refresh-cache.py", NULL);
+}
+
diff --git a/backends/apt/pk-python-backend-common.h b/backends/apt/pk-python-backend-common.h
new file mode 100644
index 0000000..a0b56bd
--- /dev/null
+++ b/backends/apt/pk-python-backend-common.h
@@ -0,0 +1,28 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PYTHON_BACKEND_COMMON_H
+#define PYTHON_BACKEND_COMMON_H
+
+void python_refresh_cache(PkBackend * backend, gboolean force);
+
+#endif
+
diff --git a/backends/apt/pk-sqlite-pkg-cache.c b/backends/apt/pk-sqlite-pkg-cache.c
new file mode 100644
index 0000000..29647a5
--- /dev/null
+++ b/backends/apt/pk-sqlite-pkg-cache.c
@@ -0,0 +1,228 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <sqlite3.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include "sqlite-pkg-cache.h"
+
+static sqlite3 *db = NULL;
+
+typedef struct {
+ PkPackageId *pi;
+} desc_task;
+
+typedef struct {
+ gchar *search;
+ gchar *filter;
+ SearchDepth depth;
+} search_task;
+
+void
+sqlite_init_cache(PkBackend *backend, const char* dbname, const char *compare_fname, void (*build_db)(PkBackend *, sqlite3 *))
+{
+ int ret;
+ struct stat st;
+ time_t db_age;
+
+ ret = sqlite3_open (dbname, &db);
+ ret = sqlite3_exec(db,"PRAGMA synchronous = OFF",NULL,NULL,NULL);
+ g_assert(ret == SQLITE_OK);
+
+ g_stat(dbname, &st);
+ db_age = st.st_mtime;
+ g_stat(compare_fname, &st);
+ if (db_age>=st.st_mtime)
+ {
+ ret = sqlite3_exec(db, "select value from params where name = 'build_complete'", NULL, NULL, NULL);
+ if (ret != SQLITE_ERROR)
+ return;
+ }
+ ret = sqlite3_exec(db,"drop table packages",NULL,NULL,NULL); // wipe it!
+ //g_assert(ret == SQLITE_OK);
+ pk_debug("wiped db");
+ ret = sqlite3_exec(db,"create table packages (name text, version text, deps text, arch text, short_desc text, long_desc text, repo string, primary key(name,version,arch,repo))",NULL,NULL,NULL);
+ g_assert(ret == SQLITE_OK);
+
+ build_db(backend,db);
+
+ sqlite3_exec(db,"create table params (name text primary key, value integer)", NULL, NULL, NULL);
+ sqlite3_exec(db,"insert into params values ('build_complete',1)", NULL, NULL, NULL);
+}
+
+// sqlite_search_packages_thread
+static gboolean
+sqlite_search_packages_thread (PkBackend *backend, gpointer data)
+{
+ search_task *st = (search_task *) data;
+ int res;
+ gchar *sel;
+
+ pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_no_percentage_updates(backend);
+
+ pk_debug("finding %s", st->search);
+
+ sqlite3_stmt *package = NULL;
+ g_strdelimit(st->search," ",'%');
+
+ if (st->depth == SEARCH_NAME)
+ sel = g_strdup_printf("select name,version,arch,repo,short_desc from packages where name like '%%%s%%'",st->search);
+ else if (st->depth == SEARCH_DETAILS)
+ sel = g_strdup_printf("select name,version,arch,repo,short_desc from packages where name like '%%%s%%' or short_desc like '%%%s%%' or long_desc like '%%%s%%'",st->search, st->search, st->search);
+ else
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Unknown search task type");
+ goto end_search_packages;
+ }
+
+ pk_debug("statement is '%s'",sel);
+ res = sqlite3_prepare_v2(db,sel, -1, &package, NULL);
+ g_free(sel);
+ if (res!=SQLITE_OK)
+ pk_error("sqlite error during select prepare: %s", sqlite3_errmsg(db));
+ res = sqlite3_step(package);
+ while (res == SQLITE_ROW)
+ {
+ gchar *pid = pk_package_id_build((const gchar*)sqlite3_column_text(package,0),
+ (const gchar*)sqlite3_column_text(package,1),
+ (const gchar*)sqlite3_column_text(package,2),
+ (const gchar*)sqlite3_column_text(package,3));
+ pk_backend_package(backend, PK_INFO_ENUM_UNKNOWN, pid, (const gchar*)sqlite3_column_text(package,4));
+ g_free(pid);
+ if (res==SQLITE_ROW)
+ res = sqlite3_step(package);
+ }
+ if (res!=SQLITE_DONE)
+ {
+ pk_debug("sqlite error during step (%d): %s", res, sqlite3_errmsg(db));
+ g_assert(0);
+ }
+
+ end_search_packages:
+ g_free(st->search);
+ g_free(st);
+
+ return TRUE;
+}
+
+/**
+ * backend_search_common
+ **/
+void
+backend_search_common(PkBackend * backend, const gchar * filter, const gchar * search, SearchDepth which, PkBackendThreadFunc func)
+{
+ g_return_if_fail (backend != NULL);
+ search_task *data = g_new(search_task, 1);
+ if (data == NULL)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for search task");
+ pk_backend_finished(backend);
+ }
+ else
+ {
+ data->search = g_strdup(search);
+ data->filter = g_strdup(filter);
+ data->depth = which;
+ pk_backend_thread_helper (backend, func, data);
+ }
+}
+
+/**
+ * sqlite_search_details:
+ */
+void
+sqlite_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+ backend_search_common(backend, filter, search, SEARCH_DETAILS, sqlite_search_packages_thread);
+}
+
+/**
+ * sqlite_search_name:
+ */
+void
+sqlite_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+ backend_search_common(backend, filter, search, SEARCH_NAME, sqlite_search_packages_thread);
+}
+
+// sqlite_get_description_thread
+static gboolean sqlite_get_description_thread (PkBackend *backend, gpointer data)
+{
+ desc_task *dt = (desc_task *) data;
+ int res;
+
+ pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_no_percentage_updates(backend);
+
+ pk_debug("finding %s", dt->pi->name);
+
+ sqlite3_stmt *package = NULL;
+ gchar *sel = g_strdup_printf("select long_desc from packages where name = '%s' and version = '%s' and repo = '%s'",dt->pi->name,dt->pi->version,dt->pi->data);
+ pk_debug("statement is '%s'",sel);
+ res = sqlite3_prepare_v2(db,sel, -1, &package, NULL);
+ g_free(sel);
+ if (res!=SQLITE_OK)
+ pk_error("sqlite error during select prepare: %s", sqlite3_errmsg(db));
+ res = sqlite3_step(package);
+ pk_backend_description(backend,dt->pi->name, "unknown", PK_GROUP_ENUM_OTHER,(const gchar*)sqlite3_column_text(package,0),"",0,"");
+ res = sqlite3_step(package);
+ if (res==SQLITE_ROW)
+ pk_error("multiple matches for that package!");
+ if (res!=SQLITE_DONE)
+ {
+ pk_debug("sqlite error during step (%d): %s", res, sqlite3_errmsg(db));
+ g_assert(0);
+ }
+
+ g_free(dt);
+
+ return TRUE;
+}
+
+/**
+ * sqlite_get_description:
+ */
+void
+sqlite_get_description (PkBackend *backend, const gchar *package_id)
+{
+ g_return_if_fail (backend != NULL);
+ desc_task *data = g_new(desc_task, 1);
+ if (data == NULL)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for search task");
+ pk_backend_finished(backend);
+ return;
+ }
+
+ data->pi = pk_package_id_new_from_string(package_id);
+ if (data->pi == NULL)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+ pk_backend_finished(backend);
+ return;
+ }
+
+ pk_backend_thread_helper (backend, sqlite_get_description_thread, data);
+ return;
+}
+
+
diff --git a/backends/apt/pk-sqlite-pkg-cache.h b/backends/apt/pk-sqlite-pkg-cache.h
new file mode 100644
index 0000000..68f5287
--- /dev/null
+++ b/backends/apt/pk-sqlite-pkg-cache.h
@@ -0,0 +1,39 @@
+#ifndef SQLITE_PKT_CACHE
+#define SQLITE_PKT_CACHE
+
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+typedef enum {
+ SEARCH_NAME = 1,
+ SEARCH_DETAILS,
+ SEARCH_FILE
+} SearchDepth;
+
+#include <pk-backend.h>
+
+void sqlite_init_cache(PkBackend *backend, const char* dbname, const char* compare_fname, void (*build_db)(PkBackend *, sqlite3 *db));
+void sqlite_search_details (PkBackend *backend, const gchar *filter, const gchar *search);
+void sqlite_search_name (PkBackend *backend, const gchar *filter, const gchar *search);
+void backend_search_common(PkBackend * backend, const gchar * filter, const gchar * search, SearchDepth which, PkBackendThreadFunc func);
+void sqlite_get_description (PkBackend *backend, const gchar *package_id);
+
+#endif
diff --git a/backends/apt/python-backend-common.c b/backends/apt/python-backend-common.c
deleted file mode 100644
index 41b3788..0000000
--- a/backends/apt/python-backend-common.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <pk-backend.h>
-
-/**
- * python_refresh_cache:
- **/
-void python_refresh_cache(PkBackend * backend, gboolean force)
-{
- /* check network state */
- if (pk_backend_network_is_online(backend) == FALSE)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
- pk_backend_finished(backend);
- return;
- }
-
- pk_backend_spawn_helper (backend, "refresh-cache.py", NULL);
-}
-
diff --git a/backends/apt/python-backend-common.h b/backends/apt/python-backend-common.h
deleted file mode 100644
index a0b56bd..0000000
--- a/backends/apt/python-backend-common.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef PYTHON_BACKEND_COMMON_H
-#define PYTHON_BACKEND_COMMON_H
-
-void python_refresh_cache(PkBackend * backend, gboolean force);
-
-#endif
-
diff --git a/backends/apt/sqlite-pkg-cache.c b/backends/apt/sqlite-pkg-cache.c
deleted file mode 100644
index 29647a5..0000000
--- a/backends/apt/sqlite-pkg-cache.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <sqlite3.h>
-#include <glib.h>
-#include <glib/gstdio.h>
-#include "sqlite-pkg-cache.h"
-
-static sqlite3 *db = NULL;
-
-typedef struct {
- PkPackageId *pi;
-} desc_task;
-
-typedef struct {
- gchar *search;
- gchar *filter;
- SearchDepth depth;
-} search_task;
-
-void
-sqlite_init_cache(PkBackend *backend, const char* dbname, const char *compare_fname, void (*build_db)(PkBackend *, sqlite3 *))
-{
- int ret;
- struct stat st;
- time_t db_age;
-
- ret = sqlite3_open (dbname, &db);
- ret = sqlite3_exec(db,"PRAGMA synchronous = OFF",NULL,NULL,NULL);
- g_assert(ret == SQLITE_OK);
-
- g_stat(dbname, &st);
- db_age = st.st_mtime;
- g_stat(compare_fname, &st);
- if (db_age>=st.st_mtime)
- {
- ret = sqlite3_exec(db, "select value from params where name = 'build_complete'", NULL, NULL, NULL);
- if (ret != SQLITE_ERROR)
- return;
- }
- ret = sqlite3_exec(db,"drop table packages",NULL,NULL,NULL); // wipe it!
- //g_assert(ret == SQLITE_OK);
- pk_debug("wiped db");
- ret = sqlite3_exec(db,"create table packages (name text, version text, deps text, arch text, short_desc text, long_desc text, repo string, primary key(name,version,arch,repo))",NULL,NULL,NULL);
- g_assert(ret == SQLITE_OK);
-
- build_db(backend,db);
-
- sqlite3_exec(db,"create table params (name text primary key, value integer)", NULL, NULL, NULL);
- sqlite3_exec(db,"insert into params values ('build_complete',1)", NULL, NULL, NULL);
-}
-
-// sqlite_search_packages_thread
-static gboolean
-sqlite_search_packages_thread (PkBackend *backend, gpointer data)
-{
- search_task *st = (search_task *) data;
- int res;
- gchar *sel;
-
- pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
- pk_backend_no_percentage_updates(backend);
-
- pk_debug("finding %s", st->search);
-
- sqlite3_stmt *package = NULL;
- g_strdelimit(st->search," ",'%');
-
- if (st->depth == SEARCH_NAME)
- sel = g_strdup_printf("select name,version,arch,repo,short_desc from packages where name like '%%%s%%'",st->search);
- else if (st->depth == SEARCH_DETAILS)
- sel = g_strdup_printf("select name,version,arch,repo,short_desc from packages where name like '%%%s%%' or short_desc like '%%%s%%' or long_desc like '%%%s%%'",st->search, st->search, st->search);
- else
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Unknown search task type");
- goto end_search_packages;
- }
-
- pk_debug("statement is '%s'",sel);
- res = sqlite3_prepare_v2(db,sel, -1, &package, NULL);
- g_free(sel);
- if (res!=SQLITE_OK)
- pk_error("sqlite error during select prepare: %s", sqlite3_errmsg(db));
- res = sqlite3_step(package);
- while (res == SQLITE_ROW)
- {
- gchar *pid = pk_package_id_build((const gchar*)sqlite3_column_text(package,0),
- (const gchar*)sqlite3_column_text(package,1),
- (const gchar*)sqlite3_column_text(package,2),
- (const gchar*)sqlite3_column_text(package,3));
- pk_backend_package(backend, PK_INFO_ENUM_UNKNOWN, pid, (const gchar*)sqlite3_column_text(package,4));
- g_free(pid);
- if (res==SQLITE_ROW)
- res = sqlite3_step(package);
- }
- if (res!=SQLITE_DONE)
- {
- pk_debug("sqlite error during step (%d): %s", res, sqlite3_errmsg(db));
- g_assert(0);
- }
-
- end_search_packages:
- g_free(st->search);
- g_free(st);
-
- return TRUE;
-}
-
-/**
- * backend_search_common
- **/
-void
-backend_search_common(PkBackend * backend, const gchar * filter, const gchar * search, SearchDepth which, PkBackendThreadFunc func)
-{
- g_return_if_fail (backend != NULL);
- search_task *data = g_new(search_task, 1);
- if (data == NULL)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for search task");
- pk_backend_finished(backend);
- }
- else
- {
- data->search = g_strdup(search);
- data->filter = g_strdup(filter);
- data->depth = which;
- pk_backend_thread_helper (backend, func, data);
- }
-}
-
-/**
- * sqlite_search_details:
- */
-void
-sqlite_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
-{
- backend_search_common(backend, filter, search, SEARCH_DETAILS, sqlite_search_packages_thread);
-}
-
-/**
- * sqlite_search_name:
- */
-void
-sqlite_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
-{
- backend_search_common(backend, filter, search, SEARCH_NAME, sqlite_search_packages_thread);
-}
-
-// sqlite_get_description_thread
-static gboolean sqlite_get_description_thread (PkBackend *backend, gpointer data)
-{
- desc_task *dt = (desc_task *) data;
- int res;
-
- pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
- pk_backend_no_percentage_updates(backend);
-
- pk_debug("finding %s", dt->pi->name);
-
- sqlite3_stmt *package = NULL;
- gchar *sel = g_strdup_printf("select long_desc from packages where name = '%s' and version = '%s' and repo = '%s'",dt->pi->name,dt->pi->version,dt->pi->data);
- pk_debug("statement is '%s'",sel);
- res = sqlite3_prepare_v2(db,sel, -1, &package, NULL);
- g_free(sel);
- if (res!=SQLITE_OK)
- pk_error("sqlite error during select prepare: %s", sqlite3_errmsg(db));
- res = sqlite3_step(package);
- pk_backend_description(backend,dt->pi->name, "unknown", PK_GROUP_ENUM_OTHER,(const gchar*)sqlite3_column_text(package,0),"",0,"");
- res = sqlite3_step(package);
- if (res==SQLITE_ROW)
- pk_error("multiple matches for that package!");
- if (res!=SQLITE_DONE)
- {
- pk_debug("sqlite error during step (%d): %s", res, sqlite3_errmsg(db));
- g_assert(0);
- }
-
- g_free(dt);
-
- return TRUE;
-}
-
-/**
- * sqlite_get_description:
- */
-void
-sqlite_get_description (PkBackend *backend, const gchar *package_id)
-{
- g_return_if_fail (backend != NULL);
- desc_task *data = g_new(desc_task, 1);
- if (data == NULL)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for search task");
- pk_backend_finished(backend);
- return;
- }
-
- data->pi = pk_package_id_new_from_string(package_id);
- if (data->pi == NULL)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
- pk_backend_finished(backend);
- return;
- }
-
- pk_backend_thread_helper (backend, sqlite_get_description_thread, data);
- return;
-}
-
-
diff --git a/backends/apt/sqlite-pkg-cache.h b/backends/apt/sqlite-pkg-cache.h
deleted file mode 100644
index 68f5287..0000000
--- a/backends/apt/sqlite-pkg-cache.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef SQLITE_PKT_CACHE
-#define SQLITE_PKT_CACHE
-
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-typedef enum {
- SEARCH_NAME = 1,
- SEARCH_DETAILS,
- SEARCH_FILE
-} SearchDepth;
-
-#include <pk-backend.h>
-
-void sqlite_init_cache(PkBackend *backend, const char* dbname, const char* compare_fname, void (*build_db)(PkBackend *, sqlite3 *db));
-void sqlite_search_details (PkBackend *backend, const gchar *filter, const gchar *search);
-void sqlite_search_name (PkBackend *backend, const gchar *filter, const gchar *search);
-void backend_search_common(PkBackend * backend, const gchar * filter, const gchar * search, SearchDepth which, PkBackendThreadFunc func);
-void sqlite_get_description (PkBackend *backend, const gchar *package_id);
-
-#endif
More information about the PackageKit
mailing list