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

Richard Hughes hughsient at kemper.freedesktop.org
Tue Oct 2 09:25:19 PDT 2007


 TODO                                     |   11 +++++
 backends/BACKENDS                        |    2 
 backends/box/pk-backend-box.c            |    4 +
 backends/conary/helpers/conaryBackend.py |    4 +
 backends/dummy/pk-backend-dummy.c        |    4 +
 backends/yum/helpers/resolve.py          |   18 ++++++++
 backends/yum/helpers/yumBackend.py       |   66 ++++++++++++++++++++++++++++---
 client/pk-console.c                      |    6 ++
 docs/backends.xml                        |    2 
 docs/introduction.xml                    |   12 +++++
 libpackagekit/pk-client.c                |   14 ++++--
 python/packagekit/backend.py             |   13 +++++-
 python/packagekit/frontend.py            |   12 +++--
 python/pk-frontend-test.py               |    6 ++
 src/pk-backend.c                         |   21 ++++++---
 src/pk-backend.h                         |    4 +
 src/pk-engine.c                          |   13 +++---
 src/pk-interface.xml                     |    2 
 src/pk-marshal.list                      |    3 -
 19 files changed, 178 insertions(+), 39 deletions(-)

New commits:
diff-tree 4b18b9c8a328d00de0a1f4e1f8b22abf56750b29 (from fc87623193abc49701ea39f07503647666e7038e)
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 2 17:25:06 2007 +0100

    update TODO

diff --git a/TODO b/TODO
index 1f2eb3d..9249822 100644
--- a/TODO
+++ b/TODO
@@ -8,6 +8,12 @@ NOTE: RELEASE BLOCKER
 *** don't output the same package in different repos ***
 Need to store Package() in the server properly, and compare the first chunk
 (not the data) to avoid reporting the same package more than once.
+Have pk-package-cache.c object which is created in pk-backend for each instance
+Instead of Gstring have PkPackageCache instance.
+pk_package_cache_add (i=role, s=package_id, s=summary) s=pk_package_cache_get_string()
+We can also use this in the client library (perhaps?)
+Also: pk_package_id_compare (gboolean use_data)
+Need to unit test...
 NOTE: RELEASE BLOCKER
 
 *** Add new callback for status ***
diff-tree fc87623193abc49701ea39f07503647666e7038e (from parents)
Merge: 51f028d6ce5c7a76ddc195e664abb0376abe4754 dd98fa856c9d4d01af36c0c7dc2e13a13143e247
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Tue Oct 2 09:49:27 2007 -0400

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

diff-tree 51f028d6ce5c7a76ddc195e664abb0376abe4754 (from d549164970eb52827a21a456930dca5707a7ab38)
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Tue Oct 2 09:49:10 2007 -0400

    Add support for size of package and list of included files from the description signal.

diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 35f5434..1a908d9 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -286,7 +286,9 @@ backend_get_description_thread (PkBacken
 		return FALSE;
 	}
 
-	pk_backend_description (backend, pi->name, "unknown", PK_GROUP_ENUM_OTHER, ps->description, "");
+	/* Package size and file list go here, but I don't know how to find those for 'boxes'. */
+	/* Also, if I ever write a packaging system, they will be called 'presents'. Or perhaps 'parcels'. */
+	pk_backend_description (backend, pi->name, "unknown", PK_GROUP_ENUM_OTHER, ps->description, "", 0, "");
 
 	pk_package_id_free (pi);
 	box_db_repos_package_list_free (list);
diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 8543d8c..07ddfae 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -243,7 +243,9 @@ class PackageKitConaryBackend(PackageKit
             longDesc = self._get_metadata(id, 'longDesc') or ""
             url = "http://www.foresightlinux.org/packages/" + name + ".html"
             categories = self._get_metadata(id, 'categories') or "unknown"
-            self.description(shortDesc, id, categories, longDesc, url)
+
+            # Package size and file list go here, but I don't know how to find those for conary packages.
+            self.description(shortDesc, id, categories, longDesc, url, 0, "")
         else:
             self.error(ERROR_INTERNAL_ERROR,'Package was not found')
 
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 9f31248..215b124 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -111,7 +111,9 @@ backend_get_description (PkBackend *back
 "While the goals of the program are for ease of use and simple easy to "
 "understand tools, Scribus offers support for professional publishing "
 "features, such as CMYK color, easy PDF creation, Encapsulated Postscript "
-"import/export and creation of color separations.", "http://live.gnome.org/GnomePowerManager");
+"import/export and creation of color separations.", "http://live.gnome.org/GnomePowerManager",
+				11214665, "/usr/share/man/man1;/usr/share/man/man1/gnome-power-manager.1.gz"
+				);
 	pk_backend_finished (backend);
 }
 
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 65acde4..6aa0499 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -387,8 +387,14 @@ class PackageKitYumBackend(PackageKitBas
             desc = pkg.description
             desc = desc.replace('\n\n',';')
             desc = desc.replace('\n',' ')            
+            
+            files = pkg.returnFileEntries('dir')
+            files.extend(pkg.returnFileEntries()) # regular files
+
+            file_list = ";".join(files)
+
             self.description(id, "%s-%s" % (pkg.version, pkg.release),
-                                 "unknown", desc, pkg.url)
+                                 "unknown", desc, pkg.url, pkg.size, file_list)
         else:
             self.error(ERROR_INTERNAL_ERROR,'Package was not found')
     
diff --git a/client/pk-console.c b/client/pk-console.c
index df2b7c7..6efa360 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -406,13 +406,17 @@ pk_console_error_code_cb (PkClient *clie
 static void
 pk_console_description_cb (PkClient *client, const gchar *package_id,
 			   const gchar *licence, PkGroupEnum group,
-			   const gchar *description, const gchar *url, gpointer data)
+			   const gchar *description, const gchar *url, gulong size, const gchar *filelist,
+			   gpointer data)
 {
 	g_print ("description\n");
 	g_print ("  package:     '%s'\n", package_id);
 	g_print ("  licence:     '%s'\n", licence);
 	g_print ("  group:       '%s'\n", pk_group_enum_to_text (group));
 	g_print ("  description: '%s'\n", description);
+	g_print ("  size:        '%ld' bytes\n", size);
+	/* filelist is probably too long to just dump to the screen */
+	/* g_print ("  files:       '%s'\n", filelist); */
 	g_print ("  url:         '%s'\n", url);
 }
 
diff --git a/docs/backends.xml b/docs/backends.xml
index a44cb25..059cb23 100644
--- a/docs/backends.xml
+++ b/docs/backends.xml
@@ -166,7 +166,7 @@
           </row>
           <row>
             <entry>Description</entry>
-            <entry><literal>description[tab]package_id[tab]group[tab]detail[tab]url</literal></entry>
+            <entry><literal>description[tab]package_id[tab]group[tab]detail[tab]url[tab]size_in_bytes[tab]file_list</literal></entry>
             <entry><literal>stdout</literal></entry>
           </row>
           <row>
diff --git a/docs/introduction.xml b/docs/introduction.xml
index 9e74280..6ba5264 100644
--- a/docs/introduction.xml
+++ b/docs/introduction.xml
@@ -1385,6 +1385,18 @@
               <entry><literal>url</literal></entry>
               <entry>The upstream project homepage</entry>
             </row>
+            <row>
+              <entry><literal>size</literal></entry>
+              <entry>
+		The size of the package in bytes.  This should be the
+		size of the entire package file, not the size of the
+		files installed on the system.
+	      </entry>
+            </row>
+            <row>
+              <entry><literal>file_list</literal></entry>
+              <entry>A list of all files and directories created by the package at install time.  Separated by the ';' character.</entry>
+            </row>
           </tbody>
         </tgroup>
       </informaltable>
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 9488d5d..1a4d969 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -426,6 +426,8 @@ pk_client_description_cb (DBusGProxy  *p
 			  const gchar *group_text,
 			  const gchar *description,
 			  const gchar *url,
+			  gulong size,
+			  const gchar *filelist,
 			  PkClient    *client)
 {
 	PkGroupEnum group;
@@ -434,8 +436,8 @@ pk_client_description_cb (DBusGProxy  *p
 
 	if (pk_transaction_id_equal (tid, client->priv->tid) == TRUE) {
 		group = pk_group_enum_from_text (group_text);
-		pk_debug ("emit description %s, %s, %i, %s, %s", package_id, licence, group, description, url);
-		g_signal_emit (client , signals [PK_CLIENT_DESCRIPTION], 0, package_id, licence, group, description, url);
+		pk_debug ("emit description %s, %s, %i, %s, %s, %ld, %s", package_id, licence, group, description, url, size, filelist);
+		g_signal_emit (client , signals [PK_CLIENT_DESCRIPTION], 0, package_id, licence, group, description, url, size, filelist);
 	}
 }
 
@@ -1714,8 +1716,9 @@ pk_client_class_init (PkClientClass *kla
 	signals [PK_CLIENT_DESCRIPTION] =
 		g_signal_new ("description",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
-			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_UINT_STRING_STRING,
-			      G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_UINT_STRING_STRING_ULONG_STRING,
+			      G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING,
+			      G_TYPE_STRING, G_TYPE_ULONG, G_TYPE_STRING);
 	signals [PK_CLIENT_ERROR_CODE] =
 		g_signal_new ("error-code",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
@@ -1876,7 +1879,8 @@ pk_client_init (PkClient *client)
 
 	dbus_g_proxy_add_signal (proxy, "Description",
 				 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
-				 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+				 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_ULONG,
+				 G_TYPE_STRING, G_TYPE_INVALID);
 	dbus_g_proxy_connect_signal (proxy, "Description",
 				     G_CALLBACK (pk_client_description_cb), client, NULL);
 
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 8eca7b4..17dede9 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -115,7 +115,7 @@ class PackageKitBaseBackend:
         '''
         print >> sys.stderr,"data\t%s" % (data)
 
-    def description(self,id,licence,group,desc,url):
+    def description(self,id,licence,group,desc,url,bytes,file_list):
         '''
         Send 'description' signal
         @param id: The package ID name, e.g. openoffice-clipart;2.6.22;ppc64;fedora
@@ -123,8 +123,10 @@ class PackageKitBaseBackend:
         @param group: The enumerated group
         @param desc: The multi line package description
         @param url: The upstream project homepage
+        @param bytes: The size of the package, in bytes
+        @param file_list: List of the files in the package, separated by ';'
         '''
-        print >> sys.stdout,"description\t%s\t%s\t%s\t%s\t%s" % (id,licence,group,desc,url)
+        print >> sys.stdout,"description\t%s\t%s\t%s\t%s\t%s\t%ld\t%s" % (id,licence,group,desc,url,bytes,file_list)
 
     def require_restart(self,restart_type,details):
         '''
diff --git a/python/packagekit/frontend.py b/python/packagekit/frontend.py
index 9dc5a85..9f974b7 100644
--- a/python/packagekit/frontend.py
+++ b/python/packagekit/frontend.py
@@ -121,7 +121,7 @@ class PackageKit:
 		elif kwargs['member'] == "UpdateDetail":
 			self.UpdateDetail(args[0],args[1],args[2],args[3],args[4],args[5],args[6])
 		elif kwargs['member'] == "Description":
-			self.Description(args[0],args[1],args[2],args[3],args[4],args[5])
+			self.Description(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7])
 		elif kwargs['member'] == "ErrorCode":
 			self.ErrorCode(args[0],args[1],args[2])
 		elif kwargs['member'] == "RequireRestart":
@@ -183,7 +183,9 @@ class PackageKit:
 			license,
 			group,
 			detail,
-			url
+			url,
+			size,       # in bytes
+			file_list   # separated by ';'
 			):
 		pass
 
diff --git a/python/pk-frontend-test.py b/python/pk-frontend-test.py
index 8f8eb25..2020d89 100755
--- a/python/pk-frontend-test.py
+++ b/python/pk-frontend-test.py
@@ -29,10 +29,14 @@ class pkt(PackageKit):
 	def Package(self,jid,value,name,summary):
 		print "Package: %s - %s"%(name,summary)
 
-	def Description(self,jid,package_id,license,group,detail,url):
+	def Description(self,jid,package_id,license,group,detail,url,size,file_list):
 		print "Package: %s" % package_id
 		print "  %s" % url
 		print "  %s" % detail
+		print "  %s bytes" % size
+		print "  Files:"
+		for file in file_list.split(";"):
+			print "    %s" % file
 
 	def Transaction(self,jid,old_jid,timespec,succeeded,role,duration):
 		success = "Failed"
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 7cdeba2..d2e3754 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -241,6 +241,7 @@ pk_backend_parse_common_output (PkBacken
 	gboolean ret = TRUE;
 	PkInfoEnum info;
 	PkGroupEnum group;
+	gulong package_size;
 
 	/* check if output line */
 	if (line == NULL || strstr (line, "\t") == NULL)
@@ -274,13 +275,15 @@ pk_backend_parse_common_output (PkBacken
 			pk_warning ("invalid package_id");
 		}
 	} else if (strcmp (command, "description") == 0) {
-		if (size != 6) {
+		if (size != 8) {
 			g_error ("invalid command '%s'", command);
 			ret = FALSE;
 			goto out;
 		}
 		group = pk_group_enum_from_text (sections[3]);
-		pk_backend_description (backend, sections[1], sections[2], group, sections[4], sections[5]);
+		package_size = atol(sections[6]);
+		pk_backend_description (backend, sections[1], sections[2], group, sections[4], sections[5],
+					package_size, sections[7]);
 	} else {
 		pk_warning ("invalid command '%s'", command);
 	}
@@ -728,13 +731,16 @@ pk_backend_require_restart (PkBackend *b
 gboolean
 pk_backend_description (PkBackend *backend, const gchar *package_id,
 			const gchar *licence, PkGroupEnum group,
-			const gchar *description, const gchar *url)
+			const gchar *description, const gchar *url,
+			gulong size, const gchar *filelist)
 {
 	g_return_val_if_fail (backend != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
 
-	pk_debug ("emit description %s, %s, %i, %s, %s", package_id, licence, group, description, url);
-	g_signal_emit (backend, signals [PK_BACKEND_DESCRIPTION], 0, package_id, licence, group, description, url);
+	pk_debug ("emit description %s, %s, %i, %s, %s, %ld, %s", package_id, licence, group, description, url,
+		  size, filelist);
+	g_signal_emit (backend, signals [PK_BACKEND_DESCRIPTION], 0, package_id, licence, group, description, url,
+		       size, filelist);
 
 	return TRUE;
 }
@@ -1479,8 +1485,9 @@ pk_backend_class_init (PkBackendClass *k
 	signals [PK_BACKEND_DESCRIPTION] =
 		g_signal_new ("description",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
-			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_UINT_STRING_STRING,
-			      G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_UINT_STRING_STRING_ULONG_STRING,
+			      G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING,
+			      G_TYPE_ULONG,G_TYPE_STRING);
 	signals [PK_BACKEND_ERROR_CODE] =
 		g_signal_new ("error-code",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-backend.h b/src/pk-backend.h
index d9be55f..64a25fb 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -61,7 +61,9 @@ gboolean	 pk_backend_description			(PkBa
 							 const gchar	*licence,
 							 PkGroupEnum	 group,
 							 const gchar	*description,
-							 const gchar	*url);
+							 const gchar	*url,
+							 gulong          size,
+							 const gchar    *filelist);
 gboolean	 pk_backend_error_code			(PkBackend	*backend,
 							 guint		 code,
 							 const gchar	*details, ...);
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 7faf3a7..de49f30 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -387,7 +387,8 @@ pk_engine_require_restart_cb (PkBackend 
  **/
 static void
 pk_engine_description_cb (PkBackend *backend, const gchar *package_id, const gchar *licence, PkGroupEnum group,
-			  const gchar *detail, const gchar *url, PkEngine *engine)
+			  const gchar *detail, const gchar *url, gulong size, const gchar *filelist, 
+			  PkEngine *engine)
 {
 	PkTransactionItem *item;
 	const gchar *group_text;
@@ -402,8 +403,8 @@ pk_engine_description_cb (PkBackend *bac
 	}
 	group_text = pk_group_enum_to_text (group);
 
-	pk_debug ("emitting description tid:%s, %s, %s, %s, %s, %s", item->tid, package_id, licence, group_text, detail, url);
-	g_signal_emit (engine, signals [PK_ENGINE_DESCRIPTION], 0, item->tid, package_id, licence, group_text, detail, url);
+	pk_debug ("emitting description tid:%s, %s, %s, %s, %s, %s, %ld, %s", item->tid, package_id, licence, group_text, detail, url, size, filelist);
+	g_signal_emit (engine, signals [PK_ENGINE_DESCRIPTION], 0, item->tid, package_id, licence, group_text, detail, url, size, filelist);
 }
 
 /**
@@ -1947,9 +1948,9 @@ pk_engine_class_init (PkEngineClass *kla
 	signals [PK_ENGINE_DESCRIPTION] =
 		g_signal_new ("description",
 			      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);
+			      0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING_ULONG_STRING,
+			      G_TYPE_NONE, 8, G_TYPE_STRING, G_TYPE_STRING,
+			      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_ULONG, G_TYPE_STRING);
 	signals [PK_ENGINE_FINISHED] =
 		g_signal_new ("finished",
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index fa6b524..e7bb6ab 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -108,6 +108,8 @@
       <arg type="s" name="group" direction="out"/>
       <arg type="s" name="detail" direction="out"/>
       <arg type="s" name="url" direction="out"/>
+      <arg type="u" name="size" direction="out"/> <!-- size of package file in bytes -->
+      <arg type="s" name="file_list" direction="out"/> <!-- list of files and dirs separated by ';' -->
     </signal>
     <signal name="UpdateDetail">
       <arg type="s" name="tid" direction="out"/>
diff --git a/src/pk-marshal.list b/src/pk-marshal.list
index 6713374..f1cd591 100644
--- a/src/pk-marshal.list
+++ b/src/pk-marshal.list
@@ -13,7 +13,8 @@ VOID:STRING,STRING,STRING,STRING
 VOID:STRING,STRING,STRING,STRING,STRING
 VOID:STRING,STRING,STRING,STRING,STRING,STRING
 VOID:STRING,STRING,STRING,STRING,STRING,STRING,STRING
-VOID:STRING,STRING,UINT,STRING,STRING
+VOID:STRING,STRING,UINT,STRING,STRING,ULONG,STRING
+VOID:STRING,STRING,STRING,STRING,STRING,STRING,ULONG,STRING
 VOID:STRING,UINT,STRING,STRING
 VOID:STRING,STRING,UINT,UINT,UINT
 VOID:STRING,STRING,BOOL,UINT,UINT,STRING
diff-tree dd98fa856c9d4d01af36c0c7dc2e13a13143e247 (from 4671b3f59f349441ede15635347f2fb66a359b05)
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Tue Oct 2 13:52:39 2007 +0200

    updated yum status i BACKENDS

diff --git a/backends/BACKENDS b/backends/BACKENDS
index c7962ca..da20006 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -2,7 +2,7 @@ Current status of the backends
 
                   | conary | yum | apt | box | alpm |
 -----------------------------------------------------
-resolve           |        |     |     |  X  |      |
+resolve           |        |  X  |     |  X  |      |
 refresh-cache     |   X    |  X  |  X  |  X  |      |
 get-updates       |   X    |  X  |     |  X  |      |
 update-system     |   X    |  X  |     |     |      |
diff-tree 4671b3f59f349441ede15635347f2fb66a359b05 (from f5d813eb393f365d144d30b82643bb4b2558471f)
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Tue Oct 2 13:47:18 2007 +0200

    make remove yes/no package work right in the yum backend (don't remove dependencies if not yes is used as first parameter

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 7a7bba8..2f5082c 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -372,7 +372,7 @@ class PackageKitYumBackend(PackageKitBas
                 self.require_restart(RESTART_SYSTEM,"")
                 break
     
-    def _runYumTransaction(self):
+    def _runYumTransaction(self,removedeps=None):
         '''
         Run the yum Transaction
         This will only work with yum 3.2.4 or higher
@@ -383,6 +383,12 @@ class PackageKitYumBackend(PackageKitBas
             self.error(ERROR_DEP_RESOLUTION_FAILED,retmsg)
         else:
             self._check_for_reboot()
+            if removedeps == False:
+                if len(self.yumbase.tsInfo) > 1:
+                    retmsg = 'package could not be remove, because something depends on it'
+                    self.error(ERROR_DEP_RESOLUTION_FAILED,retmsg)
+                    return
+
             try:
                 rpmDisplay = PackageKitCallback(self)
                 callback = ProcessTransPackageKitCallback(self)
@@ -409,7 +415,10 @@ class PackageKitYumBackend(PackageKitBas
         if pkg and inst:        
             txmbr = self.yumbase.remove(name=pkg.name)
             if txmbr:
-                self._runYumTransaction()
+                if allowdep != 'yes':
+                    self._runYumTransaction(removedeps=False)
+                else:
+                    self._runYumTransaction(removedeps=True)
             else:
                 self.error(ERROR_PACKAGE_NOT_INSTALLED,"Package is not installed")
         else:
diff-tree f5d813eb393f365d144d30b82643bb4b2558471f (from dba78a006f41de938bdd7e0b9bd6b7428e2c8a37)
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Tue Oct 2 13:29:13 2007 +0200

    Added restart require check and fixed epoch bug

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index ccf4a24..7a7bba8 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -34,6 +34,12 @@ from yum.callbacks import *
 
 class PackageKitYumBackend(PackageKitBaseBackend):
 
+    # Packages there require a reboot     
+    rebootpkgs = ("kernel", "kernel-smp", "kernel-xen-hypervisor", "kernel-PAE",
+              "kernel-xen0", "kernel-xenU", "kernel-xen", "kernel-xen-guest",
+              "glibc", "hal", "dbus", "xen")
+
+
     def __init__(self,args):
         PackageKitBaseBackend.__init__(self,args)
         self.yumbase = yum.YumBase()
@@ -192,7 +198,7 @@ class PackageKitYumBackend(PackageKitBas
         cpos = idver.find(':')
         if cpos != -1:
             epoch = idver[:cpos]
-            idver = idver[cpos:]
+            idver = idver[cpos+1:]
         else:
             epoch = '0'
         (version,release) = tuple(idver.split('-'))
@@ -207,6 +213,7 @@ class PackageKitYumBackend(PackageKitBas
         # get e,v,r from package id version
         e,v,r = self._getEVR(idver)
         # search the rpmdb for the nevra
+        print n,e,v,r,a
         pkgs = self.yumbase.rpmdb.searchNevra(name=n,epoch=e,ver=v,rel=r,arch=a)
         # if the package is found, then return it
         if len(pkgs) != 0:
@@ -356,6 +363,14 @@ class PackageKitYumBackend(PackageKitBas
         else:
             self.error(ERROR_PACKAGE_ALREADY_INSTALLED,"No available updates")
 
+    def _check_for_reboot(self):
+        for txmbr in self.yumbase.tsInfo:
+            pkg = txmbr.po
+            # check if package is in reboot list and is installed/updated etc
+            print pkg.name,txmbr.output_state
+            if pkg.name in self.rebootpkgs and txmbr.ts_state in TS_INSTALL_STATES:
+                self.require_restart(RESTART_SYSTEM,"")
+                break
     
     def _runYumTransaction(self):
         '''
@@ -367,6 +382,7 @@ class PackageKitYumBackend(PackageKitBas
             retmsg = "Error in Dependency Resolution;" +";".join(msgs)
             self.error(ERROR_DEP_RESOLUTION_FAILED,retmsg)
         else:
+            self._check_for_reboot()
             try:
                 rpmDisplay = PackageKitCallback(self)
                 callback = ProcessTransPackageKitCallback(self)
diff-tree dba78a006f41de938bdd7e0b9bd6b7428e2c8a37 (from 6db6670f1cbb85bb4ef2f638d4ece7ca2d91d505)
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Tue Oct 2 12:32:21 2007 +0200

    fixed typo

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 6febdeb..ccf4a24 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -395,7 +395,7 @@ class PackageKitYumBackend(PackageKitBas
             if txmbr:
                 self._runYumTransaction()
             else:
-                self.erhror(ERROR_PACKAGE_NOT_INSTALLED,"Package is not installed")
+                self.error(ERROR_PACKAGE_NOT_INSTALLED,"Package is not installed")
         else:
             self.error(ERROR_PACKAGE_NOT_INSTALLED,"Package is not installed")
 
diff-tree 6db6670f1cbb85bb4ef2f638d4ece7ca2d91d505 (from d549164970eb52827a21a456930dca5707a7ab38)
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Tue Oct 2 12:12:42 2007 +0200

    implement resolve in backend base & in yum backend

diff --git a/backends/yum/helpers/resolve.py b/backends/yum/helpers/resolve.py
new file mode 100755
index 0000000..bfb1216
--- /dev/null
+++ b/backends/yum/helpers/resolve.py
@@ -0,0 +1,18 @@
+#!/usr/bin/python
+#
+# 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.
+
+import sys
+
+from yumBackend import PackageKitYumBackend
+name=sys.argv[1]
+backend = PackageKitYumBackend(sys.argv[1:])
+backend.resolve(name)
+sys.exit(0)
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 65acde4..6febdeb 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -293,6 +293,31 @@ class PackageKitYumBackend(PackageKitBas
         except yum.Errors.YumBaseError, e:
             self.error(ERROR_INTERNAL_ERROR,str(e))
 
+    def _is_inst(self,name): # fast check for if package is installed
+        mi = self.yumbase.ts.ts.dbMatch('name', name)
+        if mi.count() > 0:
+            return True
+        return False         
+
+    def resolve(self, name):
+        '''
+        Implement the {backend}-resolve functionality
+        '''
+        # Get installed packages
+        installedByKey = self.yumbase.rpmdb.searchNevra(name=name)
+        for pkg in installedByKey:
+            self._show_package(pkg,INFO_INSTALLED)      
+        # Get availabe packages
+        for pkg in self.yumbase.pkgSack.returnNewestByNameArch():
+            if pkg.name == name:
+                show = True
+                for instpo in installedByKey:
+                    if pkg.EVR < instpo.EVR or pkg.EVR == instpo.EVR:  # Check if package have a smaller & equal EVR to a inst pkg
+                        show = False
+                if show:
+                    self._show_package(pkg,INFO_AVAILABLE)
+                    break
+
     def install(self, package):
         '''
         Implement the {backend}-install functionality
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 8eca7b4..ca91976 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -229,6 +229,13 @@ class PackageKitBaseBackend:
         '''
         self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
 
+    def resolve(self, name):
+        '''
+        Implement the {backend}-resolve functionality
+        Needed to be implemented in a sub class
+        '''
+        self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
     def remove(self, allowdep, package):
         '''
         Implement the {backend}-remove functionality
diff-tree d549164970eb52827a21a456930dca5707a7ab38 (from 1dafd936ba21cfa0d8cd233fa05ae82b8511f145)
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 2 00:20:06 2007 +0100

    update TODO

diff --git a/TODO b/TODO
index f5a2387..1f2eb3d 100644
--- a/TODO
+++ b/TODO
@@ -5,6 +5,11 @@ Do automatic updates at login time when 
  * needs gnome-screensaver integration
 NOTE: RELEASE BLOCKER
 
+*** don't output the same package in different repos ***
+Need to store Package() in the server properly, and compare the first chunk
+(not the data) to avoid reporting the same package more than once.
+NOTE: RELEASE BLOCKER
+
 *** Add new callback for status ***
 TimeRemaining()
  
diff-tree 1dafd936ba21cfa0d8cd233fa05ae82b8511f145 (from parents)
Merge: 1259cf9206fe47ba3de5b3249f1847163b1f70fc 48297dbb9e4af55686af6ccd272a441b035fa5f2
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Mon Oct 1 16:08:24 2007 -0400

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

diff-tree 1259cf9206fe47ba3de5b3249f1847163b1f70fc (from f5432fe0048a6edffd53536a420f5a76650d707f)
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Mon Oct 1 16:08:14 2007 -0400

    fix description of Resolve

diff --git a/python/packagekit/frontend.py b/python/packagekit/frontend.py
index 1ee56f9..9dc5a85 100644
--- a/python/packagekit/frontend.py
+++ b/python/packagekit/frontend.py
@@ -245,10 +245,10 @@ class PackageKit:
 
 	@dbusException
 	@job_id
-	def Resolve(self,package_id):
+	def Resolve(self,package_name):
 		"""
-		Resolves dependancies.
-		(description is a guess, since this not yet supported in yum backend, and maybe others)
+		Finds a package with the given name, and gives back a Package that matches that name exactly
+		(not yet supported in yum backend, and maybe others)
 		"""
 		return self.pk_iface.Resolve(self.tid(),package_id)
 



More information about the PackageKit mailing list