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

Richard Hughes hughsient at kemper.freedesktop.org
Wed Mar 26 13:53:37 PDT 2008


 TODO                                    |   25 -----
 backends/yum/helpers/Makefile.am        |    1 
 backends/yum/helpers/what-provides.py   |   24 +++++
 backends/yum/helpers/yumBackend.py      |  149 +++++++++++++++-----------------
 backends/yum/pk-backend-yum.c           |   15 +++
 backends/yum2/helpers/yumDBUSBackend.py |   40 +++++++-
 configure.ac                            |    2 
 docs/spec/pk-concepts.xml               |   63 +++++++++++++
 libpackagekit/pk-client.c               |   20 +---
 libpackagekit/pk-enum.c                 |    3 
 libpackagekit/pk-enum.h                 |    3 
 python/packagekit/backend.py            |   14 +++
 12 files changed, 239 insertions(+), 120 deletions(-)

New commits:
commit 00312d7ed1206301e6d90637ae0d72965076d883
Author: Scott Reeves <sreeves at novell.com>
Date:   Wed Mar 26 14:25:51 2008 -0600

    bump libzypp required version.

diff --git a/configure.ac b/configure.ac
index cd2f50e..b97ac9c 100755
--- a/configure.ac
+++ b/configure.ac
@@ -513,7 +513,7 @@ if test x$enable_poldek = xyes; then
 fi
 
 if test x$enable_zypp = xyes; then
-	PKG_CHECK_MODULES(ZYPP, libzypp >= 4.3.1)
+	PKG_CHECK_MODULES(ZYPP, libzypp >= 4.5.0)
 	AC_SUBST(ZYPP_CFLAGS)
 	AC_SUBST(ZYPP_LIBS)
 fi
commit b02582b522b2efcc151a9ffddef5bb3d75d3dc40
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 20:19:29 2008 +0000

    manually flush the output ratehr than relying on python to do it for us - this makes the yum backend so much more responsive

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index be02520..abf23c5 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -771,7 +771,9 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         Implement the {backend}-resolve functionality
         '''
+        print >> sys.stderr, "start init"
         self._check_init(lazy_cache=True)
+        print >> sys.stderr, "end init"
         self.allow_cancel(True);
         self.percentage(None)
         self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 270c018..706d580 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -60,6 +60,7 @@ class PackageKitBaseBackend:
             print "percentage\t%i" % (percent)
         else:
             print "no-percentage-updates"
+        sys.stdout.flush()
 
     def sub_percentage(self,percent=None):
         '''
@@ -67,6 +68,7 @@ class PackageKitBaseBackend:
         @param percent: subprogress percentage
         '''
         print "subpercentage\t%i" % (percent)
+        sys.stdout.flush()
 
     def error(self,err,description,exit=True):
         '''
@@ -76,6 +78,7 @@ class PackageKitBaseBackend:
         @param exit: exit application with rc=1, if true
         '''
         print "error\t%s\t%s" % (err,description)
+        sys.stdout.flush()
         if exit:
             if self.isLocked():
                 self.unLock()
@@ -89,6 +92,7 @@ class PackageKitBaseBackend:
         @param summary: The package Summary
         '''
         print >> sys.stdout,"package\t%s\t%s\t%s" % (status,id,summary)
+        sys.stdout.flush()
 
     def status(self,state):
         '''
@@ -96,6 +100,7 @@ class PackageKitBaseBackend:
         @param state: STATUS_DOWNLOAD, STATUS_INSTALL, STATUS_UPDATE, STATUS_REMOVE, STATUS_WAIT
         '''
         print "status\t%s" % (state)
+        sys.stdout.flush()
 
     def repo_detail(self,repoid,name,state):
         '''
@@ -104,6 +109,7 @@ class PackageKitBaseBackend:
         @param state: false is repo is disabled else true.
         '''
         print >> sys.stdout,"repo-detail\t%s\t%s\t%s" % (repoid,name,state)
+        sys.stdout.flush()
 
     def data(self,data):
         '''
@@ -111,6 +117,7 @@ class PackageKitBaseBackend:
         @param data:  The current worked on package
         '''
         print "data\t%s" % (data)
+        sys.stdout.flush()
 
     def metadata(self,typ,fname):
         '''
@@ -119,6 +126,7 @@ class PackageKitBaseBackend:
         @param fname:  The filename being downloaded
         '''
         print "metadata\t%s\t%s" % (typ,fname)
+        sys.stdout.flush()
 
     def description(self,id,license,group,desc,url,bytes):
         '''
@@ -131,6 +139,7 @@ class PackageKitBaseBackend:
         @param bytes: The size of the package, in bytes
         '''
         print >> sys.stdout,"description\t%s\t%s\t%s\t%s\t%s\t%ld" % (id,license,group,desc,url,bytes)
+        sys.stdout.flush()
 
     def files(self, id, file_list):
         '''
@@ -138,6 +147,7 @@ class PackageKitBaseBackend:
         @param file_list: List of the files in the package, separated by ';'
         '''
         print >> sys.stdout,"files\t%s\t%s" % (id, file_list)
+        sys.stdout.flush()
 
     def update_detail(self,id,updates,obsoletes,vendor_url,bugzilla_url,cve_url,restart,update_text):
         '''
@@ -152,6 +162,7 @@ class PackageKitBaseBackend:
         @param update_text:
         '''
         print >> sys.stdout,"updatedetail\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (id,updates,obsoletes,vendor_url,bugzilla_url,cve_url,restart,update_text)
+        sys.stdout.flush()
 
     def require_restart(self,restart_type,details):
         '''
@@ -160,6 +171,7 @@ class PackageKitBaseBackend:
         @param details: Optional details about the restart
         '''
         print "requirerestart\t%s\t%s" % (restart_type,details)
+        sys.stdout.flush()
 
     def allow_cancel(self,allow):
         '''
@@ -171,6 +183,7 @@ class PackageKitBaseBackend:
         else:
             data = 'false'
         print "allow-cancel\t%s" % (data)
+        sys.stdout.flush()
 
     def repo_signature_required(self,repo_name,key_url,key_userid,key_id,key_fingerprint,key_timestamp,type):
         '''
@@ -186,6 +199,7 @@ class PackageKitBaseBackend:
         print "repo-signature-required\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (
             repo_name,key_url,key_userid,key_id,key_fingerprint,key_timestamp,type
             )
+        sys.stdout.flush()
 
     def get_package_id(self,name,version,arch,data):
         return "%s;%s;%s;%s" % (name,version,arch,data)
commit 733ac2414327c5fa81be1a50284e8f25b823b1f2
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Wed Mar 26 15:21:10 2008 -0400

    Emit dep-resolve for yum and yum2 backends

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index ebb22ff..be02520 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -223,7 +223,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
     def __init__(self,args,lock=True):
         signal.signal(signal.SIGQUIT, sigquit)
         PackageKitBaseBackend.__init__(self,args)
-        self.yumbase = PackageKitYumBase()
+        self.yumbase = PackageKitYumBase(self)
         yumbase = self.yumbase
         self._setup_yum()
         if lock:
@@ -1397,15 +1397,37 @@ class ProcessTransPackageKitCallback:
             self.base.percentage(50)
             pass
 
+
+class DepSolveCallback(object):
+
+    # XXX takes a PackageKitBackend so we can call StatusChanged on it.
+    # That's kind of hurky.
+    def __init__(self, backend):
+        self.started = False
+        self.backend = backend
+
+    def start(self):
+       if not self.started:
+           self.backend.status(STATUS_DEP_RESOLVE)
+
+    # Be lazy and not define the others explicitly
+    def _do_nothing(self, *args, **kwargs):
+        pass
+
+    def __getattr__(self, x):
+        return self._do_nothing
+
+
 class PackageKitYumBase(yum.YumBase):
     """
     Subclass of YumBase.  Needed so we can overload _checkSignatures
     and nab the gpg sig data
     """
 
-    def __init__(self):
+    def __init__(self, backend):
         yum.YumBase.__init__(self)
         self.missingGPGKey = None
+        self.dsCallback = DepSolveCallback(backend)
 
     def _checkSignatures(self,pkgs,callback):
         ''' The the signatures of the downloaded packages '''
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index f87f35c..2079525 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -330,7 +330,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
     def doInit(self):
         print "Now in doInit()"
         # yumbase is defined outside of this class so the sigquit handler can close the DB.
-        yumbase = PackageKitYumBase()
+        yumbase = PackageKitYumBase(self)
         self.yumbase = yumbase
         print "new yumbase object"
         self._setup_yum()
@@ -2124,16 +2124,38 @@ class ProcessTransPackageKitCallback:
             self.base.PercentageChanged(50)
             pass
 
+
+class DepSolveCallback(object):
+
+    # XXX takes a PackageKitBackend so we can call StatusChanged on it.
+    # That's kind of hurky.
+    def __init__(self, backend):
+        self.started = False
+        self.backend = backend
+
+    def start(self):
+       if not self.started:
+           self.backend.StatusChanged(STATUS_DEP_RESOLVE)
+
+    # Be lazy and not define the others explicitly
+    def _do_nothing(self, *args, **kwargs):
+        pass
+
+    def __getattr__(self, x):
+        return self._do_nothing
+
+
 class PackageKitYumBase(yum.YumBase):
     """
     Subclass of YumBase.  Needed so we can overload _checkSignatures
     and nab the gpg sig data
     """
 
-    def __init__(self):
+    def __init__(self, backend):
         yum.YumBase.__init__(self)
         self.missingGPGKey = None
         self.skipped_packages = []
+        self.dsCallback = DepSolveCallback(backend)
 
     # Modified searchGenerator to make sure that
     # non unicode strings read from rpmdb is converted to unicode
commit a2fbc4b63280d7adea80fc4e916214da520a9d8e
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 17:06:04 2008 +0000

    add another status enum TEST_COMMIT

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index f871c95..ebb22ff 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -1390,6 +1390,7 @@ class ProcessTransPackageKitCallback:
         elif state == PT_TEST_TRANS:
             self.base.allow_cancel(False)
             self.base.percentage(45)
+            self.base.status(STATUS_TEST_COMMIT)
             pass
         elif state == PT_TRANSACTION:
             self.base.allow_cancel(False)
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 88078ef..f87f35c 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -2117,6 +2117,7 @@ class ProcessTransPackageKitCallback:
         elif state == PT_TEST_TRANS:
             self.base.AllowCancel(False)
             self.base.PercentageChanged(45)
+            self.base.StatusChanged(STATUS_TEST_COMMIT)
             pass
         elif state == PT_TRANSACTION:
             self.base.AllowCancel(False)
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 642fce2..8767a12 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -64,6 +64,7 @@ static PkEnumMatch enum_status[] = {
 	{PK_STATUS_ENUM_DEP_RESOLVE,		"dep-resolve"},
 	{PK_STATUS_ENUM_SIG_CHECK,		"sig-check"},
 	{PK_STATUS_ENUM_ROLLBACK,		"rollback"},
+	{PK_STATUS_ENUM_TEST_COMMIT,		"test-commit"},
 	{PK_STATUS_ENUM_COMMIT,			"commit"},
 	{PK_STATUS_ENUM_REQUEST,		"request"},
 	{PK_STATUS_ENUM_FINISHED,		"finished"},
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 8658842..d733652 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -109,6 +109,7 @@ typedef enum {
 	PK_STATUS_ENUM_DEP_RESOLVE,
 	PK_STATUS_ENUM_SIG_CHECK,
 	PK_STATUS_ENUM_ROLLBACK,
+	PK_STATUS_ENUM_TEST_COMMIT,
 	PK_STATUS_ENUM_COMMIT,
 	PK_STATUS_ENUM_REQUEST,
 	PK_STATUS_ENUM_FINISHED,
commit a6e81f20aa343062e6f8700dd70b998d6d012450
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 16:57:31 2008 +0000

    yum: spawn the file when we do what_provides

diff --git a/backends/yum/helpers/Makefile.am b/backends/yum/helpers/Makefile.am
index aefc764..7f78291 100644
--- a/backends/yum/helpers/Makefile.am
+++ b/backends/yum/helpers/Makefile.am
@@ -23,6 +23,7 @@ dist_helper_DATA = 			\
 	update.py			\
 	install-file.py			\
 	refresh-cache.py		\
+	what-provides.py		\
 	update-system.py		\
 	yumBackend.py			\
 	$(NULL)
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 35e306c..789db09 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -378,6 +378,19 @@ backend_repo_set_data (PkBackend *backend, const gchar *rid, const gchar *parame
 	pk_backend_spawn_helper (spawn, "repo-set-data.py", rid, parameter, value, NULL);
 }
 
+/**
+ * backend_what_provides:
+ */
+static void
+backend_what_provides (PkBackend *backend, const gchar *filter, PkProvidesEnum provides, const gchar *search)
+{
+	const gchar *provides_text;
+	g_return_if_fail (backend != NULL);
+	g_return_if_fail (spawn != NULL);
+	provides_text = pk_provides_enum_to_text (provides);
+	pk_backend_spawn_helper (spawn, "what-provides.py", filter, provides_text, search, NULL);
+}
+
 PK_BACKEND_OPTIONS (
 	"YUM",					/* description */
 	"Tim Lauridsen <timlau at fedoraproject.org>",	/* author */
@@ -408,6 +421,6 @@ PK_BACKEND_OPTIONS (
 	backend_repo_enable,			/* repo_enable */
 	backend_repo_set_data,			/* repo_set_data */
 	NULL,					/* service_pack */
-	NULL					/* what_provides */
+	backend_what_provides			/* what_provides */
 );
 
commit 805f4342203ab70c2195af708af051ae187c8baf
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 16:53:19 2008 +0000

    add another status enum SIG_CHECK

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 3ac2dc9..f871c95 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -1385,6 +1385,7 @@ class ProcessTransPackageKitCallback:
             self.base.dnlCallback.setPackages(data,10,30)
         elif state == PT_GPGCHECK:
             self.base.percentage(40)
+            self.base.status(STATUS_SIG_CHECK)
             pass
         elif state == PT_TEST_TRANS:
             self.base.allow_cancel(False)
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 97e5108..88078ef 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -2112,6 +2112,7 @@ class ProcessTransPackageKitCallback:
             self.base.dnlCallback.setPackages(data,10,30)
         elif state == PT_GPGCHECK:
             self.base.PercentageChanged(40)
+            self.base.StatusChanged(STATUS_SIG_CHECK)
             pass
         elif state == PT_TEST_TRANS:
             self.base.AllowCancel(False)
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 8ba2b0d..642fce2 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -62,6 +62,7 @@ static PkEnumMatch enum_status[] = {
 	{PK_STATUS_ENUM_CLEANUP,		"cleanup"},
 	{PK_STATUS_ENUM_OBSOLETE,		"obsolete"},
 	{PK_STATUS_ENUM_DEP_RESOLVE,		"dep-resolve"},
+	{PK_STATUS_ENUM_SIG_CHECK,		"sig-check"},
 	{PK_STATUS_ENUM_ROLLBACK,		"rollback"},
 	{PK_STATUS_ENUM_COMMIT,			"commit"},
 	{PK_STATUS_ENUM_REQUEST,		"request"},
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 9248886..8658842 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -107,6 +107,7 @@ typedef enum {
 	PK_STATUS_ENUM_CLEANUP,
 	PK_STATUS_ENUM_OBSOLETE,
 	PK_STATUS_ENUM_DEP_RESOLVE,
+	PK_STATUS_ENUM_SIG_CHECK,
 	PK_STATUS_ENUM_ROLLBACK,
 	PK_STATUS_ENUM_COMMIT,
 	PK_STATUS_ENUM_REQUEST,
commit e7a3736574ddaabe610d47d1bc9ec62df87fde9d
Author: Tim Lauridsen <tim at naboo.local>
Date:   Wed Mar 26 17:42:48 2008 +0100

    yum: added what-provides support (needs testing)

diff --git a/backends/yum/helpers/what-provides.py b/backends/yum/helpers/what-provides.py
new file mode 100755
index 0000000..1fc057e
--- /dev/null
+++ b/backends/yum/helpers/what-provides.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+# Copyright (C) 2007 Red Hat Inc, Seth Vidal <skvidal at fedoraproject.org>
+#
+# 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
+
+filters = sys.argv[1]
+provides_type = sys.argv[2]
+search = sys.argv[3]
+
+from yumBackend import PackageKitYumBackend
+
+backend = PackageKitYumBackend(sys.argv[1:],lock=False)
+backend.what_provides(filters, provides_type, search)
+sys.exit(0)
+
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 8139500..3ac2dc9 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -537,6 +537,34 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                         self._show_package(pkg, INFO_AVAILABLE)
                         found[str(pkg)] = 1
 
+    def what_provides(self, filters, provides_type, search):
+        '''
+        Implement the {backend}-what-provides functionality
+        '''
+        self._check_init(lazy_cache=True)
+        self.allow_cancel(True)
+        self.percentage(None)
+        self.status(STATUS_QUERY)
+
+        fltlist = filters.split(';')
+        found = {}
+        if not FILTER_NOT_INSTALLED in fltlist:
+            # Check installed for file
+            matches = self.yumbase.rpmdb.searchProvides(search)
+            for pkg in matches:
+                if not found.has_key(str(pkg)):
+                    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
+            matches = self.yumbase.pkgSack.searchProvides(search)
+            for pkg in matches:
+                if found.has_key(str(pkg)):
+                    if self._do_extra_filtering(pkg, fltlist):
+                        self._show_package(pkg, INFO_AVAILABLE)
+                        found[str(pkg)] = 1
+
     def _getEVR(self,idver):
         '''
         get the e,v,r from the package id version
commit 40c48be7bf1face641a9e12a9c82c5258fc2778b
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 16:38:20 2008 +0000

    add some STATUS running calls to the yum and yum2 backends

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 02a09a2..8139500 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -696,6 +696,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self._check_init(lazy_cache=True)
         self.allow_cancel(False)
         self.percentage(0)
+        self.status(STATUS_RUNNING)
 
         txmbr = self.yumbase.update() # Add all updates to Transaction
         if txmbr:
@@ -780,6 +781,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self._check_init()
         self.allow_cancel(False)
         self.percentage(0)
+        self.status(STATUS_RUNNING)
         txmbrs = []
         for package in packages:
             pkg,inst = self._findPackage(package)
@@ -803,6 +805,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self._check_init()
         self.allow_cancel(False);
         self.percentage(0)
+        self.status(STATUS_RUNNING)
 
         pkgs_to_inst = []
         self.yumbase.conf.gpgcheck=0
@@ -824,6 +827,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self._check_init()
         self.allow_cancel(False);
         self.percentage(0)
+        self.status(STATUS_RUNNING)
         txmbrs = []
         for package in packages:
             pkg,inst = self._findPackage(package)
@@ -906,6 +910,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self._check_init()
         self.allow_cancel(False);
         self.percentage(0)
+        self.status(STATUS_RUNNING)
 
         pkg,inst = self._findPackage( package)
         if pkg and inst:
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 0d75ea1..97e5108 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -639,6 +639,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self._lock_yum()
         self.AllowCancel(False)
         self.PercentageChanged(0)
+        self.StatusChanged(STATUS_RUNNING)
         old_throttle = self.yumbase.conf.throttle
         self.yumbase.conf.throttle = "60%" # Set bandwidth throttle to 60%
                                            # to avoid taking all the system's bandwidth.
@@ -800,6 +801,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self._lock_yum()
         self.AllowCancel(False)
         self.PercentageChanged(0)
+        self.StatusChanged(STATUS_RUNNING)
 
         pkg,inst = self._findPackage(package)
         if pkg:
@@ -897,6 +899,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self._lock_yum()
         self.AllowCancel(False)
         self.PercentageChanged(0)
+        self.StatusChanged(STATUS_RUNNING)
 
         for package_id in packages:
             package, installed = self._findPackage(package_id)
@@ -942,6 +945,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self._lock_yum()
         self.AllowCancel(False)
         self.PercentageChanged(0)
+        self.StatusChanged(STATUS_RUNNING)
 
         pkg,inst = self._findPackage( package)
         if pkg and inst:
@@ -1259,6 +1263,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self._lock_yum()
         self.AllowCancel(True)
         self.PercentageChanged(0)
+        self.StatusChanged(STATUS_RUNNING)
 
         # Go get the GPG key from the given URL
         try:
commit c2625e0e3ae8f8ef036f2064644f1e5a62937c2c
Merge: 5d0f5c6... 0c82321...
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 15:12:16 2008 +0000

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

commit 5d0f5c62742d97ed6e043865ede133895953f8f1
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 15:10:28 2008 +0000

    don't emit STATUS_WAIT in the yum and yum backends to avoid a nag-error

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 94effc8..2a54fd7 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -267,8 +267,6 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 self.yumbase.doLock( YUM_PID_FILE )
                 PackageKitBaseBackend.doLock(self)
             except:
-                if retries == 0:
-                    self.status(STATUS_WAIT)
                 time.sleep(2)
                 retries += 1
                 if retries > 100:
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index baa761a..0d75ea1 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -350,8 +350,6 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 self.yumbase.doLock( YUM_PID_FILE )
                 self.locked = True
             except:
-                if retries == 0:
-                    self.StatusChanged(STATUS_WAIT)
                 time.sleep(2)
                 retries += 1
                 if retries > 20:
commit 0c8232137a2dc9d1292a1908936bded2895f4ed0
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Wed Mar 26 15:50:17 2008 +0100

    yum : cleanup install_file and use code in current yum instead

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 94effc8..a669cb7 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -33,6 +33,7 @@ from yum.constants import *
 from yum.update_md import UpdateMetadata
 from yum.callbacks import *
 from yum.misc import prco_tuple_to_string, unique
+from yum.packages import YumLocalPackage
 import rpmUtils
 import exceptions
 import types
@@ -792,78 +793,6 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         else:
             self.error(ERROR_PACKAGE_ALREADY_INSTALLED,"No packages to instal")
 
-    def _localInstall(self, inst_file):
-        """handles installs/updates of rpms provided on the filesystem in a
-           local dir (ie: not from a repo)"""
-
-        # Slightly modified localInstall from yum's cli.py
-
-        # read in each package into a YumLocalPackage Object
-        # append it to self.yumbase.localPackages
-        # check if it can be installed or updated based on nevra versus rpmdb
-        # don't import the repos until we absolutely need them for depsolving
-
-        oldcount = len(self.yumbase.tsInfo)
-
-        installpkgs = []
-        updatepkgs = []
-
-        pkg = inst_file
-        try:
-            po = yum.packages.YumLocalPackage(ts=self.yumbase.rpmdb.readOnlyTS(), filename=pkg)
-        except yum.Errors.MiscError:
-            self.error(ERROR_INTERNAL_ERROR,'Cannot open file: %s. Skipping.' % pkg)
-
-        # everything installed that matches the name
-        installedByKey = self.yumbase.rpmdb.searchNevra(name=po.name)
-        # go through each package
-        if len(installedByKey) == 0: # nothing installed by that name
-            installpkgs.append(po)
-        else:
-            for installed_pkg in installedByKey:
-                if po.EVR > installed_pkg.EVR: # we're newer - this is an update, pass to them
-                    if installed_pkg.name in self.yumbase.conf.exactarchlist:
-                        if po.arch == installed_pkg.arch:
-                            updatepkgs.append((po, installed_pkg))
-                            continue
-                        else:
-                            continue
-                    else:
-                        updatepkgs.append((po, installed_pkg))
-                        continue
-                elif po.EVR == installed_pkg.EVR:
-                    if po.arch != installed_pkg.arch and (isMultiLibArch(po.arch) or
-                              isMultiLibArch(installed_pkg.arch)):
-                        installpkgs.append(po)
-                        continue
-                    else:
-                        continue
-                else:
-                    continue
-
-        # handle excludes for a localinstall
-        toexc = []
-        if len(self.yumbase.conf.exclude) > 0:
-           exactmatch, matched, unmatched = \
-                   yum.packages.parsePackages(installpkgs + map(lambda x: x[0], updatepkgs),
-                                 self.yumbase.conf.exclude, casematch=1)
-           toexc = exactmatch + matched
-
-        # Process potential installs
-        for po in installpkgs:
-            if po in toexc:
-               continue     # Exclude package
-            # Add package to transaction for installation
-            self.yumbase.localPackages.append(po)
-            self.yumbase.install(po=po)
-        # Process potential updates
-        for (po, oldpo) in updatepkgs:
-            if po in toexc:
-               continue # Excludeing package
-            # Add Package to transaction for updating
-            self.yumbase.localPackages.append(po)
-            self.yumbase.tsInfo.addUpdate(po, oldpo)
-
     def install_file (self, inst_file):
         '''
         Implement the {backend}-install_file functionality
@@ -879,7 +808,8 @@ class PackageKitYumBackend(PackageKitBaseBackend):
 
         pkgs_to_inst = []
         self.yumbase.conf.gpgcheck=0
-        self._localInstall(inst_file)
+        txmbr = self.yumbase.installLocal(inst_file)
+        print txmbr
         try:
             # Added the package to the transaction set
             if len(self.yumbase.tsInfo) > 0:
@@ -1273,7 +1203,10 @@ class DownloadCallback( BaseMeter ):
     def _getPackage(self,name):
         if self.pkgs:
             for pkg in self.pkgs:
-                rpmfn = os.path.basename(pkg.remote_path) # get the rpm filename of the package
+                if isinstance(pkg, YumLocalPackage):
+                    rpmfn = pkg.localPkg
+                else:
+                    rpmfn = os.path.basename(pkg.remote_path) # get the rpm filename of the package
                 if rpmfn == name:
                     return pkg
         return None
commit 5fdc4c7f6ce5c2cf3731c8a9720675af29537ae2
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 14:05:47 2008 +0000

    update TODO

diff --git a/TODO b/TODO
index 46bb125..7ada72e 100644
--- a/TODO
+++ b/TODO
@@ -3,18 +3,11 @@ Order of no particular importance:
 * Make installing firmware with udev possible:
   http://lists.freedesktop.org/archives/packagekit/2008-March/002430.html
 
-* Make the Update call into Updates. Big change.
-
 * Fix ServicePack to work correctly:
   http://lists.freedesktop.org/archives/packagekit/2008-March/002434.html
 
 * Find out why yum doesn't output some package status calls.
 
-* Lots of the functions are not well commented with gtk-doc. Most
-important is to get the libpackagekit/*.c annotated as it's used in
-other projects. This is probably quite a boring job but is a good way to
-work out how PackageKit is put together.
-
 * We need to make sure the html documentation is still correct and easy
 to read - does any of it sound like technobabble? Is it easy enough for
 developers to get detailed information about how to contribute?
@@ -38,17 +31,9 @@ org.freedesktop.PackageKit.conf file installed in the system prefix -
 maybe we can #ifdef the daemon to run in the session bus for some
 testing.
 
-* The gnome-packagekit tools don't exactly conform the the GNOME Human
-Interface Guidelines (HIG). Someone needs to evaluate the GUI tools and
-suggest changing some control types, adding key-shortcuts and tooltips
-and changing the spacing between widgets where needed.
-
 *** write to the database for config stuff
  - Probably should move the job number too
 
-*** package->status ***
-Convert the backends to send more status calls.
-
 *** Add a way to import GPG keys ***
 In fedora, if you add a signed repo you have to agree to the GPG key.
 
@@ -59,17 +44,7 @@ Have different permissions for signed and unsigned repos.
 To do rollbacks sanely in PK we need a few things:
  - allow transaction data to be changed in _db
 
-*** Make resolve easier to use ***
-resolve in pkcon has to check for installed package already - and not
-display a cryptic message when already installed
-
 *** Don't display install if something is upgradable
  - Return update when we search for something that is installed, but an
    update exists for
 
-*** FIX WAF:
- - build errors
- - build enum.py
- - install the bash completion script
- - install the yum module
-
commit 699aced200453effaf8e0fdd67a73fe45ab9d01f
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 13:25:37 2008 +0000

    add a sensible error for installing source packages

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index c343b84..94effc8 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -871,7 +871,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         Needed to be implemented in a sub class
         '''
         if inst_file.endswith('.src.rpm'):
-            self.error(ERROR_INTERNAL_ERROR,'Backend will not install a src rpm file')
+            self.error(ERROR_CANNOT_INSTALL_SOURCE_PACKAGE,'Backend will not install a src rpm file')
             return
         self._check_init()
         self.allow_cancel(False);
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 106ac7a..baa761a 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -840,7 +840,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         Needed to be implemented in a sub class
         '''
         if inst_file.endswith('.src.rpm'):
-            self.ErrorCode(ERROR_INTERNAL_ERROR,'Backend will not install a src rpm file')
+            self.ErrorCode(ERROR_CANNOT_INSTALL_SOURCE_PACKAGE,'Backend will not install a src rpm file')
             self.Finished(EXIT_FAILED)
             return
         
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index e779094..8ba2b0d 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -130,6 +130,7 @@ static PkEnumMatch enum_error[] = {
 	{PK_ERROR_ENUM_CANNOT_WRITE_REPO_CONFIG,        "cannot-write-repo-config"},
 	{PK_ERROR_LOCAL_INSTALL_FAILED,         "local-install-failed"},
 	{PK_ERROR_BAD_GPG_SIGNATURE,            "bad-gpg-signature"},
+	{PK_ERROR_ENUM_CANNOT_INSTALL_SOURCE_PACKAGE,       "cannot-install-source-package"},
 	{0, NULL}
 };
 
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index d449c2a..9248886 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -212,6 +212,7 @@ typedef enum {
 	PK_ERROR_ENUM_CANNOT_WRITE_REPO_CONFIG,
 	PK_ERROR_LOCAL_INSTALL_FAILED,
 	PK_ERROR_BAD_GPG_SIGNATURE,
+	PK_ERROR_ENUM_CANNOT_INSTALL_SOURCE_PACKAGE,
 	PK_ERROR_ENUM_UNKNOWN
 } PkErrorCodeEnum;
 
commit ae882c1366fab59d51c7065b23fb1579a2c3b355
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Wed Mar 26 12:26:58 2008 +0100

    yum2: Make InstallFile bail out on a src.rpm (this time in the right place)

diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 979fa32..106ac7a 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -798,11 +798,6 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         Implement the {backend}-install functionality
         This will only work with yum 3.2.4 or higher
         '''
-        if inst_file.endswith('.src.rpm'):
-            self.ErrorCode(ERROR_INTERNAL_ERROR,'Backend will not install a src rpm file')
-            self.Finished(EXIT_FAILED)
-            return
-        
         self._check_init()
         self._lock_yum()
         self.AllowCancel(False)
@@ -844,6 +839,11 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         Install the package containing the inst_file file
         Needed to be implemented in a sub class
         '''
+        if inst_file.endswith('.src.rpm'):
+            self.ErrorCode(ERROR_INTERNAL_ERROR,'Backend will not install a src rpm file')
+            self.Finished(EXIT_FAILED)
+            return
+        
         self._check_init()
         self._lock_yum()
         self.AllowCancel(True)
commit 1e278e8293a23530a8c3af9489b3f6e0937112e1
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Wed Mar 26 12:25:36 2008 +0100

    yum2: Make InstallFile bail out on a src.rpm

diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 40642ae..979fa32 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -798,6 +798,11 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         Implement the {backend}-install functionality
         This will only work with yum 3.2.4 or higher
         '''
+        if inst_file.endswith('.src.rpm'):
+            self.ErrorCode(ERROR_INTERNAL_ERROR,'Backend will not install a src rpm file')
+            self.Finished(EXIT_FAILED)
+            return
+        
         self._check_init()
         self._lock_yum()
         self.AllowCancel(False)
commit b76b0b389f7b9f8408f82464964e35fad28a14a8
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Wed Mar 26 12:21:14 2008 +0100

    yum: Make install-file bailout on a src.rpm

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index da6808b..c343b84 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -870,6 +870,9 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         Install the package containing the inst_file file
         Needed to be implemented in a sub class
         '''
+        if inst_file.endswith('.src.rpm'):
+            self.error(ERROR_INTERNAL_ERROR,'Backend will not install a src rpm file')
+            return
         self._check_init()
         self.allow_cancel(False);
         self.percentage(0)
commit 2fde8894a992f16c690fea139ff57c84341288f0
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 11:08:45 2008 +0000

    do the requeue in a sane way, without nuking the cached things we are trying to preserve...

diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 25bf66b..482a41e 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -183,7 +183,7 @@ pk_client_error_set (GError **error, gint code, const gchar *format, ...)
 
 	/* dumb */
 	if (error == NULL) {
-		pk_warning ("%s", buffer);
+		pk_warning ("No error set, so can't set: %s", buffer);
 		ret = FALSE;
 		goto out;
 	}
@@ -521,12 +521,10 @@ pk_client_reset (PkClient *client, GError **error)
 	client->priv->cached_full_path = NULL;
 	client->priv->cached_filter = NULL;
 	client->priv->cached_search = NULL;
-	client->priv->cached_search = NULL;
 	client->priv->cached_package_ids = NULL;
 	client->priv->use_buffer = FALSE;
 	client->priv->synchronous = FALSE;
 	client->priv->name_filter = 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;
@@ -3119,7 +3117,6 @@ pk_client_get_filters (PkClient *client)
 gboolean
 pk_client_requeue (PkClient *client, GError **error)
 {
-	PkRoleEnum role;
 	gboolean ret;
 	PkClientPrivate *priv = PK_CLIENT_GET_PRIVATE (client);
 
@@ -3132,14 +3129,15 @@ pk_client_requeue (PkClient *client, GError **error)
 		return FALSE;
 	}
 
-	/* save the role */
-	role = priv->role;
-
-	/* reset this client, which doesn't clear cached data */
-	pk_client_reset (client, NULL);
+	/* clear enough data of the client to allow us to requeue */
+	g_free (client->priv->tid);
+	client->priv->tid = NULL;
+	client->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
+	client->priv->is_finished = FALSE;
 
-	/* restore the role */
-	priv->role = role;
+	/* clear hash and package list */
+	g_hash_table_remove_all (client->priv->hash);
+	pk_package_list_clear (client->priv->package_list);
 
 	/* do the correct action with the cached parameters */
 	if (priv->role == PK_ROLE_ENUM_GET_DEPENDS) {
commit e56b53f6a017f573e58f71dabb30b119205880db
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Mar 26 09:34:59 2008 +0000

    document the PkStatusEnum state machine

diff --git a/docs/spec/pk-concepts.xml b/docs/spec/pk-concepts.xml
index 9c54af0..10b8944 100644
--- a/docs/spec/pk-concepts.xml
+++ b/docs/spec/pk-concepts.xml
@@ -522,5 +522,68 @@
       <literal>45;dafeca;checkpoint32</literal>
     </para>
   </sect1>
+
+  <sect1 id="introduction-ideas-status">
+    <title>Status Values</title>
+    <para>
+      A transaction will have different status values as it it queued, prepared
+      and executed.
+      The <literal>::StatusChanged</literal> signal from PkClient allow you
+      to design user interfaces that tell the user what is happening with the
+      transaction.
+    </para>
+    <para>
+      A typical transaction will have the following states:
+    </para>
+    <itemizedlist>
+      <listitem>
+        <para>
+          Queued in the active queue (<literal>PK_STATUS_ENUM_WAIT</literal>)
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          Transaction started, and is being prepared (<literal>PK_STATUS_ENUM_SETUP</literal>)
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          The transaction is running (<literal>PK_STATUS_ENUM_RUNNING</literal>)
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          (optional) Data is downloading (<literal>PK_STATUS_ENUM_DOWNLOADING</literal>)
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          (optional) Data is installing (<literal>PK_STATUS_ENUM_INSTALLING</literal>)
+        </para>
+      </listitem>
+      <listitem>
+        <para>
+          The transaction is finished (<literal>PK_STATUS_ENUM_FINISHED</literal>)
+        </para>
+      </listitem>
+    </itemizedlist>
+    <para>
+      If the transaction is waiting for other jobs to finish (in the active queue)
+      then the status will be stuck at <literal>PK_STATUS_ENUM_WAIT</literal>
+      and the UI should show a message to this effect.
+    </para>
+    <para>
+      If the transaction is waiting for a package lock (when a legacy tool like
+      <literal>pirut</literal> is loaded and has the <literal>yum</literal> lock)
+      then the transaction will be stuck at <literal>PK_STATUS_ENUM_SETUP</literal>.
+    </para>
+    <para>
+      As a backend writer, you do not have to set <literal>PK_STATUS_ENUM_RUNNING</literal>
+      manually, as this will be set for you if you set any other value such as
+      <literal>PK_STATUS_ENUM_DOWNLOADING</literal> or <literal>PK_STATUS_ENUM_INFO</literal>.
+      However, you will need to avoid setting any status values until a package
+      lock is available and the transaction has started.
+    </para>
+  </sect1>
 </chapter>
 



More information about the PackageKit mailing list