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

Richard Hughes hughsient at kemper.freedesktop.org
Sun Oct 14 23:36:44 PDT 2007


 TODO                                     |   12 +++
 backends/conary/helpers/conaryBackend.py |   12 +--
 backends/yum/helpers/Makefile.am         |    1 
 backends/yum/helpers/yumBackend.py       |   98 ++++++++++---------------------
 backends/yum/pk-backend-yum.c            |    2 
 libpackagekit/pk-client.c                |    5 +
 python/packagekit/backend.py             |    8 ++
 src/pk-spawn.c                           |   10 ++-
 src/pk-transaction-db.c                  |   49 +++++++++++++--
 src/pk-transaction-db.h                  |    1 
 10 files changed, 117 insertions(+), 81 deletions(-)

New commits:
commit 845b291a8aa2cd64f5bb1622f4cdfb56f826e72e
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Sun Oct 14 22:19:23 2007 -0400

    yum: Emit no-precentage-updates for searching by file and details.

diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 307546a..e1e6922 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -162,6 +162,7 @@ backend_search_details (PkBackend *backend, const gchar *filter, const gchar *se
 {
 	g_return_if_fail (backend != NULL);
 	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_no_percentage_updates (backend);
 	pk_backend_spawn_helper (backend, "search-details.py", filter, search, NULL);
 }
 
@@ -173,6 +174,7 @@ backend_search_file (PkBackend *backend, const gchar *filter, const gchar *searc
 {
 	g_return_if_fail (backend != NULL);
 	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_no_percentage_updates (backend);
 	pk_backend_spawn_helper (backend, "search-file.py", filter, search, NULL);
 }
 
commit a9e72c1cf917f42e16045faeaa3e12bd31e40c32
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Sun Oct 14 21:36:07 2007 -0400

    yum: Filter on devel as well installed when searching for files.

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 13c5d34..e18b183 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -156,17 +156,19 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 filelist = pkg.filelist
                 for fn in filelist:
                     if key in fn and not found.has_key(str(pkg)):
-                        self._show_package(pkg, INFO_INSTALLED)
-                        found[str(pkg)] = 1
-        if not 'installed' in fltlist:
+                        if self._do_extra_filtering(pkg, fltlist):
+                            self._show_package(pkg, INFO_INSTALLED)
+                            found[str(pkg)] = 1
+        if not FILTER_INSTALLED in fltlist:
             # Check available for file
             self.yumbase.repos.populateSack(mdtype='filelists')
             for pkg in self.yumbase.pkgSack:
                 filelist = pkg.filelist
                 for fn in filelist:
                     if key in fn and not found.has_key(str(pkg)):
-                        self._show_package(pkg, INFO_AVAILABLE)
-                        found[str(pkg)] = 1
+                        if self._do_extra_filtering(pkg, fltlist):
+                            self._show_package(pkg, INFO_AVAILABLE)
+                            found[str(pkg)] = 1
 
 
     def _getEVR(self,idver):
commit 8a6814ddf674d3e98a973866ad6a834921354b15
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Sun Oct 14 13:40:16 2007 -0400

    yum: search must return installed package then available packages.
    
    Yum's search methods use a generator and do not return results in any
    particular order. So we must save the available packages in another
    list as we run through the generator, then return to them.

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 7469e74..13c5d34 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -68,6 +68,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         res = self.yumbase.searchGenerator(searchlist, [key])
         fltlist = filters.split(';')
 
+        available = []
         count = 1
         for (pkg,values) in res:
             if count > 100:
@@ -75,33 +76,17 @@ class PackageKitYumBackend(PackageKitBaseBackend):
             count+=1
             # are we installed?
             if pkg.repoid == 'installed':
-                installed = INFO_INSTALLED
+                if FILTER_NON_INSTALLED not in fltlist:
+                    if self._do_extra_filtering(pkg,fltlist):
+                        self._show_package(pkg, INFO_INSTALLED)
             else:
-                installed = INFO_AVAILABLE
-
-            if self._do_filtering(pkg,fltlist,installed):
-                self._show_package(pkg, installed)
-
-
-    def _do_filtering(self,pkg,filterList,installed):
-        ''' Filter the package, based on the filter in filterList '''
+                available.append(pkg)
 
-        # do we print to stdout?
-        do_print = False;
-        if filterList == ['none']: # 'none' = all packages.
-            return True
-        elif FILTER_INSTALLED in filterList and installed == INFO_INSTALLED:
-            do_print = True
-        elif FILTER_NON_INSTALLED in filterList and installed == INFO_AVAILABLE:
-            do_print = True
-
-        if len(filterList) == 1: # Only one filter, return
-            return do_print
-
-        if do_print:
-            return self._do_extra_filtering(pkg,filterList)
-        else:
-            return do_print
+        # Now show available packages.
+        if FILTER_INSTALLED not in fltlist:
+            for pkg in available:
+                if self._do_extra_filtering(pkg,fltlist):
+                    self._show_package(pkg, INFO_AVAILABLE)
 
     def _do_extra_filtering(self,pkg,filterList):
         ''' do extra filtering (gui,devel etc) '''
commit 1f5e7961c0cb90e113b5326a01c1ea543ff1c218
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Sun Oct 14 19:39:19 2007 -0400

    yum: Fix typo in _do_extra_filtering

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 70b6ccd..7469e74 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -109,10 +109,10 @@ class PackageKitYumBackend(PackageKitBaseBackend):
             if filter in (FILTER_INSTALLED, FILTER_NON_INSTALLED):
                 continue
             elif filter in (FILTER_GUI, FILTER_NON_GUI):
-                if not self._do_gui_filtering(flt,pkg):
+                if not self._do_gui_filtering(filter, pkg):
                     return False
             elif filter in (FILTER_DEVEL, FILTER_NON_DEVEL):
-                if not self._do_devel_filtering(flt,pkg):
+                if not self._do_devel_filtering(filter, pkg):
                     return False
         return True
 
commit 361925572408f56d8cd0d870ceee655a6d20275f
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 14 23:33:00 2007 +0100

    recreate the transaction.sb file is it does not exist

diff --git a/src/pk-transaction-db.c b/src/pk-transaction-db.c
index bfbafeb..4f76fdc 100644
--- a/src/pk-transaction-db.c
+++ b/src/pk-transaction-db.c
@@ -326,18 +326,59 @@ pk_transaction_db_class_init (PkTransactionDbClass *klass)
 }
 
 /**
+ * pk_transaction_db_create:
+ **/
+static void
+pk_transaction_db_create (PkTransactionDb *tdb)
+{
+	const gchar *statement;
+	statement = "CREATE TABLE transactions ("
+		    "transaction_id TEXT primary key,"
+		    "timespec TEXT,"
+		    "duration INTEGER,"
+		    "succeeded INTEGER DEFAULT 0,"
+		    "role TEXT,"
+		    "data TEXT,"
+		    "description TEXT);";
+	sqlite3_exec (tdb->priv->db, statement, NULL, 0, NULL);
+}
+
+/**
+ * pk_transaction_db_empty:
+ **/
+gboolean
+pk_transaction_db_empty (PkTransactionDb *tdb)
+{
+	const gchar *statement;
+
+	g_return_val_if_fail (tdb != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_TRANSACTION_DB (tdb), FALSE);
+
+	statement = "TRUNCATE TABLE transactions;";
+	sqlite3_exec (tdb->priv->db, statement, NULL, 0, NULL);
+	return TRUE;
+}
+
+/**
  * pk_transaction_db_init:
  **/
 static void
 pk_transaction_db_init (PkTransactionDb *tdb)
 {
-	const gchar *statement;
+	gboolean ret;
 	gint rc;
 
 	g_return_if_fail (tdb != NULL);
 	g_return_if_fail (PK_IS_TRANSACTION_DB (tdb));
 
 	tdb->priv = PK_TRANSACTION_DB_GET_PRIVATE (tdb);
+
+	/* if the database file was not installed (or was nuked) recreate it */
+	ret = g_file_test (PK_TRANSACTION_DB_FILE, G_FILE_TEST_EXISTS);
+	if (ret == FALSE) {
+		pk_transaction_db_create (tdb);
+	}
+
 	pk_debug ("trying to open database '%s'", PK_TRANSACTION_DB_FILE);
 	rc = sqlite3_open (PK_TRANSACTION_DB_FILE, &tdb->priv->db);
 	if (rc) {
@@ -345,12 +386,6 @@ pk_transaction_db_init (PkTransactionDb *tdb)
 		sqlite3_close (tdb->priv->db);
 		return;
 	}
-
-	/* add extra tables */
-	statement = "ALTER table transactions ADD timespec TEXT;";
-	sqlite3_exec (tdb->priv->db, statement, NULL, 0, NULL);
-	statement = "ALTER table transactions ADD data TEXT;";
-	sqlite3_exec (tdb->priv->db, statement, NULL, 0, NULL);
 }
 
 /**
diff --git a/src/pk-transaction-db.h b/src/pk-transaction-db.h
index 856829f..6b7900a 100644
--- a/src/pk-transaction-db.h
+++ b/src/pk-transaction-db.h
@@ -49,6 +49,7 @@ typedef struct
 
 GType		 pk_transaction_db_get_type		(void);
 PkTransactionDb	*pk_transaction_db_new			(void);
+gboolean	 pk_transaction_db_empty		(PkTransactionDb	*tdb);
 gboolean	 pk_transaction_db_add			(PkTransactionDb	*tdb,
 							 const gchar		*tid);
 gboolean	 pk_transaction_db_print		(PkTransactionDb	*tdb);
commit fbee9f317b7adb5254883a3f8f17295a6145d6b9
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 14 18:22:25 2007 +0100

    update TODO

diff --git a/TODO b/TODO
index d8124be..01dde3a 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,17 @@
 Order of no particular importance:
 
+*** Make the daemon aware on how long between updates ***
+Requires writing to a database for config stuff
+ - Probably should move the job number stuff there too
+New method GetHoursSinceLastUpdate
+Use this in the update icon
+
+*** yum backends should call no-percentage-updates when no feedback ***
+To fix: get_updates
+
+*** backends have to emit the installed packages first ***
+To fix: yum
+
 *** Add new callback for status ***
 TimeRemaining()
 
commit 43db14156e96d09897424c1dc0913f6eb2048714
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 14 17:14:28 2007 +0100

    make sure we disconnect the 100ms poll on unref in case we were cancelled before completion. should fix the segfault in http://www.foresightlinux.org/paste/1458/

diff --git a/src/pk-spawn.c b/src/pk-spawn.c
index d3561b1..503d779 100644
--- a/src/pk-spawn.c
+++ b/src/pk-spawn.c
@@ -57,6 +57,7 @@ struct PkSpawnPrivate
 	gint			 child_pid;
 	gint			 stderr_fd;
 	gint			 stdout_fd;
+	guint			 poll_id;
 	GString			*stderr_buf;
 	GString			*stdout_buf;
 };
@@ -237,8 +238,8 @@ pk_spawn_command (PkSpawn *spawn, const gchar *command)
 	fcntl (spawn->priv->stdout_fd, F_SETFL, O_NONBLOCK);
 	fcntl (spawn->priv->stderr_fd, F_SETFL, O_NONBLOCK);
 
-	/* poll every quickly */
-	g_timeout_add (PK_SPAWN_POLL_DELAY, (GSourceFunc) pk_spawn_check_child, spawn);
+	/* poll quickly */
+	spawn->priv->poll_id = g_timeout_add (PK_SPAWN_POLL_DELAY, (GSourceFunc) pk_spawn_check_child, spawn);
 
 	return TRUE;
 }
@@ -285,6 +286,7 @@ pk_spawn_init (PkSpawn *spawn)
 	spawn->priv->child_pid = -1;
 	spawn->priv->stderr_fd = -1;
 	spawn->priv->stdout_fd = -1;
+	spawn->priv->poll_id = 0;
 
 	spawn->priv->stderr_buf = g_string_new ("");
 	spawn->priv->stdout_buf = g_string_new ("");
@@ -306,6 +308,10 @@ pk_spawn_finalize (GObject *object)
 
 	g_return_if_fail (spawn->priv != NULL);
 
+	/* disconnect the poll in case we were cancelled before completion */
+	g_source_remove (spawn->priv->poll_id);
+
+	/* free the buffers */
 	g_string_free (spawn->priv->stderr_buf, TRUE);
 	g_string_free (spawn->priv->stdout_buf, TRUE);
 
commit 0ae9556fcb0deefaf34ca560a32d9aff18d60cdf
Merge: 011c429... 34bb31f...
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 14 17:09:50 2007 +0100

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

commit 011c42903552df264fac88fe32f16af23205f433
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 14 17:09:35 2007 +0100

    set the role for a couple of methods I missed

diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index d97db80..737c941 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -196,6 +196,7 @@ pk_client_reset (PkClient *client)
 	client->priv->use_buffer = FALSE;
 	client->priv->tid = NULL;
 	client->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
+	client->priv->role = PK_ROLE_ENUM_UNKNOWN;
 	client->priv->is_finished = FALSE;
 	pk_package_list_clear (client->priv->package_list);
 	return TRUE;
@@ -907,6 +908,8 @@ pk_client_get_updates (PkClient *client)
 		pk_warning ("Failed to get transaction ID");
 		return FALSE;
 	}
+	/* save this so we can re-issue it */
+	client->priv->role = PK_ROLE_ENUM_GET_UPDATES;
 
 	error = NULL;
 	ret = dbus_g_proxy_call (client->priv->proxy, "GetUpdates", &error,
@@ -970,6 +973,8 @@ pk_client_update_system (PkClient *client)
 		pk_warning ("Failed to get transaction ID");
 		return FALSE;
 	}
+	/* save this so we can re-issue it */
+	client->priv->role = PK_ROLE_ENUM_UPDATE_SYSTEM;
 
 	/* hopefully do the operation first time */
 	ret = pk_client_update_system_action (client, &error);
commit 34bb31f276465402803a89a166357da8f6fad5f0
Author: Luke Macken <lmacken at redhat.com>
Date:   Sun Oct 14 11:52:14 2007 -0400

    Remove duplicate PackageKitYumBase class definition.

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 2949cfe..70b6ccd 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -36,20 +36,6 @@ import exceptions
 class GPGKeyNotImported(exceptions.Exception):
     pass
 
-class PackageKitYumBase(yum.YumBase):
-    """ 
-    Custom YumBase Class for PackageKit
-    Used to overload methods in YumBase there need to be different in
-    PackageKit
-    
-    """
-    def _askForGPGKeyImport(self, po, userid, hexkeyid):
-        ''' 
-        Ask for GPGKeyImport 
-        '''
-        # TODO: Add code here to send the RepoSignatureRequired signal
-        return False    
-
 class PackageKitYumBackend(PackageKitBaseBackend):
 
     # Packages there require a reboot
@@ -758,7 +744,7 @@ class PackageKitYumBase(yum.YumBase):
     def _checkSignatures(self,pkgs,callback):
         ''' The the signatures of the downloaded packages '''
         # This can be overloaded by a subclass.
-        
+
         for po in pkgs:
             result, errmsg = self.sigCheckPkg(po)
             if result == 0:
@@ -776,3 +762,9 @@ class PackageKitYumBase(yum.YumBase):
 
         raise GPGKeyNotImported()
 
+    def _askForGPGKeyImport(self, po, userid, hexkeyid):
+        ''' 
+        Ask for GPGKeyImport 
+        '''
+        # TODO: Add code here to send the RepoSignatureRequired signal
+        return False
commit 5d619b50b6245a55b4bbe90e6265a86fddd504ea
Merge: 523ac4d... 1dcf260...
Author: Luke Macken <lmacken at redhat.com>
Date:   Sun Oct 14 11:24:24 2007 -0400

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

commit 1dcf26027b47defa5ff9d5930906c30c8dba74a9
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 14 16:18:50 2007 +0100

    ship the resolve.py file for the yum backend

diff --git a/backends/yum/helpers/Makefile.am b/backends/yum/helpers/Makefile.am
index eb107b2..e9bd526 100644
--- a/backends/yum/helpers/Makefile.am
+++ b/backends/yum/helpers/Makefile.am
@@ -14,6 +14,7 @@ dist_helper_DATA = 			\
 	get-description.py		\
 	install.py			\
 	remove.py			\
+	resolve.py			\
 	update.py			\
 	refresh-cache.py		\
 	update-system.py		\
commit 523ac4d9d9ab628bf00347913d6826fa21f51be3
Author: Luke Macken <lmacken at redhat.com>
Date:   Sun Oct 14 00:48:59 2007 -0400

    Backend filter cleanups.
    
    Pull the filter types into globals in the backend.py, and make the yum and conary backends utilize them.

diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 5845500..4ecc816 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -299,9 +299,9 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
         do_print = False;
         if filterList == ['none']: # 'none' = all packages.
             return True
-        elif 'installed' in filterList and installed == INFO_INSTALLED:
+        elif FILTER_INSTALLED in filterList and installed == INFO_INSTALLED:
             do_print = True
-        elif '~installed' in filterList and installed == INFO_AVAILABLE:
+        elif FILTER_NON_INSTALLED in filterList and installed == INFO_AVAILABLE:
             do_print = True
 
         if len(filterList) == 1: # Only one filter, return
@@ -315,17 +315,17 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
     def _do_extra_filtering(self, pkg, filterList):
         ''' do extra filtering (devel etc) '''
 
-        for flt in filterList:
-            if flt == 'installed' or flt =='~installed':
+        for filter in filterList:
+            if filter in (FILTER_INSTALLED, FILTER_NON_INSTALLED):
                 continue
-            elif flt =='devel' or flt=='~devel':
+            elif filter in (FILTER_DEVEL, FILTER_NON_DEVEL):
                 if not self._do_devel_filtering(flt,pkg):
                     return False
         return True
 
     def _do_devel_filtering(self, flt, pkg):
         isDevel = False
-        if flt == 'devel':
+        if flt == FILTER_DEVEL:
             wantDevel = True
         else:
             wantDevel = False
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index e2f2827..2949cfe 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -104,9 +104,9 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         do_print = False;
         if filterList == ['none']: # 'none' = all packages.
             return True
-        elif 'installed' in filterList and installed == INFO_INSTALLED:
+        elif FILTER_INSTALLED in filterList and installed == INFO_INSTALLED:
             do_print = True
-        elif '~installed' in filterList and installed == INFO_AVAILABLE:
+        elif FILTER_NON_INSTALLED in filterList and installed == INFO_AVAILABLE:
             do_print = True
 
         if len(filterList) == 1: # Only one filter, return
@@ -119,46 +119,35 @@ class PackageKitYumBackend(PackageKitBaseBackend):
 
     def _do_extra_filtering(self,pkg,filterList):
         ''' do extra filtering (gui,devel etc) '''
-
-        for flt in filterList:
-            if flt == 'installed' or flt =='~installed':
+        for filter in filterList:
+            if filter in (FILTER_INSTALLED, FILTER_NON_INSTALLED):
                 continue
-            elif flt == 'gui' or flt =='~gui':
+            elif filter in (FILTER_GUI, FILTER_NON_GUI):
                 if not self._do_gui_filtering(flt,pkg):
                     return False
-            elif flt =='devel' or flt=='~devel':
+            elif filter in (FILTER_DEVEL, FILTER_NON_DEVEL):
                 if not self._do_devel_filtering(flt,pkg):
                     return False
         return True
 
     def _do_gui_filtering(self,flt,pkg):
         isGUI = False
-        if flt == 'gui':
+        if flt == FILTER_GUI:
             wantGUI = True
         else:
             wantGUI = False
-        #
-        # TODO: Add GUI detection Code here.Set isGUI = True, if it is a GUI app
-        #
         isGUI = wantGUI # Fake it for now
-        #
-        #
         return isGUI == wantGUI
 
     def _do_devel_filtering(self,flt,pkg):
         isDevel = False
-        if flt == 'devel':
+        if flt == FILTER_DEVEL:
             wantDevel = True
         else:
             wantDevel = False
-        #
-        # TODO: Add Devel detection Code here.Set isDevel = True, if it is a devel app
-        #
         regex =  re.compile(r'(-devel)|(-dgb)|(-static)')
         if regex.search(pkg.name):
             isDevel = True
-        #
-        #
         return isDevel == wantDevel
 
 
@@ -190,7 +179,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         #self.yumbase.conf.cache = 1 # Only look in cache.
         fltlist = filters.split(';')
         found = {}
-        if not '~installed' in fltlist:
+        if not FILTER_NON_INSTALLED in fltlist:
             # Check installed for file
             for pkg in self.yumbase.rpmdb:
                 filelist = pkg.filelist
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 55894c3..73654da 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -59,6 +59,13 @@ INFO_UPDATING = "updating"
 INFO_INSTALLING = "installing"
 INFO_REMOVING = "removing"
 
+FILTER_INSTALLED = "installed"
+FILTER_NON_INSTALLED = "~installed"
+FILTER_GUI = "gui"
+FILTER_NON_GUI = "~gui"
+FILTER_DEVEL = "devel"
+FILTER_NON_DEVEL = "~devel"
+
 # Classes
 
 class PackageKitBaseBackend:
@@ -282,4 +289,3 @@ class PackageKitBaseBackend:
         Needed to be implemented in a sub class
         '''
         self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-



More information about the PackageKit mailing list