[PackageKit-commit] packagekit: Branch 'master' - 11 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Fri Jun 6 04:04:45 PDT 2008
RELEASE | 2
backends/alpm/pk-backend-alpm.c | 140 ++++++++---------
backends/yum/helpers/yumBackend.py | 14 +
backends/yum2/helpers/yumDBUSBackend.py | 14 +
client/pk-console.c | 4
docs/api/PackageKit-docs.sgml | 1
libpackagekit/Makefile.am | 5
libpackagekit/pk-client.c | 136 +++++++++++++----
libpackagekit/pk-enum.c | 1
libpackagekit/pk-enum.h | 3
libpackagekit/pk-polkit-client.c | 251 --------------------------------
libpackagekit/pk-polkit-client.h | 64 --------
12 files changed, 210 insertions(+), 425 deletions(-)
New commits:
commit 813fa8cfb139246cf180d52895b52b28616ae2f5
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Jun 6 11:40:03 2008 +0100
trivial: fix make distcheck by #ifdef'ing out the polkit bits when not USE_SECURITY_POLKIT
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 8418281..4bc34c9 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -41,7 +41,10 @@
#include <glib/gi18n.h>
#include <glib/gprintf.h>
#include <dbus/dbus-glib.h>
+
+#ifdef USE_SECURITY_POLKIT
#include <polkit-dbus/polkit-dbus.h>
+#endif
#include "pk-enum.h"
#include "pk-client.h"
@@ -294,7 +297,8 @@ pk_client_error_refused_by_policy (GError *error)
gboolean
pk_client_error_auth_obtain (GError *error)
{
- polkit_bool_t ret;
+ gboolean ret = FALSE;
+#ifdef USE_SECURITY_POLKIT
PolKitAction *action = NULL;
PolKitResult result;
gchar *action_id = NULL; /* we don't free this */
@@ -327,7 +331,7 @@ pk_client_error_auth_obtain (GError *error)
pk_debug ("gained %s privilege = %d", action_id, ret);
polkit_action_unref (action);
-
+#endif
return ret;
}
commit b17298fb1a1654d249bae476d54c0327edca7005
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Jun 6 11:38:29 2008 +0100
trivial: remove PkPolkitClient from the API docs
diff --git a/docs/api/PackageKit-docs.sgml b/docs/api/PackageKit-docs.sgml
index 61eb8cc..7b4a1cc 100644
--- a/docs/api/PackageKit-docs.sgml
+++ b/docs/api/PackageKit-docs.sgml
@@ -18,7 +18,6 @@
<chapter>
<title>libpackagekit</title>
<xi:include href="xml/pk-connection.xml"/>
- <xi:include href="xml/pk-polkit-client.xml"/>
<xi:include href="xml/pk-extra.xml"/>
<xi:include href="xml/pk-client.xml"/>
<xi:include href="xml/pk-package-list.xml"/>
commit 96a18c68d2907a1e1a80fbf8f78ee3b6ee1c46d3
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Jun 6 11:33:10 2008 +0100
bugfix: remove the unused PkPolkitClient now we are using polkit-auth to use native session or text widgets
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index c8d9095..8f1f2c5 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -45,7 +45,6 @@ libpackagekit_include_HEADERS = \
pk-client.h \
pk-control.h \
pk-task-list.h \
- pk-polkit-client.h \
$(NULL)
libpackagekit_la_SOURCES = \
@@ -75,8 +74,6 @@ libpackagekit_la_SOURCES = \
pk-control.h \
pk-task-list.c \
pk-task-list.h \
- pk-polkit-client.c \
- pk-polkit-client.h \
$(NULL)
libpackagekit_la_LIBADD = \
diff --git a/libpackagekit/pk-polkit-client.c b/libpackagekit/pk-polkit-client.c
deleted file mode 100644
index 7308a29..0000000
--- a/libpackagekit/pk-polkit-client.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 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.
- */
-
-/**
- * SECTION:pk-polkit-client
- * @short_description: Provides a nice GObject to get a PolKit action auth
- *
- * This file contains functions that can be used for authorising a PolKit action.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <string.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
-#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
-
-#include "pk-common.h"
-#include "pk-debug.h"
-#include "pk-polkit-client.h"
-
-static void pk_polkit_client_class_init (PkPolkitClientClass *klass);
-static void pk_polkit_client_init (PkPolkitClient *polkit_client);
-static void pk_polkit_client_finalize (GObject *object);
-
-#define PK_POLKIT_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_POLKIT_CLIENT, PkPolkitClientPrivate))
-
-#define POLKIT_DBUS_SERVICE "org.gnome.PolicyKit"
-#define POLKIT_DBUS_PATH "/org/gnome/PolicyKit/Manager"
-#define POLKIT_DBUS_INTERFACE "org.gnome.PolicyKit.Manager"
-
-/**
- * PkPolkitClientPrivate:
- *
- * Private #PkPolkitClient data
- **/
-struct _PkPolkitClientPrivate
-{
- DBusGConnection *connection;
- DBusGProxy *proxy;
-};
-
-G_DEFINE_TYPE (PkPolkitClient, pk_polkit_client, G_TYPE_OBJECT)
-
-/**
- * pk_polkit_client_gain_privilege:
- * @pclient: a valid #PkPolkitClient instance
- * @pk_action: a PolicyKit action description, e.g. "org.freedesktop.packagekit.installfile"
- *
- * This function is indented to be used by client tools to gain extra privileges
- * needed to do extra functionality.
- *
- * Return value: if we gained the privilege we asked for
- **/
-gboolean
-pk_polkit_client_gain_privilege (PkPolkitClient *pclient, const gchar *pk_action)
-{
- GError *error = NULL;
- gboolean gained_privilege;
-
- g_return_val_if_fail (PK_IS_POLKIT_CLIENT (pclient), FALSE);
- g_return_val_if_fail (pk_action != NULL, FALSE);
-
- /* Use PolicyKit-gnome to bring up an auth dialog (we
- * don't have any windows so set the XID to "null") */
- if (!dbus_g_proxy_call_with_timeout (pclient->priv->proxy,
- "ShowDialog",
- INT_MAX,
- &error,
- /* parameters: */
- G_TYPE_STRING, pk_action, /* action_id */
- G_TYPE_UINT, 0, /* X11 window ID */
- G_TYPE_INVALID,
- /* return values: */
- G_TYPE_BOOLEAN, &gained_privilege,
- G_TYPE_INVALID)) {
- pk_warning ("Caught exception '%s'", error->message);
- g_error_free (error);
- return FALSE;
- }
- pk_debug ("gained %s privilege = %d", pk_action, gained_privilege);
-
- return gained_privilege;
-}
-
-/**
- * pk_polkit_client_gain_privilege_str:
- * @pclient: a valid #PkPolkitClient instance
- * @error_str: the raw output error, e.g. "org.freedesktop.packagekit.installfile no"
- *
- * This function is indented to be passed failure messages from dbus methods
- * so that extra auth can be requested.
- *
- * Return value: if we gained the privilege we asked for
- **/
-gboolean
-pk_polkit_client_gain_privilege_str (PkPolkitClient *pclient, const gchar *error_str)
-{
- gboolean ret;
- gchar **tokens;
-
- g_return_val_if_fail (PK_IS_POLKIT_CLIENT (pclient), FALSE);
- g_return_val_if_fail (error_str != NULL, FALSE);
-
- tokens = g_strsplit (error_str, " ", 0);
- if (tokens == NULL) {
- pk_warning ("invalid string (null)");
- return FALSE;
- }
- if (g_strv_length (tokens) < 2) {
- pk_warning ("invalid string '%s'", error_str);
- g_strfreev (tokens);
- return FALSE;
- }
-
- /* we've now just got the pk_action */
- pk_debug ("pk_action='%s' pk_result='%s'", tokens[0], tokens[1]);
- ret = pk_polkit_client_gain_privilege (pclient, tokens[0]);
-
- g_strfreev (tokens);
- return ret;
-}
-
-/**
- * pk_polkit_client_error_denied_by_policy:
- * @error: a valid #GError
- *
- * Return value: %TRUE if the error is the PolicyKit "RefusedByPolicy"
- **/
-gboolean
-pk_polkit_client_error_denied_by_policy (GError *error)
-{
- const gchar *error_name;
-
- /* if not set */
- if (error == NULL) {
- pk_debug ("not an error, is this sane?");
- return FALSE;
- }
-
- /* not a dbus error */
- if (error->code != DBUS_GERROR_REMOTE_EXCEPTION) {
- pk_warning ("not a remote exception: %s", error->message);
- return FALSE;
- }
-
- /* check for specific error */
- error_name = dbus_g_error_get_name (error);
- pk_debug ("ERROR: %s: %s", error_name, error->message);
- if (pk_strequal (error_name, "org.freedesktop.PackageKit.RefusedByPolicy")) {
- return TRUE;
- }
- if (pk_strequal (error_name, "org.freedesktop.PackageKit.Transaction.RefusedByPolicy")) {
- return TRUE;
- }
- return FALSE;
-}
-
-/**
- * pk_polkit_client_class_init:
- **/
-static void
-pk_polkit_client_class_init (PkPolkitClientClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = pk_polkit_client_finalize;
- g_type_class_add_private (klass, sizeof (PkPolkitClientPrivate));
-}
-
-/**
- * pk_polkit_client_init:
- **/
-static void
-pk_polkit_client_init (PkPolkitClient *pclient)
-{
- GError *error = NULL;
-
- pclient->priv = PK_POLKIT_CLIENT_GET_PRIVATE (pclient);
-
- /* check dbus connections, exit if not valid */
- pclient->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (error) {
- pk_warning ("%s", error->message);
- g_error_free (error);
- g_error ("Could not connect to system DBUS.");
- }
-
- /* get a connection */
- pclient->priv->proxy = dbus_g_proxy_new_for_name (pclient->priv->connection,
- POLKIT_DBUS_SERVICE,
- POLKIT_DBUS_PATH,
- POLKIT_DBUS_INTERFACE);
- if (pclient->priv->proxy == NULL) {
- g_error ("Cannot connect to PackageKit.");
- }
-}
-
-/**
- * pk_polkit_client_finalize:
- **/
-static void
-pk_polkit_client_finalize (GObject *object)
-{
- PkPolkitClient *pclient;
- g_return_if_fail (object != NULL);
- g_return_if_fail (PK_IS_POLKIT_CLIENT (object));
- pclient = PK_POLKIT_CLIENT (object);
- g_return_if_fail (pclient->priv != NULL);
-
- /* free the proxy */
- g_object_unref (G_OBJECT (pclient->priv->proxy));
-
- G_OBJECT_CLASS (pk_polkit_client_parent_class)->finalize (object);
-}
-
-/**
- * pk_polkit_client_new:
- **/
-PkPolkitClient *
-pk_polkit_client_new (void)
-{
- PkPolkitClient *pclient;
- pclient = g_object_new (PK_TYPE_POLKIT_CLIENT, NULL);
- return PK_POLKIT_CLIENT (pclient);
-}
-
diff --git a/libpackagekit/pk-polkit-client.h b/libpackagekit/pk-polkit-client.h
deleted file mode 100644
index f5e70e7..0000000
--- a/libpackagekit/pk-polkit-client.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 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.
- */
-
-#ifndef __PK_POLKIT_CLIENT_H
-#define __PK_POLKIT_CLIENT_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define PK_TYPE_POLKIT_CLIENT (pk_polkit_client_get_type ())
-#define PK_POLKIT_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_POLKIT_CLIENT, PkPolkitClient))
-#define PK_POLKIT_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_POLKIT_CLIENT, PkPolkitClientClass))
-#define PK_IS_POLKIT_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_POLKIT_CLIENT))
-#define PK_IS_POLKIT_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_POLKIT_CLIENT))
-#define PK_POLKIT_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_POLKIT_CLIENT, PkPolkitClientClass))
-
-typedef struct _PkPolkitClientPrivate PkPolkitClientPrivate;
-typedef struct _PkPolkitClient PkPolkitClient;
-typedef struct _PkPolkitClientClass PkPolkitClientClass;
-
-struct _PkPolkitClient
-{
- GObject parent;
- PkPolkitClientPrivate *priv;
-};
-
-struct _PkPolkitClientClass
-{
- GObjectClass parent_class;
-};
-
-GType pk_polkit_client_get_type (void) G_GNUC_CONST;
-PkPolkitClient *pk_polkit_client_new (void);
-
-gboolean pk_polkit_client_gain_privilege (PkPolkitClient *pclient,
- const gchar *pk_action)
- G_GNUC_WARN_UNUSED_RESULT;
-gboolean pk_polkit_client_gain_privilege_str (PkPolkitClient *pclient,
- const gchar *error_str)
- G_GNUC_WARN_UNUSED_RESULT;
-gboolean pk_polkit_client_error_denied_by_policy(GError *error);
-
-G_END_DECLS
-
-#endif /* __PK_POLKIT_CLIENT_H */
commit bae3ce7b98adfc79e9ed8c3c2c4786ef48025072
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Jun 6 11:30:32 2008 +0100
bugfix: don't manually use org.gnome.PolicyKit as our AuthenticationAgent, use polkit_auth_obtain.
This means that pkcon now works in a tty, and in KDE the native KDE widgets are used
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 7df7f1d..8418281 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -41,6 +41,7 @@
#include <glib/gi18n.h>
#include <glib/gprintf.h>
#include <dbus/dbus-glib.h>
+#include <polkit-dbus/polkit-dbus.h>
#include "pk-enum.h"
#include "pk-client.h"
@@ -50,7 +51,6 @@
#include "pk-package-list.h"
#include "pk-debug.h"
#include "pk-marshal.h"
-#include "pk-polkit-client.h"
#include "pk-common.h"
#include "pk-control.h"
@@ -77,7 +77,6 @@ struct _PkClientPrivate
PkControl *control;
PkPackageList *package_list;
PkConnection *pconnection;
- PkPolkitClient *polkit;
PkRestartEnum require_restart;
PkStatusEnum last_status;
PkRoleEnum role;
@@ -250,6 +249,89 @@ pk_client_error_fixup (GError **error)
}
/**
+ * pk_client_error_refused_by_policy:
+ * @error: a valid #GError
+ *
+ * Return value: %TRUE if the error is the PolicyKit "RefusedByPolicy"
+ **/
+gboolean
+pk_client_error_refused_by_policy (GError *error)
+{
+ const gchar *error_name;
+
+ /* if not set */
+ if (error == NULL) {
+ return FALSE;
+ }
+
+ /* not a dbus error */
+ if (error->code != DBUS_GERROR_REMOTE_EXCEPTION) {
+ pk_warning ("not a remote exception: %s", error->message);
+ return FALSE;
+ }
+
+ /* check for specific error */
+ error_name = dbus_g_error_get_name (error);
+ pk_debug ("ERROR: %s: %s", error_name, error->message);
+ if (pk_strequal (error_name, "org.freedesktop.PackageKit.RefusedByPolicy")) {
+ return TRUE;
+ }
+ if (pk_strequal (error_name, "org.freedesktop.PackageKit.Transaction.RefusedByPolicy")) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * pk_client_error_auth_obtain:
+ * @error: the GError with the failure
+ *
+ * This function is indented to be passed failure messages from dbus methods
+ * so that extra auth can be requested.
+ *
+ * Return value: if we gained the privilege we asked for
+ **/
+gboolean
+pk_client_error_auth_obtain (GError *error)
+{
+ polkit_bool_t ret;
+ PolKitAction *action = NULL;
+ PolKitResult result;
+ gchar *action_id = NULL; /* we don't free this */
+ DBusError error2;
+ dbus_error_init (&error2);
+
+ g_return_val_if_fail (error != NULL, FALSE);
+
+ /* get PolKitAction */
+ ret = polkit_dbus_error_parse_from_strings ("org.freedesktop.PolicyKit.Error.NotAuthorized", error->message, &action, &result);
+ if (!ret) {
+ pk_debug ("Not a polkit auth failure: %s", error->message);
+ return FALSE;
+ }
+
+ /* get action_id from PolKitAction */
+ ret = polkit_action_get_action_id (action, &action_id);
+ if (!ret) {
+ pk_debug ("Unable to get an action ID");
+ return FALSE;
+ }
+
+ /* this blocks - use polkit_gnome_auth_obtain for non blocking version */
+ ret = polkit_auth_obtain (action_id, 0, getpid (), &error2);
+ if (dbus_error_is_set (&error2)) {
+ pk_warning ("Failed to obtain auth: %s", error2.message);
+ }
+ dbus_error_free (&error2);
+
+ pk_debug ("gained %s privilege = %d", action_id, ret);
+
+ polkit_action_unref (action);
+
+ return ret;
+}
+
+/**
* pk_client_get_tid:
* @client: a valid #PkClient instance
*
@@ -1074,15 +1156,15 @@ pk_client_update_system (PkClient *client, GError **error)
ret = pk_client_update_system_action (client, &error_pk);
/* we were refused by policy */
- if (!ret && pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* try to get auth */
- if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+ if (pk_client_error_auth_obtain (error_pk)) {
/* clear old error */
g_clear_error (&error_pk);
/* retry the action now we have got auth */
ret = pk_client_update_system_action (client, &error_pk);
}
- if (pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* we failed to get an auth */
pk_client_error_set (error, PK_CLIENT_ERROR_FAILED_AUTH, error_pk->message);
/* clear old error */
@@ -1931,9 +2013,9 @@ pk_client_remove_packages (PkClient *client, gchar **package_ids, gboolean allow
ret = pk_client_remove_packages_action (client, package_ids, allow_deps, autoremove, &error_pk);
/* we were refused by policy */
- if (!ret && pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* try to get auth */
- if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+ if (pk_client_error_auth_obtain (error_pk)) {
/* clear old error */
g_clear_error (&error_pk);
/* retry the action now we have got auth */
@@ -2016,9 +2098,9 @@ pk_client_refresh_cache (PkClient *client, gboolean force, GError **error)
ret = pk_client_refresh_cache_action (client, force, &error_pk);
/* we were refused by policy */
- if (!ret && pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* try to get auth */
- if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+ if (pk_client_error_auth_obtain (error_pk)) {
/* clear old error */
g_clear_error (&error_pk);
/* retry the action now we have got auth */
@@ -2110,9 +2192,9 @@ pk_client_install_packages (PkClient *client, gchar **package_ids, GError **erro
ret = pk_client_install_package_action (client, package_ids, &error_pk);
/* we were refused by policy */
- if (!ret && pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* try to get auth */
- if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+ if (pk_client_error_auth_obtain (error_pk)) {
/* clear old error */
g_clear_error (&error_pk);
/* retry the action now we have got auth */
@@ -2210,9 +2292,9 @@ pk_client_install_signature (PkClient *client, PkSigTypeEnum type, const gchar *
ret = pk_client_install_signature_action (client, type, key_id, package_id, &error_pk);
/* we were refused by policy */
- if (!ret && pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* try to get auth */
- if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+ if (pk_client_error_auth_obtain (error_pk)) {
/* clear old error */
g_clear_error (&error_pk);
/* retry the action now we have got auth */
@@ -2308,9 +2390,9 @@ pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error
ret = pk_client_update_packages_action (client, package_ids, &error_pk);
/* we were refused by policy */
- if (!ret && pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* try to get auth */
- if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+ if (pk_client_error_auth_obtain (error_pk)) {
/* clear old error */
g_clear_error (&error_pk);
/* retry the action now we have got auth */
@@ -2538,9 +2620,9 @@ pk_client_install_files (PkClient *client, gboolean trusted, gchar **files_rel,
ret = pk_client_install_files_action (client, trusted, files, &error_pk);
/* we were refused by policy */
- if (!ret && pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* try to get auth */
- if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+ if (pk_client_error_auth_obtain (error_pk)) {
/* clear old error */
g_clear_error (&error_pk);
/* retry the action now we have got auth */
@@ -2671,9 +2753,9 @@ pk_client_accept_eula (PkClient *client, const gchar *eula_id, GError **error)
ret = pk_client_accept_eula_action (client, eula_id, &error_pk);
/* we were refused by policy */
- if (!ret && pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* try to get auth */
- if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+ if (pk_client_error_auth_obtain (error_pk)) {
/* clear old error */
g_clear_error (&error_pk);
/* retry the action now we have got auth */
@@ -2755,9 +2837,9 @@ pk_client_repo_enable (PkClient *client, const gchar *repo_id, gboolean enabled,
ret = pk_client_repo_enable_action (client, repo_id, enabled, &error_pk);
/* we were refused by policy */
- if (!ret && pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* try to get auth */
- if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+ if (pk_client_error_auth_obtain (error_pk)) {
/* clear old error */
g_clear_error (&error_pk);
/* retry the action now we have got auth */
@@ -2848,9 +2930,9 @@ pk_client_repo_set_data (PkClient *client, const gchar *repo_id, const gchar *pa
ret = pk_client_repo_set_data_action (client, repo_id, parameter, value, &error_pk);
/* we were refused by policy */
- if (!ret && pk_polkit_client_error_denied_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_pk)) {
/* try to get auth */
- if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+ if (pk_client_error_auth_obtain (error_pk)) {
/* clear old error */
g_clear_error (&error_pk);
/* retry the action now we have got auth */
@@ -3590,9 +3672,6 @@ pk_client_init (PkClient *client)
pk_client_connect (client);
}
- /* use PolicyKit */
- client->priv->polkit = pk_polkit_client_new ();
-
/* Use a main control object */
client->priv->control = pk_control_new ();
@@ -3694,7 +3773,6 @@ pk_client_finalize (GObject *object)
/* disconnect signal handlers */
pk_client_disconnect_proxy (client);
g_object_unref (client->priv->pconnection);
- g_object_unref (client->priv->polkit);
g_object_unref (client->priv->package_list);
g_object_unref (client->priv->control);
commit e76f8988e3b03ab8f4140bb98210b517b5de397d
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Jun 6 11:20:09 2008 +0100
trivial: if we do update_system, don't fallback to doing update_package
diff --git a/client/pk-console.c b/client/pk-console.c
index 67c06bc..4e7280e 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -1477,8 +1477,9 @@ main (int argc, char *argv[])
if (value == NULL) {
/* do the system update */
ret = pk_client_update_system (client, &error);
+ } else {
+ ret = pk_console_update_package (client, value, &error);
}
- ret = pk_console_update_package (client, value, &error);
} else if (strcmp (mode, "resolve") == 0) {
if (value == NULL) {
commit 8229d4083eab16ec9f9f582dc0c95aecc2fc8827
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Jun 6 11:17:24 2008 +0100
bugfix: Use PolicyKit libs and cflags in libpackagekit
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index aeafe44..c8d9095 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -4,6 +4,7 @@ NULL =
INCLUDES = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
+ $(POLKIT_CFLAGS) \
$(SQLITE_CFLAGS) \
-I$(top_srcdir)/libpackagekit \
-I$(top_srcdir)/libgbus \
@@ -82,6 +83,7 @@ libpackagekit_la_LIBADD = \
$(GLIB_LIBS) \
$(DBUS_LIBS) \
$(GBUS_LIBS) \
+ $(POLKIT_LIBS) \
$(SQLITE_LIBS) \
$(NULL)
commit 18ba9388c4c1b6a102d5e450e7f592aa0f5a9ce3
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Jun 6 11:16:22 2008 +0100
bugfix: don't use the error pathway when updating the system so we wait for 'pkcon update'
diff --git a/client/pk-console.c b/client/pk-console.c
index c0c1e3c..67c06bc 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -1477,7 +1477,6 @@ main (int argc, char *argv[])
if (value == NULL) {
/* do the system update */
ret = pk_client_update_system (client, &error);
- goto out;
}
ret = pk_console_update_package (client, value, &error);
commit 6049da54808488db5e92f1180feca66d513423b9
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Jun 6 08:55:09 2008 +0100
trivial: add a new status enum for repackaging
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 48903e4..4703638 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -1629,6 +1629,10 @@ class PackageKitCallback(RPMBaseCallback):
self.curpkg = None
self.startPct = 50
self.numPct = 50
+
+ # this isn't defined in yum as it's only used in the rollback plugin
+ TS_REPACKAGING = 'repackaging'
+
# Map yum transactions with pk info enums
self.info_actions = { TS_UPDATE : INFO_UPDATING,
TS_ERASE: INFO_REMOVING,
@@ -1645,7 +1649,8 @@ class PackageKitCallback(RPMBaseCallback):
TS_TRUEINSTALL : STATUS_INSTALL,
TS_OBSOLETED: STATUS_OBSOLETE,
TS_OBSOLETING: STATUS_INSTALL,
- TS_UPDATED: STATUS_CLEANUP}
+ TS_UPDATED: STATUS_CLEANUP,
+ TS_REPACKAGING: STATUS_REPACKAGING}
def _calcTotalPct(self,ts_current,ts_total):
bump = float(self.numPct)/ts_total
@@ -1663,8 +1668,11 @@ class PackageKitCallback(RPMBaseCallback):
def event(self,package,action,te_current,te_total,ts_current,ts_total):
if str(package) != str(self.curpkg):
self.curpkg = package
- self.base.status(self.state_actions[action])
- self._showName(self.info_actions[action])
+ try:
+ self.base.status(self.state_actions[action])
+ self._showName(self.info_actions[action])
+ except exceptions.KeyError,e:
+ self.base.message(MESSAGE_WARNING,"The constant '%s' was unknown, please report" % action)
pct = self._calcTotalPct(ts_current,ts_total)
self.base.percentage(pct)
val = (ts_current*100L)/ts_total
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 9f00e08..7209baa 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -2113,6 +2113,10 @@ class PackageKitCallback(RPMBaseCallback):
self.curpkg = None
self.startPct = 50
self.numPct = 50
+
+ # this isn't defined in yum as it's only used in the rollback plugin
+ TS_REPACKAGING = 'repackaging'
+
# Map yum transactions with pk info enums
self.info_actions = { TS_UPDATE : INFO_UPDATING,
TS_ERASE: INFO_REMOVING,
@@ -2129,7 +2133,8 @@ class PackageKitCallback(RPMBaseCallback):
TS_TRUEINSTALL : STATUS_INSTALL,
TS_OBSOLETED: STATUS_OBSOLETE,
TS_OBSOLETING: STATUS_INSTALL,
- TS_UPDATED: STATUS_CLEANUP}
+ TS_UPDATED: STATUS_CLEANUP,
+ TS_REPACKAGING: STATUS_REPACKAGING}
def _calcTotalPct(self,ts_current,ts_total):
bump = float(self.numPct)/ts_total
@@ -2150,8 +2155,11 @@ class PackageKitCallback(RPMBaseCallback):
if str(package) != str(self.curpkg):
self.curpkg = package
- self.base.StatusChanged(self.state_actions[action])
- self._showName(self.info_actions[action])
+ try:
+ self.base.StatusChanged(self.state_actions[action])
+ self._showName(self.info_actions[action])
+ except exceptions.KeyError,e:
+ self.base.Message(MESSAGE_WARNING,"The constant '%s' was unknown, please report" % action)
pct = self._calcTotalPct(ts_current, ts_total)
self.base.PercentageChanged(pct)
val = (ts_current*100L)/ts_total
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 9dccdd0..55a15a2 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -77,6 +77,7 @@ static PkEnumMatch enum_status[] = {
{PK_STATUS_ENUM_DOWNLOAD_CHANGELOG, "download-changelog"},
{PK_STATUS_ENUM_DOWNLOAD_GROUP, "download-group"},
{PK_STATUS_ENUM_DOWNLOAD_UPDATEINFO, "download-updateinfo"},
+ {PK_STATUS_ENUM_REPACKAGING, "repackaging"},
{0, NULL}
};
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index f2df1ae..cc7cd7b 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -128,7 +128,8 @@ typedef enum {
PK_STATUS_ENUM_DOWNLOAD_CHANGELOG = 1 << 23,
PK_STATUS_ENUM_DOWNLOAD_GROUP = 1 << 24,
PK_STATUS_ENUM_DOWNLOAD_UPDATEINFO = 1 << 25,
- PK_STATUS_ENUM_UNKNOWN = 1 << 26
+ PK_STATUS_ENUM_REPACKAGING = 1 << 26,
+ PK_STATUS_ENUM_UNKNOWN = 1 << 27
} PkStatusEnum;
/**
commit 4004e750985c7814cf91fb0eaa9bf4e3056afcec
Merge: c7a7079... 38ce7ff...
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date: Thu Jun 5 22:53:45 2008 +0300
Merge branch 'master' of git+ssh://onestep_ua@git.packagekit.org/srv/git/PackageKit
commit c7a707969a07f4664fac5ad60a0356208faa90a0
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date: Thu Jun 5 22:53:27 2008 +0300
alpm: fixed critical error in package_source_free, fixed backend_install_packages, package installation stuff moved to another thread
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 77a2dca..ef9a024 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -59,7 +59,7 @@ typedef struct _PackageSource
void
package_source_free (PackageSource *source)
{
- alpm_pkg_free (source->pkg);
+ g_free (source);
}
gchar *
@@ -79,12 +79,22 @@ cb_trans_evt (pmtransevt_t event, void *data1, void *data2)
gchar *package_id_str;
switch (event) {
- case PM_TRANS_EVT_REMOVE_DONE:
+ case PM_TRANS_EVT_REMOVE_START:
package_id_str = pkg_to_package_id_str (data1, "local");
pk_backend_package (backend_instance, PK_INFO_ENUM_REMOVING, package_id_str, alpm_pkg_get_desc (data1));
g_free (package_id_str);
break;
- default: pk_debug ("alpm: event happened, id=%i", event);
+ case PM_TRANS_EVT_ADD_START:
+ package_id_str = pkg_to_package_id_str (data1, "local");
+ pk_backend_package (backend_instance, PK_INFO_ENUM_INSTALLING, package_id_str, alpm_pkg_get_desc (data1));
+ g_free (package_id_str);
+ break;
+ case PM_TRANS_EVT_UPGRADE_START:
+ package_id_str = pkg_to_package_id_str (data1, "local");
+ pk_backend_package (backend_instance, PK_INFO_ENUM_UPDATING, package_id_str, alpm_pkg_get_desc (data1));
+ g_free (package_id_str);
+ break;
+ default: pk_debug ("alpm: event %i happened", event);
}
}
@@ -940,7 +950,8 @@ backend_install_files_thread (PkBackend *backend)
alpm_trans_release ();
pk_backend_finished (backend);
return FALSE;
- }
+ } else
+ pk_debug ("alpm: %s added to transaction queue", full_paths[iterator]);
}
alpm_list_t *data = NULL;
@@ -953,6 +964,7 @@ backend_install_files_thread (PkBackend *backend)
pk_backend_finished (backend);
return FALSE;
}
+ pk_debug ("alpm: %s", "transaction prepared");
/* commit transaction */
if (alpm_trans_commit (&data) == -1) {
@@ -982,89 +994,75 @@ backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
}
/**
- * backend_install_packages:
+ * backend_install_packages_thread:
*/
-static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+static gboolean
+backend_install_packages_thread (PkBackend *backend)
{
- pk_debug ("hello %i", GPOINTER_TO_INT (backend));
-/*
- alpm_list_t *syncdbs = alpm_option_get_syncdbs ();
-*/
- alpm_list_t *result = NULL;
- alpm_list_t *problems = NULL;
- PkPackageId *id = pk_package_id_new_from_string (package_ids[0]);
- pmtransflag_t flags = 0;
- GThread *progress = NULL;
-
- flags |= PM_TRANS_FLAG_NODEPS;
-
- // Next generation code?
-/*
- for (; syncdbs; syncdbs = alpm_list_next (syncdbs))
- result = alpm_list_join (result, find_packages_by_details (id->name, (pmdb_t *) syncdbs->data));
-
- if (result == NULL) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "Package not found");
- pk_backend_finished (backend);
- alpm_list_free (result);
- alpm_list_free (syncdbs);
- pk_package_id_free (id);
- return;
- }
+ pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
- for (; result; result = alpm_list_next (result))
- if (pkg_equals_to ((pmpkg_t *) result->data, id->name, id->version))
- break;
+ gchar **package_ids = pk_backend_get_strv (backend, "package_ids");
- if (!result) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "Package not found");
+ /* create a new transaction */
+ if (alpm_trans_init (PM_TRANS_TYPE_SYNC, PM_TRANS_FLAG_NODEPS, cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ());
pk_backend_finished (backend);
- alpm_list_free (result);
- alpm_list_free (syncdbs);
- pk_package_id_free (id);
- return;
+ return FALSE;
}
-*/
+ pk_debug ("alpm: %s", "transaction initialized");
- if (alpm_trans_init (PM_TRANS_TYPE_SYNC, flags, cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerror (pm_errno));
- pk_backend_finished (backend);
- alpm_list_free (result);
- pk_package_id_free (id);
- return;
+ /* add targets to the transaction */
+ int iterator;
+ for (iterator = 0; iterator < g_strv_length (package_ids); ++iterator) {
+ PkPackageId *package_id = pk_package_id_new_from_string (package_ids[iterator]);
+ if (alpm_trans_addtarget (package_id->name) == -1) {
+ pk_warning ("alpm: %s", alpm_strerrorlast ());
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ());
+ alpm_trans_release ();
+ pk_backend_finished (backend);
+ return FALSE;
+ } else
+ pk_debug ("alpm: %s added to transaction queue", package_id->name);
+ pk_package_id_free (package_id);
}
- pk_debug ("init");
-
- alpm_trans_addtarget (id->name);
+ alpm_list_t *data = NULL;
- if (alpm_trans_prepare (&problems) != 0) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerror (pm_errno));
- pk_backend_finished (backend);
+ /* prepare transaction */
+ if (alpm_trans_prepare (&data) == -1) {
+ pk_warning ("alpm: %s", alpm_strerrorlast ());
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ());
alpm_trans_release ();
- alpm_list_free (result);
- pk_package_id_free (id);
- return;
+ pk_backend_finished (backend);
+ return FALSE;
}
+ pk_debug ("alpm: %s", "transaction prepared");
- pk_backend_package (backend, PK_INFO_ENUM_DOWNLOADING, package_ids[0], "An HTML widget for GTK+ 2.0");
-
- progress = g_thread_create (state_notify, (void *) backend, TRUE, NULL);
-
- if (alpm_trans_commit (&problems) != 0) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerror (pm_errno));
- pk_backend_finished (backend);
+ /* commit transaction */
+ if (alpm_trans_commit (&data) == -1) {
+ pk_warning ("alpm: %s", alpm_strerrorlast ());
+ pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerrorlast ());
alpm_trans_release ();
- alpm_list_free (result);
- pk_package_id_free (id);
- return;
+ pk_backend_finished (backend);
+ return FALSE;
}
alpm_trans_release ();
- alpm_list_free (result);
- pk_package_id_free (id);
+ pk_debug ("alpm: %s", "transaction released");
+
pk_backend_finished (backend);
+ return TRUE;
+}
+
+/**
+ * backend_install_packages:
+ */
+static void
+backend_install_packages (PkBackend *backend, gchar **package_ids)
+{
+ pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
+
+ pk_backend_thread_create (backend, backend_install_packages_thread);
}
/**
@@ -1151,7 +1149,8 @@ backend_remove_packages_thread (PkBackend *backend)
alpm_trans_release ();
pk_backend_finished (backend);
return FALSE;
- }
+ } else
+ pk_debug ("alpm: %s added to transaction queue", package_id->name);
pk_package_id_free (package_id);
}
@@ -1165,6 +1164,7 @@ backend_remove_packages_thread (PkBackend *backend)
pk_backend_finished (backend);
return FALSE;
}
+ pk_debug ("alpm: %s", "transaction prepared");
/* commit transaction */
if (alpm_trans_commit (&data) == -1) {
commit 38ce7ff061690b251fa0e23d25b07d21bdf5c3b6
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Jun 5 20:05:52 2008 +0100
trivial: add two more steps to RELEASE
diff --git a/RELEASE b/RELEASE
index 896f644..60ebd78 100644
--- a/RELEASE
+++ b/RELEASE
@@ -15,6 +15,8 @@ $ git commit -a -m "Release version 0.2.3"
$ git tag -a -f -m "Release 0.2.3" PACKAGEKIT_0_2_3
$ git push --tags
$ git push
+$ git push git+ssh://username@git.freedesktop.org/git/packagekit
+$ git push --tags git+ssh://username@git.freedesktop.org/git/packagekit
5. Commit changes in gnome-packagekit git:
More information about the PackageKit-commit
mailing list