[PackageKit-commit] packagekit: Branch 'master' - 19 commits

Richard Hughes hughsient at kemper.freedesktop.org
Thu Apr 17 06:40:47 PDT 2008


 Makefile.am                                 |    8 ++
 backends/dummy/pk-backend-dummy.c           |   54 +++++++++--------
 backends/yum/helpers/yumBackend.py          |    7 +-
 client/pk-console.c                         |   46 +++++++++++++-
 configure.ac                                |    3 
 contrib/PackageKit.spec.in                  |    2 
 contrib/pk-completion.bash                  |    1 
 docs/html/pk-faq.html                       |    4 -
 docs/spec/pk-backend-spawn.xml              |    2 
 docs/spec/pk-introduction.xml               |   10 +--
 libpackagekit/pk-client.c                   |   86 +++++++++++++++++++++++++++-
 libpackagekit/pk-client.h                   |    4 +
 libpackagekit/pk-common.c                   |   18 +++++
 libpackagekit/pk-enum.c                     |    2 
 libpackagekit/pk-enum.h                     |    4 -
 libpackagekit/pk-package-list.c             |   10 ++-
 policy/org.freedesktop.packagekit.policy.in |   11 +++
 src/pk-backend.c                            |   78 +++++++++++++++++++++++++
 src/pk-backend.h                            |    4 +
 src/pk-engine.c                             |    4 +
 src/pk-interface-transaction.xml            |    4 +
 src/pk-security-polkit.c                    |    8 +-
 src/pk-transaction.c                        |   66 +++++++++++++++++++--
 src/pk-transaction.h                        |    5 +
 24 files changed, 387 insertions(+), 54 deletions(-)

New commits:
commit 6f598e147113ba5273df2a38caf2c3269a3132b0
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 14:16:56 2008 +0100

    add a AcceptEula on the .Transaction interface and add support into pkcon

diff --git a/client/pk-console.c b/client/pk-console.c
index 4784614..df94715 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -402,6 +402,13 @@ pk_console_finished_cb (PkClient *client, PkExitEnum exit, guint runtime, gpoint
 
 	/* have we failed to install, and the gpg key is now installed */
 	if (exit == PK_EXIT_ENUM_KEY_REQUIRED && need_requeue) {
+		pk_debug ("key now installed");
+		return;
+	}
+
+	/* have we failed to install, and the eula key is now installed */
+	if (exit == PK_EXIT_ENUM_EULA_REQUIRED && need_requeue) {
+		pk_debug ("eula now agreed");
 		return;
 	}
 
@@ -778,9 +785,13 @@ static void
 pk_console_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gchar *details, gpointer data)
 {
 	/* handled */
-	if (need_requeue && error_code == PK_ERROR_ENUM_GPG_FAILURE) {
-		pk_debug ("ignoring GPG error as handled");
-		return;
+	if (need_requeue) {
+		if (error_code == PK_ERROR_ENUM_GPG_FAILURE ||
+		    error_code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT) {
+			pk_debug ("ignoring %s error as handled", pk_error_enum_to_text (error_code));
+			return;
+		}
+		pk_warning ("set requeue, but did not handle error");
 	}
 	if (awaiting_space) {
 		g_print ("\n");
@@ -866,6 +877,7 @@ pk_console_repo_signature_required_cb (PkClient *client, const gchar *package_id
 	/* get user input */
 	import = pk_console_get_prompt (_("Okay to import key?"), FALSE);
 	if (!import) {
+		need_requeue = FALSE;
 		g_print ("%s\n", _("Did not import key, task will fail"));
 		return;
 	}
@@ -893,6 +905,8 @@ pk_console_eula_required_cb (PkClient *client, const gchar *eula_id, const gchar
 			     const gchar *vendor_name, const gchar *license_agreement, gpointer data)
 {
 	gboolean import;
+	gboolean ret;
+	GError *error = NULL;
 
 	if (awaiting_space) {
 		g_print ("\n");
@@ -906,10 +920,23 @@ pk_console_eula_required_cb (PkClient *client, const gchar *eula_id, const gchar
 	/* get user input */
 	import = pk_console_get_prompt (_("Do you agree?"), FALSE);
 	if (!import) {
+		need_requeue = FALSE;
 		g_print ("%s\n", _("Did not agree to licence, task will fail"));
 		return;
 	}
-	g_print ("Importing licences is not yet supported!\n");
+
+	/* accept eula */
+	pk_debug ("accept eula %s", eula_id);
+	ret = pk_client_accept_eula (client_signature, eula_id, &error);
+	/* we succeeded, so wait for the requeue */
+	if (!ret) {
+		pk_warning ("failed to accept eula: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+
+	/* we accepted eula */
+	need_requeue = TRUE;
 }
 
 /**
@@ -1045,6 +1072,9 @@ pk_console_get_summary (PkRoleEnum roles)
 	if (pk_enums_contain (roles, PK_ROLE_ENUM_WHAT_PROVIDES)) {
 		g_string_append_printf (string, "  %s\n", "what-provides [search]");
 	}
+	if (pk_enums_contain (roles, PK_ROLE_ENUM_ACCEPT_EULA)) {
+		g_string_append_printf (string, "  %s\n", "accept-eula [eula-id]");
+	}
 	return g_string_free (string, FALSE);
 }
 
@@ -1255,6 +1285,14 @@ main (int argc, char *argv[])
 		}
 		ret = pk_console_remove_package (client, value, &error);
 
+	} else if (strcmp (mode, "accept-eula") == 0) {
+		if (value == NULL) {
+			g_print (_("You need to specify a eula-id"));
+			goto out;
+		}
+		ret = pk_client_accept_eula (client, value, &error);
+		maybe_sync = FALSE;
+
 	} else if (strcmp (mode, "update") == 0) {
 		if (value == NULL) {
 			/* do the system update */
diff --git a/contrib/pk-completion.bash b/contrib/pk-completion.bash
index ecdf2e2..b5163ab 100755
--- a/contrib/pk-completion.bash
+++ b/contrib/pk-completion.bash
@@ -17,6 +17,7 @@
 
 
 __pkcon_commandlist="
+    accept-eula
     get-actions
     get-depends
     get-description
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index c933884..8a0eaef 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -2432,7 +2432,7 @@ pk_resolve_local_path (const gchar *rel_path)
 /**
  * pk_client_install_file:
  * @client: a valid #PkClient instance
- * @file: a file such as "/home/hughsie/Desktop/hal-devel-0.10.0.rpm"
+ * @file_rel: a file such as "/home/hughsie/Desktop/hal-devel-0.10.0.rpm"
  * @error: a %GError to put the error code and message in, or %NULL
  *
  * Install a file locally, and get the deps from the repositories.
@@ -2548,6 +2548,88 @@ pk_client_get_repo_list (PkClient *client, PkFilterEnum filters, GError **error)
 }
 
 /**
+ * pk_client_accept_eula_action:
+ **/
+static gboolean
+pk_client_accept_eula_action (PkClient *client, const gchar *eula_id, GError **error)
+{
+	gboolean ret;
+
+	g_return_val_if_fail (client != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+	/* check to see if we have a valid proxy */
+	if (client->priv->proxy == NULL) {
+		pk_client_error_set (error, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
+		return FALSE;
+	}
+	ret = dbus_g_proxy_call (client->priv->proxy, "AcceptEula", error,
+				 G_TYPE_STRING, eula_id,
+				 G_TYPE_INVALID, G_TYPE_INVALID);
+	return ret;
+}
+
+/**
+ * pk_client_accept_eula:
+ * @client: a valid #PkClient instance
+ * @eula_id: the <literal>eula_id</literal> we are agreeing to
+ * @error: a %GError to put the error code and message in, or %NULL
+ *
+ * We may want to agree to a EULA dialog if one is presented.
+ *
+ * Return value: %TRUE if the daemon queued the transaction
+ */
+gboolean
+pk_client_accept_eula (PkClient *client, const gchar *eula_id, GError **error)
+{
+	gboolean ret;
+	GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+
+	g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+	g_return_val_if_fail (eula_id != NULL, FALSE);
+
+	/* get and set a new ID */
+	ret = pk_client_allocate_transaction_id (client, error);
+	if (!ret) {
+		return FALSE;
+	}
+
+	/* save this so we can re-issue it */
+	client->priv->role = PK_ROLE_ENUM_ACCEPT_EULA;
+
+	/* hopefully do the operation first time */
+	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)) {
+		/* try to get auth */
+		if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error_pk->message)) {
+			/* clear old error */
+			g_clear_error (&error_pk);
+			/* retry the action now we have got auth */
+			ret = pk_client_accept_eula_action (client, eula_id, &error_pk);
+		}
+	}
+	/* we failed one of these, return the error to the user */
+	if (!ret) {
+		pk_client_error_fixup (&error_pk);
+		g_propagate_error (error, error_pk);
+	}
+
+	if (ret) {
+		/* allow clients to respond in the status changed callback */
+		pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
+
+		/* spin until finished */
+		if (client->priv->synchronous) {
+			g_main_loop_run (client->priv->loop);
+		}
+	}
+
+	return ret;
+}
+
+/**
  * pk_client_repo_enable_action:
  **/
 static gboolean
@@ -2631,6 +2713,8 @@ pk_client_repo_enable (PkClient *client, const gchar *repo_id, gboolean enabled,
 	return ret;
 }
 
+
+
 /**
  * pk_client_repo_set_data_action:
  **/
diff --git a/libpackagekit/pk-client.h b/libpackagekit/pk-client.h
index 2d7dfe7..2a19112 100644
--- a/libpackagekit/pk-client.h
+++ b/libpackagekit/pk-client.h
@@ -310,6 +310,10 @@ gboolean	 pk_client_cancel			(PkClient	*client,
 gboolean	 pk_client_requeue			(PkClient	*client,
 							 GError		**error)
 							 G_GNUC_WARN_UNUSED_RESULT;
+gboolean	 pk_client_accept_eula			(PkClient	*client,
+							 const gchar	*eula_id,
+							 GError		**error)
+							 G_GNUC_WARN_UNUSED_RESULT;
 
 /* repo stuff */
 gboolean	 pk_client_get_repo_list		(PkClient	*client,
diff --git a/src/pk-interface-transaction.xml b/src/pk-interface-transaction.xml
index 683da72..131eff8 100644
--- a/src/pk-interface-transaction.xml
+++ b/src/pk-interface-transaction.xml
@@ -4,6 +4,10 @@
        PackageKit 0.2.0 -->
   <interface name="org.freedesktop.PackageKit.Transaction">
 
+    <method name="AcceptEula">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="eula_id" direction="in"/>
+    </method>
     <method name="Cancel">
     </method>
     <method name="GetAllowCancel">
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 936a1e5..7877d7f 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -1079,6 +1079,56 @@ pk_transaction_priv_get_role (PkTransaction *transaction)
 }
 
 /**
+ * pk_transaction_accept_eula:
+ *
+ * This should be called when a eula_id needs to be added into an internal db.
+ **/
+void
+pk_transaction_accept_eula (PkTransaction *transaction, const gchar *eula_id, DBusGMethodInvocation *context)
+{
+	gboolean ret;
+	GError *error;
+	const gchar *exit_text;
+	gchar *sender;
+
+	g_return_if_fail (PK_IS_TRANSACTION (transaction));
+	g_return_if_fail (transaction->priv->tid != NULL);
+
+	/* check for sanity */
+	ret = pk_strvalidate (eula_id);
+	if (!ret) {
+		error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_INPUT_INVALID,
+				     "Invalid input passed to daemon");
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
+	/* check if the action is allowed from this client - if not, set an error */
+	sender = dbus_g_method_get_sender (context);
+	ret = pk_transaction_action_is_allowed (transaction, sender, PK_ROLE_ENUM_ACCEPT_EULA, &error);
+	g_free (sender);
+	if (!ret) {
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
+	pk_debug ("AcceptEula method called: %s", eula_id);
+	ret = pk_backend_accept_eula (transaction->priv->backend, eula_id);
+	if (!ret) {
+		error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_INPUT_INVALID,
+				     "EULA failed to be added");
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
+	exit_text = pk_exit_enum_to_text (PK_EXIT_ENUM_SUCCESS);
+	pk_debug ("emitting finished transaction '%s', %i", exit_text, 0);
+	g_signal_emit (transaction, signals [PK_TRANSACTION_FINISHED], 0, exit_text, 0);
+
+	dbus_g_method_return (context);
+}
+
+/**
  * pk_transaction_cancel:
  **/
 gboolean
diff --git a/src/pk-transaction.h b/src/pk-transaction.h
index b34b7fd..a3c50e2 100644
--- a/src/pk-transaction.h
+++ b/src/pk-transaction.h
@@ -95,6 +95,9 @@ gboolean	 pk_transaction_set_tid			(PkTransaction	*transaction,
 							 const gchar	*tid);
 
 /* dbus methods */
+void		 pk_transaction_accept_eula		(PkTransaction	*transaction,
+							 const gchar	*eula_id,
+							 DBusGMethodInvocation *context);
 gboolean	 pk_transaction_cancel			(PkTransaction	*transaction,
 							 GError		**error);
 gboolean	 pk_transaction_get_allow_cancel	(PkTransaction	*transaction,
commit e1ea26b84a43b71b314fcabc55dfc9fa4a9f3cb5
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 13:51:18 2008 +0100

    keep a PkSecurity instance around to avoid creating and destroying it all the time

diff --git a/src/pk-engine.c b/src/pk-engine.c
index c9b273f..c081251 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -58,6 +58,7 @@
 #include "pk-marshal.h"
 #include "pk-notify.h"
 #include "pk-restart.h"
+#include "pk-security.h"
 
 static void     pk_engine_class_init	(PkEngineClass *klass);
 static void     pk_engine_init		(PkEngine      *engine);
@@ -87,6 +88,7 @@ struct PkEnginePrivate
 	PkBackend		*backend;
 	PkInhibit		*inhibit;
 	PkNetwork		*network;
+	PkSecurity		*security;
 	PkNotify		*notify;
 	PkRestart		*restart;
 	PkRoleEnum		 actions;
@@ -488,6 +490,7 @@ pk_engine_init (PkEngine *engine)
 
 	/* we dont need this, just don't keep creating and destroying it */
 	engine->priv->network = pk_network_new ();
+	engine->priv->security = pk_security_new ();
 
 	/* create a new backend so we can get the static stuff */
 	engine->priv->actions = pk_backend_get_actions (engine->priv->backend);
@@ -571,6 +574,7 @@ pk_engine_finalize (GObject *object)
 	g_object_unref (engine->priv->transaction_list);
 	g_object_unref (engine->priv->transaction_db);
 	g_object_unref (engine->priv->network);
+	g_object_unref (engine->priv->security);
 	g_object_unref (engine->priv->notify);
 	g_object_unref (engine->priv->backend);
 	g_object_unref (engine->priv->cache);
commit 558629cdcf8f14ddcc7c45d01e537107510393c9
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 13:01:50 2008 +0100

    emit a different finished exit code if we did a EULA

diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 8269881..333cd0e 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -44,6 +44,7 @@ static PkEnumMatch enum_exit[] = {
 	{PK_EXIT_ENUM_FAILED,			"failed"},
 	{PK_EXIT_ENUM_CANCELLED,		"cancelled"},
 	{PK_EXIT_ENUM_KEY_REQUIRED,		"key-required"},
+	{PK_EXIT_ENUM_EULA_REQUIRED,		"eula-required"},
 	{PK_EXIT_ENUM_KILLED,			"killed"},
 	{0, NULL}
 };
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 3eac959..c7f5ad4 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -135,6 +135,7 @@ typedef enum {
 	PK_EXIT_ENUM_FAILED,
 	PK_EXIT_ENUM_CANCELLED,
 	PK_EXIT_ENUM_KEY_REQUIRED,
+	PK_EXIT_ENUM_EULA_REQUIRED,
 	PK_EXIT_ENUM_KILLED, /* when we forced the cancel, but had to SIGKILL */
 	PK_EXIT_ENUM_UNKNOWN
 } PkExitEnum;
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 190e925..936a1e5 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -72,7 +72,8 @@ struct PkTransactionPrivate
 	gboolean		 finished;
 	gboolean		 running;
 	gboolean		 allow_cancel;
-	gboolean		 emit_key_required;
+	gboolean		 emit_eula_required;
+	gboolean		 emit_signature_required;
 	LibGBus			*libgbus;
 	PkBackend		*backend;
 	PkInhibit		*inhibit;
@@ -437,9 +438,11 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransaction *
 	/* mark not running */
 	transaction->priv->running = FALSE;
 
-	/* if we did ::repo-signature-required, change the error code */
-	if (transaction->priv->emit_key_required) {
+	/* if we did ::repo-signature-required or ::eula-required, change the error code */
+	if (transaction->priv->emit_signature_required) {
 		exit = PK_EXIT_ENUM_KEY_REQUIRED;
+	} else if (transaction->priv->emit_eula_required) {
+		exit = PK_EXIT_ENUM_EULA_REQUIRED;
 	}
 
 	/* invalidate some caches if we succeeded*/
@@ -622,7 +625,7 @@ pk_transaction_repo_signature_required_cb (PkBackend *backend, const gchar *pack
 		       key_fingerprint, key_timestamp, type_text);
 
 	/* we should mark this transaction so that we finish with a special code */
-	transaction->priv->emit_key_required = TRUE;
+	transaction->priv->emit_signature_required = TRUE;
 }
 
 /**
@@ -642,7 +645,7 @@ pk_transaction_eula_required_cb (PkBackend *backend, const gchar *eula_id, const
 		       eula_id, package_id, vendor_name, license_agreement);
 
 	/* we should mark this transaction so that we finish with a special code */
-	transaction->priv->emit_key_required = TRUE;
+	transaction->priv->emit_eula_required = TRUE;
 }
 
 /**
@@ -2944,7 +2947,8 @@ pk_transaction_init (PkTransaction *transaction)
 	transaction->priv->finished = FALSE;
 	transaction->priv->running = FALSE;
 	transaction->priv->allow_cancel = FALSE;
-	transaction->priv->emit_key_required = FALSE;
+	transaction->priv->emit_eula_required = FALSE;
+	transaction->priv->emit_signature_required = FALSE;
 	transaction->priv->dbus_name = NULL;
 	transaction->priv->cached_enabled = FALSE;
 	transaction->priv->cached_key_id = NULL;
commit 423f4b7870b42871bc1afe3872f64836505f0849
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 12:38:50 2008 +0100

    allow adding a package with NULL summary to the packagelist

diff --git a/libpackagekit/pk-package-list.c b/libpackagekit/pk-package-list.c
index 29e3831..b0a1a71 100644
--- a/libpackagekit/pk-package-list.c
+++ b/libpackagekit/pk-package-list.c
@@ -75,7 +75,6 @@ pk_package_list_add (PkPackageList *plist, PkInfoEnum info, const gchar *package
 
 	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 (summary != NULL, FALSE);
 
 	pk_debug ("adding to cache array package %s, %s, %s", pk_info_enum_to_text (info), package_id, summary);
 	item = g_new0 (PkPackageItem, 1);
@@ -316,6 +315,15 @@ libst_package_list (LibSelfTest *test)
 	}
 	g_free (text);
 
+	/************************************************************/
+	libst_title (test, "add entry with NULL summary");
+	ret = pk_package_list_add (plist, PK_INFO_ENUM_INSTALLED, "nosummary;1.23;i386;data", NULL);
+	if (ret) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "could not add NULL summary");
+	}
+
 	libst_end (test);
 }
 #endif
commit 40080165e39e9600202a5179040153297dbe372f
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 12:30:41 2008 +0100

    check for valid UTF8 in pk_strsafe() to avoid crashing the daemon on invalid input

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 7f59ed8..36f4b99 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -231,12 +231,20 @@ gchar *
 pk_strsafe (const gchar *text)
 {
 	gchar *text_safe;
+	gboolean ret;
 	const gchar *delimiters;
 
 	if (text == NULL) {
 		return NULL;
 	}
 
+	/* is valid UTF8? */
+	ret = g_utf8_validate (text, -1, NULL);
+	if (!ret) {
+		pk_warning ("text '%s' was not valid UTF8!", text);
+		return NULL;
+	}
+
 	/* rip out any insane characters */
 	delimiters = "\\\f\n\r\t\"'";
 	text_safe = g_strdup (text);
commit d54044282fb3ca6b4c667991cfc31e7fca101944
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 12:20:45 2008 +0100

    add the PolicyKit glue in PkSecurity for accept-eula

diff --git a/src/pk-security-polkit.c b/src/pk-security-polkit.c
index f09dad7..242de66 100644
--- a/src/pk-security-polkit.c
+++ b/src/pk-security-polkit.c
@@ -117,6 +117,8 @@ pk_security_role_to_action (PkSecurity *security, PkRoleEnum role)
 		policy = "org.freedesktop.packagekit.localinstall";
 	} else if (role == PK_ROLE_ENUM_INSTALL_SIGNATURE) {
 		policy = "org.freedesktop.packagekit.install-signature";
+	} else if (role == PK_ROLE_ENUM_ACCEPT_EULA) {
+		policy = "org.freedesktop.packagekit.accept-eula";
 	} else if (role == PK_ROLE_ENUM_ROLLBACK) {
 		policy = "org.freedesktop.packagekit.rollback";
 	} else if (role == PK_ROLE_ENUM_REPO_ENABLE ||
@@ -124,8 +126,6 @@ pk_security_role_to_action (PkSecurity *security, PkRoleEnum role)
 		policy = "org.freedesktop.packagekit.repo-change";
 	} else if (role == PK_ROLE_ENUM_REFRESH_CACHE) {
 		policy = "org.freedesktop.packagekit.refresh-cache";
-	} else {
-		pk_warning ("policykit type required for '%s'", pk_role_enum_to_text (role));
 	}
 	return policy;
 }
@@ -148,6 +148,10 @@ pk_security_action_is_allowed (PkSecurity *security, const gchar *dbus_sender,
 
 	/* map the roles to policykit rules */
 	policy = pk_security_role_to_action (security, role);
+	if (policy == NULL) {
+		pk_warning ("policykit type required for '%s'", pk_role_enum_to_text (role));
+		return FALSE;
+	}
 
 	/* get the dbus sender */
 	pk_result = pk_security_can_do_action (security, dbus_sender, policy);
commit dcda5d039c0805bb183a7edda3d0064a176f19d1
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 12:17:24 2008 +0100

    dummy: check eula status before emitting

diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index bb833c2..b9f983b 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -142,7 +142,7 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
 	g_return_if_fail (backend != NULL);
 	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
 	pk_backend_description (backend, "gnome-power-manager;2.6.19;i386;fedora", "GPL2", PK_GROUP_ENUM_PROGRAMMING,
-"Scribus is an desktop open source page layout program with "
+"Scribus is an desktop open source page layöut program with "
 "the aim of producing commercial grade output in PDF and "
 "Postscript, primarily, though not exclusively for Linux.\n"
 "\n"
@@ -305,6 +305,7 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 	g_return_if_fail (backend != NULL);
 	const gchar *license_agreement;
 	const gchar *eula_id;
+	gboolean has_eula;
 
 	if (pk_strequal (package_id, "vips-doc;7.12.4-2.fc8;noarch;linva")) {
 		if (!_has_signature) {
@@ -320,30 +321,33 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 			return;
 		}
 		eula_id = "eula_hughsie_dot_com";
-		license_agreement = "Narrator: In A.D. 2101, war was beginning.\n"
-				    "Captain: What happen ?\n"
-				    "Mechanic: Somebody set up us the bomb.\n\n"
-				    "Operator: We get signal.\n"
-				    "Captain: What !\n"
-				    "Operator: Main screen turn on.\n"
-				    "Captain: It's you !!\n"
-				    "CATS: How are you gentlemen !!\n"
-				    "CATS: All your base are belong to us.\n"
-				    "CATS: You are on the way to destruction.\n\n"
-				    "Captain: What you say !!\n"
-				    "CATS: You have no chance to survive make your time.\n"
-				    "CATS: Ha Ha Ha Ha ....\n\n"
-				    "Operator: Captain!! *\n"
-				    "Captain: Take off every 'ZIG' !!\n"
-				    "Captain: You know what you doing.\n"
-				    "Captain: Move 'ZIG'.\n"
-				    "Captain: For great justice.\n";
-		pk_backend_eula_required (backend, eula_id, package_id,
-					  "CATS Inc.", license_agreement);
-		pk_backend_error_code (backend, PK_ERROR_ENUM_NO_LICENSE_AGREEMENT,
-				       "licence not installed so cannot install");
-		pk_backend_finished (backend);
-		return;
+		has_eula = pk_backend_is_eula_valid (backend, eula_id);
+		if (!has_eula) {
+			license_agreement = "Narrator: In A.D. 2101, war was beginning.\n"
+					    "Captain: What happen ?\n"
+					    "Mechanic: Somebody set up us the bomb.\n\n"
+					    "Operator: We get signal.\n"
+					    "Captain: What !\n"
+					    "Operator: Main screen turn on.\n"
+					    "Captain: It's you !!\n"
+					    "CATS: How are you gentlemen !!\n"
+					    "CATS: All your base are belong to us.\n"
+					    "CATS: You are on the way to destruction.\n\n"
+					    "Captain: What you say !!\n"
+					    "CATS: You have no chance to survive make your time.\n"
+					    "CATS: Ha Ha Ha Ha ....\n\n"
+					    "Operator: Captain!! *\n"
+					    "Captain: Take off every 'ZIG' !!\n"
+					    "Captain: You know what you doing.\n"
+					    "Captain: Move 'ZIG'.\n"
+					    "Captain: For great justice.\n";
+			pk_backend_eula_required (backend, eula_id, package_id,
+						  "CATS Inc.", license_agreement);
+			pk_backend_error_code (backend, PK_ERROR_ENUM_NO_LICENSE_AGREEMENT,
+					       "licence not installed so cannot install");
+			pk_backend_finished (backend);
+			return;
+		}
 	}
 
 	pk_backend_set_allow_cancel (backend, TRUE);
commit 7727a61e1b3aeaf65e887967724eac77e66ea3ce
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 12:15:54 2008 +0100

    add pk_backend_accept_eula and pk_backend_is_eula_valid

diff --git a/src/pk-backend.c b/src/pk-backend.c
index d798b72..6ba4073 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -80,6 +80,7 @@ struct _PkBackendPrivate
 {
 	GModule			*handle;
 	PkTime			*time;
+	GHashTable		*eulas;
 	gchar			*name;
 	gchar			*c_tid;
 	gboolean		 locked;
@@ -1312,6 +1313,45 @@ pk_backend_set_current_tid (PkBackend *backend, const gchar *tid)
 }
 
 /**
+ * pk_backend_accept_eula:
+ */
+gboolean
+pk_backend_accept_eula (PkBackend *backend, const gchar *eula_id)
+{
+	gpointer present;
+
+	g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
+	g_return_val_if_fail (eula_id != NULL, FALSE);
+
+	pk_debug ("eula_id %s", eula_id);
+	present = g_hash_table_lookup (backend->priv->eulas, eula_id);
+	if (present != NULL) {
+		pk_debug ("already added %s to accepted list", eula_id);
+		return FALSE;
+	}
+	g_hash_table_insert (backend->priv->eulas, g_strdup (eula_id), GINT_TO_POINTER (1));
+	return TRUE;
+}
+
+/**
+ * pk_backend_is_eula_valid:
+ */
+gboolean
+pk_backend_is_eula_valid (PkBackend *backend, const gchar *eula_id)
+{
+	gpointer present;
+
+	g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
+	g_return_val_if_fail (eula_id != NULL, FALSE);
+
+	present = g_hash_table_lookup (backend->priv->eulas, eula_id);
+	if (present != NULL) {
+		return TRUE;
+	}
+	return FALSE;
+}
+
+/**
  * pk_backend_finalize:
  **/
 static void
@@ -1325,6 +1365,7 @@ pk_backend_finalize (GObject *object)
 
 	g_object_unref (backend->priv->time);
 	g_object_unref (backend->priv->inhibit);
+	g_hash_table_destroy (backend->priv->eulas);
 
 	/* do finish now, as we might be unreffing quickly */
 	if (backend->priv->signal_finished != 0) {
@@ -1477,6 +1518,7 @@ pk_backend_init (PkBackend *backend)
 	backend->priv->during_initialize = FALSE;
 	backend->priv->time = pk_time_new ();
 	backend->priv->inhibit = pk_inhibit_new ();
+	backend->priv->eulas = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 	pk_backend_reset (backend);
 }
 
@@ -1548,6 +1590,42 @@ libst_backend (LibSelfTest *test)
 	g_signal_connect (backend, "finished", G_CALLBACK (pk_backend_test_finished_cb), test);
 
 	/************************************************************/
+	libst_title (test, "get eula that does not exist");
+	ret = pk_backend_is_eula_valid (backend, "license_foo");
+	if (!ret) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "eula valid");
+	}
+
+	/************************************************************/
+	libst_title (test, "accept eula");
+	ret = pk_backend_accept_eula (backend, "license_foo");
+	if (ret) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "eula was not accepted");
+	}
+
+	/************************************************************/
+	libst_title (test, "get eula that does exist");
+	ret = pk_backend_is_eula_valid (backend, "license_foo");
+	if (ret) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "eula valid");
+	}
+
+	/************************************************************/
+	libst_title (test, "accept eula (again)");
+	ret = pk_backend_accept_eula (backend, "license_foo");
+	if (!ret) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "eula was accepted twice");
+	}
+
+	/************************************************************/
 	libst_title (test, "get backend name");
 	text = pk_backend_get_name (backend);
 	if (text == NULL) {
diff --git a/src/pk-backend.h b/src/pk-backend.h
index b6065cf..20fa743 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -35,6 +35,10 @@ typedef struct _PkBackend PkBackend;
 /* set the state */
 gboolean	 pk_backend_set_current_tid		(PkBackend	*backend,
 							 const gchar	*tid);
+gboolean	 pk_backend_accept_eula			(PkBackend	*backend,
+							 const gchar	*eula_id);
+gboolean	 pk_backend_is_eula_valid		(PkBackend	*backend,
+							 const gchar	*eula_id);
 gboolean	 pk_backend_set_role			(PkBackend	*backend,
 							 PkRoleEnum	 role);
 gboolean	 pk_backend_set_status			(PkBackend	*backend,
commit 3f258a68e4dcedbbcd28d426464f2c778fef68e2
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 12:15:12 2008 +0100

    add a role to allow us to accept a eula

diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 559c431..8269881 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -101,6 +101,7 @@ static PkEnumMatch enum_role[] = {
 	{PK_ROLE_ENUM_UPDATE_PACKAGES,		"update-package"},
 	{PK_ROLE_ENUM_UPDATE_SYSTEM,		"update-system"},
 	{PK_ROLE_ENUM_WHAT_PROVIDES,		"what-provides"},
+	{PK_ROLE_ENUM_ACCEPT_EULA,		"accept-eula"},
 	{0, NULL}
 };
 
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index fcd5460..3eac959 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -77,7 +77,8 @@ typedef enum {
 	PK_ROLE_ENUM_UPDATE_PACKAGES		= 1 << 23,
 	PK_ROLE_ENUM_UPDATE_SYSTEM		= 1 << 24,
 	PK_ROLE_ENUM_WHAT_PROVIDES		= 1 << 25,
-	PK_ROLE_ENUM_UNKNOWN			= 1 << 26
+	PK_ROLE_ENUM_ACCEPT_EULA		= 1 << 26,
+	PK_ROLE_ENUM_UNKNOWN			= 1 << 27
 } PkRoleEnum;
 
 /**
commit b409d8a8ba9cda291a8b5d75a32dc139b2252932
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 12:14:14 2008 +0100

    trivial formatting fix

diff --git a/src/pk-transaction.h b/src/pk-transaction.h
index 50cb738..b34b7fd 100644
--- a/src/pk-transaction.h
+++ b/src/pk-transaction.h
@@ -201,7 +201,7 @@ void		 pk_transaction_search_name		(PkTransaction	*transaction,
 							 const gchar	*filter,
 							 const gchar	*search,
 							 DBusGMethodInvocation *context);
-gboolean	 pk_transaction_service_pack			(PkTransaction	*transaction,
+gboolean	 pk_transaction_service_pack		(PkTransaction	*transaction,
 							 const gchar	*location,
 							 gboolean	 enabled);
 void		 pk_transaction_update_packages		(PkTransaction	*transaction,
commit 199e473c6687cb3c7cf3fdaf5fc82570d17f65d1
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 12:11:39 2008 +0100

    add a self test to show shaas

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 475aff2..7f59ed8 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -1173,7 +1173,7 @@ libst_common (LibSelfTest *test)
 	/************************************************************/
 	libst_title (test, "test replace UTF8 unsafe (okay)");
 	text_safe = pk_strsafe ("Gölas");
-	if (pk_strequal (text_safe, "Richard Hughes")) {
+	if (pk_strequal (text_safe, "Gölas")) {
 		libst_success (test, NULL);
 	} else {
 		libst_failed (test, "failed the replace unsafe '%s'", text_safe);
commit 204556c9dc76047798984a6eaafb8d49b322639e
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 12:09:35 2008 +0100

    add a self test to show shaas

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 841ee38..475aff2 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -1171,6 +1171,16 @@ libst_common (LibSelfTest *test)
 	g_free (text_safe);
 
 	/************************************************************/
+	libst_title (test, "test replace UTF8 unsafe (okay)");
+	text_safe = pk_strsafe ("Gölas");
+	if (pk_strequal (text_safe, "Richard Hughes")) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "failed the replace unsafe '%s'", text_safe);
+	}
+	g_free (text_safe);
+
+	/************************************************************/
 	libst_title (test, "test replace unsafe (one invalid)");
 	text_safe = pk_strsafe ("Richard\tHughes");
 	if (pk_strequal (text_safe, "Richard Hughes")) {
commit 54f2cbaa701b0f2e8bc3fb31234983dedb045e1c
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 12:05:51 2008 +0100

    add in a PolicyKit action for accept-eula

diff --git a/policy/org.freedesktop.packagekit.policy.in b/policy/org.freedesktop.packagekit.policy.in
index 0de231a..701a866 100644
--- a/policy/org.freedesktop.packagekit.policy.in
+++ b/policy/org.freedesktop.packagekit.policy.in
@@ -46,6 +46,17 @@
     </defaults>
   </action>
 
+  <action id="org.freedesktop.packagekit.accept-eula">
+    <_description>Accept EULA</_description>
+    <_message>System policy prevents accepting EULA</_message>
+    <icon_name>pk-package-add</icon_name>
+    <vendor_url>http://www.packagekit.org/pk-reference.html#methods-accept-eula</vendor_url>
+    <defaults>
+      <allow_inactive>no</allow_inactive>
+      <allow_active>auth_admin_keep_always</allow_active>
+    </defaults>
+  </action>
+
   <action id="org.freedesktop.packagekit.update-package">
     <_description>Update package</_description>
     <_message>System policy prevents updating package</_message>
commit 44c38dd4dfddfa981b59f382ac9655de633b13ab
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 17 10:10:52 2008 +0100

    disable local when building distcheck and the RPM

diff --git a/Makefile.am b/Makefile.am
index 3d00bbd..460040b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -93,5 +93,11 @@ EXTRA_DIST =						\
         intltool-update.in				\
 	$(NULL)
 
-DISTCHECK_CONFIGURE_FLAGS = --disable-gcov --enable-gtk-doc --with-security-framework=dummy --disable-developer
+DISTCHECK_CONFIGURE_FLAGS = 				\
+	--disable-gcov					\
+	--enable-gtk-doc				\
+	--with-security-framework=dummy			\
+	--disable-developer				\
+	--disable-local					\
+	$(NULL)
 
diff --git a/contrib/PackageKit.spec.in b/contrib/PackageKit.spec.in
index d543766..c8b08ff 100644
--- a/contrib/PackageKit.spec.in
+++ b/contrib/PackageKit.spec.in
@@ -87,7 +87,7 @@ Headers and libraries for PackageKit.
 %setup -q
 
 %build
-%configure --enable-yum --enable-yum2 --with-default-backend=yum
+%configure --enable-yum --enable-yum2 --with-default-backend=yum --disable-local
 
 make %{?_smp_mflags}
 
commit 1872ffe7d298283f39db29e49db8ab4159ec655a
Author: Scott Reeves <sreeves at novell.com>
Date:   Wed Apr 16 16:59:26 2008 -0600

    The generated code (docs/api/PackageKit-scan.c) does not compile with this flag set

diff --git a/configure.ac b/configure.ac
index 68b5afc..073a445 100755
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,8 @@ dnl - Extra verbose warning switches
 dnl ---------------------------------------------------------------------------
 if test "$GCC" = "yes"; then
 	CPPFLAGS="$CPPFLAGS -Werror -Wcast-align -Wno-uninitialized"
-	CPPFLAGS="$CPPFLAGS -Wall -Wformat-security"
+#	CPPFLAGS="$CPPFLAGS -Wall -Wformat-security"
+	CPPFLAGS="$CPPFLAGS -Wall"
 fi
 
 dnl ---------------------------------------------------------------------------
commit fcede2e3426badd09e757d81af52f6f7c46dd40f
Merge: 85c11ff... 7d85024...
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Wed Apr 16 13:13:54 2008 -0400

    Merge branch 'master' of git+ssh://rnorwood@git.packagekit.org/srv/git/PackageKit

commit 85c11ff4021250d0d6e46f613749828d10b83e78
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Wed Apr 16 13:07:49 2008 -0400

    Fix some error messages.

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 1e97002..c462242 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -232,7 +232,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 try:
                     func(*args, **kwargs)
                 except yum.Errors.RepoError, e:
-                    self.error(ERROR_NO_CACHE,"Package cache is invalid and could not be rebuilt .")
+                    self.error(ERROR_NO_CACHE,"Package cache is invalid and could not be rebuilt.")
 
         return wrapper
 
@@ -1386,9 +1386,10 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         to packagekit.
         Overload this method if you what handle special Tracebacks
         '''
-        if issubclass(tb, (yum.Errors.RepoError, IOError)):
+        if issubclass(tb, yum.Errors.RepoError):
             # Unhandled Repo error, can be network problems
-            self.error(ERROR_REPO_NOT_AVAILABLE, "Problem connecting to repository, this can be caused by network problems or a misconfigured repository")
+            
+            self.error(ERROR_REPO_NOT_AVAILABLE, "Problem connecting to software source.  This can be caused by network problems or a misconfiguration.")
             return True
         else: # Do the default stuff
             return False
commit 7d850249c34f6e72c84ee331f7471a362bc90c45
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Apr 16 17:17:33 2008 +0100

    add a reference to debian policy and stdin - provided by Rahul, thanks.

diff --git a/docs/html/pk-faq.html b/docs/html/pk-faq.html
index 44367d5..857f0c3 100644
--- a/docs/html/pk-faq.html
+++ b/docs/html/pk-faq.html
@@ -28,7 +28,7 @@
 <li><a href="#remaining-times">Why are the remaining times sometimes wildly wrong?</a></li>
 <li><a href="#different-options">How will PackageKit support all the different options?</a></li>
 <li><a href="#error-codes">Error codes are different on each backend?</a></li>
-<li><a href="#user-interaction">Installation an application that needs user interaction?</a></li>
+<li><a href="#user-interaction">Installing packages needs user interaction!</a></li>
 <li><a href="#up2date">Does PackageKit replace up2date?</a></li>
 <li><a href="#system-daemon">Is PackageKit a system daemon, always running and using resources?</a></li>
 <li><a href="#dependencies">How does PackageKit handle dependencies?</a></li>
@@ -669,6 +669,8 @@ EULAs should preferably be shown per-user - i.e. the first time an application i
 <p>
 PackageKit will not install packages with broken maintainer scripts that
 require a stdin.
+<a href="http://www.debian.org/doc/debian-policy/ch-binary.html#s-maintscriptprompt">Debian</a>
+policy clearly says that prompting on <code>stdin</code> instead of using debconf is deprecated.
 If this is attempted the backend should detect this and error out of the
 transaction with <code>PK_ERROR_ENUM_BROKEN_PACKAGE</code>.
 <b>We cannot and will not ask the user for random standard input.</b>
commit 3dfc66d641ed6d94028c832881e8c1acc4757af0
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Apr 16 11:47:59 2008 +0100

    correct a few typos in the documentation

diff --git a/docs/spec/pk-backend-spawn.xml b/docs/spec/pk-backend-spawn.xml
index 7c73e59..c6610f3 100644
--- a/docs/spec/pk-backend-spawn.xml
+++ b/docs/spec/pk-backend-spawn.xml
@@ -59,7 +59,7 @@
     <title>Methods</title>
     <para>
       The following methods are mapped from the helper to comand line programs
-      in the compile helper.
+      in the spawn helper.
     </para>
     <informaltable>
       <tgroup cols="2">
diff --git a/docs/spec/pk-introduction.xml b/docs/spec/pk-introduction.xml
index 776c553..affb2ae 100644
--- a/docs/spec/pk-introduction.xml
+++ b/docs/spec/pk-introduction.xml
@@ -42,7 +42,7 @@
       A backend is just a compiled <literal>.so</literal> object that is
       loaded at run-time and provides an interface to the underlying package
       commands.
-      A backend converts an async request into either a new thread
+      A backend converts an asynchronous request into either a new thread
       in the same process, executes external "glue" files that
       can be written in any language, or uses DBUS to signal a
       daemon process to handle the request.
@@ -54,14 +54,14 @@
       elements for those commands.
       Please see the <literal>html/pk-faq.html</literal> file for the current
       status of the existing backends.
-      Backend maintainers, please keep this file updated.
+      Backed maintainers, please keep this file updated.
     </para>
   </sect1>
 
   <sect1 id="config-main">
     <title>Daemon Config Options</title>
     <para>
-      The config file <literal>/etc/PackageKit.conf</literal> allows to the
+      The config file <literal>/etc/PackageKit/PackageKit.conf</literal> allows to the
       administrator to change system daemon options.
       In normal use this file does not have to be changed, but it may be
       useful to people debugging the daemon or developing backends.
@@ -72,8 +72,8 @@
     <sect2 id="config-main-logging">
       <title>TransactionLogging</title>
       <para>
-        This logs all transactions to a database so old transactions can be
-        viewed, and rollbacks can be done.
+        This logs all transactions to <literal>/var/log/PackageKit</literal> so old
+        daemon debugging output can be observed.
       </para>
     </sect2>
     <sect2 id="config-main-timeout">


More information about the PackageKit-commit mailing list