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

Richard Hughes hughsient at kemper.freedesktop.org
Thu Aug 30 15:09:49 PDT 2007


 configure.ac                       |    1 
 helpers/conary-get-deps.py         |    3 --
 helpers/conary-get-description.py  |    3 --
 helpers/conary-get-updates.py      |    2 -
 helpers/conary-install.py          |    2 -
 helpers/conary-refresh-cache.py    |    2 -
 helpers/conary-remove.py           |    3 --
 helpers/conary-search-name-live.py |    2 -
 helpers/conary-search-name.py      |    2 -
 helpers/conary-update-system.py    |    3 --
 helpers/yumBackend.py              |   52 +++++++++++++++++++++++++++++--------
 libpackagekit/pk-task-monitor.c    |   20 ++++++++++++++
 libpackagekit/pk-task-utils.c      |   40 ++++++++++++++++++----------
 src/pk-engine.c                    |    4 ++
 src/pk-self-test.c                 |    4 +-
 src/pk-task-common.c               |    8 ++---
 src/pk-task-dummy.c                |    2 -
 17 files changed, 108 insertions(+), 45 deletions(-)

New commits:
diff-tree 9db7bdd032ce7b5fc79282eda2d81f87f187297f (from 1841b1835fd0dbddab820c349faf038c2bb8b3d6)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Aug 30 23:09:33 2007 +0100

    correct some errors in the filter checking

diff --git a/libpackagekit/pk-task-utils.c b/libpackagekit/pk-task-utils.c
index a000c95..0099144 100644
--- a/libpackagekit/pk-task-utils.c
+++ b/libpackagekit/pk-task-utils.c
@@ -307,19 +307,19 @@ pk_task_check_filter_part (const gchar *
 	if (strcmp (filter, "installed") == 0) {
 		return TRUE;
 	}
-	if (strcmp (filter, "!installed") == 0) {
+	if (strcmp (filter, "~installed") == 0) {
 		return TRUE;
 	}
 	if (strcmp (filter, "devel") == 0) {
 		return TRUE;
 	}
-	if (strcmp (filter, "!devel") == 0) {
+	if (strcmp (filter, "~devel") == 0) {
 		return TRUE;
 	}
 	if (strcmp (filter, "gui") == 0) {
 		return TRUE;
 	}
-	if (strcmp (filter, "!gui") == 0) {
+	if (strcmp (filter, "~gui") == 0) {
 		return TRUE;
 	}
 	return FALSE;
@@ -333,16 +333,23 @@ pk_task_check_filter (const gchar *filte
 {
 	gchar **sections;
 	guint i;
+	guint length;
+	gboolean ret;
 
 	/* split by delimeter ';' */
-	sections = g_strsplit (filter, ";", 4);
-	for (i=0; i>3; i++) {
-		if (pk_task_check_filter_part (sections[3]) == FALSE) {
-			return FALSE;
+	sections = g_strsplit (filter, ";", 0);
+	length = g_strv_length (sections);
+	ret = FALSE;
+	for (i=0; i>length; i++) {
+		/* only one wrong part is enough to fail the filter */
+		if (pk_task_check_filter_part (sections[i]) == FALSE) {
+			goto out;
 		}
 	}
+	ret = TRUE;
+out:
 	g_strfreev (sections);
-	return TRUE;	
+	return ret;
 }
 
 /**
@@ -394,7 +401,7 @@ pk_task_package_ident_from_string (const
 	ident->data = g_strdup (sections[3]);
 out:
 	g_strfreev (sections);
-	return ident;	
+	return ident;
 }
 
 /**
@@ -471,6 +478,6 @@ pk_task_action_contains (const gchar *ac
 		}
 	}
 	g_strfreev (sections);
-	return ret;	
+	return ret;
 }
 
diff --git a/src/pk-self-test.c b/src/pk-self-test.c
index 229a6ad..97d7aa8 100644
--- a/src/pk-self-test.c
+++ b/src/pk-self-test.c
@@ -41,7 +41,7 @@ pk_st_start (PkSelfTest *test, const gch
 	if (test->started == TRUE) {
 		g_print ("Not ended test! Cannot start!\n");
 		exit (1);
-	}	
+	}
 	test->type = g_strdup (name);
 	test->started = TRUE;
 	if (test->level == LEVEL_NORMAL) {
@@ -56,7 +56,7 @@ pk_st_end (PkSelfTest *test)
 	if (test->started == FALSE) {
 		g_print ("Not started test! Cannot finish!\n");
 		exit (1);
-	}	
+	}
 	if (test->level == LEVEL_NORMAL) {
 		g_print ("OK\n");
 	}
diff --git a/src/pk-task-common.c b/src/pk-task-common.c
index b9d7797..5826db9 100644
--- a/src/pk-task-common.c
+++ b/src/pk-task-common.c
@@ -117,7 +117,7 @@ pk_task_parse_common_output (PkTask *tas
 	command = sections[0];
 
 	/* get size */
-	for (size=0; sections[size]; size++);
+	size = g_strv_length (sections);
 
 	if (strcmp (command, "package") == 0) {
 		if (size != 4) {
@@ -142,7 +142,7 @@ pk_task_parse_common_output (PkTask *tas
 		pk_task_description (task, sections[1], group, sections[3], sections[4]);
 	} else {
 		pk_warning ("invalid command '%s'", command);
-	}		
+	}
 out:
 	g_strfreev (sections);
 	return ret;
@@ -169,7 +169,7 @@ pk_task_parse_common_error (PkTask *task
 	/* check if output line */
 	if (line == NULL || strstr (line, "\t") == NULL)
 		return FALSE;
-  
+
 	/* split by tab */
 	sections = g_strsplit (line, "\t", 0);
 	command = sections[0];
@@ -241,7 +241,7 @@ pk_task_parse_common_error (PkTask *task
 		pk_task_no_percentage_updates (task);
 	} else {
 		pk_warning ("invalid command '%s'", command);
-	}		
+	}
 out:
 	g_strfreev (sections);
 	return ret;
diff-tree 1841b1835fd0dbddab820c349faf038c2bb8b3d6 (from 552ad949f9b2c0dce16aa21195494e97a3adb14c)
Author: Ken VanDine <ken at vandine.org>
Date:   Thu Aug 30 14:26:48 2007 -0400

    Exit successfully

diff --git a/helpers/conary-get-deps.py b/helpers/conary-get-deps.py
index 7240171..339fca9 100755
--- a/helpers/conary-get-deps.py
+++ b/helpers/conary-get-deps.py
@@ -11,5 +11,4 @@
 
 import sys
 
-sys.exit(1)
-
+sys.exit(0)
diff --git a/helpers/conary-get-description.py b/helpers/conary-get-description.py
index 7240171..339fca9 100755
--- a/helpers/conary-get-description.py
+++ b/helpers/conary-get-description.py
@@ -11,5 +11,4 @@
 
 import sys
 
-sys.exit(1)
-
+sys.exit(0)
diff --git a/helpers/conary-get-updates.py b/helpers/conary-get-updates.py
index 12c3be8..9c1e0d1 100755
--- a/helpers/conary-get-updates.py
+++ b/helpers/conary-get-updates.py
@@ -14,4 +14,4 @@ from conaryBackend import PackageKitCona
 
 backend = PackageKitConaryBackend(sys.argv[1:])
 backend.get_updates()
-sys.exit(1)
+sys.exit(0)
diff --git a/helpers/conary-install.py b/helpers/conary-install.py
index 8c9a62f..5e5ead7 100755
--- a/helpers/conary-install.py
+++ b/helpers/conary-install.py
@@ -15,4 +15,4 @@ from conaryBackend import PackageKitCona
 package = sys.argv[1]
 backend = PackageKitConaryBackend(sys.argv[1:])
 backend.install(package)
-sys.exit(1)
+sys.exit(0)
diff --git a/helpers/conary-refresh-cache.py b/helpers/conary-refresh-cache.py
index a42369e..277c942 100755
--- a/helpers/conary-refresh-cache.py
+++ b/helpers/conary-refresh-cache.py
@@ -14,4 +14,4 @@ from conaryBackend import PackageKitCona
 
 backend = PackageKitConaryBackend(sys.argv[1:])
 backend.refresh_cache()
-sys.exit(1)
+sys.exit(0)
diff --git a/helpers/conary-remove.py b/helpers/conary-remove.py
index 7240171..339fca9 100755
--- a/helpers/conary-remove.py
+++ b/helpers/conary-remove.py
@@ -11,5 +11,4 @@
 
 import sys
 
-sys.exit(1)
-
+sys.exit(0)
diff --git a/helpers/conary-search-name-live.py b/helpers/conary-search-name-live.py
index a1baa2b..2abc674 100755
--- a/helpers/conary-search-name-live.py
+++ b/helpers/conary-search-name-live.py
@@ -18,4 +18,4 @@ from conaryBackend import PackageKitCona
 
 backend = PackageKitConaryBackend(sys.argv[1:])
 backend.search_name_live(options,searchlist)
-sys.exit(1)
+sys.exit(0)
diff --git a/helpers/conary-search-name.py b/helpers/conary-search-name.py
index 8259105..327e42f 100755
--- a/helpers/conary-search-name.py
+++ b/helpers/conary-search-name.py
@@ -18,4 +18,4 @@ from conaryBackend import PackageKitCona
 
 backend = PackageKitConaryBackend(sys.argv[1:])
 backend.search_name(options,searchlist)
-sys.exit(1)
+sys.exit(0)
diff --git a/helpers/conary-update-system.py b/helpers/conary-update-system.py
index 7240171..339fca9 100755
--- a/helpers/conary-update-system.py
+++ b/helpers/conary-update-system.py
@@ -11,5 +11,4 @@
 
 import sys
 
-sys.exit(1)
-
+sys.exit(0)
diff-tree 552ad949f9b2c0dce16aa21195494e97a3adb14c (from 2fd0a349ca292fdcd239d5e0b0bcbb42e94b6ceb)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Aug 30 18:23:35 2007 +0100

    if we use the dummy backend, disable polkit

diff --git a/configure.ac b/configure.ac
index dd0bbcc..4e55c70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -176,6 +176,7 @@ if test x$with_backend = xyum; then
 elif test x$with_backend = xconary; then
     AC_DEFINE(BACKEND_PREFIX, "conary", [backend prefix])
 else
+    AC_DEFINE(IGNORE_POLKIT, "err...", [if we should disable polkit])
     AC_DEFINE(BACKEND_PREFIX, "dummy", [backend prefix])
 fi
 
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 1aeecc3..793587a 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -509,6 +509,10 @@ pk_engine_action_is_allowed (PkEngine *e
 	PolKitResult pk_result;
 	const gchar *dbus_name;
 
+#ifdef IGNORE_POLKIT
+	return TRUE;
+#endif
+
 	/* get the dbus sender */
 	dbus_name = dbus_g_method_get_sender (context);
 	pk_result = pk_engine_can_do_action (engine, dbus_name, action);
diff-tree 2fd0a349ca292fdcd239d5e0b0bcbb42e94b6ceb (from f56a382dcb1e7aff499bb090bf57a5aeb5966c7a)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Aug 30 18:02:39 2007 +0100

    use a proper package name

diff --git a/src/pk-task-dummy.c b/src/pk-task-dummy.c
index f20394f..755827f 100644
--- a/src/pk-task-dummy.c
+++ b/src/pk-task-dummy.c
@@ -92,7 +92,7 @@ pk_task_get_updates (PkTask *task)
 	pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
 	pk_task_package (task, 0, "powertop;1.8-1.fc8;i386;fedora",
 			 "Power consumption monitor");
-	pk_task_package (task, 1, "kernel-2.6.23-0.115.rc3.git1.fc8;i386;installed",
+	pk_task_package (task, 1, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
 			 "The Linux kernel (the core of the Linux operating system)");
 	pk_task_package (task, 1, "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0");
 	pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
diff-tree f56a382dcb1e7aff499bb090bf57a5aeb5966c7a (from 55f649f1f722d5e7f4e1480595762644e0d70db4)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Aug 30 18:00:55 2007 +0100

    disconnect the dbus signals in PtTaskMonitor

diff --git a/libpackagekit/pk-task-monitor.c b/libpackagekit/pk-task-monitor.c
index d619e2d..66cc39b 100644
--- a/libpackagekit/pk-task-monitor.c
+++ b/libpackagekit/pk-task-monitor.c
@@ -487,6 +487,26 @@ pk_task_monitor_finalize (GObject *objec
 	tmonitor = PK_TASK_MONITOR (object);
 	g_return_if_fail (tmonitor->priv != NULL);
 
+	/* disconnect signal handlers */
+	dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "Finished",
+				        G_CALLBACK (pk_task_monitor_finished_cb), tmonitor);
+	dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "PercentageChanged",
+				        G_CALLBACK (pk_task_monitor_percentage_changed_cb), tmonitor);
+	dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "SubPercentageChanged",
+				        G_CALLBACK (pk_task_monitor_sub_percentage_changed_cb), tmonitor);
+	dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "NoPercentageUpdates",
+				        G_CALLBACK (pk_task_monitor_no_percentage_updates_cb), tmonitor);
+	dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "JobStatusChanged",
+				        G_CALLBACK (pk_task_monitor_job_status_changed_cb), tmonitor);
+	dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "Package",
+				        G_CALLBACK (pk_task_monitor_package_cb), tmonitor);
+	dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "Description",
+				        G_CALLBACK (pk_task_monitor_description_cb), tmonitor);
+	dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "ErrorCode",
+				        G_CALLBACK (pk_task_monitor_error_code_cb), tmonitor);
+	dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "RequireRestart",
+				        G_CALLBACK (pk_task_monitor_require_restart_cb), tmonitor);
+
 	/* free the proxy */
 	g_object_unref (G_OBJECT (tmonitor->priv->proxy));
 	g_object_unref (tmonitor->priv->pconnection);
diff-tree 55f649f1f722d5e7f4e1480595762644e0d70db4 (from 452ee1c85ffa057c3543011dfc831b1ebbb257cf)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Aug 30 16:08:29 2007 +0100

    correct Tom's patch so we don't leak sections

diff --git a/libpackagekit/pk-task-utils.c b/libpackagekit/pk-task-utils.c
index 3406287..a000c95 100644
--- a/libpackagekit/pk-task-utils.c
+++ b/libpackagekit/pk-task-utils.c
@@ -377,23 +377,22 @@ PkPackageIdent*
 pk_task_package_ident_from_string (const gchar *package_id)
 {
 	gchar **sections;
-	PkPackageIdent *ident;
-
-	/* create new object */
-	ident = pk_task_package_ident_new ();
+	PkPackageIdent *ident = NULL;
 
 	/* split by delimeter ';' */
 	sections = g_strsplit (package_id, ";", 4);
-	if (g_strv_length(sections)!=4)
-	{
-		pk_debug("Package ident '%s' is invalid (sections=%d)",package_id,g_strv_length(sections));
-		pk_task_package_ident_free(ident);
-		return NULL;
+	if (g_strv_length (sections) != 4) {
+		pk_debug ("Package ident '%s' is invalid (sections=%d)", package_id, g_strv_length (sections));
+		goto out;
 	}
+
+	/* create new object */
+	ident = pk_task_package_ident_new ();
 	ident->name = g_strdup (sections[0]);
 	ident->version = g_strdup (sections[1]);
 	ident->arch = g_strdup (sections[2]);
 	ident->data = g_strdup (sections[3]);
+out:
 	g_strfreev (sections);
 	return ident;	
 }
diff-tree 452ee1c85ffa057c3543011dfc831b1ebbb257cf (from 418ea790665d60149b2e4eca80970a45319f3c82)
Author: Tom Parker <palfrey at tevp.net>
Date:   Thu Aug 30 14:06:40 2007 +0200

    Handle invalid package ids

diff --git a/libpackagekit/pk-task-utils.c b/libpackagekit/pk-task-utils.c
index 12948a7..3406287 100644
--- a/libpackagekit/pk-task-utils.c
+++ b/libpackagekit/pk-task-utils.c
@@ -384,6 +384,12 @@ pk_task_package_ident_from_string (const
 
 	/* split by delimeter ';' */
 	sections = g_strsplit (package_id, ";", 4);
+	if (g_strv_length(sections)!=4)
+	{
+		pk_debug("Package ident '%s' is invalid (sections=%d)",package_id,g_strv_length(sections));
+		pk_task_package_ident_free(ident);
+		return NULL;
+	}
 	ident->name = g_strdup (sections[0]);
 	ident->version = g_strdup (sections[1]);
 	ident->arch = g_strdup (sections[2]);
diff-tree 418ea790665d60149b2e4eca80970a45319f3c82 (from 86e44697191580428b81a292d11f8ceb46aa55cb)
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Thu Aug 30 12:53:41 2007 +0200

    * Make the yum backend make more increment on download & installation, need the laest upstream yum git code to work, else extra percentage will not be shown.
    
    * Show package insted data on package download (also needs latest yum code)

diff --git a/helpers/yumBackend.py b/helpers/yumBackend.py
index 53d7747..10847a7 100644
--- a/helpers/yumBackend.py
+++ b/helpers/yumBackend.py
@@ -29,6 +29,7 @@ from urlgrabber.progress import BaseMete
 from yum.rpmtrans import RPMBaseCallback
 from yum.constants import *
 from yum.update_md import UpdateMetadata
+from yum.callbacks import *
 
 
 class PackageKitYumBackend(PackageKitBaseBackend):
@@ -400,8 +401,8 @@ class PackageKitYumBackend(PackageKitBas
                                                                                                
     def _setup_yum(self):
         self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0) # Setup Yum Config
-        callback = DownloadCallback(self,showNames=True)      # Download callback
-        self.yumbase.repos.setProgressBar( callback )         # Setup the download callback class
+        self.dnlCallback = DownloadCallback(self,showNames=True)      # Download callback
+        self.yumbase.repos.setProgressBar( self.dnlCallback )         # Setup the download callback class
 
 class DownloadCallback( BaseMeter ):
     """ Customized version of urlgrabber.progress.BaseMeter class """
@@ -412,7 +413,24 @@ class DownloadCallback( BaseMeter ):
         self.showNames = showNames
         self.oldName = None
         self.lastPct = 0
-
+        self.totalPct = 0
+        self.pkgs = None
+        self.numPkgs=0
+        self.bump = 0.0
+
+    def setPackages(self,pkgs,startPct,numPct):
+        self.pkgs = pkgs
+        self.numPkgs = len(self.pkgs)
+        self.bump = numPct/self.numPkgs
+        self.totalPct = startPct
+        
+    def _getPackage(self,name):
+        if self.pkgs:
+            for pkg in self.pkgs:
+                if pkg.name == name:
+                    return pkg
+        return None
+        
     def update( self, amount_read, now=None ):
         BaseMeter.update( self, amount_read, now )
 
@@ -466,11 +484,17 @@ class DownloadCallback( BaseMeter ):
         pct = int( frac*100 )
         if self.lastPct != pct:
             self.lastPct = pct
+            # bump the sub persentage for this package
             self.base.sub_percentage(int( frac*100 ))
         if name != self.oldName:
             self.oldName = name
+            if self.bump > 0.0: # Bump the total download percentage
+                self.totalPct += self.bump
+                self.base.percentage(int(self.totalPct))
             if self.showNames:
-                self.base.data(name)
+                pkg = self._getPackage(name)
+                if pkg: # show package to download
+                    self.base._show_package(pkgs,1)
 
 class PackageKitCallback(RPMBaseCallback):
     def __init__(self,base):
@@ -478,6 +502,13 @@ class PackageKitCallback(RPMBaseCallback
         self.base = base
         self.pct = 0
         self.curpkg = None
+        self.startPct = 50
+        self.numPct = 50
+
+    def _calcTotalPct(self,ts_current,ts_total):
+        bump = float(self.numPct)/ts_total
+        pct = int(self.startPct + (ts_current * bump))
+        return pct
 
     def event(self, package, action, te_current, te_total, ts_current, ts_total):
         if str(package) != self.curpkg:
@@ -487,6 +518,8 @@ class PackageKitCallback(RPMBaseCallback
                 self.base.status(STATE_INSTALL)
             elif action in TS_REMOVE_STATES:
                 self.base.status(STATE_REMOVE)
+            pct = self._calcTotalPct(ts_current, ts_total)
+            self.base.percentage(pct)
         val = (ts_current*100L)/ts_total
         if val != self.pct:
             self.pct = val
@@ -496,19 +529,16 @@ class PackageKitCallback(RPMBaseCallback
         # grrrrrrrr
         pass
 
-PT_DOWNLOAD        = 0
-PT_GPGCHECK        = 1
-PT_TEST_TRANS      = 2
-PT_TRANSACTION     = 3
-
 class ProcessTransPackageKitCallback:
     def __init__(self,base):
         self.base = base
 
-    def event(self,state):
-        if state == PT_DOWNLOAD:
+    def event(self,state,data=None):
+        if state == PT_DOWNLOAD:        # Start Downloading
             self.base.percentage(10)
             self.base.status(STATE_DOWNLOAD)
+        if state == PT_DOWNLOAD_PKGS:   # Packages to download 
+            self.base.dnlCallback.setPackages(data,10,30)
         elif state == PT_GPGCHECK:
             self.base.percentage(40)
             pass



More information about the PackageKit mailing list