[PackageKit-commit] packagekit: Branch 'master' - 13 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Sun Jun 29 10:07:16 PDT 2008
backends/Makefile.am | 4
backends/razor/.gitignore | 10
backends/razor/Makefile.am | 8
backends/razor/pk-backend-razor.c | 384 +++++++++++++++++++++++++++++++++
backends/smart/helpers/smartBackend.py | 15 +
backends/yum/helpers/yumBackend.py | 2
client/pk-console.c | 51 +---
client/pk-import-desktop.c | 21 -
configure.ac | 14 +
libpackagekit/pk-client.c | 35 ++-
libpackagekit/pk-client.h | 4
libpackagekit/pk-common.c | 83 -------
libpackagekit/pk-common.h | 5
libpackagekit/pk-details-obj.c | 79 +++---
libpackagekit/pk-details-obj.h | 18 -
libpackagekit/pk-package-id.c | 170 +++++++++-----
libpackagekit/pk-package-id.h | 34 +-
libpackagekit/pk-package-ids.c | 4
libpackagekit/pk-package-list.c | 97 ++++++--
libpackagekit/pk-package-list.h | 2
libpackagekit/pk-package-obj.c | 26 +-
libpackagekit/pk-package-obj.h | 5
libpackagekit/pk-update-detail-list.c | 10
libpackagekit/pk-update-detail-list.h | 2
libpackagekit/pk-update-detail-obj.c | 89 +++----
libpackagekit/pk-update-detail-obj.h | 9
src/pk-backend.c | 46 ++-
src/pk-transaction.c | 54 ++--
28 files changed, 879 insertions(+), 402 deletions(-)
New commits:
commit 78b8e295ac1003abd23b7c3792a78abde4e80381
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date: Fri Jun 27 12:21:48 2008 +0200
use smart status flags (#16525)
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index d95ce2a..20f1836 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -19,6 +19,7 @@
import smart
from packagekit.backend import PackageKitBaseBackend, INFO_INSTALLED, \
INFO_AVAILABLE, INFO_NORMAL, FILTER_NOT_INSTALLED, FILTER_INSTALLED, \
+ INFO_SECURITY, INFO_BUGFIX, INFO_ENHANCEMENT, \
ERROR_REPO_NOT_FOUND, ERROR_PACKAGE_ALREADY_INSTALLED
@@ -139,7 +140,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
trans.run()
for (package, op) in trans.getChangeSet().items():
if op == smart.transaction.INSTALL:
- self._show_package(package, status=INFO_NORMAL)
+ status = self._get_status(package)
+ self._show_package(package, status)
@needs_cache
def resolve(self, filters, packagename):
@@ -301,6 +303,17 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.package(self.get_package_id(package.name, version, arch,
channel.getAlias()), status, info.getSummary())
+ def _get_status(self, package):
+ flags = smart.pkgconf.testAllFlags(package)
+ for flag in flags:
+ if flag == 'security':
+ return INFO_SECURITY
+ elif flag == 'bugfix':
+ return INFO_BUGFIX
+ elif flag == 'enhancement':
+ return INFO_ENHANCEMENT
+ return INFO_NORMAL
+
def _process_search_results(self, results):
packages = []
for obj in results:
commit 62745ad52a014d8b35cbfc91bf68e03cd15cfbf3
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 26 21:18:33 2008 +0100
use PkPackageId rather than a package_id in the PkUpdateDetail and PkDetails structs
diff --git a/client/pk-console.c b/client/pk-console.c
index 4b89515..973450a 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -210,7 +210,7 @@ pk_console_update_detail_cb (PkClient *client, const PkUpdateDetailObj *detail,
g_print ("\n");
}
g_print ("%s\n", _("Update detail"));
- g_print (" package: '%s'\n", detail->package_id);
+ g_print (" package: '%s-%s.%s'\n", detail->id->name, detail->id->version, detail->id->arch);
if (pk_strzero (detail->updates) == FALSE) {
g_print (" updates: '%s'\n", detail->updates);
}
@@ -990,7 +990,7 @@ pk_console_details_cb (PkClient *client, const PkDetailsObj *details, gpointer d
g_print ("\n");
}
g_print ("%s\n", _("Package description"));
- g_print (" package: '%s'\n", details->package_id);
+ g_print (" package: '%s-%s.%s'\n", details->id->name, details->id->version, details->id->arch);
g_print (" license: '%s'\n", details->license);
g_print (" group: '%s'\n", pk_group_enum_to_text (details->group));
g_print (" description: '%s'\n", details->description);
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index a33e723..753805f 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -601,16 +601,19 @@ pk_client_update_detail_cb (DBusGProxy *proxy, const gchar *package_id, const g
{
PkRestartEnum restart;
PkUpdateDetailObj *detail;
+ PkPackageId *id;
g_return_if_fail (PK_IS_CLIENT (client));
pk_debug ("emit update-detail %s, %s, %s, %s, %s, %s, %s, %s",
package_id, updates, obsoletes, vendor_url, bugzilla_url, cve_url, restart_text, update_text);
+ id = pk_package_id_new_from_string (package_id);
restart = pk_restart_enum_from_text (restart_text);
- detail = pk_update_detail_obj_new_from_data (package_id, updates, obsoletes, vendor_url,
- bugzilla_url, cve_url, restart, update_text);
+ detail = pk_update_detail_obj_new_from_data (id, updates, obsoletes, vendor_url,
+ bugzilla_url, cve_url, restart, update_text);
g_signal_emit (client, signals [PK_CLIENT_UPDATE_DETAIL], 0, detail);
+ pk_package_id_free (id);
pk_update_detail_obj_free (detail);
}
@@ -624,15 +627,19 @@ pk_client_details_cb (DBusGProxy *proxy, const gchar *package_id, const gchar *l
{
PkGroupEnum group;
PkDetailsObj *details;
+ PkPackageId *id;
+
g_return_if_fail (PK_IS_CLIENT (client));
group = pk_group_enum_from_text (group_text);
+ id = pk_package_id_new_from_string (package_id);
pk_debug ("emit details %s, %s, %s, %s, %s, %ld",
- package_id, license, pk_group_enum_to_text (group), description, url, (long int) size);
+ package_id, license, group_text, description, url, (long int) size);
- details = pk_details_obj_new_from_data (package_id, license, group, description, url, size);
+ details = pk_details_obj_new_from_data (id, license, group, description, url, size);
g_signal_emit (client, signals [PK_CLIENT_DETAILS], 0, details);
+ pk_package_id_free (id);
pk_details_obj_free (details);
}
diff --git a/libpackagekit/pk-details-obj.c b/libpackagekit/pk-details-obj.c
index fe56a6e..e5e5c93 100644
--- a/libpackagekit/pk-details-obj.c
+++ b/libpackagekit/pk-details-obj.c
@@ -47,16 +47,16 @@
PkDetailsObj *
pk_details_obj_new (void)
{
- PkDetailsObj *detail;
- detail = g_new0 (PkDetailsObj, 1);
- detail->package_id = NULL;
- detail->license = NULL;
- detail->group = 0;
- detail->description = NULL;
- detail->url = NULL;
- detail->size = 0;
-
- return detail;
+ PkDetailsObj *obj;
+ obj = g_new0 (PkDetailsObj, 1);
+ obj->id = NULL;
+ obj->license = NULL;
+ obj->group = 0;
+ obj->description = NULL;
+ obj->url = NULL;
+ obj->size = 0;
+
+ return obj;
}
/**
@@ -67,21 +67,34 @@ pk_details_obj_new (void)
* Return value: a new #PkDetailsObj object
**/
PkDetailsObj *
-pk_details_obj_new_from_data (const gchar *package_id, const gchar *license, PkGroupEnum group,
+pk_details_obj_new_from_data (const PkPackageId *id, const gchar *license, PkGroupEnum group,
const gchar *description, const gchar *url, guint64 size)
{
- PkDetailsObj *detail = NULL;
+ PkDetailsObj *obj = NULL;
/* create new object */
- detail = pk_details_obj_new ();
- detail->package_id = g_strdup (package_id);
- detail->license = g_strdup (license);
- detail->group = group;
- detail->description = g_strdup (description);
- detail->url = g_strdup (url);
- detail->size = size;
-
- return detail;
+ obj = pk_details_obj_new ();
+ obj->id = pk_package_id_copy (id);
+ obj->license = g_strdup (license);
+ obj->group = group;
+ obj->description = g_strdup (description);
+ obj->url = g_strdup (url);
+ obj->size = size;
+
+ return obj;
+}
+
+/**
+ * pk_details_obj_copy:
+ *
+ * Return value: a new #PkDetailsObj object
+ **/
+PkDetailsObj *
+pk_details_obj_copy (const PkDetailsObj *obj)
+{
+ g_return_val_if_fail (obj != NULL, NULL);
+ return pk_details_obj_new_from_data (obj->id, obj->license, obj->group,
+ obj->description, obj->url, obj->size);
}
/**
@@ -91,16 +104,16 @@ pk_details_obj_new_from_data (const gchar *package_id, const gchar *license, PkG
* Return value: %TRUE if the #PkDetailsObj object was freed.
**/
gboolean
-pk_details_obj_free (PkDetailsObj *detail)
+pk_details_obj_free (PkDetailsObj *obj)
{
- if (detail == NULL) {
+ if (obj == NULL) {
return FALSE;
}
- g_free (detail->package_id);
- g_free (detail->license);
- g_free (detail->description);
- g_free (detail->url);
- g_free (detail);
+ pk_package_id_free (obj->id);
+ g_free (obj->license);
+ g_free (obj->description);
+ g_free (obj->url);
+ g_free (obj);
return TRUE;
}
@@ -114,7 +127,7 @@ void
libst_details (LibSelfTest *test)
{
gboolean ret;
- PkDetailsObj *detail;
+ PkDetailsObj *obj;
if (libst_start (test, "PkDetailsObj", CLASS_AUTO) == FALSE) {
return;
@@ -122,8 +135,8 @@ libst_details (LibSelfTest *test)
/************************************************************/
libst_title (test, "get an details object");
- detail = pk_details_obj_new ();
- if (detail != NULL) {
+ obj = pk_details_obj_new ();
+ if (obj != NULL) {
libst_success (test, NULL);
} else {
libst_failed (test, NULL);
@@ -131,7 +144,7 @@ libst_details (LibSelfTest *test)
/************************************************************/
libst_title (test, "test details");
- ret = pk_details_obj_free (detail);
+ ret = pk_details_obj_free (obj);
if (ret) {
libst_success (test, NULL);
} else {
diff --git a/libpackagekit/pk-details-obj.h b/libpackagekit/pk-details-obj.h
index 854fddc..489a0ea 100644
--- a/libpackagekit/pk-details-obj.h
+++ b/libpackagekit/pk-details-obj.h
@@ -24,6 +24,7 @@
#include <glib-object.h>
#include <pk-enum.h>
+#include <pk-package-id.h>
G_BEGIN_DECLS
@@ -34,7 +35,7 @@ G_BEGIN_DECLS
**/
typedef struct
{
- gchar *package_id;
+ PkPackageId *id;
gchar *license;
PkGroupEnum group;
gchar *description;
@@ -43,13 +44,14 @@ typedef struct
} PkDetailsObj;
PkDetailsObj *pk_details_obj_new (void);
-PkDetailsObj *pk_details_obj_new_from_data (const gchar *package_id,
- const gchar *license,
- PkGroupEnum group,
- const gchar *description,
- const gchar *url,
- guint64 size);
-gboolean pk_details_obj_free (PkDetailsObj *detail);
+PkDetailsObj *pk_details_obj_copy (const PkDetailsObj *obj);
+PkDetailsObj *pk_details_obj_new_from_data (const PkPackageId *id,
+ const gchar *license,
+ PkGroupEnum group,
+ const gchar *description,
+ const gchar *url,
+ guint64 size);
+gboolean pk_details_obj_free (PkDetailsObj *obj);
G_END_DECLS
diff --git a/libpackagekit/pk-update-detail-list.c b/libpackagekit/pk-update-detail-list.c
index a18b860..2767c32 100644
--- a/libpackagekit/pk-update-detail-list.c
+++ b/libpackagekit/pk-update-detail-list.c
@@ -76,9 +76,9 @@ pk_update_detail_list_add_obj (PkUpdateDetailList *list, const PkUpdateDetailObj
g_return_val_if_fail (obj != NULL, FALSE);
/* are we already in the cache? */
- obj_found = pk_update_detail_list_get_obj (list, obj->package_id);
+ obj_found = pk_update_detail_list_get_obj (list, obj->id);
if (obj_found != NULL) {
- pk_debug ("already in list: %s", obj->package_id);
+ pk_debug ("already in list: %s", obj->id->name);
return FALSE;
}
@@ -95,19 +95,19 @@ pk_update_detail_list_add_obj (PkUpdateDetailList *list, const PkUpdateDetailObj
* Gets an object from the list
**/
const PkUpdateDetailObj *
-pk_update_detail_list_get_obj (PkUpdateDetailList *list, const gchar *package_id)
+pk_update_detail_list_get_obj (PkUpdateDetailList *list, const PkPackageId *id)
{
guint i;
guint len;
PkUpdateDetailObj *obj;
g_return_val_if_fail (PK_IS_UPDATE_DETAIL_LIST (list), NULL);
- g_return_val_if_fail (package_id != NULL, NULL);
+ g_return_val_if_fail (id != NULL, NULL);
len = list->priv->array->len;
for (i=0; i<len; i++) {
obj = (PkUpdateDetailObj *) g_ptr_array_index (list->priv->array, i);
- if (pk_strequal (package_id, obj->package_id)) {
+ if (pk_package_id_equal (id, obj->id)) {
return obj;
}
}
diff --git a/libpackagekit/pk-update-detail-list.h b/libpackagekit/pk-update-detail-list.h
index 41ac877..f3b9bd5 100644
--- a/libpackagekit/pk-update-detail-list.h
+++ b/libpackagekit/pk-update-detail-list.h
@@ -54,7 +54,7 @@ gboolean pk_update_detail_list_clear (PkUpdateDetailList *list);
gboolean pk_update_detail_list_add_obj (PkUpdateDetailList *list,
const PkUpdateDetailObj *obj);
const PkUpdateDetailObj *pk_update_detail_list_get_obj (PkUpdateDetailList *list,
- const gchar *package_id);
+ const PkPackageId *id);
G_END_DECLS
diff --git a/libpackagekit/pk-update-detail-obj.c b/libpackagekit/pk-update-detail-obj.c
index 2c0059c..64b5e2a 100644
--- a/libpackagekit/pk-update-detail-obj.c
+++ b/libpackagekit/pk-update-detail-obj.c
@@ -47,17 +47,17 @@
PkUpdateDetailObj *
pk_update_detail_obj_new (void)
{
- PkUpdateDetailObj *detail;
- detail = g_new0 (PkUpdateDetailObj, 1);
- detail->updates = NULL;
- detail->obsoletes = NULL;
- detail->vendor_url = NULL;
- detail->bugzilla_url = NULL;
- detail->cve_url = NULL;
- detail->restart = 0;
- detail->update_text = NULL;
-
- return detail;
+ PkUpdateDetailObj *obj;
+ obj = g_new0 (PkUpdateDetailObj, 1);
+ obj->updates = NULL;
+ obj->obsoletes = NULL;
+ obj->vendor_url = NULL;
+ obj->bugzilla_url = NULL;
+ obj->cve_url = NULL;
+ obj->restart = 0;
+ obj->update_text = NULL;
+
+ return obj;
}
/**
@@ -68,24 +68,24 @@ pk_update_detail_obj_new (void)
* Return value: a new #PkUpdateDetailObj object
**/
PkUpdateDetailObj *
-pk_update_detail_obj_new_from_data (const gchar *package_id, const gchar *updates, const gchar *obsoletes,
+pk_update_detail_obj_new_from_data (const PkPackageId *id, const gchar *updates, const gchar *obsoletes,
const gchar *vendor_url, const gchar *bugzilla_url, const gchar *cve_url,
PkRestartEnum restart, const gchar *update_text)
{
- PkUpdateDetailObj *detail = NULL;
+ PkUpdateDetailObj *obj = NULL;
/* create new object */
- detail = pk_update_detail_obj_new ();
- detail->package_id = g_strdup (package_id);
- detail->updates = g_strdup (updates);
- detail->obsoletes = g_strdup (obsoletes);
- detail->vendor_url = g_strdup (vendor_url);
- detail->bugzilla_url = g_strdup (bugzilla_url);
- detail->cve_url = g_strdup (cve_url);
- detail->restart = restart;
- detail->update_text = g_strdup (update_text);
-
- return detail;
+ obj = pk_update_detail_obj_new ();
+ obj->id = pk_package_id_copy (id);
+ obj->updates = g_strdup (updates);
+ obj->obsoletes = g_strdup (obsoletes);
+ obj->vendor_url = g_strdup (vendor_url);
+ obj->bugzilla_url = g_strdup (bugzilla_url);
+ obj->cve_url = g_strdup (cve_url);
+ obj->restart = restart;
+ obj->update_text = g_strdup (update_text);
+
+ return obj;
}
/**
@@ -94,33 +94,34 @@ pk_update_detail_obj_new_from_data (const gchar *package_id, const gchar *update
* Return value: a new #PkUpdateDetailObj object
**/
PkUpdateDetailObj *
-pk_update_detail_obj_copy (const PkUpdateDetailObj *detail)
+pk_update_detail_obj_copy (const PkUpdateDetailObj *obj)
{
- g_return_val_if_fail (detail != NULL, NULL);
- return pk_update_detail_obj_new_from_data (detail->package_id, detail->updates, detail->obsoletes,
- detail->vendor_url, detail->bugzilla_url, detail->cve_url,
- detail->restart, detail->update_text);
+ g_return_val_if_fail (obj != NULL, NULL);
+ return pk_update_detail_obj_new_from_data (obj->id, obj->updates, obj->obsoletes,
+ obj->vendor_url, obj->bugzilla_url, obj->cve_url,
+ obj->restart, obj->update_text);
}
/**
* pk_update_detail_obj_free:
- * @detail: the #PkUpdateDetailObj object
+ * @obj: the #PkUpdateDetailObj object
*
* Return value: %TRUE if the #PkUpdateDetailObj object was freed.
**/
gboolean
-pk_update_detail_obj_free (PkUpdateDetailObj *detail)
+pk_update_detail_obj_free (PkUpdateDetailObj *obj)
{
- if (detail == NULL) {
+ if (obj == NULL) {
return FALSE;
}
- g_free (detail->updates);
- g_free (detail->obsoletes);
- g_free (detail->vendor_url);
- g_free (detail->bugzilla_url);
- g_free (detail->cve_url);
- g_free (detail->update_text);
- g_free (detail);
+ pk_package_id_free (obj->id);
+ g_free (obj->updates);
+ g_free (obj->obsoletes);
+ g_free (obj->vendor_url);
+ g_free (obj->bugzilla_url);
+ g_free (obj->cve_url);
+ g_free (obj->update_text);
+ g_free (obj);
return TRUE;
}
@@ -134,7 +135,7 @@ void
libst_update_detail (LibSelfTest *test)
{
gboolean ret;
- PkUpdateDetailObj *detail;
+ PkUpdateDetailObj *obj;
if (libst_start (test, "PkUpdateDetailObj", CLASS_AUTO) == FALSE) {
return;
@@ -146,8 +147,8 @@ libst_update_detail (LibSelfTest *test)
/************************************************************/
libst_title (test, "get an detail object");
- detail = pk_update_detail_obj_new ();
- if (detail != NULL) {
+ obj = pk_update_detail_obj_new ();
+ if (obj != NULL) {
libst_success (test, NULL);
} else {
libst_failed (test, NULL);
@@ -155,7 +156,7 @@ libst_update_detail (LibSelfTest *test)
/************************************************************/
libst_title (test, "test detail");
- ret = pk_update_detail_obj_free (detail);
+ ret = pk_update_detail_obj_free (obj);
if (ret) {
libst_success (test, NULL);
} else {
diff --git a/libpackagekit/pk-update-detail-obj.h b/libpackagekit/pk-update-detail-obj.h
index caa0569..c6c31d0 100644
--- a/libpackagekit/pk-update-detail-obj.h
+++ b/libpackagekit/pk-update-detail-obj.h
@@ -24,6 +24,7 @@
#include <glib-object.h>
#include <pk-enum.h>
+#include <pk-package-id.h>
G_BEGIN_DECLS
@@ -34,7 +35,7 @@ G_BEGIN_DECLS
**/
typedef struct
{
- gchar *package_id;
+ PkPackageId *id;
gchar *updates;
gchar *obsoletes;
gchar *vendor_url;
@@ -45,8 +46,8 @@ typedef struct
} PkUpdateDetailObj;
PkUpdateDetailObj *pk_update_detail_obj_new (void);
-PkUpdateDetailObj *pk_update_detail_obj_copy (const PkUpdateDetailObj *detail);
-PkUpdateDetailObj *pk_update_detail_obj_new_from_data (const gchar *package_id,
+PkUpdateDetailObj *pk_update_detail_obj_copy (const PkUpdateDetailObj *obj);
+PkUpdateDetailObj *pk_update_detail_obj_new_from_data (const PkPackageId *id,
const gchar *updates,
const gchar *obsoletes,
const gchar *vendor_url,
@@ -54,7 +55,7 @@ PkUpdateDetailObj *pk_update_detail_obj_new_from_data (const gchar *package_id,
const gchar *cve_url,
PkRestartEnum restart,
const gchar *update_text);
-gboolean pk_update_detail_obj_free (PkUpdateDetailObj *detail);
+gboolean pk_update_detail_obj_free (PkUpdateDetailObj *obj);
G_END_DECLS
diff --git a/src/pk-backend.c b/src/pk-backend.c
index c8389ff..d77c72e 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -985,6 +985,7 @@ pk_backend_update_detail (PkBackend *backend, const gchar *package_id,
{
gchar *update_text_safe;
PkUpdateDetailObj *detail;
+ PkPackageId *id;
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
g_return_val_if_fail (package_id != NULL, FALSE);
@@ -1000,9 +1001,12 @@ pk_backend_update_detail (PkBackend *backend, const gchar *package_id,
update_text_safe = pk_strsafe (update_text);
/* form PkUpdateDetailObj struct */
- detail = pk_update_detail_obj_new_from_data (package_id, updates, obsoletes, vendor_url, bugzilla_url, cve_url, restart, update_text_safe);
+ id = pk_package_id_new_from_string (package_id);
+ detail = pk_update_detail_obj_new_from_data (id, updates, obsoletes, vendor_url,
+ bugzilla_url, cve_url, restart, update_text_safe);
g_signal_emit (backend, signals [PK_BACKEND_UPDATE_DETAIL], 0, detail);
+ pk_package_id_free (id);
pk_update_detail_obj_free (detail);
g_free (update_text_safe);
return TRUE;
@@ -1110,6 +1114,7 @@ pk_backend_details (PkBackend *backend, const gchar *package_id,
{
gchar *description_safe;
PkDetailsObj *details;
+ PkPackageId *id;
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
g_return_val_if_fail (package_id != NULL, FALSE);
@@ -1124,9 +1129,11 @@ pk_backend_details (PkBackend *backend, const gchar *package_id,
/* replace unsafe chars */
description_safe = pk_strsafe (description);
- details = pk_details_obj_new_from_data (package_id, license, group, description_safe, url, size);
+ id = pk_package_id_new_from_string (package_id);
+ details = pk_details_obj_new_from_data (id, license, group, description_safe, url, size);
g_signal_emit (backend, signals [PK_BACKEND_DETAILS], 0, details);
+ pk_package_id_free (id);
pk_details_obj_free (details);
g_free (description_safe);
return TRUE;
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 9ed704e..3c47ba0 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -362,17 +362,19 @@ pk_transaction_caller_active_changed_cb (LibGBus *libgbus, gboolean is_active, P
* pk_transaction_details_cb:
**/
static void
-pk_transaction_details_cb (PkBackend *backend, PkDetailsObj *details, PkTransaction *transaction)
+pk_transaction_details_cb (PkBackend *backend, PkDetailsObj *obj, PkTransaction *transaction)
{
const gchar *group_text;
+ gchar *package_id;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
- group_text = pk_group_enum_to_text (details->group);
- g_signal_emit (transaction, signals [PK_TRANSACTION_DETAILS], 0,
- details->package_id, details->license, group_text, details->description,
- details->url, details->size);
+ group_text = pk_group_enum_to_text (obj->group);
+ package_id = pk_package_id_to_string (obj->id);
+ g_signal_emit (transaction, signals [PK_TRANSACTION_DETAILS], 0, package_id,
+ obj->license, group_text, obj->description, obj->url, obj->size);
+ g_free (package_id);
}
/**
@@ -715,6 +717,7 @@ static void
pk_transaction_update_detail_cb (PkBackend *backend, const PkUpdateDetailObj *detail, PkTransaction *transaction)
{
const gchar *restart_text;
+ gchar *package_id;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -723,9 +726,11 @@ pk_transaction_update_detail_cb (PkBackend *backend, const PkUpdateDetailObj *de
pk_update_detail_list_add_obj (transaction->priv->update_detail_list, detail);
restart_text = pk_restart_enum_to_text (detail->restart);
+ package_id = pk_package_id_to_string (detail->id);
g_signal_emit (transaction, signals [PK_TRANSACTION_UPDATE_DETAIL], 0,
- detail->package_id, detail->updates, detail->obsoletes, detail->vendor_url,
+ package_id, detail->updates, detail->obsoletes, detail->vendor_url,
detail->bugzilla_url, detail->cve_url, restart_text, detail->update_text);
+ g_free (package_id);
}
@@ -1756,8 +1761,10 @@ pk_transaction_get_update_detail (PkTransaction *transaction, gchar **package_id
gboolean ret;
GError *error;
gchar *package_ids_temp;
+ gchar *package_id;
gchar **package_ids_new;
const PkUpdateDetailObj *detail;
+ PkPackageId *id;
GPtrArray *array;
guint i;
guint len;
@@ -1803,14 +1810,18 @@ pk_transaction_get_update_detail (PkTransaction *transaction, gchar **package_id
/* try and reuse cache */
len = g_strv_length (package_ids);
for (i=0; i<len; i++) {
- detail = pk_update_detail_list_get_obj (transaction->priv->update_detail_list, package_ids[i]);
+ id = pk_package_id_new_from_string (package_ids[i]);
+ detail = pk_update_detail_list_get_obj (transaction->priv->update_detail_list, id);
+ pk_package_id_free (id);
if (detail != NULL) {
pk_warning ("got %s", package_ids[i]);
+ package_id = pk_package_id_to_string (detail->id);
/* emulate the backend */
g_signal_emit (transaction, signals [PK_TRANSACTION_UPDATE_DETAIL], 0,
- detail->package_id, detail->updates, detail->obsoletes,
+ package_id, detail->updates, detail->obsoletes,
detail->vendor_url, detail->bugzilla_url, detail->cve_url,
pk_restart_enum_to_text (detail->restart), detail->update_text);
+ g_free (package_id);
} else {
pk_warning ("not got %s", package_ids[i]);
g_ptr_array_add (array, g_strdup (package_ids[i]));
commit 60b53d61f9512bf4e54cf441517c2e8159fae219
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 26 18:31:28 2008 +0100
don't store the package_id as a char* in PkPackageObj, use a PkPackageId instead
diff --git a/client/pk-console.c b/client/pk-console.c
index 5df4da2..4b89515 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -123,35 +123,27 @@ pk_console_start_bar (const gchar *text)
* pk_console_package_cb:
**/
static void
-pk_console_package_cb (PkClient *client, PkInfoEnum info, const gchar *package_id, const gchar *summary, gpointer data)
+pk_console_package_cb (PkClient *client, const PkPackageObj *obj, gpointer data)
{
- PkPackageId *ident;
PkRoleEnum role;
gchar *package = NULL;
gchar *info_pad = NULL;
gchar *text = NULL;
- /* split */
- ident = pk_package_id_new_from_string (package_id);
- if (ident == NULL) {
- pk_warning ("Could not get valid ident from %s", package_id);
- return;
- }
-
- /* make these all the same lenght */
- info_pad = pk_strpad (pk_info_enum_to_text (info), 12);
+ /* make these all the same length */
+ info_pad = pk_strpad (pk_info_enum_to_text (obj->info), 12);
/* don't pretty print */
if (!is_console) {
- g_print ("%s %s-%s.%s\n", info_pad, ident->name, ident->version, ident->arch);
+ g_print ("%s %s-%s.%s\n", info_pad, obj->id->name, obj->id->version, obj->id->arch);
goto out;
}
/* pad the name-version */
- if (pk_strzero (ident->version)) {
- package = g_strdup (ident->name);
+ if (pk_strzero (obj->id->version)) {
+ package = g_strdup (obj->id->name);
} else {
- package = g_strdup_printf ("%s-%s", ident->name, ident->version);
+ package = g_strdup_printf ("%s-%s", obj->id->name, obj->id->version);
}
/* mark previous complete */
@@ -183,7 +175,6 @@ pk_console_package_cb (PkClient *client, PkInfoEnum info, const gchar *package_i
out:
/* free all the data */
- pk_package_id_free (ident);
g_free (package);
g_free (info_pad);
}
@@ -483,7 +474,7 @@ pk_console_perhaps_resolve (PkClient *client, PkFilterEnum filter, const gchar *
gboolean valid;
guint i;
guint length;
- const PkPackageObj *item;
+ const PkPackageObj *obj;
PkPackageList *list;
gchar **packages;
@@ -537,8 +528,8 @@ pk_console_perhaps_resolve (PkClient *client, PkFilterEnum filter, const gchar *
/* only found one, great! */
if (length == 1) {
- item = pk_package_list_get_obj (list, 0);
- return g_strdup (item->package_id);
+ obj = pk_package_list_get_obj (list, 0);
+ return pk_package_id_to_string (obj->id);
}
/* else list the options if multiple matches found */
@@ -547,17 +538,16 @@ pk_console_perhaps_resolve (PkClient *client, PkFilterEnum filter, const gchar *
}
g_print ("%s\n", _("There are multiple package matches"));
for (i=0; i<length; i++) {
- item = pk_package_list_get_obj (list, i);
- g_print ("%i. %s\n", i+1, item->package_id);
+ obj = pk_package_list_get_obj (list, i);
+ g_print ("%i. %s-%s.%s\n", i+1, obj->id->name, obj->id->version, obj->id->arch);
}
/* find out what package the user wants to use */
i = pk_console_get_number (_("Please enter the package number: "), length);
- item = pk_package_list_get_obj (list, i-1);
- pk_debug ("package_id = %s", item->package_id);
+ obj = pk_package_list_get_obj (list, i-1);
g_object_unref (list);
- return g_strdup (item->package_id);
+ return pk_package_id_to_string (obj->id);
}
/**
@@ -718,8 +708,7 @@ pk_console_remove_packages (PkClient *client, gchar **packages, GError **error)
{
gchar *package_id;
gboolean ret = TRUE;
- const PkPackageObj *item;
- PkPackageId *ident;
+ const PkPackageObj *obj;
guint i;
guint length;
gboolean remove;
@@ -797,10 +786,8 @@ pk_console_remove_packages (PkClient *client, gchar **packages, GError **error)
}
g_print ("%s:\n", _("The following packages have to be removed"));
for (i=0; i<length; i++) {
- item = pk_package_list_get_obj (list, i);
- ident = pk_package_id_new_from_string (item->package_id);
- g_print ("%i\t%s-%s\n", i, ident->name, ident->version);
- pk_package_id_free (ident);
+ obj = pk_package_list_get_obj (list, i);
+ g_print ("%i\t%s-%s.%s\n", i, obj->id->name, obj->id->version, obj->id->arch);
}
/* get user input */
diff --git a/client/pk-import-desktop.c b/client/pk-import-desktop.c
index 5194471..8f46a77 100644
--- a/client/pk-import-desktop.c
+++ b/client/pk-import-desktop.c
@@ -45,8 +45,7 @@ pk_desktop_get_name_for_file (const gchar *filename)
{
guint size;
gchar *name = NULL;
- const PkPackageObj *item;
- PkPackageId *pid;
+ const PkPackageObj *obj;
gboolean ret;
GError *error = NULL;
PkPackageList *list = NULL;
@@ -74,23 +73,15 @@ pk_desktop_get_name_for_file (const gchar *filename)
goto out;
}
- /* get the item */
- item = pk_package_list_get_obj (list, 0);
- if (item == NULL) {
- pk_error ("cannot get item");
- goto out;
- }
-
- /* get the package name */
- pid = pk_package_id_new_from_string (item->package_id);
- if (pid == NULL) {
- pk_error ("cannot allocate package id");
+ /* get the obj */
+ obj = pk_package_list_get_obj (list, 0);
+ if (obj == NULL) {
+ pk_error ("cannot get obj");
goto out;
}
/* strip the name */
- name = g_strdup (pid->name);
- pk_package_id_free (pid);
+ name = g_strdup (obj->id->name);
out:
if (list != NULL) {
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index b0573bc..a33e723 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -554,17 +554,23 @@ pk_client_package_cb (DBusGProxy *proxy,
PkClient *client)
{
PkInfoEnum info;
+ PkPackageId *id;
+ PkPackageObj *obj;
g_return_if_fail (PK_IS_CLIENT (client));
- pk_debug ("emit package %s, %s, %s", info_text, package_id, summary);
info = pk_info_enum_from_text (info_text);
- g_signal_emit (client , signals [PK_CLIENT_PACKAGE], 0, info, package_id, summary);
+ id = pk_package_id_new_from_string (package_id);
+ obj = pk_package_obj_new (info, id, summary);
+
+ pk_debug ("emit package %s, %s, %s", info_text, package_id, summary);
+ g_signal_emit (client , signals [PK_CLIENT_PACKAGE], 0, obj);
/* cache */
if (client->priv->use_buffer || client->priv->synchronous) {
- pk_package_list_add (client->priv->package_list, info, package_id, summary);
+ pk_package_list_add_obj (client->priv->package_list, obj);
}
+ pk_package_obj_free (obj);
}
/**
@@ -3199,8 +3205,8 @@ pk_client_class_init (PkClientClass *klass)
g_signal_new ("package",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PkClientClass, package),
- NULL, NULL, pk_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+ NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
/**
* PkClient::transaction:
* @client: the #PkClient instance that emitted the signal
@@ -3752,7 +3758,7 @@ libst_client_copy_finished_cb (PkClient *client, PkExitEnum exit, guint runtime,
}
static void
-libst_client_copy_package_cb (PkClient *client, PkInfoEnum info, const gchar *package_id, const gchar *summary, LibSelfTest *test)
+libst_client_copy_package_cb (PkClient *client, const PkPackageObj *obj, LibSelfTest *test)
{
clone_packages++;
}
diff --git a/libpackagekit/pk-client.h b/libpackagekit/pk-client.h
index 61c7b09..4ac50b7 100644
--- a/libpackagekit/pk-client.h
+++ b/libpackagekit/pk-client.h
@@ -88,9 +88,7 @@ struct _PkClientClass
guint elapsed,
guint remaining);
void (* package) (PkClient *client,
- PkInfoEnum info,
- const gchar *package_id,
- const gchar *summary);
+ PkPackageObj *obj);
void (* transaction) (PkClient *client,
const gchar *tid,
const gchar *timespec,
diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 110884c..4099d51 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -188,59 +188,6 @@ pk_iso8601_difference (const gchar *isodate)
}
/**
- * pk_ptr_array_find_string:
- * @array: The GPtrArray to operate on
- * @string: The string to search for
- *
- * Return value: The array index, or -1 if not found
- **/
-gint
-pk_ptr_array_find_string (GPtrArray *array, const gchar *string)
-{
- gint i;
- gchar *item;
-
- g_return_val_if_fail (array != NULL, FALSE);
- g_return_val_if_fail (string != NULL, FALSE);
-
- for (i=0; i<array->len; i++) {
- item = (gchar *) g_ptr_array_index (array, i);
- if (pk_strequal (string, item)) {
- return i;
- }
- }
- return -1;
-}
-
-/**
- * pk_ptr_array_remove_string:
- * @array: The GPtrArray to operate on
- * @string: The string to search for
- *
- * Return value: %TRUE if we removed any strings
- **/
-gboolean
-pk_ptr_array_remove_string (GPtrArray *array, const gchar *string)
-{
- guint i;
- gchar *item;
- gboolean ret = FALSE;
-
- g_return_val_if_fail (array != NULL, FALSE);
- g_return_val_if_fail (string != NULL, FALSE);
-
- for (i=0; i<array->len; i++) {
- item = (gchar *) g_ptr_array_index (array, i);
- if (pk_strequal (string, item)) {
- g_free (item);
- g_ptr_array_remove_index (array, i);
- ret = TRUE;
- }
- }
- return ret;
-}
-
-/**
* pk_strvalidate_char:
* @item: A single char to test
*
diff --git a/libpackagekit/pk-common.h b/libpackagekit/pk-common.h
index fcba059..d4b9824 100644
--- a/libpackagekit/pk-common.h
+++ b/libpackagekit/pk-common.h
@@ -87,10 +87,6 @@ gchar *pk_strbuild_va (const gchar *first_element,
gchar *pk_strreplace (const gchar *text,
const gchar *find,
const gchar *replace);
-gint pk_ptr_array_find_string (GPtrArray *array,
- const gchar *string);
-gboolean pk_ptr_array_remove_string (GPtrArray *array,
- const gchar *string);
gchar **pk_ptr_array_to_argv (GPtrArray *array)
G_GNUC_WARN_UNUSED_RESULT;
gchar **pk_va_list_to_argv (const gchar *string_first,
diff --git a/libpackagekit/pk-details-obj.c b/libpackagekit/pk-details-obj.c
index 619c9c8..fe56a6e 100644
--- a/libpackagekit/pk-details-obj.c
+++ b/libpackagekit/pk-details-obj.c
@@ -138,8 +138,6 @@ libst_details (LibSelfTest *test)
libst_failed (test, NULL);
}
- pk_details_obj_free (detail);
-
libst_end (test);
}
#endif
diff --git a/libpackagekit/pk-package-id.c b/libpackagekit/pk-package-id.c
index 0fc9036..c7a1d6c 100644
--- a/libpackagekit/pk-package-id.c
+++ b/libpackagekit/pk-package-id.c
@@ -48,13 +48,13 @@
PkPackageId *
pk_package_id_new (void)
{
- PkPackageId *ident;
- ident = g_new0 (PkPackageId, 1);
- ident->name = NULL;
- ident->version = NULL;
- ident->arch = NULL;
- ident->data = NULL;
- return ident;
+ PkPackageId *id;
+ id = g_new0 (PkPackageId, 1);
+ id->name = NULL;
+ id->version = NULL;
+ id->arch = NULL;
+ id->data = NULL;
+ return id;
}
/**
@@ -94,7 +94,7 @@ PkPackageId *
pk_package_id_new_from_string (const gchar *package_id)
{
gchar **sections;
- PkPackageId *ident = NULL;
+ PkPackageId *id = NULL;
sections = pk_strsplit (package_id, 4);
if (sections == NULL) {
@@ -102,21 +102,21 @@ pk_package_id_new_from_string (const gchar *package_id)
}
/* create new object */
- ident = pk_package_id_new ();
+ id = pk_package_id_new ();
if (pk_strzero (sections[0]) == FALSE) {
- ident->name = g_strdup (sections[0]);
+ id->name = g_strdup (sections[0]);
}
if (pk_strzero (sections[1]) == FALSE) {
- ident->version = g_strdup (sections[1]);
+ id->version = g_strdup (sections[1]);
}
if (pk_strzero (sections[2]) == FALSE) {
- ident->arch = g_strdup (sections[2]);
+ id->arch = g_strdup (sections[2]);
}
if (pk_strzero (sections[3]) == FALSE) {
- ident->data = g_strdup (sections[3]);
+ id->data = g_strdup (sections[3]);
}
g_strfreev (sections);
- return ident;
+ return id;
}
/**
@@ -133,29 +133,43 @@ pk_package_id_new_from_string (const gchar *package_id)
PkPackageId *
pk_package_id_new_from_list (const gchar *name, const gchar *version, const gchar *arch, const gchar *data)
{
- PkPackageId *ident = NULL;
+ PkPackageId *id = NULL;
/* create new object */
- ident = pk_package_id_new ();
- ident->name = g_strdup (name);
- ident->version = g_strdup (version);
- ident->arch = g_strdup (arch);
- ident->data = g_strdup (data);
- return ident;
+ id = pk_package_id_new ();
+ id->name = g_strdup (name);
+ id->version = g_strdup (version);
+ id->arch = g_strdup (arch);
+ id->data = g_strdup (data);
+ return id;
+}
+
+/**
+ * pk_package_id_copy:
+ * @id: the %PkPackageId structure to copy
+ *
+ * Copies into a new #PkPackageId object.
+ *
+ * Return value: a new #PkPackageId object
+ **/
+PkPackageId *
+pk_package_id_copy (const PkPackageId *id)
+{
+ return pk_package_id_new_from_list (id->name, id->version, id->arch, id->data);
}
/**
* pk_package_id_to_string:
- * @ident: A #PkPackageId object
+ * @id: A #PkPackageId object
*
* Return value: returns a string representation of #PkPackageId.
**/
gchar *
-pk_package_id_to_string (const PkPackageId *ident)
+pk_package_id_to_string (const PkPackageId *id)
{
return g_strdup_printf ("%s;%s;%s;%s",
- ident->name, ident->version,
- ident->arch, ident->data);
+ id->name, id->version,
+ id->arch, id->data);
}
/**
@@ -176,26 +190,45 @@ pk_package_id_build (const gchar *name, const gchar *version,
/**
* pk_package_id_free:
- * @ident: the #PkPackageId object
+ * @id: the #PkPackageId object
*
* Return value: %TRUE if the #PkPackageId object was freed.
**/
gboolean
-pk_package_id_free (PkPackageId *ident)
+pk_package_id_free (PkPackageId *id)
{
- if (ident == NULL) {
+ if (id == NULL) {
return FALSE;
}
- g_free (ident->name);
- g_free (ident->arch);
- g_free (ident->version);
- g_free (ident->data);
- g_free (ident);
+ g_free (id->name);
+ g_free (id->arch);
+ g_free (id->version);
+ g_free (id->data);
+ g_free (id);
return TRUE;
}
/**
* pk_package_id_equal:
+ * @id1: the first %PkPackageId
+ * @id2: the second %PkPackageId
+ *
+ * Only compare the name, version, and arch
+ *
+ * Return value: %TRUE if the ids can be considered equal.
+ **/
+gboolean
+pk_package_id_equal (const PkPackageId *id1, const PkPackageId *id2)
+{
+ if (pk_strequal (id1->name, id2->name) &&
+ pk_strequal (id1->version, id2->version) &&
+ pk_strequal (id1->arch, id2->arch))
+ return TRUE;
+ return FALSE;
+}
+
+/**
+ * pk_package_id_equal_strings:
* @pid1: the first package_id
* @pid2: the second package_id
*
@@ -204,7 +237,7 @@ pk_package_id_free (PkPackageId *ident)
* Return value: %TRUE if the package_id's can be considered equal.
**/
gboolean
-pk_package_id_equal (const gchar *pid1, const gchar *pid2)
+pk_package_id_equal_strings (const gchar *pid1, const gchar *pid2)
{
return pk_strcmp_sections (pid1, pid2, 4, 3);
}
@@ -221,18 +254,18 @@ libst_package_id (LibSelfTest *test)
gboolean ret;
gchar *text;
const gchar *temp;
- PkPackageId *ident;
+ PkPackageId *id;
if (libst_start (test, "PkPackageId", CLASS_AUTO) == FALSE) {
return;
}
/************************************************************
- **************** IDENT ******************
+ **************** id ******************
************************************************************/
libst_title (test, "pid equal pass (same)");
- ret = pk_package_id_equal ("moo;0.0.1;i386;fedora", "moo;0.0.1;i386;fedora");
+ ret = pk_package_id_equal_strings ("moo;0.0.1;i386;fedora", "moo;0.0.1;i386;fedora");
if (ret) {
libst_success (test, NULL);
} else {
@@ -241,7 +274,7 @@ libst_package_id (LibSelfTest *test)
/************************************************************/
libst_title (test, "pid equal pass (different)");
- ret = pk_package_id_equal ("moo;0.0.1;i386;fedora", "moo;0.0.1;i386;data");
+ ret = pk_package_id_equal_strings ("moo;0.0.1;i386;fedora", "moo;0.0.1;i386;data");
if (ret) {
libst_success (test, NULL);
} else {
@@ -249,17 +282,17 @@ libst_package_id (LibSelfTest *test)
}
/************************************************************/
- libst_title (test, "get an ident object");
- ident = pk_package_id_new ();
- if (ident != NULL) {
+ libst_title (test, "get an id object");
+ id = pk_package_id_new ();
+ if (id != NULL) {
libst_success (test, NULL);
} else {
libst_failed (test, NULL);
}
/************************************************************/
- libst_title (test, "test ident freeing early");
- ret = pk_package_id_free (ident);
+ libst_title (test, "test id freeing early");
+ ret = pk_package_id_free (id);
if (ret) {
libst_success (test, NULL);
} else {
@@ -269,8 +302,8 @@ libst_package_id (LibSelfTest *test)
/************************************************************/
libst_title (test, "parse incorrect package_id from string (null)");
temp = NULL;
- ident = pk_package_id_new_from_string (temp);
- if (ident == NULL) {
+ id = pk_package_id_new_from_string (temp);
+ if (id == NULL) {
libst_success (test, NULL);
} else {
libst_failed (test, "passed an invalid string '%s'", temp);
@@ -279,8 +312,8 @@ libst_package_id (LibSelfTest *test)
/************************************************************/
libst_title (test, "parse incorrect package_id from string (empty)");
temp = "";
- ident = pk_package_id_new_from_string (temp);
- if (ident == NULL) {
+ id = pk_package_id_new_from_string (temp);
+ if (id == NULL) {
libst_success (test, NULL);
} else {
libst_failed (test, "passed an invalid string '%s'", temp);
@@ -289,8 +322,8 @@ libst_package_id (LibSelfTest *test)
/************************************************************/
libst_title (test, "parse incorrect package_id from string (not enough)");
temp = "moo;0.0.1;i386";
- ident = pk_package_id_new_from_string (temp);
- if (ident == NULL) {
+ id = pk_package_id_new_from_string (temp);
+ if (id == NULL) {
libst_success (test, NULL);
} else {
libst_failed (test, "passed an invalid string '%s'", temp);
@@ -298,41 +331,41 @@ libst_package_id (LibSelfTest *test)
/************************************************************/
libst_title (test, "parse package_id from string");
- ident = pk_package_id_new_from_string ("moo;0.0.1;i386;fedora");
- if (ident != NULL &&
- pk_strequal (ident->name, "moo") &&
- pk_strequal (ident->arch, "i386") &&
- pk_strequal (ident->data, "fedora") &&
- pk_strequal (ident->version, "0.0.1")) {
+ id = pk_package_id_new_from_string ("moo;0.0.1;i386;fedora");
+ if (id != NULL &&
+ pk_strequal (id->name, "moo") &&
+ pk_strequal (id->arch, "i386") &&
+ pk_strequal (id->data, "fedora") &&
+ pk_strequal (id->version, "0.0.1")) {
libst_success (test, NULL);
} else {
libst_failed (test, NULL);
}
/************************************************************/
- libst_title (test, "test ident building with valid data");
- text = pk_package_id_to_string (ident);
+ libst_title (test, "test id building with valid data");
+ text = pk_package_id_to_string (id);
if (pk_strequal (text, "moo;0.0.1;i386;fedora")) {
libst_success (test, NULL);
} else {
libst_failed (test, "package_id is '%s'", text);
}
g_free (text);
- pk_package_id_free (ident);
+ pk_package_id_free (id);
/************************************************************/
libst_title (test, "parse short package_id from string");
- ident = pk_package_id_new_from_string ("moo;0.0.1;;");
- if (ident != NULL &&
- pk_strequal (ident->name, "moo") &&
- pk_strequal (ident->version, "0.0.1") &&
- ident->data == NULL &&
- ident->arch == NULL) {
+ id = pk_package_id_new_from_string ("moo;0.0.1;;");
+ if (id != NULL &&
+ pk_strequal (id->name, "moo") &&
+ pk_strequal (id->version, "0.0.1") &&
+ id->data == NULL &&
+ id->arch == NULL) {
libst_success (test, NULL);
} else {
libst_failed (test, NULL);
}
- pk_package_id_free (ident);
+ pk_package_id_free (id);
libst_end (test);
}
diff --git a/libpackagekit/pk-package-id.h b/libpackagekit/pk-package-id.h
index 058ce8b..1a27296 100644
--- a/libpackagekit/pk-package-id.h
+++ b/libpackagekit/pk-package-id.h
@@ -38,27 +38,33 @@ typedef struct {
gchar *data;
} PkPackageId;
+/* objects */
PkPackageId *pk_package_id_new (void);
-PkPackageId *pk_package_id_new_from_string (const gchar *package_id)
+PkPackageId *pk_package_id_new_from_string (const gchar *package_id)
G_GNUC_WARN_UNUSED_RESULT;
-PkPackageId *pk_package_id_new_from_list (const gchar *name,
- const gchar *version,
- const gchar *arch,
- const gchar *data)
+PkPackageId *pk_package_id_new_from_list (const gchar *name,
+ const gchar *version,
+ const gchar *arch,
+ const gchar *data)
G_GNUC_WARN_UNUSED_RESULT;
-gchar *pk_package_id_build (const gchar *name,
- const gchar *version,
- const gchar *arch,
- const gchar *data)
+PkPackageId *pk_package_id_copy (const PkPackageId *id)
G_GNUC_WARN_UNUSED_RESULT;
-gchar *pk_package_id_to_string (const PkPackageId *ident)
+gboolean pk_package_id_equal (const PkPackageId *id1,
+ const PkPackageId *id2);
+gchar *pk_package_id_to_string (const PkPackageId *id)
G_GNUC_WARN_UNUSED_RESULT;
-gboolean pk_package_id_free (PkPackageId *ident);
-gboolean pk_package_id_check (const gchar *package_id)
+gboolean pk_package_id_free (PkPackageId *id);
+
+/* string helpers */
+gchar *pk_package_id_build (const gchar *name,
+ const gchar *version,
+ const gchar *arch,
+ const gchar *data)
G_GNUC_WARN_UNUSED_RESULT;
-gboolean pk_package_id_equal (const gchar *pid1,
- const gchar *pid2)
+gboolean pk_package_id_check (const gchar *package_id)
G_GNUC_WARN_UNUSED_RESULT;
+gboolean pk_package_id_equal_strings (const gchar *pid1,
+ const gchar *pid2);
G_END_DECLS
diff --git a/libpackagekit/pk-package-ids.c b/libpackagekit/pk-package-ids.c
index 3bf7acd..1f09ff2 100644
--- a/libpackagekit/pk-package-ids.c
+++ b/libpackagekit/pk-package-ids.c
@@ -276,7 +276,7 @@ libst_package_ids (LibSelfTest *test)
/************************************************************/
libst_title (test, "first correct");
- ret = pk_package_id_equal (package_ids[0], "foo;0.0.1;i386;fedora");
+ ret = pk_package_id_equal_strings (package_ids[0], "foo;0.0.1;i386;fedora");
if (ret) {
libst_success (test, NULL);
} else {
@@ -285,7 +285,7 @@ libst_package_ids (LibSelfTest *test)
/************************************************************/
libst_title (test, "second correct");
- ret = pk_package_id_equal (package_ids[1], "bar;0.1.1;noarch;livna");
+ ret = pk_package_id_equal_strings (package_ids[1], "bar;0.1.1;noarch;livna");
if (ret) {
libst_success (test, NULL);
} else {
diff --git a/libpackagekit/pk-package-list.c b/libpackagekit/pk-package-list.c
index 34c7a72..00d3cb0 100644
--- a/libpackagekit/pk-package-list.c
+++ b/libpackagekit/pk-package-list.c
@@ -70,14 +70,14 @@ G_DEFINE_TYPE (PkPackageList, pk_package_list, G_TYPE_OBJECT)
* pk_package_list_add:
**/
gboolean
-pk_package_list_add (PkPackageList *plist, PkInfoEnum info, const gchar *package_id, const gchar *summary)
+pk_package_list_add (PkPackageList *plist, PkInfoEnum info, const PkPackageId *ident, const gchar *summary)
{
PkPackageObj *obj;
g_return_val_if_fail (PK_IS_PACKAGE_LIST (plist), FALSE);
- g_return_val_if_fail (package_id != NULL, FALSE);
+ g_return_val_if_fail (ident != NULL, FALSE);
- obj = pk_package_obj_new (info, package_id, summary);
+ obj = pk_package_obj_new (info, ident, summary);
g_ptr_array_add (plist->priv->array, obj);
return TRUE;
@@ -144,6 +144,7 @@ pk_package_list_to_string (PkPackageList *plist)
guint length;
const gchar *info_text;
GString *package_cache;
+ gchar *package_id;
g_return_val_if_fail (PK_IS_PACKAGE_LIST (plist), NULL);
@@ -152,7 +153,9 @@ pk_package_list_to_string (PkPackageList *plist)
for (i=0; i<length; i++) {
obj = g_ptr_array_index (plist->priv->array, i);
info_text = pk_info_enum_to_text (obj->info);
- g_string_append_printf (package_cache, "%s\t%s\t%s\n", info_text, obj->package_id, obj->summary);
+ package_id = pk_package_id_to_string (obj->id);
+ g_string_append_printf (package_cache, "%s\t%s\t%s\n", info_text, package_id, obj->summary);
+ g_free (package_id);
}
/* remove trailing newline */
@@ -172,6 +175,7 @@ pk_package_list_to_argv (PkPackageList *plist)
PkPackageObj *obj;
GPtrArray *array;
gchar **package_ids;
+ gchar *package_id;
guint length;
guint i;
@@ -179,7 +183,9 @@ pk_package_list_to_argv (PkPackageList *plist)
length = plist->priv->array->len;
for (i=0; i<length; i++) {
obj = g_ptr_array_index (plist->priv->array, i);
- g_ptr_array_add (array, obj->package_id);
+ package_id = pk_package_id_to_string (obj->id);
+ g_ptr_array_add (array, package_id);
+ g_free (package_id);
}
/* convert to argv */
@@ -205,7 +211,13 @@ pk_package_list_get_size (PkPackageList *plist)
static gint
pk_package_list_sort_compare_package_id_func (PkPackageObj **a, PkPackageObj **b)
{
- return strcmp ((*a)->package_id, (*b)->package_id);
+ guint ret;
+ gchar *a_text = pk_package_id_to_string ((*a)->id);
+ gchar *b_text = pk_package_id_to_string ((*b)->id);
+ ret = strcmp (a_text, b_text);
+ g_free (a_text);
+ g_free (b_text);
+ return ret;
}
/**
@@ -319,6 +331,7 @@ pk_package_list_contains (PkPackageList *plist, const gchar *package_id)
guint i;
guint length;
gboolean ret = FALSE;
+ gchar *package_id_temp;
g_return_val_if_fail (PK_IS_PACKAGE_LIST (plist), FALSE);
g_return_val_if_fail (package_id != NULL, FALSE);
@@ -326,7 +339,9 @@ pk_package_list_contains (PkPackageList *plist, const gchar *package_id)
length = plist->priv->array->len;
for (i=0; i<length; i++) {
obj = g_ptr_array_index (plist->priv->array, i);
- ret = pk_package_id_equal (obj->package_id, package_id);
+ package_id_temp = pk_package_id_to_string (obj->id);
+ ret = pk_package_id_equal_strings (package_id_temp, package_id);
+ g_free (package_id_temp);
if (ret) {
break;
}
@@ -344,6 +359,7 @@ pk_package_list_remove (PkPackageList *plist, const gchar *package_id)
guint i;
guint length;
gboolean ret = FALSE;
+ gchar *package_id_temp;
g_return_val_if_fail (PK_IS_PACKAGE_LIST (plist), FALSE);
g_return_val_if_fail (package_id != NULL, FALSE);
@@ -351,7 +367,9 @@ pk_package_list_remove (PkPackageList *plist, const gchar *package_id)
length = plist->priv->array->len;
for (i=0; i<length; i++) {
obj = g_ptr_array_index (plist->priv->array, i);
- ret = pk_package_id_equal (obj->package_id, package_id);
+ package_id_temp = pk_package_id_to_string (obj->id);
+ ret = pk_package_id_equal_strings (package_id_temp, package_id);
+ g_free (package_id_temp);
if (ret) {
pk_package_obj_free (obj);
g_ptr_array_remove_index (plist->priv->array, i);
@@ -459,6 +477,10 @@ libst_package_list (LibSelfTest *test)
const PkPackageObj *r0;
const PkPackageObj *r1;
const PkPackageObj *r2;
+ gchar *r0_text;
+ gchar *r1_text;
+ gchar *r2_text;
+ PkPackageId *id;
if (libst_start (test, "PkPackageList", CLASS_AUTO) == FALSE) {
return;
@@ -475,7 +497,9 @@ libst_package_list (LibSelfTest *test)
/************************************************************/
libst_title (test, "add entry");
- ret = pk_package_list_add (plist, PK_INFO_ENUM_INSTALLED, "gnome;1.23;i386;data", "GNOME!");
+ id = pk_package_id_new_from_string ("gnome;1.23;i386;data");
+ ret = pk_package_list_add (plist, PK_INFO_ENUM_INSTALLED, id, "GNOME!");
+ pk_package_id_free (id);
if (ret) {
libst_success (test, NULL);
} else {
@@ -484,6 +508,7 @@ libst_package_list (LibSelfTest *test)
/************************************************************/
libst_title (test, "check not exists");
+ id = pk_package_id_new_from_string ("gnome;1.23;i386;data");
ret = pk_package_list_contains (plist, "liferea;1.23;i386;data");
if (ret == FALSE) {
libst_success (test, NULL);
@@ -521,7 +546,9 @@ libst_package_list (LibSelfTest *test)
/************************************************************/
libst_title (test, "add entry with NULL summary");
- ret = pk_package_list_add (plist, PK_INFO_ENUM_INSTALLED, "nosummary;1.23;i386;data", NULL);
+ id = pk_package_id_new_from_string ("nosummary;1.23;i386;data");
+ ret = pk_package_list_add (plist, PK_INFO_ENUM_INSTALLED, id, NULL);
+ pk_package_id_free (id);
if (ret) {
libst_success (test, NULL);
} else {
@@ -533,15 +560,21 @@ libst_package_list (LibSelfTest *test)
/************************************************************/
libst_title (test, "add entries");
- ret = pk_package_list_add (plist, PK_INFO_ENUM_SECURITY, "def;1.23;i386;data", "zed");
+ id = pk_package_id_new_from_string ("def;1.23;i386;data");
+ ret = pk_package_list_add (plist, PK_INFO_ENUM_SECURITY, id, "zed");
+ pk_package_id_free (id);
if (!ret) {
libst_failed (test, NULL);
}
- ret = pk_package_list_add (plist, PK_INFO_ENUM_BUGFIX, "abc;1.23;i386;data", "fed");
+ id = pk_package_id_new_from_string ("abc;1.23;i386;data");
+ ret = pk_package_list_add (plist, PK_INFO_ENUM_BUGFIX, id, "fed");
+ pk_package_id_free (id);
if (!ret) {
libst_failed (test, NULL);
}
- ret = pk_package_list_add (plist, PK_INFO_ENUM_ENHANCEMENT, "ghi;1.23;i386;data", "aed");
+ id = pk_package_id_new_from_string ("ghi;1.23;i386;data");
+ ret = pk_package_list_add (plist, PK_INFO_ENUM_ENHANCEMENT, id, "aed");
+ pk_package_id_free (id);
if (!ret) {
libst_failed (test, NULL);
}
@@ -553,12 +586,15 @@ libst_package_list (LibSelfTest *test)
r0 = pk_package_list_get_obj (plist, 0);
r1 = pk_package_list_get_obj (plist, 1);
r2 = pk_package_list_get_obj (plist, 2);
- if (pk_strequal (r0->package_id, "abc;1.23;i386;data") &&
- pk_strequal (r1->package_id, "def;1.23;i386;data") &&
- pk_strequal (r2->package_id, "ghi;1.23;i386;data")) {
+ r0_text = pk_package_id_to_string (r0->id);
+ r1_text = pk_package_id_to_string (r1->id);
+ r2_text = pk_package_id_to_string (r2->id);
+ if (pk_strequal (r0_text, "abc;1.23;i386;data") &&
+ pk_strequal (r1_text, "def;1.23;i386;data") &&
+ pk_strequal (r2_text, "ghi;1.23;i386;data")) {
libst_success (test, NULL);
} else {
- libst_failed (test, "could not sort: %s,%s,%s", r0->package_id, r1->package_id, r2->package_id);
+ libst_failed (test, "could not sort: %s,%s,%s", r0_text, r1_text, r2_text);
}
/************************************************************/
@@ -592,10 +628,18 @@ libst_package_list (LibSelfTest *test)
g_object_unref (plist);
plist = pk_package_list_new ();
- pk_package_list_add (plist, PK_INFO_ENUM_SECURITY, "def;1.23;i386;data", "zed");
- pk_package_list_add (plist, PK_INFO_ENUM_SECURITY, "abc;1.23;i386;data", "fed");
- pk_package_list_add (plist, PK_INFO_ENUM_BUGFIX, "ghi;1.23;i386;data", "aed");
- pk_package_list_add (plist, PK_INFO_ENUM_BUGFIX, "jkl;1.23;i386;data", "med");
+ id = pk_package_id_new_from_string ("def;1.23;i386;data");
+ pk_package_list_add (plist, PK_INFO_ENUM_SECURITY, id, "zed");
+ pk_package_id_free (id);
+ id = pk_package_id_new_from_string ("abc;1.23;i386;data");
+ pk_package_list_add (plist, PK_INFO_ENUM_SECURITY, id, "fed");
+ pk_package_id_free (id);
+ id = pk_package_id_new_from_string ("ghi;1.23;i386;data");
+ pk_package_list_add (plist, PK_INFO_ENUM_BUGFIX, id, "aed");
+ pk_package_id_free (id);
+ id = pk_package_id_new_from_string ("jkl;1.23;i386;data");
+ pk_package_list_add (plist, PK_INFO_ENUM_BUGFIX, id, "med");
+ pk_package_id_free (id);
/************************************************************/
libst_title (test, "sort by package_id then priority (should not mess up previous sort)");
@@ -604,12 +648,15 @@ libst_package_list (LibSelfTest *test)
r0 = pk_package_list_get_obj (plist, 0);
r1 = pk_package_list_get_obj (plist, 1);
r2 = pk_package_list_get_obj (plist, 2);
- if (pk_strequal (r0->package_id, "abc;1.23;i386;data") &&
- pk_strequal (r1->package_id, "def;1.23;i386;data") &&
- pk_strequal (r2->package_id, "ghi;1.23;i386;data")) {
+ r0_text = pk_package_id_to_string (r0->id);
+ r1_text = pk_package_id_to_string (r1->id);
+ r2_text = pk_package_id_to_string (r2->id);
+ if (pk_strequal (r0_text, "abc;1.23;i386;data") &&
+ pk_strequal (r1_text, "def;1.23;i386;data") &&
+ pk_strequal (r2_text, "ghi;1.23;i386;data")) {
libst_success (test, NULL);
} else {
- libst_failed (test, "could not sort: %s,%s,%s", r0->package_id, r1->package_id, r2->package_id);
+ libst_failed (test, "could not sort: %s,%s,%s", r0_text, r1_text, r2_text);
}
g_object_unref (plist);
diff --git a/libpackagekit/pk-package-list.h b/libpackagekit/pk-package-list.h
index 314a5db..324a7f4 100644
--- a/libpackagekit/pk-package-list.h
+++ b/libpackagekit/pk-package-list.h
@@ -55,7 +55,7 @@ GType pk_package_list_get_type (void) G_GNUC_CONST;
PkPackageList *pk_package_list_new (void);
gboolean pk_package_list_add (PkPackageList *plist,
PkInfoEnum info,
- const gchar *package_id,
+ const PkPackageId *ident,
const gchar *summary);
gboolean pk_package_list_add_obj (PkPackageList *plist,
const PkPackageObj *obj);
diff --git a/libpackagekit/pk-package-obj.c b/libpackagekit/pk-package-obj.c
index 519e93d..db945d0 100644
--- a/libpackagekit/pk-package-obj.c
+++ b/libpackagekit/pk-package-obj.c
@@ -50,15 +50,15 @@
* pk_package_obj_new:
**/
PkPackageObj *
-pk_package_obj_new (PkInfoEnum info, const gchar *package_id, const gchar *summary)
+pk_package_obj_new (PkInfoEnum info, const PkPackageId *id, const gchar *summary)
{
PkPackageObj *obj;
- g_return_val_if_fail (package_id != NULL, FALSE);
+ g_return_val_if_fail (id != NULL, FALSE);
obj = g_new0 (PkPackageObj, 1);
obj->info = info;
- obj->package_id = g_strdup (package_id);
+ obj->id = pk_package_id_copy (id);
obj->summary = g_strdup (summary);
return obj;
}
@@ -72,7 +72,7 @@ pk_package_obj_free (PkPackageObj *obj)
if (obj == NULL) {
return FALSE;
}
- g_free (obj->package_id);
+ pk_package_id_free (obj->id);
g_free (obj->summary);
g_free (obj);
return TRUE;
@@ -89,8 +89,7 @@ pk_package_obj_equal (const PkPackageObj *obj1, const PkPackageObj *obj2)
if (obj1 == NULL || obj2 == NULL) {
return FALSE;
}
- return (obj1->info == obj2->info &&
- pk_strequal (obj1->package_id, obj2->package_id));
+ return (obj1->info == obj2->info && pk_package_id_equal (obj1->id, obj2->id));
}
/**
@@ -102,7 +101,7 @@ PkPackageObj *
pk_package_obj_copy (const PkPackageObj *obj)
{
g_return_val_if_fail (obj != NULL, NULL);
- return pk_package_obj_new (obj->info, obj->package_id, obj->summary);
+ return pk_package_obj_new (obj->info, obj->id, obj->summary);
}
/***************************************************************************
@@ -118,6 +117,7 @@ libst_package_obj (LibSelfTest *test)
PkPackageObj *obj2;
PkPackageObj *obj3;
gboolean ret;
+ PkPackageId *id;
if (libst_start (test, "PkPackageObj", CLASS_AUTO) == FALSE) {
return;
@@ -125,21 +125,25 @@ libst_package_obj (LibSelfTest *test)
/************************************************************/
libst_title (test, "add entry");
- obj1 = pk_package_obj_new (PK_INFO_ENUM_INSTALLED, "gnome;1.23;i386;data", "GNOME!");
+ id = pk_package_id_new_from_string ("gnome;1.23;i386;data");
+ obj1 = pk_package_obj_new (PK_INFO_ENUM_INSTALLED, id, "GNOME!");
if (obj1 != NULL) {
libst_success (test, NULL);
} else {
libst_failed (test, NULL);
}
+ pk_package_id_free (id);
/************************************************************/
libst_title (test, "add entry");
- obj2 = pk_package_obj_new (PK_INFO_ENUM_INSTALLED, "gnome;1.23;i386;data", "GNOME foo!");
+ id = pk_package_id_new_from_string ("gnome;1.23;i386;data");
+ obj2 = pk_package_obj_new (PK_INFO_ENUM_INSTALLED, id, "GNOME foo!");
if (obj2 != NULL) {
libst_success (test, NULL);
} else {
libst_failed (test, NULL);
}
+ pk_package_id_free (id);
/************************************************************/
libst_title (test, "copy entry");
@@ -164,12 +168,14 @@ libst_package_obj (LibSelfTest *test)
/************************************************************/
libst_title (test, "add entry");
- obj2 = pk_package_obj_new (PK_INFO_ENUM_INSTALLED, "gnome-do;1.23;i386;data", "GNOME doo!");
+ id = pk_package_id_new_from_string ("gnome-do;1.23;i386;data");
+ obj2 = pk_package_obj_new (PK_INFO_ENUM_INSTALLED, id, "GNOME doo!");
if (obj2 != NULL) {
libst_success (test, NULL);
} else {
libst_failed (test, NULL);
}
+ pk_package_id_free (id);
/************************************************************/
libst_title (test, "check !equal");
diff --git a/libpackagekit/pk-package-obj.h b/libpackagekit/pk-package-obj.h
index 5b4d097..01f6494 100644
--- a/libpackagekit/pk-package-obj.h
+++ b/libpackagekit/pk-package-obj.h
@@ -24,6 +24,7 @@
#include <glib-object.h>
#include <pk-enum.h>
+#include <pk-package-id.h>
/**
* PkPackageObj:
@@ -32,12 +33,12 @@
*/
typedef struct {
PkInfoEnum info;
- gchar *package_id;
+ PkPackageId *id;
gchar *summary;
} PkPackageObj;
PkPackageObj *pk_package_obj_new (PkInfoEnum info,
- const gchar *package_id,
+ const PkPackageId *id,
const gchar *summary);
gboolean pk_package_obj_free (PkPackageObj *obj);
PkPackageObj *pk_package_obj_copy (const PkPackageObj *obj);
diff --git a/libpackagekit/pk-update-detail-obj.c b/libpackagekit/pk-update-detail-obj.c
index 1723add..2c0059c 100644
--- a/libpackagekit/pk-update-detail-obj.c
+++ b/libpackagekit/pk-update-detail-obj.c
@@ -162,8 +162,6 @@ libst_update_detail (LibSelfTest *test)
libst_failed (test, NULL);
}
- pk_update_detail_obj_free (detail);
-
libst_end (test);
}
#endif
diff --git a/src/pk-backend.c b/src/pk-backend.c
index c282805..c8389ff 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -909,7 +909,8 @@ gboolean
pk_backend_package (PkBackend *backend, PkInfoEnum info, const gchar *package_id, const gchar *summary)
{
gchar *summary_safe;
- PkPackageObj *item;
+ PkPackageObj *obj;
+ PkPackageId *id;
gboolean ret;
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
@@ -923,18 +924,21 @@ pk_backend_package (PkBackend *backend, PkInfoEnum info, const gchar *package_id
return FALSE;
}
+ /* replace unsafe chars */
+ summary_safe = pk_strsafe (summary);
+
/* check against the old one */
- item = pk_package_obj_new (info, package_id, summary);
- ret = pk_package_obj_equal (item, backend->priv->last_package);
+ id = pk_package_id_new_from_string (package_id);
+ obj = pk_package_obj_new (info, id, summary_safe);
+ ret = pk_package_obj_equal (obj, backend->priv->last_package);
if (ret) {
- pk_package_obj_free (item);
+ pk_package_obj_free (obj);
pk_debug ("skipping duplicate %s", package_id);
return FALSE;
}
/* update the 'last' package */
pk_package_obj_free (backend->priv->last_package);
- backend->priv->last_package = pk_package_obj_copy (item);
- pk_package_obj_free (item);
+ backend->priv->last_package = pk_package_obj_copy (obj);
/* have we already set an error? */
if (backend->priv->set_error) {
@@ -960,11 +964,11 @@ pk_backend_package (PkBackend *backend, PkInfoEnum info, const gchar *package_id
/* we've sent a package for this transaction */
backend->priv->has_sent_package = TRUE;
- /* replace unsafe chars */
- summary_safe = pk_strsafe (summary);
-
pk_debug ("emit package %s, %s, %s", pk_info_enum_to_text (info), package_id, summary_safe);
- g_signal_emit (backend, signals [PK_BACKEND_PACKAGE], 0, info, package_id, summary_safe);
+ g_signal_emit (backend, signals [PK_BACKEND_PACKAGE], 0, obj);
+
+ pk_package_id_free (id);
+ pk_package_obj_free (obj);
g_free (summary_safe);
return TRUE;
}
@@ -1759,8 +1763,8 @@ pk_backend_class_init (PkBackendClass *klass)
signals [PK_BACKEND_PACKAGE] =
g_signal_new ("package",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+ 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
signals [PK_BACKEND_UPDATE_DETAIL] =
g_signal_new ("update-detail",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index d2db512..9ed704e 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -536,10 +536,10 @@ pk_transaction_message_cb (PkBackend *backend, PkMessageEnum message, const gcha
* pk_transaction_package_cb:
**/
static void
-pk_transaction_package_cb (PkBackend *backend, PkInfoEnum info, const gchar *package_id,
- const gchar *summary, PkTransaction *transaction)
+pk_transaction_package_cb (PkBackend *backend, const PkPackageObj *obj, PkTransaction *transaction)
{
const gchar *info_text;
+ gchar *package_id;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -554,7 +554,7 @@ pk_transaction_package_cb (PkBackend *backend, PkInfoEnum info, const gchar *pac
if (transaction->priv->role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
transaction->priv->role == PK_ROLE_ENUM_INSTALL_PACKAGES ||
transaction->priv->role == PK_ROLE_ENUM_UPDATE_PACKAGES) {
- if (info == PK_INFO_ENUM_INSTALLED) {
+ if (obj->info == PK_INFO_ENUM_INSTALLED) {
pk_backend_message (transaction->priv->backend, PK_MESSAGE_ENUM_DAEMON,
"backend emitted 'installed' rather than 'installing' "
"- you need to do the package *before* you do the action");
@@ -563,12 +563,13 @@ pk_transaction_package_cb (PkBackend *backend, PkInfoEnum info, const gchar *pac
}
/* add to package cache even if we already got a result */
- info_text = pk_info_enum_to_text (info);
- pk_package_list_add (transaction->priv->package_list, info, package_id, summary);
+ info_text = pk_info_enum_to_text (obj->info);
+ pk_package_list_add_obj (transaction->priv->package_list, obj);
/* emit */
- pk_debug ("emitting package info=%s %s, %s", info_text, package_id, summary);
- g_signal_emit (transaction, signals [PK_TRANSACTION_PACKAGE], 0, info_text, package_id, summary);
+ package_id = pk_package_id_to_string (obj->id);
+ g_signal_emit (transaction, signals [PK_TRANSACTION_PACKAGE], 0, info_text, package_id, obj->summary);
+ g_free (package_id);
}
/**
@@ -1857,6 +1858,7 @@ pk_transaction_get_updates (PkTransaction *transaction, const gchar *filter, DBu
gboolean ret;
GError *error;
PkPackageList *updates_cache;
+ gchar *package_id;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -1890,7 +1892,7 @@ pk_transaction_get_updates (PkTransaction *transaction, const gchar *filter, DBu
/* try and reuse cache */
updates_cache = pk_cache_get_updates (transaction->priv->cache);
if (updates_cache != NULL) {
- const PkPackageObj *package;
+ const PkPackageObj *obj;
const gchar *info_text;
const gchar *exit_text;
guint i;
@@ -1901,10 +1903,12 @@ pk_transaction_get_updates (PkTransaction *transaction, const gchar *filter, DBu
/* emulate the backend */
for (i=0; i<length; i++) {
- package = pk_package_list_get_obj (updates_cache, i);
- info_text = pk_info_enum_to_text (package->info);
+ obj = pk_package_list_get_obj (updates_cache, i);
+ info_text = pk_info_enum_to_text (obj->info);
+ package_id = pk_package_id_to_string (obj->id);
g_signal_emit (transaction, signals [PK_TRANSACTION_PACKAGE], 0,
- info_text, package->package_id, package->summary);
+ info_text, package_id, obj->summary);
+ g_free (package_id);
}
/* we are done */
commit 1df67036a47fcf01a8d76cba1fbdd2a11b15d196
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 26 13:56:12 2008 +0100
trivial: documentation fix
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 02fd380..b0573bc 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -458,7 +458,7 @@ pk_client_get_require_restart (PkClient *client)
* We do not provide access to the internal package list (as it could be being
* updated) so provide a way to get access to objects here.
*
- * Return value: The #PkPackageObj or %NULL if not found or invalid
+ * Return value: The #PkPackageList or %NULL if not found or invalid
**/
PkPackageList *
pk_client_get_package_list (PkClient *client)
commit cddae598a47e9acf163266b95667838154395627
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 26 10:57:29 2008 +0100
trivial: razor doesn't do get-updates yet
diff --git a/backends/razor/pk-backend-razor.c b/backends/razor/pk-backend-razor.c
index 59dd14b..cbc236e 100644
--- a/backends/razor/pk-backend-razor.c
+++ b/backends/razor/pk-backend-razor.c
@@ -346,23 +346,6 @@ backend_get_filters (PkBackend *backend)
return (PK_FILTER_ENUM_DEVELOPMENT);
}
-static gboolean
-backend_get_updates_thread (PkBackend *backend)
-{
- PkFilterEnum filters;
- filters = pk_backend_get_uint (backend, "filters");
- pk_backend_finished (backend);
- return TRUE;
-}
-
-static void
-backend_get_updates (PkBackend *backend, PkFilterEnum filters)
-{
- pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
- pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_thread_create (backend, backend_get_updates_thread);
-}
-
PK_BACKEND_OPTIONS (
"razor", /* description */
"Richard Hughes <richard at hughsie.com>", /* author */
@@ -379,7 +362,7 @@ PK_BACKEND_OPTIONS (
NULL, /* get_repo_list */
NULL, /* get_requires */
NULL, /* get_update_detail */
- backend_get_updates, /* get_updates */
+ NULL, /* get_updates */
NULL, /* install_files */
NULL, /* install_packages */
NULL, /* install_signature */
commit 541ab8ad21b42fa1edd99e6ecfcb78e22c18a07e
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 26 10:38:16 2008 +0100
razor: add the devel filter
diff --git a/backends/razor/pk-backend-razor.c b/backends/razor/pk-backend-razor.c
index 6ffd5cc..59dd14b 100644
--- a/backends/razor/pk-backend-razor.c
+++ b/backends/razor/pk-backend-razor.c
@@ -37,8 +37,7 @@ static const char *system_details = "/home/hughsie/Code/razor/src/system-details
typedef enum {
PK_RAZOR_SEARCH_TYPE_NAME,
- PK_RAZOR_SEARCH_TYPE_SUMMARY,
- PK_RAZOR_SEARCH_TYPE_UNKNOWN
+ PK_RAZOR_SEARCH_TYPE_SUMMARY
} PkRazorSearchType;
/**
@@ -60,22 +59,48 @@ backend_destroy (PkBackend *backend)
razor_set_destroy (set);
}
+/**
+ * pk_razor_filter_devel:
+ */
static gboolean
-backend_refresh_cache_thread (PkBackend *backend)
+pk_razor_filter_devel (const gchar *name)
{
- pk_backend_finished (backend);
- return TRUE;
+ if (g_str_has_suffix (name, "-debuginfo"))
+ return TRUE;
+ if (g_str_has_suffix (name, "-devel"))
+ return TRUE;
+ if (g_str_has_suffix (name, "-libs"))
+ return TRUE;
+ return FALSE;
}
/**
- * backend_refresh_cache:
+ * pk_razor_emit_package:
*/
-static void
-backend_refresh_cache (PkBackend *backend, gboolean force)
+static gboolean
+pk_razor_emit_package (PkBackend *backend, const gchar *name, const gchar *version, const gchar *arch, const gchar *summary)
{
- pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
- pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_thread_create (backend, backend_refresh_cache_thread);
+ PkFilterEnum filters;
+ gchar *package_id;
+ gboolean ret;
+
+ filters = pk_backend_get_uint (backend, "filters");
+
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_DEVELOPMENT)) {
+ ret = pk_razor_filter_devel (name);
+ if (!ret)
+ return FALSE;
+ }
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_NOT_DEVELOPMENT)) {
+ ret = pk_razor_filter_devel (name);
+ if (ret)
+ return FALSE;
+ }
+
+ package_id = pk_package_id_build (name, version, arch, "installed");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, summary);
+ g_free (package_id);
+ return TRUE;
}
static gboolean
@@ -86,7 +111,6 @@ backend_resolve_thread (PkBackend *backend)
struct razor_package_iterator *pi;
struct razor_package *package;
const gchar *name, *version, *arch, *summary;
- gchar *package_id;
gchar **package_ids;
package_ids = pk_backend_get_strv (backend, "package_ids");
@@ -96,10 +120,8 @@ backend_resolve_thread (PkBackend *backend)
while (razor_package_iterator_next (pi, &package, &name, &version, &arch)) {
for (i=0; i<length; i++) {
if (pk_strequal (name, package_ids[i])) {
- package_id = pk_package_id_build (name, version, arch, "installed");
razor_package_get_details (set, package, &summary, NULL, NULL, NULL);
- pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, summary);
- g_free (package_id);
+ pk_razor_emit_package (backend, name, version, arch, summary);
}
}
}
@@ -195,15 +217,11 @@ backend_get_packages_thread (PkBackend *backend)
struct razor_package_iterator *pi;
struct razor_package *package;
const gchar *name, *version, *arch, *summary;
- gchar *package_id;
pi = razor_package_iterator_create (set);
-
while (razor_package_iterator_next (pi, &package, &name, &version, &arch)) {
- package_id = pk_package_id_build (name, version, arch, "installed");
razor_package_get_details (set, package, &summary, NULL, NULL, NULL);
- pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, summary);
- g_free (package_id);
+ pk_razor_emit_package (backend, name, version, arch, summary);
}
razor_package_iterator_destroy (pi);
@@ -260,7 +278,6 @@ backend_search_thread (PkBackend *backend)
struct razor_package_iterator *pi;
struct razor_package *package;
const gchar *name, *version, *arch, *summary, *description;
- gchar *package_id;
PkRazorSearchType type;
gboolean found;
const gchar *search;
@@ -277,9 +294,7 @@ backend_search_thread (PkBackend *backend)
/* find in the name */
found = pk_str_case_contains (name, search);
if (found) {
- package_id = pk_package_id_build (name, version, arch, "installed");
- pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, summary);
- g_free (package_id);
+ pk_razor_emit_package (backend, name, version, arch, summary);
/* look in summary and description if we are searching by description */
} else if (type == PK_RAZOR_SEARCH_TYPE_SUMMARY) {
@@ -288,9 +303,7 @@ backend_search_thread (PkBackend *backend)
found = pk_str_case_contains (description, search);
}
if (found) {
- package_id = pk_package_id_build (name, version, arch, "installed");
- pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, summary);
- g_free (package_id);
+ pk_razor_emit_package (backend, name, version, arch, summary);
}
}
}
@@ -324,93 +337,20 @@ backend_search_description (PkBackend *backend, PkFilterEnum filters, const gcha
pk_backend_thread_create (backend, backend_search_thread);
}
-static void
-backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
-{
- pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
- pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_thread_create (backend, backend_search_thread);
-}
-
-
-static gboolean
-backend_install_packages_thread (PkBackend *backend)
-{
- pk_backend_finished (backend);
- return FALSE;
-}
-
-static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
-{
- pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
- pk_backend_thread_create (backend, backend_install_packages_thread);
-}
-
-static gboolean
-backend_remove_packages_thread (PkBackend *backend)
-{
- pk_backend_finished (backend);
- return FALSE;
-}
-
-static void
-backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove)
-{
- pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE);
- pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_thread_create (backend, backend_remove_packages_thread);
-}
-
/**
* backend_get_filters:
*/
static PkFilterEnum
backend_get_filters (PkBackend *backend)
{
- return (PK_FILTER_ENUM_INSTALLED |
- PK_FILTER_ENUM_DEVELOPMENT |
- PK_FILTER_ENUM_GUI);
-}
-
-
-static gboolean
-backend_update_system_thread (PkBackend *backend)
-{
- pk_backend_finished (backend);
- return FALSE;
-}
-
-static void
-backend_update_system (PkBackend *backend)
-{
- pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
- pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_thread_create (backend, backend_update_system_thread);
-}
-
-/**
- * backend_update_package:
- */
-static gboolean
-backend_update_package_thread (PkBackend *backend)
-{
- pk_backend_finished (backend);
- return FALSE;
-}
-
-static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
-{
- pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
- pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_thread_create (backend, backend_update_package_thread);
+ return (PK_FILTER_ENUM_DEVELOPMENT);
}
static gboolean
backend_get_updates_thread (PkBackend *backend)
{
+ PkFilterEnum filters;
+ filters = pk_backend_get_uint (backend, "filters");
pk_backend_finished (backend);
return TRUE;
}
@@ -423,27 +363,12 @@ backend_get_updates (PkBackend *backend, PkFilterEnum filters)
pk_backend_thread_create (backend, backend_get_updates_thread);
}
-/**
- * backend_get_groups:
- */
-static PkGroupEnum
-backend_get_groups (PkBackend *backend)
-{
- return (PK_GROUP_ENUM_COMMUNICATION |
- PK_GROUP_ENUM_PROGRAMMING |
- PK_GROUP_ENUM_GAMES |
- PK_GROUP_ENUM_OTHER |
- PK_GROUP_ENUM_INTERNET |
- PK_GROUP_ENUM_REPOS |
- PK_GROUP_ENUM_MAPS);
-}
-
PK_BACKEND_OPTIONS (
"razor", /* description */
"Richard Hughes <richard at hughsie.com>", /* author */
backend_initialize, /* initalize */
backend_destroy, /* destroy */
- backend_get_groups, /* get_groups */
+ NULL, /* get_groups */
backend_get_filters, /* get_filters */
NULL, /* cancel */
NULL, /* download_packages */
@@ -456,21 +381,21 @@ PK_BACKEND_OPTIONS (
NULL, /* get_update_detail */
backend_get_updates, /* get_updates */
NULL, /* install_files */
- backend_install_packages, /* install_packages */
+ NULL, /* install_packages */
NULL, /* install_signature */
- backend_refresh_cache, /* refresh_cache */
- backend_remove_packages, /* remove_packages */
+ NULL, /* refresh_cache */
+ NULL, /* remove_packages */
NULL, /* repo_enable */
NULL, /* repo_set_data */
backend_resolve, /* resolve */
NULL, /* rollback */
backend_search_description, /* search_details */
NULL, /* search_file */
- backend_search_group, /* search_group */
+ NULL, /* search_group */
backend_search_name, /* search_name */
NULL, /* service_pack */
- backend_update_packages, /* update_packages */
- backend_update_system, /* update_system */
+ NULL, /* update_packages */
+ NULL, /* update_system */
NULL /* what_provides */
);
commit 9e04834e622afaebce06a4eb99c3a9bbfd3823d8
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 26 10:17:14 2008 +0100
razor: add SearchName and SearchDescription
diff --git a/backends/razor/pk-backend-razor.c b/backends/razor/pk-backend-razor.c
index 312a309..6ffd5cc 100644
--- a/backends/razor/pk-backend-razor.c
+++ b/backends/razor/pk-backend-razor.c
@@ -35,6 +35,11 @@ static struct razor_set *set = NULL;
static const char *repo_filename = "/home/hughsie/Code/razor/src/system.repo";
static const char *system_details = "/home/hughsie/Code/razor/src/system-details.repo";
+typedef enum {
+ PK_RAZOR_SEARCH_TYPE_NAME,
+ PK_RAZOR_SEARCH_TYPE_SUMMARY,
+ PK_RAZOR_SEARCH_TYPE_UNKNOWN
+} PkRazorSearchType;
/**
* backend_initialize:
@@ -62,6 +67,17 @@ backend_refresh_cache_thread (PkBackend *backend)
return TRUE;
}
+/**
+ * backend_refresh_cache:
+ */
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_refresh_cache_thread);
+}
+
static gboolean
backend_resolve_thread (PkBackend *backend)
{
@@ -105,6 +121,52 @@ backend_resolve (PkBackend *backend, PkFilterEnum filters, gchar **packages)
}
/**
+ * backend_get_details:
+ */
+static gboolean
+backend_get_details_thread (PkBackend *backend)
+{
+ guint i;
+ guint length;
+ struct razor_package_iterator *pi;
+ struct razor_package *package;
+ const gchar *name, *version, *arch, *summary, *description, *url, *license;
+ gchar *package_id;
+ gchar **package_ids;
+ PkPackageId *ident;
+
+ package_ids = pk_backend_get_strv (backend, "package_ids");
+ length = g_strv_length (package_ids);
+
+ pi = razor_package_iterator_create (set);
+ while (razor_package_iterator_next (pi, &package, &name, &version, &arch)) {
+ for (i=0; i<length; i++) {
+ /* TODO: we should cache this */
+ ident = pk_package_id_new_from_string (package_ids[i]);
+ if (pk_strequal (name, ident->name)) {
+ package_id = pk_package_id_build (name, version, arch, "installed");
+ razor_package_get_details (set, package, &summary, &description, &url, &license);
+ pk_backend_details (backend, package_ids[i], license, PK_GROUP_ENUM_UNKNOWN, description, url, 0);
+ g_free (package_id);
+ }
+ pk_package_id_free (ident);
+ }
+ }
+
+ razor_package_iterator_destroy (pi);
+ pk_backend_finished (backend);
+ return TRUE;
+}
+
+static void
+backend_get_details (PkBackend *backend, gchar **package_ids)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_get_details_thread);
+}
+
+/**
* backend_get_files:
*/
static void
@@ -161,28 +223,92 @@ backend_get_packages (PkBackend *backend, PkFilterEnum filters)
}
/**
- * backend_refresh_cache:
+ * pk_str_case_contains:
*/
-static void
-backend_refresh_cache (PkBackend *backend, gboolean force)
+static gboolean
+pk_str_case_contains (const gchar *haystack, const gchar *needle)
{
- pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
- pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_thread_create (backend, backend_refresh_cache_thread);
+ gint ret;
+ guint i;
+ guint haystack_length;
+ guint needle_length;
+
+ haystack_length = pk_strlen (haystack, 1024);
+ needle_length = pk_strlen (needle, 1024);
+
+ /* needle longer than haystack */
+ if (needle_length > haystack_length) {
+ return FALSE;
+ }
+
+ /* search case insensitive */
+ for (i=0; i<haystack_length - needle_length; i++) {
+ ret = g_strncasecmp (haystack+i, needle, needle_length);
+ if (ret == 0) {
+ return TRUE;
+ }
+ }
+ return FALSE;
}
+/**
+ * backend_search_thread:
+ */
static gboolean
backend_search_thread (PkBackend *backend)
{
+ struct razor_package_iterator *pi;
+ struct razor_package *package;
+ const gchar *name, *version, *arch, *summary, *description;
+ gchar *package_id;
+ PkRazorSearchType type;
+ gboolean found;
+ const gchar *search;
+
+ type = pk_backend_get_uint (backend, "search-type");
+ search = pk_backend_get_string (backend, "search");
+
+ pi = razor_package_iterator_create (set);
+ while (razor_package_iterator_next (pi, &package, &name, &version, &arch)) {
+
+ /* we need the summary just for ::Package */
+ razor_package_get_details (set, package, &summary, &description, NULL, NULL);
+
+ /* find in the name */
+ found = pk_str_case_contains (name, search);
+ if (found) {
+ package_id = pk_package_id_build (name, version, arch, "installed");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, summary);
+ g_free (package_id);
+
+ /* look in summary and description if we are searching by description */
+ } else if (type == PK_RAZOR_SEARCH_TYPE_SUMMARY) {
+ found = pk_str_case_contains (summary, search);
+ if (!found) {
+ found = pk_str_case_contains (description, search);
+ }
+ if (found) {
+ package_id = pk_package_id_build (name, version, arch, "installed");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, summary);
+ g_free (package_id);
+ }
+ }
+ }
+
+ razor_package_iterator_destroy (pi);
pk_backend_finished (backend);
- return FALSE;
+ return TRUE;
}
+/**
+ * backend_search_name:
+ */
static void
backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_set_uint (backend, "search-type", PK_RAZOR_SEARCH_TYPE_NAME);
pk_backend_thread_create (backend, backend_search_thread);
}
@@ -192,7 +318,9 @@ backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *sear
static void
backend_search_description (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_set_uint (backend, "search-type", PK_RAZOR_SEARCH_TYPE_SUMMARY);
pk_backend_thread_create (backend, backend_search_thread);
}
@@ -310,23 +438,6 @@ backend_get_groups (PkBackend *backend)
PK_GROUP_ENUM_MAPS);
}
-/**
- * backend_get_details:
- */
-static gboolean
-backend_get_details_thread (PkBackend *backend)
-{
- pk_backend_finished (backend);
- return TRUE;
-}
-
-static void
-backend_get_details (PkBackend *backend, gchar **package_ids)
-{
- pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_thread_create (backend, backend_get_details_thread);
-}
-
PK_BACKEND_OPTIONS (
"razor", /* description */
"Richard Hughes <richard at hughsie.com>", /* author */
commit 3ef561682550eefa341e788a8c616efede56fa5a
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 26 09:32:27 2008 +0100
razor: add Resolve() functionality
diff --git a/backends/razor/pk-backend-razor.c b/backends/razor/pk-backend-razor.c
index a0aada7..312a309 100644
--- a/backends/razor/pk-backend-razor.c
+++ b/backends/razor/pk-backend-razor.c
@@ -27,15 +27,23 @@
#include <pk-debug.h>
#include <pk-package-ids.h>
#include <pk-enum.h>
+#include <pk-common.h>
#include <razor/razor.h>
+static struct razor_set *set = NULL;
+static const char *repo_filename = "/home/hughsie/Code/razor/src/system.repo";
+static const char *system_details = "/home/hughsie/Code/razor/src/system-details.repo";
+
+
/**
* backend_initialize:
*/
static void
backend_initialize (PkBackend *backend)
{
+ set = razor_set_open (repo_filename);
+ razor_set_open_details (set, system_details);
}
/**
@@ -44,9 +52,9 @@ backend_initialize (PkBackend *backend)
static void
backend_destroy (PkBackend *backend)
{
+ razor_set_destroy (set);
}
-
static gboolean
backend_refresh_cache_thread (PkBackend *backend)
{
@@ -54,6 +62,48 @@ backend_refresh_cache_thread (PkBackend *backend)
return TRUE;
}
+static gboolean
+backend_resolve_thread (PkBackend *backend)
+{
+ guint i;
+ guint length;
+ struct razor_package_iterator *pi;
+ struct razor_package *package;
+ const gchar *name, *version, *arch, *summary;
+ gchar *package_id;
+ gchar **package_ids;
+
+ package_ids = pk_backend_get_strv (backend, "package_ids");
+ length = g_strv_length (package_ids);
+
+ pi = razor_package_iterator_create (set);
+ while (razor_package_iterator_next (pi, &package, &name, &version, &arch)) {
+ for (i=0; i<length; i++) {
+ if (pk_strequal (name, package_ids[i])) {
+ package_id = pk_package_id_build (name, version, arch, "installed");
+ razor_package_get_details (set, package, &summary, NULL, NULL, NULL);
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, summary);
+ g_free (package_id);
+ }
+ }
+ }
+
+ razor_package_iterator_destroy (pi);
+ pk_backend_finished (backend);
+ return TRUE;
+}
+
+/**
+ * backend_resolve:
+ */
+static void
+backend_resolve (PkBackend *backend, PkFilterEnum filters, gchar **packages)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_resolve_thread);
+}
+
/**
* backend_get_files:
*/
@@ -69,26 +119,22 @@ backend_get_files (PkBackend *backend, gchar **package_ids)
for (i=0; i<length; i++) {
package_id = package_ids[i];
ident = pk_package_id_new_from_string (package_id);
- pk_debug ("look up: %s", ident->name);
+ /* TODO: we need to get this list! */
+ razor_set_list_package_files (set, ident->name);
pk_backend_files (backend, package_id, "/usr/bin/dave;/usr/share/brian");
+ pk_package_id_free (ident);
}
pk_backend_finished (backend);
}
-static const char *repo_filename = "/home/hughsie/Code/razor/src/system.repo";
-static const char *system_details = "/home/hughsie/Code/razor/src/system-details.repo";
-
static gboolean
backend_get_packages_thread (PkBackend *backend)
{
struct razor_package_iterator *pi;
- struct razor_set *set;
struct razor_package *package;
const gchar *name, *version, *arch, *summary;
gchar *package_id;
- set = razor_set_open (repo_filename);
- razor_set_open_details (set, system_details);
pi = razor_package_iterator_create (set);
while (razor_package_iterator_next (pi, &package, &name, &version, &arch)) {
@@ -99,8 +145,6 @@ backend_get_packages_thread (PkBackend *backend)
}
razor_package_iterator_destroy (pi);
- razor_set_destroy (set);
-
pk_backend_finished (backend);
return TRUE;
}
@@ -307,7 +351,7 @@ PK_BACKEND_OPTIONS (
backend_remove_packages, /* remove_packages */
NULL, /* repo_enable */
NULL, /* repo_set_data */
- NULL, /* resolve */
+ backend_resolve, /* resolve */
NULL, /* rollback */
backend_search_description, /* search_details */
NULL, /* search_file */
commit 41e2a68e4afe450c02541c222d51959714bc2d44
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 25 20:06:36 2008 +0100
razor: add initial functionality
diff --git a/backends/razor/pk-backend-razor.c b/backends/razor/pk-backend-razor.c
index c9589eb..a0aada7 100644
--- a/backends/razor/pk-backend-razor.c
+++ b/backends/razor/pk-backend-razor.c
@@ -55,6 +55,68 @@ backend_refresh_cache_thread (PkBackend *backend)
}
/**
+ * backend_get_files:
+ */
+static void
+backend_get_files (PkBackend *backend, gchar **package_ids)
+{
+ guint i;
+ guint length;
+ const gchar *package_id;
+ PkPackageId *ident;
+
+ length = g_strv_length (package_ids);
+ for (i=0; i<length; i++) {
+ package_id = package_ids[i];
+ ident = pk_package_id_new_from_string (package_id);
+ pk_debug ("look up: %s", ident->name);
+ pk_backend_files (backend, package_id, "/usr/bin/dave;/usr/share/brian");
+ }
+ pk_backend_finished (backend);
+}
+
+static const char *repo_filename = "/home/hughsie/Code/razor/src/system.repo";
+static const char *system_details = "/home/hughsie/Code/razor/src/system-details.repo";
+
+static gboolean
+backend_get_packages_thread (PkBackend *backend)
+{
+ struct razor_package_iterator *pi;
+ struct razor_set *set;
+ struct razor_package *package;
+ const gchar *name, *version, *arch, *summary;
+ gchar *package_id;
+
+ set = razor_set_open (repo_filename);
+ razor_set_open_details (set, system_details);
+ pi = razor_package_iterator_create (set);
+
+ while (razor_package_iterator_next (pi, &package, &name, &version, &arch)) {
+ package_id = pk_package_id_build (name, version, arch, "installed");
+ razor_package_get_details (set, package, &summary, NULL, NULL, NULL);
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, summary);
+ g_free (package_id);
+ }
+
+ razor_package_iterator_destroy (pi);
+ razor_set_destroy (set);
+
+ pk_backend_finished (backend);
+ return TRUE;
+}
+
+/**
+ * backend_get_packages:
+ */
+static void
+backend_get_packages (PkBackend *backend, PkFilterEnum filters)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_get_packages_thread);
+}
+
+/**
* backend_refresh_cache:
*/
static void
@@ -232,8 +294,8 @@ PK_BACKEND_OPTIONS (
NULL, /* download_packages */
NULL, /* get_depends */
backend_get_details, /* get_details */
- NULL, /* get_files */
- NULL, /* get_packages */
+ backend_get_files, /* get_files */
+ backend_get_packages, /* get_packages */
NULL, /* get_repo_list */
NULL, /* get_requires */
NULL, /* get_update_detail */
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 88c0455..d2db512 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -565,7 +565,6 @@ pk_transaction_package_cb (PkBackend *backend, PkInfoEnum info, const gchar *pac
/* add to package cache even if we already got a result */
info_text = pk_info_enum_to_text (info);
pk_package_list_add (transaction->priv->package_list, info, package_id, summary);
- pk_debug ("caching package info=%s %s, %s", info_text, package_id, summary);
/* emit */
pk_debug ("emitting package info=%s %s, %s", info_text, package_id, summary);
commit ab0c61dd15d5a068e3827c1ddae56fe5524a4803
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 25 19:06:44 2008 +0100
bugfix: check the package_id for utf8 validity else we can crash the daemon in crazy ways with broken backends
diff --git a/libpackagekit/pk-package-id.c b/libpackagekit/pk-package-id.c
index 0098039..0fc9036 100644
--- a/libpackagekit/pk-package-id.c
+++ b/libpackagekit/pk-package-id.c
@@ -67,6 +67,13 @@ gboolean
pk_package_id_check (const gchar *package_id)
{
gchar **sections;
+ gboolean ret;
+
+ ret = g_utf8_validate (package_id, -1, NULL);
+ if (!ret) {
+ pk_warning ("invalid UTF8!");
+ return FALSE;
+ }
sections = pk_strsplit (package_id, 4);
if (sections != NULL) {
g_strfreev (sections);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index b6b5281..c282805 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -916,6 +916,13 @@ pk_backend_package (PkBackend *backend, PkInfoEnum info, const gchar *package_id
g_return_val_if_fail (package_id != NULL, FALSE);
g_return_val_if_fail (backend->priv->locked != FALSE, FALSE);
+ /* check we are valid */
+ ret = pk_package_id_check (package_id);
+ if (!ret) {
+ pk_warning ("package_id invalid and cannot be processed: %s", package_id);
+ return FALSE;
+ }
+
/* check against the old one */
item = pk_package_obj_new (info, package_id, summary);
ret = pk_package_obj_equal (item, backend->priv->last_package);
commit 8f1cc9ff0c9dabfefe815e38236b63bef92f587d
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 25 17:52:40 2008 +0100
add a razor backend
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 20279b3..c8b9744 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -24,6 +24,10 @@ if BACKEND_TYPE_OPKG
SUBDIRS += opkg
endif
+if BACKEND_TYPE_RAZOR
+SUBDIRS += razor
+endif
+
if BACKEND_TYPE_SMART
SUBDIRS += smart
endif
diff --git a/backends/razor/.gitignore b/backends/razor/.gitignore
new file mode 100644
index 0000000..c851833
--- /dev/null
+++ b/backends/razor/.gitignore
@@ -0,0 +1,10 @@
+.deps
+.libs
+Makefile
+Makefile.in
+*.la
+*.lo
+*.loT
+*.o
+*~
+
diff --git a/backends/razor/Makefile.am b/backends/razor/Makefile.am
new file mode 100644
index 0000000..ff6d3ff
--- /dev/null
+++ b/backends/razor/Makefile.am
@@ -0,0 +1,8 @@
+plugindir = $(PK_PLUGIN_DIR)
+plugin_LTLIBRARIES = libpk_backend_razor.la
+libpk_backend_razor_la_SOURCES = pk-backend-razor.c
+libpk_backend_razor_la_LIBADD = $(PK_PLUGIN_LIBS) $(RAZOR_LIBS)
+
+libpk_backend_razor_la_LDFLAGS = -module -avoid-version
+libpk_backend_razor_la_CFLAGS = $(PK_PLUGIN_CFLAGS) $(RAZOR_CFLAGS)
+
diff --git a/backends/razor/pk-backend-razor.c b/backends/razor/pk-backend-razor.c
new file mode 100644
index 0000000..c9589eb
--- /dev/null
+++ b/backends/razor/pk-backend-razor.c
@@ -0,0 +1,259 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard at hughsie.com>
+ *
+ * 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 <gmodule.h>
+#include <glib.h>
+#include <string.h>
+#include <pk-backend.h>
+#include <pk-backend-internal.h>
+#include <pk-debug.h>
+#include <pk-package-ids.h>
+#include <pk-enum.h>
+
+#include <razor/razor.h>
+
+/**
+ * backend_initialize:
+ */
+static void
+backend_initialize (PkBackend *backend)
+{
+}
+
+/**
+ * backend_destroy:
+ */
+static void
+backend_destroy (PkBackend *backend)
+{
+}
+
+
+static gboolean
+backend_refresh_cache_thread (PkBackend *backend)
+{
+ pk_backend_finished (backend);
+ return TRUE;
+}
+
+/**
+ * backend_refresh_cache:
+ */
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_refresh_cache_thread);
+}
+
+static gboolean
+backend_search_thread (PkBackend *backend)
+{
+ pk_backend_finished (backend);
+ return FALSE;
+}
+
+static void
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_search_thread);
+}
+
+/**
+ * backend_search_description:
+ */
+static void
+backend_search_description (PkBackend *backend, PkFilterEnum filters, const gchar *search)
+{
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_search_thread);
+}
+
+static void
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_search_thread);
+}
+
+
+static gboolean
+backend_install_packages_thread (PkBackend *backend)
+{
+ pk_backend_finished (backend);
+ return FALSE;
+}
+
+static void
+backend_install_packages (PkBackend *backend, gchar **package_ids)
+{
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
+ pk_backend_thread_create (backend, backend_install_packages_thread);
+}
+
+static gboolean
+backend_remove_packages_thread (PkBackend *backend)
+{
+ pk_backend_finished (backend);
+ return FALSE;
+}
+
+static void
+backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_remove_packages_thread);
+}
+
+/**
+ * backend_get_filters:
+ */
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
+{
+ return (PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT |
+ PK_FILTER_ENUM_GUI);
+}
+
+
+static gboolean
+backend_update_system_thread (PkBackend *backend)
+{
+ pk_backend_finished (backend);
+ return FALSE;
+}
+
+static void
+backend_update_system (PkBackend *backend)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_update_system_thread);
+}
+
+/**
+ * backend_update_package:
+ */
+static gboolean
+backend_update_package_thread (PkBackend *backend)
+{
+ pk_backend_finished (backend);
+ return FALSE;
+}
+
+static void
+backend_update_packages (PkBackend *backend, gchar **package_ids)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_update_package_thread);
+}
+
+static gboolean
+backend_get_updates_thread (PkBackend *backend)
+{
+ pk_backend_finished (backend);
+ return TRUE;
+}
+
+static void
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_get_updates_thread);
+}
+
+/**
+ * backend_get_groups:
+ */
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
+{
+ return (PK_GROUP_ENUM_COMMUNICATION |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_OTHER |
+ PK_GROUP_ENUM_INTERNET |
+ PK_GROUP_ENUM_REPOS |
+ PK_GROUP_ENUM_MAPS);
+}
+
+/**
+ * backend_get_details:
+ */
+static gboolean
+backend_get_details_thread (PkBackend *backend)
+{
+ pk_backend_finished (backend);
+ return TRUE;
+}
+
+static void
+backend_get_details (PkBackend *backend, gchar **package_ids)
+{
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
+ pk_backend_thread_create (backend, backend_get_details_thread);
+}
+
+PK_BACKEND_OPTIONS (
+ "razor", /* description */
+ "Richard Hughes <richard at hughsie.com>", /* author */
+ backend_initialize, /* initalize */
+ backend_destroy, /* destroy */
+ backend_get_groups, /* get_groups */
+ backend_get_filters, /* get_filters */
+ NULL, /* cancel */
+ NULL, /* download_packages */
+ NULL, /* get_depends */
+ backend_get_details, /* get_details */
+ NULL, /* get_files */
+ NULL, /* get_packages */
+ NULL, /* get_repo_list */
+ NULL, /* get_requires */
+ NULL, /* get_update_detail */
+ backend_get_updates, /* get_updates */
+ NULL, /* install_files */
+ backend_install_packages, /* install_packages */
+ NULL, /* install_signature */
+ backend_refresh_cache, /* refresh_cache */
+ backend_remove_packages, /* remove_packages */
+ NULL, /* repo_enable */
+ NULL, /* repo_set_data */
+ NULL, /* resolve */
+ NULL, /* rollback */
+ backend_search_description, /* search_details */
+ NULL, /* search_file */
+ backend_search_group, /* search_group */
+ backend_search_name, /* search_name */
+ NULL, /* service_pack */
+ backend_update_packages, /* update_packages */
+ backend_update_system, /* update_system */
+ NULL /* what_provides */
+);
+
diff --git a/configure.ac b/configure.ac
index 6b9678a..c31313c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -234,6 +234,7 @@ AC_ARG_ENABLE(dummy, AS_HELP_STRING([--enable-dummy],[use the dummy backend]),en
AC_ARG_ENABLE(opkg, AS_HELP_STRING([--enable-opkg],[use the OPKG backend]),enable_opkg=$enableval,enable_opkg=no)
AC_ARG_ENABLE(pisi, AS_HELP_STRING([--enable-pisi],[use the PiSi backend]),enable_pisi=$enableval,enable_pisi=no)
AC_ARG_ENABLE(poldek, AS_HELP_STRING([--enable-poldek],[use the poldek backend]),enable_poldek=$enableval,enable_poldek=no)
+AC_ARG_ENABLE(razor, AS_HELP_STRING([--enable-razor],[use the razor backend]),enable_razor=$enableval,enable_razor=no)
AC_ARG_ENABLE(smart, AS_HELP_STRING([--enable-smart],[use the SMART backend]),enable_smart=$enableval,enable_smart=no)
AC_ARG_ENABLE(urpmi, AS_HELP_STRING([--enable-urpmi],[use the URPMI backend]),enable_urpmi=$enableval,enable_urpmi=no)
AC_ARG_ENABLE(yum, AS_HELP_STRING([--enable-yum],[use the YUM backend]),enable_yum=$enableval,enable_yum=no)
@@ -249,6 +250,7 @@ AM_CONDITIONAL(BACKEND_TYPE_DUMMY, [test x$enable_dummy = xyes], [using dummy ba
AM_CONDITIONAL(BACKEND_TYPE_OPKG, [test x$enable_opkg = xyes], [using OPKG backend])
AM_CONDITIONAL(BACKEND_TYPE_PISI, [test x$enable_pisi = xyes], [using PiSi backend])
AM_CONDITIONAL(BACKEND_TYPE_POLDEK, [test x$enable_poldek = xyes], [using poldek backend])
+AM_CONDITIONAL(BACKEND_TYPE_RAZOR, [test x$enable_razor = xyes], [using Razor backend])
AM_CONDITIONAL(BACKEND_TYPE_SMART, [test x$enable_smart = xyes], [using SMART backend])
AM_CONDITIONAL(BACKEND_TYPE_URPMI, [test x$enable_urpmi = xyes], [using URPMI backend])
AM_CONDITIONAL(BACKEND_TYPE_YUM, [test x$enable_yum = xyes], [using YUM backend])
@@ -374,7 +376,7 @@ dnl ---------------------------------------------------------------------------
AC_ARG_WITH([default_backend],
AS_HELP_STRING([--with-default-backend=<option>],
[Default backend to use
- alpm,apt,box,conary,dummy,smart,urpmi,yum,pisi,zypp,opkg (dummy)]))
+ alpm,apt,box,conary,dummy,razor,smart,urpmi,yum,pisi,zypp,opkg (dummy)]))
# default to a sane option for the installed tool
if test x$with_default_backend = x; then
if test -f /usr/bin/yum ; then
@@ -391,6 +393,8 @@ if test x$with_default_backend = x; then
with_default_backend=smart
elif test -f /usr/bin/pisi ; then
with_default_backend=pisi
+ elif test -f /usr/bin/razor ; then
+ with_default_backend=razor
elif test -f /usr/bin/poldek ; then
with_default_backend=poldek
elif test -f /usr/bin/urpmq ; then
@@ -441,6 +445,12 @@ if test x$enable_zypp = xyes; then
AC_SUBST(ZYPP_LIBS)
fi
+if test x$enable_razor = xyes; then
+ PKG_CHECK_MODULES(RAZOR, razor >= 0.1)
+ AC_SUBST(RAZOR_CFLAGS)
+ AC_SUBST(RAZOR_LIBS)
+fi
+
AC_SUBST(PK_CONF_DIR, "\$(sysconfdir)/PackageKit")
AC_SUBST(PK_YUM_PLUGIN_DIR, "\$(prefix)/lib/yum-plugins")
AC_SUBST(PK_DB_DIR, "\$(localstatedir)/lib/PackageKit")
@@ -481,6 +491,7 @@ backends/urpmi/Makefile
backends/urpmi/helpers/Makefile
backends/urpmi/helpers/perl_packagekit/Makefile
backends/urpmi/helpers/urpmi_backend/Makefile
+backends/razor/Makefile
backends/yum/Makefile
backends/yum/helpers/Makefile
backends/yum2/Makefile
@@ -532,6 +543,7 @@ echo "
CONARY backend: ${enable_conary}
dummy backend: ${enable_dummy}
OPKG backend: ${enable_opkg}
+ Razor backend: ${enable_razor}
PiSi backend: ${enable_pisi}
poldek backend: ${enable_poldek}
SMART backend: ${enable_smart}
commit e3bc60c001ecd687b9e5c97a673f432daf959098
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 25 15:15:41 2008 +0100
trivial: fix up the yum backend
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 1e519fe..40e2e43 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -630,7 +630,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
found[str(pkg)] = 1
@handle_repo_error
- def download_packages(self,packages,directory)
+ def download_packages(self,packages,directory):
'''
Implement the {backend}-download-packages functionality
'''
commit 8c8cc0b3dffe40d109f525546bc1c192b9424621
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 25 14:49:28 2008 +0100
trivial: remove one unused function and const more stuff
diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index b537fdd..110884c 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -703,33 +703,6 @@ pk_strreplace (const gchar *text, const gchar *find, const gchar *replace)
}
/**
- * pk_delay_yield:
- * @delay: the desired delay in seconds
- *
- * Return value: success
- **/
-gboolean
-pk_delay_yield (gfloat delay)
-{
- GTimer *timer;
- gdouble elapsed;
- guint count = 0;
-
- pk_debug ("started task");
- timer = g_timer_new ();
- do {
- g_usleep (10);
- g_thread_yield ();
- elapsed = g_timer_elapsed (timer, NULL);
- if (++count % 10000 == 0) {
- pk_debug ("elapsed %.2f", elapsed);
- }
- } while (elapsed < delay);
- g_timer_destroy (timer);
- return TRUE;
-}
-
-/**
* pk_ptr_array_to_argv:
* @array: the GPtrArray of strings
*
@@ -925,9 +898,6 @@ libst_common (LibSelfTest *test)
return;
}
- pk_delay_yield (2.0);
-
-
/************************************************************
**************** test distro-id **************
************************************************************/
diff --git a/libpackagekit/pk-common.h b/libpackagekit/pk-common.h
index e02a67d..fcba059 100644
--- a/libpackagekit/pk-common.h
+++ b/libpackagekit/pk-common.h
@@ -104,7 +104,6 @@ gboolean pk_strcmp_sections (const gchar *id1,
gchar *pk_iso8601_present (void)
G_GNUC_WARN_UNUSED_RESULT;
guint pk_iso8601_difference (const gchar *isodate);
-gboolean pk_delay_yield (gfloat delay);
gchar *pk_get_distro_id (void)
G_GNUC_WARN_UNUSED_RESULT;
diff --git a/libpackagekit/pk-package-id.c b/libpackagekit/pk-package-id.c
index cae2ab9..0098039 100644
--- a/libpackagekit/pk-package-id.c
+++ b/libpackagekit/pk-package-id.c
@@ -144,7 +144,7 @@ pk_package_id_new_from_list (const gchar *name, const gchar *version, const gcha
* Return value: returns a string representation of #PkPackageId.
**/
gchar *
-pk_package_id_to_string (PkPackageId *ident)
+pk_package_id_to_string (const PkPackageId *ident)
{
return g_strdup_printf ("%s;%s;%s;%s",
ident->name, ident->version,
diff --git a/libpackagekit/pk-package-id.h b/libpackagekit/pk-package-id.h
index 9379fd5..058ce8b 100644
--- a/libpackagekit/pk-package-id.h
+++ b/libpackagekit/pk-package-id.h
@@ -51,7 +51,7 @@ gchar *pk_package_id_build (const gchar *name,
const gchar *arch,
const gchar *data)
G_GNUC_WARN_UNUSED_RESULT;
-gchar *pk_package_id_to_string (PkPackageId *ident)
+gchar *pk_package_id_to_string (const PkPackageId *ident)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_package_id_free (PkPackageId *ident);
gboolean pk_package_id_check (const gchar *package_id)
More information about the PackageKit-commit
mailing list