[packagekit] packagekit: Branch 'master' - 3 commits

Richard Hughes hughsient at kemper.freedesktop.org
Thu Oct 4 15:19:11 PDT 2007


 backends/dummy/pk-backend-dummy.c |   10 +++++++
 client/pk-console.c               |   20 ++++++++++++++
 docs/backends.xml                 |    5 +++
 docs/introduction.xml             |   53 ++++++++++++++++++++++++++++++++++++++
 libpackagekit/pk-client.c         |   40 ++++++++++++++++++++++++++++
 libpackagekit/pk-enum.c           |   22 +++++++++++++++
 libpackagekit/pk-enum.h           |    7 +++++
 src/pk-backend.c                  |   25 +++++++++++++++++
 src/pk-backend.h                  |    7 +++++
 src/pk-engine.c                   |   35 +++++++++++++++++++++++++
 src/pk-interface.xml              |    9 ++++++
 src/pk-marshal.list               |    1 
 12 files changed, 234 insertions(+)

New commits:
diff-tree b73181810bfe2dae0504ef11a107271775aee146 (from 3388293fe57d496212623e4aa6057f2c3d3a48b5)
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Thu Oct 4 16:47:53 2007 -0400

    Add documentation for the RepoSignatureRequired signal

diff --git a/docs/backends.xml b/docs/backends.xml
index 059cb23..62d23d0 100644
--- a/docs/backends.xml
+++ b/docs/backends.xml
@@ -174,6 +174,11 @@
             <entry><literal>package_id[tab]updates[tab]obsoletes[tab]url[tab]restart[tab]update_text</literal></entry>
             <entry><literal>stdout</literal></entry>
           </row>
+          <row>
+            <entry>RepoSignatureRequired</entry>
+            <entry><literal>repository_name[tab]key_url[tab]key_userid[tab]key_id[tab]key_timestamp[tab]type</literal></entry>
+            <entry><literal>stdout</literal></entry>
+          </row>
         </tbody>
       </tgroup>
     </informaltable>
diff --git a/docs/introduction.xml b/docs/introduction.xml
index 995fbcd..5df7e1e 100644
--- a/docs/introduction.xml
+++ b/docs/introduction.xml
@@ -1453,6 +1453,59 @@
         </tgroup>
       </informaltable>
     </sect2>
+
+    <sect2 id="backends-spawn-repo-signature-required">
+      <title>RepoSignatureRequired</title>
+      <para>
+        Some backends support repositories which use a cryptographic
+        signature, such as GPG.  If a package cannot be installed
+        because it is signed with a key that has not been verified,
+        this signal is generated so the user can choose to accept or
+        decline the key.
+      </para>
+      <para>
+        This signal includes information that can be used to verify
+        that the key should be trusted, such as a URL for the company
+        or person who owns the key, the key's ID, the userid of
+        the key creator, and the date the key was generated.
+      </para>
+      <informaltable>
+        <tgroup cols="2">
+          <thead>
+            <row>
+              <entry>Option</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>repository_name</literal></entry>
+              <entry>The name of the repository associated with the provided key</entry>
+            </row>
+            <row>
+              <entry><literal>key_url</literal></entry>
+              <entry>The URL provided with the key.</entry>
+            </row>
+            <row>
+              <entry><literal>key_userid</literal></entry>
+              <entry>The user id associated with the key</entry>
+            </row>
+            <row>
+              <entry><literal>key_id</literal></entry>
+              <entry>A unique identifier for the key</entry>
+            </row>
+            <row>
+              <entry><literal>key_timestamp</literal></entry>
+              <entry>The date the key was created</entry>
+            </row>
+            <row>
+              <entry><literal>type</literal></entry>
+              <entry>The type of signature used.  'GPG', for example.</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </informaltable>
+    </sect2>
   </sect1>
 
 </chapter>
diff-tree 3388293fe57d496212623e4aa6057f2c3d3a48b5 (from parents)
Merge: ee4c8b720d9fe1b6a0b90b043ec72ebe59985292 e8d632dd0c64f9dfb1e25e433f3498dc21ac1ec2
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Thu Oct 4 14:57:54 2007 -0400

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

diff-tree ee4c8b720d9fe1b6a0b90b043ec72ebe59985292 (from f416cd5a679db256d666df03c90ea6c35b531472)
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Thu Oct 4 14:56:27 2007 -0400

    Add RepoSignatureRequired call to backend, engine, and client modules.
    For now only supported in the dummy backend.  Yum backend support to
    follow after I figure out how to do it.

diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 215b124..f0e986d 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -196,6 +196,16 @@ static void
 backend_install_package (PkBackend *backend, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
+
+	if(strcmp(package_id,"signedpackage;1.0-1.fc8;i386;fedora") == 0) {
+		pk_backend_repo_signature_required(backend, "updates", "http://example.com/gpgkey",
+						   "Test Key (Fedora) fedora at example.com",
+						   "BB7576AC", "2007-10-04", PK_SIGTYPE_ENUM_GPG);
+		pk_backend_error_code (backend, PK_ERROR_ENUM_GPG_FAILURE,
+				       "GPG signed package could not be verified");
+		pk_backend_finished (backend);
+	}
+
 	progress_percentage = 0;
 	pk_backend_package (backend, PK_INFO_ENUM_DOWNLOADING,
 			    "gtkhtml2;2.19.1-4.fc8;i386;fedora",
diff --git a/client/pk-console.c b/client/pk-console.c
index c358183..e35fbbd 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -421,6 +421,24 @@ pk_console_description_cb (PkClient *cli
 }
 
 /**
+ * pk_console_repo_signature_required_cb:
+ **/
+static void
+pk_console_repo_signature_required_cb (PkClient *client, const gchar *repository_name, const gchar *key_url,
+				       const gchar *key_userid, const gchar *key_id, const gchar *key_timestamp,
+				       PkSigTypeEnum type, gpointer data)
+{
+	g_print ("Signature Required\n");
+	g_print ("  repo name:     '%s'\n", repository_name);
+	g_print ("  key url:       '%s'\n", key_url);
+	g_print ("  key userid:    '%s'\n", key_userid);
+	g_print ("  key id:        '%s'\n", key_id);
+	g_print ("  key timestamp: '%s'\n", key_timestamp);
+	g_print ("  key type:      '%s'\n", pk_sig_type_enum_to_text (type));
+
+}
+
+/**
  * main:
  **/
 int
@@ -462,6 +480,8 @@ main (int argc, char *argv[])
 			  G_CALLBACK (pk_console_transaction_cb), NULL);
 	g_signal_connect (client, "description",
 			  G_CALLBACK (pk_console_description_cb), NULL);
+	g_signal_connect (client, "repo-signature-required",
+			  G_CALLBACK (pk_console_repo_signature_required_cb), NULL);
 	g_signal_connect (client, "update-detail",
 			  G_CALLBACK (pk_console_update_detail_cb), NULL);
 	g_signal_connect (client, "percentage-changed",
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index cfe5863..db3b55b 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -74,6 +74,7 @@ typedef enum {
 	PK_CLIENT_TRANSACTION,
 	PK_CLIENT_TRANSACTION_STATUS_CHANGED,
 	PK_CLIENT_UPDATE_DETAIL,
+	PK_CLIENT_REPO_SIGNATURE_REQUIRED,
 	PK_CLIENT_LAST_SIGNAL
 } PkSignals;
 
@@ -424,6 +425,25 @@ pk_client_description_cb (DBusGProxy  *p
 }
 
 /**
+ * pk_client_repo_signature_required_cb:
+ **/
+static void
+pk_client_repo_signature_required_cb (DBusGProxy *proxy, const gchar *tid, const gchar *repository_name,
+				      const gchar *key_url, const gchar *key_userid, const gchar *key_id, 
+				      const gchar *key_timestamp, const gchar *type_text, PkClient *client)
+{
+	g_return_if_fail (client != NULL);
+	g_return_if_fail (PK_IS_CLIENT (client));
+	
+	if (pk_transaction_id_equal (tid, client->priv->tid) == TRUE) {
+		pk_debug ("emit repo_signature_required tid:%s, %s, %s, %s, %s, %s, %s",
+			  tid, repository_name, key_url, key_userid, key_id, key_timestamp, type_text);
+		g_signal_emit (client, signals [PK_CLIENT_REPO_SIGNATURE_REQUIRED], 0,
+			       repository_name, key_url, key_userid, key_id, key_timestamp, type_text);
+	}
+}
+
+/**
  * pk_client_error_code_cb:
  */
 static void
@@ -1701,6 +1721,12 @@ pk_client_class_init (PkClientClass *kla
 			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_UINT_STRING_STRING_UINT64_STRING,
 			      G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING,
 			      G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_STRING);
+	signals [PK_CLIENT_REPO_SIGNATURE_REQUIRED] =
+		g_signal_new ("repo-signature-required",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_UINT,
+			      G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+			      G_TYPE_STRING, G_TYPE_UINT);
 	signals [PK_CLIENT_ERROR_CODE] =
 		g_signal_new ("error-code",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
@@ -1805,6 +1831,11 @@ pk_client_init (PkClient *client)
 					   G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64,
 					   G_TYPE_STRING, G_TYPE_INVALID);
 
+	/* Repo Signature Required */
+	dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING_STRING,
+					   G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+					   G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+
 	/* Package */
 	dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING,
 					   G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
@@ -1872,6 +1903,13 @@ pk_client_init (PkClient *client)
 	dbus_g_proxy_connect_signal (proxy, "Description",
 				     G_CALLBACK (pk_client_description_cb), client, NULL);
 
+	dbus_g_proxy_add_signal (proxy, "RepoSignatureRequired",
+				 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+				 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+				 G_TYPE_STRING, G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (proxy, "RepoSignatureRequired",
+				     G_CALLBACK (pk_client_repo_signature_required_cb), client, NULL);
+
 	dbus_g_proxy_add_signal (proxy, "ErrorCode",
 				 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
 	dbus_g_proxy_connect_signal (proxy, "ErrorCode",
@@ -1914,6 +1952,8 @@ pk_client_finalize (GObject *object)
 				        G_CALLBACK (pk_client_transaction_cb), client);
 	dbus_g_proxy_disconnect_signal (client->priv->proxy, "Description",
 				        G_CALLBACK (pk_client_description_cb), client);
+	dbus_g_proxy_disconnect_signal (client->priv->proxy, "RepoSignatureRequired",
+				        G_CALLBACK (pk_client_repo_signature_required_cb), client);
 	dbus_g_proxy_disconnect_signal (client->priv->proxy, "ErrorCode",
 				        G_CALLBACK (pk_client_error_code_cb), client);
 	dbus_g_proxy_disconnect_signal (client->priv->proxy, "RequireRestart",
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 4adc7ab..184dd9c 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -155,6 +155,10 @@ static PkTaskEnumMatch task_info[] = {
 	{0, NULL},
 };
 
+static PkTaskEnumMatch task_sig_type[] = {
+	{PK_SIGTYPE_ENUM_GPG,                   "gpg"},
+};
+
 /**
  * pk_task_enum_find_value:
  */
@@ -204,6 +208,24 @@ pk_task_enum_find_string (PkTaskEnumMatc
 }
 
 /**
+ * pk_sig_type_enum_from_text:
+ */
+PkSigTypeEnum
+pk_sig_type_enum_from_text (const gchar *sig_type)
+{
+	return pk_task_enum_find_value (task_sig_type, sig_type);
+}
+
+/**
+ * pk_sig_type_enum_to_text:
+ **/
+const gchar *
+pk_sig_type_enum_to_text (PkSigTypeEnum sig_type)
+{
+	return pk_task_enum_find_string (task_sig_type, sig_type);
+}
+
+/**
  * pk_info_enum_from_text:
  */
 PkInfoEnum
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index bddda8b..667f8ad 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -143,6 +143,13 @@ typedef enum {
 	PK_INFO_ENUM_UNKNOWN
 } PkInfoEnum;
 
+typedef enum {
+	PK_SIGTYPE_ENUM_GPG
+} PkSigTypeEnum;
+
+PkSigTypeEnum    pk_sig_type_enum_from_text             (const gchar    *sig_type);
+const gchar     *pk_sig_type_enum_to_text               (PkSigTypeEnum   sig_type);
+
 PkInfoEnum	 pk_info_enum_from_text			(const gchar	*info);
 const gchar	*pk_info_enum_to_text			(PkInfoEnum	 info);
 
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 28c353d..9d6ff61 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -91,6 +91,7 @@ enum {
 	PK_BACKEND_UPDATE_DETAIL,
 	PK_BACKEND_ERROR_CODE,
 	PK_BACKEND_UPDATES_CHANGED,
+	PK_BACKEND_REPO_SIGNATURE_REQUIRED,
 	PK_BACKEND_REQUIRE_RESTART,
 	PK_BACKEND_FINISHED,
 	PK_BACKEND_ALLOW_INTERRUPT,
@@ -760,6 +761,24 @@ pk_backend_updates_changed (PkBackend *b
 }
 
 /**
+ * pk_backend_repo_signature_required:
+ **/
+gboolean
+pk_backend_repo_signature_required (PkBackend *backend, const gchar *repository_name, const gchar *key_url,
+				    const gchar *key_userid, const gchar *key_id, const gchar *key_timestamp,
+				    PkSigTypeEnum type)
+{
+	g_return_val_if_fail (backend != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
+
+	pk_debug ("emit repo-signature-required %s, %s, %s, %s, %s, %i",
+		  repository_name, key_url, key_userid, key_id, key_timestamp, type);
+	g_signal_emit (backend, signals [PK_BACKEND_REPO_SIGNATURE_REQUIRED], 0,
+		       repository_name, key_url, key_userid, key_id, key_timestamp, type);
+	return TRUE;
+}
+
+/**
  * pk_backend_error_code:
  **/
 gboolean
@@ -1498,6 +1517,12 @@ pk_backend_class_init (PkBackendClass *k
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
 			      0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
 			      G_TYPE_NONE, 0);
+	signals [PK_BACKEND_REPO_SIGNATURE_REQUIRED] =
+		g_signal_new ("repo-signature-required",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING,
+			      G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+			      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
 	signals [PK_BACKEND_FINISHED] =
 		g_signal_new ("finished",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-backend.h b/src/pk-backend.h
index 64a25fb..52387c2 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -68,6 +68,13 @@ gboolean	 pk_backend_error_code			(PkBac
 							 guint		 code,
 							 const gchar	*details, ...);
 gboolean	 pk_backend_updates_changed		(PkBackend	*backend);
+gboolean         pk_backend_repo_signature_required     (PkBackend      *backend,
+							 const gchar    *repository_name,
+							 const gchar    *key_url,
+							 const gchar    *key_userid,
+							 const gchar    *key_id,
+							 const gchar    *key_timestamp,
+							 PkSigTypeEnum   type);
 gboolean	 pk_backend_spawn_helper		(PkBackend	*backend,
 							 const gchar	*script, ...);
 gboolean	 pk_backend_spawn_kill			(PkBackend	*backend);
diff --git a/src/pk-engine.c b/src/pk-engine.c
index c0cbe37..db52827 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -79,6 +79,7 @@ enum {
 	PK_ENGINE_ERROR_CODE,
 	PK_ENGINE_REQUIRE_RESTART,
 	PK_ENGINE_UPDATES_CHANGED,
+	PK_ENGINE_REPO_SIGNATURE_REQUIRED,
 	PK_ENGINE_FINISHED,
 	PK_ENGINE_UPDATE_DETAIL,
 	PK_ENGINE_DESCRIPTION,
@@ -341,6 +342,32 @@ pk_engine_updates_changed_cb (PkBackend 
 }
 
 /**
+ * pk_engine_repo_signature_required_cb:
+ **/
+static void
+pk_engine_repo_signature_required_cb (PkBackend *backend, const gchar *repository_name, const gchar *key_url, const gchar *key_userid,
+				      const gchar *key_id, const gchar *key_timestamp, PkSigTypeEnum type, PkEngine *engine)
+{
+	PkTransactionItem *item;
+	const gchar *type_text;
+
+	g_return_if_fail (engine != NULL);
+	g_return_if_fail (PK_IS_ENGINE (engine));
+
+	item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
+	if (item == NULL) {
+		pk_warning ("could not find backend");
+		return;
+	}
+	type_text = pk_sig_type_enum_to_text (type);
+
+	pk_debug ("emitting repo_signature_required tid:%s, %s, %s, %s, %s, %s, %s",
+		  item->tid, repository_name, key_url, key_userid, key_id, key_timestamp, type_text);
+	g_signal_emit (engine, signals [PK_ENGINE_REPO_SIGNATURE_REQUIRED], 0,
+		       item->tid, repository_name, key_url, key_userid, key_id, key_timestamp, type_text);
+}
+
+/**
  * pk_engine_error_code_cb:
  **/
 static void
@@ -523,6 +550,8 @@ pk_engine_new_backend (PkEngine *engine)
 			  G_CALLBACK (pk_engine_error_code_cb), engine);
 	g_signal_connect (backend, "updates-changed",
 			  G_CALLBACK (pk_engine_updates_changed_cb), engine);
+	g_signal_connect (backend, "repo-signature-required",
+			  G_CALLBACK (pk_engine_repo_signature_required_cb), engine);
 	g_signal_connect (backend, "require-restart",
 			  G_CALLBACK (pk_engine_require_restart_cb), engine);
 	g_signal_connect (backend, "finished",
@@ -1953,6 +1982,12 @@ pk_engine_class_init (PkEngineClass *kla
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
 			      0, NULL, NULL, pk_marshal_VOID__STRING,
 			      G_TYPE_NONE, 1, G_TYPE_STRING);
+	signals [PK_ENGINE_REPO_SIGNATURE_REQUIRED] =
+		g_signal_new ("repo-signature-required",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING_STRING,
+			      G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+			      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
 	signals [PK_ENGINE_DESCRIPTION] =
 		g_signal_new ("description",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index 840a0d3..252e115 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -142,6 +142,15 @@
     <signal name="UpdatesChanged">
       <arg type="s" name="tid" direction="out"/>
     </signal>
+    <signal name="RepoSignatureRequired">
+      <arg type="s" name="tid" direction="out"/>
+      <arg type="s" name="repository_name" direction="out"/>
+      <arg type="s" name="key_url" direction="out"/>
+      <arg type="s" name="key_userid" direction="out"/>
+      <arg type="s" name="key_id" direction="out"/>
+      <arg type="s" name="key_timestamp" direction="out"/>
+      <arg type="s" name="type" direction="out"/> <!-- 'gpg', for now -->
+    </signal>
 
     <!-- Do things or query transactions -->
     <method name="Cancel"> <!-- might not succeed for all manner or reasons -->
diff --git a/src/pk-marshal.list b/src/pk-marshal.list
index 79270e2..618ff76 100644
--- a/src/pk-marshal.list
+++ b/src/pk-marshal.list
@@ -15,6 +15,7 @@ VOID:STRING,STRING,STRING,STRING,STRING,
 VOID:STRING,STRING,STRING,STRING,STRING,STRING,STRING
 VOID:STRING,STRING,UINT,STRING,STRING,UINT64,STRING
 VOID:STRING,STRING,STRING,STRING,STRING,STRING,UINT64,STRING
+VOID:STRING,STRING,STRING,STRING,STRING,UINT
 VOID:STRING,UINT,STRING,STRING
 VOID:STRING,STRING,UINT,UINT,UINT
 VOID:STRING,STRING,BOOL,UINT,UINT,STRING



More information about the PackageKit mailing list