[PackageKit-commit] packagekit: Branch 'master' - 6 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Tue Jun 3 03:32:24 PDT 2008
TODO | 16 ---
backends/yum2/helpers/yumDBUSBackend.py | 5 +
libpackagekit/pk-enum.h | 10 +-
libpackagekit/pk-package-list.c | 144 ++++++++++++++++++++++++++++++++
libpackagekit/pk-package-list.h | 3
src/pk-backend-dbus.c | 94 +++++++++++++++-----
src/pk-backend.c | 2
7 files changed, 231 insertions(+), 43 deletions(-)
New commits:
commit 2a361133af00a562fe5fb4a867e3f6c383efecf2
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Jun 3 11:10:28 2008 +0100
add API to PkPackageList to enable sorting by package_id, summary or PkInfoEnum
diff --git a/libpackagekit/pk-package-list.c b/libpackagekit/pk-package-list.c
index 6bdb0d4..3727635 100644
--- a/libpackagekit/pk-package-list.c
+++ b/libpackagekit/pk-package-list.c
@@ -174,6 +174,84 @@ pk_package_list_get_size (PkPackageList *plist)
}
/**
+ * pk_package_list_sort_compare_package_id_func:
+ **/
+static gint
+pk_package_list_sort_compare_package_id_func (PkPackageItem **a, PkPackageItem **b)
+{
+ return strcmp ((*a)->package_id, (*b)->package_id);
+}
+
+/**
+ * pk_package_list_sort_compare_summary_func:
+ **/
+static gint
+pk_package_list_sort_compare_summary_func (PkPackageItem **a, PkPackageItem **b)
+{
+ if ((*a)->summary == NULL && (*b)->summary == NULL) {
+ return 0;
+ } else if ((*a)->summary == NULL) {
+ return -1;
+ } else if ((*b)->summary == NULL) {
+ return 1;
+ }
+ return strcmp ((*a)->summary, (*b)->summary);
+}
+
+/**
+ * pk_package_list_sort_compare_info_func:
+ **/
+static gint
+pk_package_list_sort_compare_info_func (PkPackageItem **a, PkPackageItem **b)
+{
+ if ((*a)->info == (*b)->info) {
+ return 0;
+ } else if ((*a)->info > (*b)->info) {
+ return -1;
+ }
+ return 1;
+}
+
+/**
+ * pk_package_list_sort:
+ *
+ * Sorts by package_id
+ **/
+gboolean
+pk_package_list_sort (PkPackageList *plist)
+{
+ g_return_val_if_fail (PK_IS_PACKAGE_LIST (plist), FALSE);
+ g_ptr_array_sort (plist->priv->array, (GCompareFunc) pk_package_list_sort_compare_package_id_func);
+ return TRUE;
+}
+
+/**
+ * pk_package_list_sort_summary:
+ *
+ * Sorts by summary
+ **/
+gboolean
+pk_package_list_sort_summary (PkPackageList *plist)
+{
+ g_return_val_if_fail (PK_IS_PACKAGE_LIST (plist), FALSE);
+ g_ptr_array_sort (plist->priv->array, (GCompareFunc) pk_package_list_sort_compare_summary_func);
+ return TRUE;
+}
+
+/**
+ * pk_package_list_sort_info:
+ *
+ * Sorts by PkInfoEnum
+ **/
+gboolean
+pk_package_list_sort_info (PkPackageList *plist)
+{
+ g_return_val_if_fail (PK_IS_PACKAGE_LIST (plist), FALSE);
+ g_ptr_array_sort (plist->priv->array, (GCompareFunc) pk_package_list_sort_compare_info_func);
+ return TRUE;
+}
+
+/**
* pk_package_list_get_item:
**/
PkPackageItem *
@@ -325,6 +403,9 @@ libst_package_list (LibSelfTest *test)
PkPackageList *plist;
gchar *text;
gboolean ret;
+ PkPackageItem *r0;
+ PkPackageItem *r1;
+ PkPackageItem *r2;
if (libst_start (test, "PkPackageList", CLASS_AUTO) == FALSE) {
return;
@@ -393,6 +474,69 @@ libst_package_list (LibSelfTest *test)
} else {
libst_failed (test, "could not add NULL summary");
}
+ g_object_unref (plist);
+
+ plist = pk_package_list_new ();
+
+ /************************************************************/
+ libst_title (test, "add entries");
+ ret = pk_package_list_add (plist, PK_INFO_ENUM_SECURITY, "def;1.23;i386;data", "zed");
+ if (!ret) {
+ libst_failed (test, NULL);
+ }
+ ret = pk_package_list_add (plist, PK_INFO_ENUM_BUGFIX, "abc;1.23;i386;data", "fed");
+ if (!ret) {
+ libst_failed (test, NULL);
+ }
+ ret = pk_package_list_add (plist, PK_INFO_ENUM_ENHANCEMENT, "ghi;1.23;i386;data", "aed");
+ if (!ret) {
+ libst_failed (test, NULL);
+ }
+ libst_success (test, NULL);
+
+ /************************************************************/
+ libst_title (test, "sort by package_id");
+ ret = pk_package_list_sort (plist);
+ r0 = pk_package_list_get_item (plist, 0);
+ r1 = pk_package_list_get_item (plist, 1);
+ r2 = pk_package_list_get_item (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")) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "could not sort: %s,%s,%s", r0->package_id, r1->package_id, r2->package_id);
+ }
+
+ /************************************************************/
+ libst_title (test, "sort by summary");
+ ret = pk_package_list_sort_summary (plist);
+ r0 = pk_package_list_get_item (plist, 0);
+ r1 = pk_package_list_get_item (plist, 1);
+ r2 = pk_package_list_get_item (plist, 2);
+ if (pk_strequal (r0->summary, "aed") &&
+ pk_strequal (r1->summary, "fed") &&
+ pk_strequal (r2->summary, "zed")) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "could not sort: %s,%s,%s", r0->summary, r1->summary, r2->summary);
+ }
+
+ /************************************************************/
+ libst_title (test, "sort by severity");
+ ret = pk_package_list_sort_info (plist);
+ r0 = pk_package_list_get_item (plist, 0);
+ r1 = pk_package_list_get_item (plist, 1);
+ r2 = pk_package_list_get_item (plist, 2);
+ if (r0->info == PK_INFO_ENUM_SECURITY &&
+ r1->info == PK_INFO_ENUM_BUGFIX &&
+ r2->info == PK_INFO_ENUM_ENHANCEMENT) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "could not sort: %s,%s,%s", r0->summary, r1->summary, r2->summary);
+ }
+
+ g_object_unref (plist);
libst_end (test);
}
diff --git a/libpackagekit/pk-package-list.h b/libpackagekit/pk-package-list.h
index 83901ab..401069b 100644
--- a/libpackagekit/pk-package-list.h
+++ b/libpackagekit/pk-package-list.h
@@ -68,6 +68,9 @@ gboolean pk_package_list_contains_item (PkPackageList *plist,
gchar *pk_package_list_get_string (PkPackageList *plist)
G_GNUC_WARN_UNUSED_RESULT;
guint pk_package_list_get_size (PkPackageList *plist);
+gboolean pk_package_list_sort (PkPackageList *plist);
+gboolean pk_package_list_sort_info (PkPackageList *plist);
+gboolean pk_package_list_sort_summary (PkPackageList *plist);
PkPackageItem *pk_package_list_get_item (PkPackageList *plist,
guint item);
gboolean pk_package_list_clear (PkPackageList *plist);
commit 516a9a0fcd90dc4899651ee7e5c754035aebdbf0
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Jun 3 11:08:48 2008 +0100
trivial: sort the PkInfoEnum's by priority
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 4cc317e..f2df1ae 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -332,11 +332,11 @@ typedef enum {
PK_INFO_ENUM_INSTALLED = 1 << 0,
PK_INFO_ENUM_AVAILABLE = 1 << 1,
PK_INFO_ENUM_LOW = 1 << 2,
- PK_INFO_ENUM_NORMAL = 1 << 3,
- PK_INFO_ENUM_IMPORTANT = 1 << 4,
- PK_INFO_ENUM_SECURITY = 1 << 5,
- PK_INFO_ENUM_BUGFIX = 1 << 6,
- PK_INFO_ENUM_ENHANCEMENT = 1 << 7,
+ PK_INFO_ENUM_ENHANCEMENT = 1 << 3,
+ PK_INFO_ENUM_NORMAL = 1 << 4,
+ PK_INFO_ENUM_BUGFIX = 1 << 5,
+ PK_INFO_ENUM_IMPORTANT = 1 << 6,
+ PK_INFO_ENUM_SECURITY = 1 << 7,
PK_INFO_ENUM_BLOCKED = 1 << 8,
PK_INFO_ENUM_DOWNLOADING = 1 << 9,
PK_INFO_ENUM_UPDATING = 1 << 10,
commit df14cb3dd2ccc0477efc29dd6c259e4997ddbe88
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Jun 3 10:29:00 2008 +0100
yum2: a couple of crasher fixes
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index a708a0c..3406b8b 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -430,6 +430,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.AllowCancel(True)
self.NoPercentageUpdates()
self.StatusChanged(STATUS_QUERY)
+ package_list = [] #we can't do emitting as found if we are post-processing
try:
pkgGroupDict = self._buildGroupDict()
@@ -1955,6 +1956,10 @@ class PackageKitYumBackend(PackageKitBaseBackend):
ver = "%s-%s" % (po.version,po.release)
return ver
+ def _get_nevra(self,pkg):
+ ''' gets the NEVRA for a pkg '''
+ return "%s-%s:%s-%s.%s" % (pkg.name,pkg.epoch,pkg.version,pkg.release,pkg.arch);
+
def _refresh_yum_cache(self):
self.StatusChanged(STATUS_REFRESH_CACHE)
old_cache_setting = self.yumbase.conf.cache
commit 86eceb3737b244a9db8a1c3a29368a57ff0a189c
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Jun 3 10:10:11 2008 +0100
bugfix: babysit the DBUS backends and do Init() again it when they crash
diff --git a/src/pk-backend-dbus.c b/src/pk-backend-dbus.c
index 4c6837a..8258a93 100644
--- a/src/pk-backend-dbus.c
+++ b/src/pk-backend-dbus.c
@@ -75,6 +75,7 @@ struct PkBackendDbusPrivate
GTimer *timer;
gchar *service;
gulong signal_finished;
+ LibGBus *gbus;
};
G_DEFINE_TYPE (PkBackendDbus, pk_backend_dbus, G_TYPE_OBJECT)
@@ -366,6 +367,43 @@ pk_backend_dbus_set_proxy (PkBackendDbus *backend_dbus, const gchar *proxy_http,
}
/**
+ * pk_backend_dbus_startup:
+ **/
+gboolean
+pk_backend_dbus_startup (PkBackendDbus *backend_dbus)
+{
+ gboolean ret;
+ GError *error = NULL;
+ gchar *proxy_http;
+ gchar *proxy_ftp;
+
+ /* manually init the backend, which should get things spawned for us */
+ pk_backend_dbus_time_reset (backend_dbus);
+ ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "Init", &error,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+ if (!ret) {
+ pk_warning ("%s", error->message);
+ /* FIXME: might be insane... */
+ pk_backend_error_code (backend_dbus->priv->backend, PK_ERROR_ENUM_INTERNAL_ERROR, error->message);
+ pk_backend_finished (backend_dbus->priv->backend);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* set the proxy */
+ proxy_http = pk_backend_get_proxy_http (backend_dbus->priv->backend);
+ proxy_ftp = pk_backend_get_proxy_http (backend_dbus->priv->backend);
+ pk_backend_dbus_set_proxy (backend_dbus, proxy_http, proxy_ftp);
+ g_free (proxy_http);
+ g_free (proxy_ftp);
+
+ /* reset the time */
+ pk_backend_dbus_time_check (backend_dbus);
+out:
+ return ret;
+}
+
+/**
* pk_backend_dbus_set_name:
**/
gboolean
@@ -373,7 +411,6 @@ pk_backend_dbus_set_name (PkBackendDbus *backend_dbus, const gchar *service)
{
DBusGProxy *proxy;
gboolean ret;
- GError *error = NULL;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->connection != NULL, FALSE);
@@ -385,6 +422,9 @@ pk_backend_dbus_set_name (PkBackendDbus *backend_dbus, const gchar *service)
g_object_unref (backend_dbus->priv->proxy);
}
+ /* watch */
+ libgbus_assign (backend_dbus->priv->gbus, LIBGBUS_SYSTEM, service);
+
/* grab this */
pk_debug ("trying to activate %s", service);
proxy = dbus_g_proxy_new_for_name (backend_dbus->priv->connection,
@@ -465,31 +505,9 @@ pk_backend_dbus_set_name (PkBackendDbus *backend_dbus, const gchar *service)
g_free (backend_dbus->priv->service);
backend_dbus->priv->service = g_strdup (service);
- /* manually init the backend, which should get things spawned for us */
- pk_backend_dbus_time_reset (backend_dbus);
- ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "Init", &error,
- G_TYPE_INVALID, G_TYPE_INVALID);
- if (error != NULL) {
- pk_warning ("%s", error->message);
- pk_backend_error_code (backend_dbus->priv->backend, PK_ERROR_ENUM_INTERNAL_ERROR, error->message);
- pk_backend_finished (backend_dbus->priv->backend);
- g_error_free (error);
- }
-
- /* set the proxy */
- if (ret) {
- gchar *proxy_http;
- gchar *proxy_ftp;
- proxy_http = pk_backend_get_proxy_http (backend_dbus->priv->backend);
- proxy_ftp = pk_backend_get_proxy_http (backend_dbus->priv->backend);
- pk_backend_dbus_set_proxy (backend_dbus, proxy_http, proxy_ftp);
- g_free (proxy_http);
- g_free (proxy_ftp);
- }
+ /* Init() */
+ ret = pk_backend_dbus_startup (backend_dbus);
- if (ret) {
- pk_backend_dbus_time_check (backend_dbus);
- }
return ret;
}
@@ -1321,6 +1339,26 @@ pk_backend_dbus_what_provides (PkBackendDbus *backend_dbus, PkFilterEnum filters
}
/**
+ * pk_backend_dbus_gbus_changed_cb:
+ **/
+static void
+pk_backend_dbus_gbus_changed_cb (LibGBus *libgbus, gboolean is_active, PkBackendDbus *backend_dbus)
+{
+ gboolean ret;
+ g_return_if_fail (PK_IS_BACKEND_DBUS (backend_dbus));
+
+ if (!is_active) {
+ pk_warning ("DBUS backend disconnected");
+ pk_backend_message (backend_dbus->priv->backend, PK_MESSAGE_ENUM_DAEMON, "DBUS backend has exited");
+ /* Init() */
+ ret = pk_backend_dbus_startup (backend_dbus);
+ if (!ret) {
+ pk_backend_message (backend_dbus->priv->backend, PK_MESSAGE_ENUM_DAEMON, "DBUS backend will not start");
+ }
+ }
+}
+
+/**
* pk_backend_dbus_finalize:
**/
static void
@@ -1341,6 +1379,7 @@ pk_backend_dbus_finalize (GObject *object)
}
g_timer_destroy (backend_dbus->priv->timer);
g_object_unref (backend_dbus->priv->backend);
+ g_object_unref (backend_dbus->priv->gbus);
G_OBJECT_CLASS (pk_backend_dbus_parent_class)->finalize (object);
}
@@ -1376,6 +1415,11 @@ pk_backend_dbus_init (PkBackendDbus *backend_dbus)
pk_error ("unable to get system connection %s", error->message);
}
+ /* babysit the backend and do Init() again it when it crashes */
+ backend_dbus->priv->gbus = libgbus_new ();
+ g_signal_connect (backend_dbus->priv->gbus, "connection-changed",
+ G_CALLBACK (pk_backend_dbus_gbus_changed_cb), backend_dbus);
+
/* ProgressChanged */
dbus_g_object_register_marshaller (pk_marshal_VOID__UINT_UINT_UINT_UINT,
G_TYPE_NONE, G_TYPE_UINT,
commit de4a1e9b044d371a5e3e4b7fdaded3eb9035eaca
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Jun 3 10:06:42 2008 +0100
trivial: update TODO
diff --git a/TODO b/TODO
index 1ffaaff..11bb2d9 100644
--- a/TODO
+++ b/TODO
@@ -1,21 +1,13 @@
-*** Timeframe: 0.1.11 ***
+*** Timeframe: 0.2.x ***
* Make PkMessages into proper enumerated types with localised descriptions
-*** Timeframe: 0.2.0 ***
+*** Timeframe: 0.3.x ***
* Enable GetUpdateDetail to handle arrays for 'updates' and 'obsoletes'
- Until then, use a space to delimit package_id's
+ Until then, use ^ to delimit package_id's
-* Make one-click installs work
-
-* We need more unit tests.
- Where we can actually simulate _using_ packagekit, probably using an
- enhanced dummy backend and libpackagekit.
- This is a tricky one as we can't assume we have the
- org.freedesktop.PackageKit.conf file installed in the system prefix -
- maybe we can #ifdef the daemon to run in the session bus for some
- testing.
+* Perhaps add RepoAdd(s=repo_id,as=urls,as=auth) and RepoRemove(s=repo_id)
*** Timeframe: Sometime in the future ***
commit acf5c0674466ea77708ca942e3da7453bb7ea413
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Jun 3 09:58:13 2008 +0100
trivial: relax the restriction on pk_backend_message() being done before ErrorCode()
diff --git a/src/pk-backend.c b/src/pk-backend.c
index f0f245f..6efa55e 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1049,7 +1049,7 @@ pk_backend_message (PkBackend *backend, PkMessageEnum message, const gchar *form
g_return_val_if_fail (backend->priv->locked != FALSE, FALSE);
/* have we already set an error? */
- if (backend->priv->set_error) {
+ if (backend->priv->set_error && message != PK_MESSAGE_ENUM_DAEMON) {
pk_warning ("already set error, cannot process");
return FALSE;
}
More information about the PackageKit-commit
mailing list