[packagekit] packagekit: Branch 'master' - 6 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Thu Oct 18 11:04:53 PDT 2007
TODO | 28 +++++++++++++----
backends/yum/helpers/refresh-cache.py | 1
backends/yum/helpers/remove.py | 2 +
backends/yum/helpers/resolve.py | 1
backends/yum/helpers/search-details.py | 2 -
backends/yum/helpers/search-file.py | 2 -
backends/yum/helpers/search-group.py | 2 -
backends/yum/helpers/search-name.py | 2 -
backends/yum/helpers/update-system.py | 1
backends/yum/helpers/update.py | 1
backends/yum/helpers/yumBackend.py | 52 +++++++++++++++++++++++++++++++--
python/packagekit/backend.py | 14 ++++++++
12 files changed, 95 insertions(+), 13 deletions(-)
New commits:
commit ba18968994f1e87496c4cb20e536c4d44a137664
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Oct 18 19:02:53 2007 +0100
add some items to the todo
diff --git a/TODO b/TODO
index 6068743..9b4ca02 100644
--- a/TODO
+++ b/TODO
@@ -24,4 +24,27 @@ To do rollbacks sanely in PK we need a few things:
*** Use resolve for pkcon operations ***
'pkcon install zsh' should work as well as 'pkcon install "zsh;1.0;i386;repo"'
+def command_resolve(package, filter_enum)
+ret=client_resolve (package, filter)
+if ret wait()
+length=get_length
+if length == 1 return get_item(client, 0)
+else
+print matched too many, quit
+for each length
+print get_item(client, 1)
+
+case: INSTALL
+if not a valid package_id then
+ pacakge=command_resolve(package, ENUM_AVAILABLE);
+ if (package== NULL) {
+ error
+ }
+
+*** Unit tests ***
+PkSpawn is a complex and untested bit of code.
+
+*** Send SIGQUIT ***
+Do SIGKILL only if SIGQUIT didn't work...
+
commit 1e745db08e341f17c2758eccb2c1d32213902fae
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Oct 18 19:00:46 2007 +0100
update TODO - we have uploaded the website now
diff --git a/TODO b/TODO
index e19c9b7..6068743 100644
--- a/TODO
+++ b/TODO
@@ -25,7 +25,3 @@ To do rollbacks sanely in PK we need a few things:
*** Use resolve for pkcon operations ***
'pkcon install zsh' should work as well as 'pkcon install "zsh;1.0;i386;repo"'
-*** HTML help files ***
-Spellcheck and grammar check!
-Add not about the development server and anon-cvs
-
commit f82233b69fbbed246e3d70d72fd50b42976a0499
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Oct 18 19:00:29 2007 +0100
update TODO - we have to poll for async use
diff --git a/TODO b/TODO
index 77920b2..e19c9b7 100644
--- a/TODO
+++ b/TODO
@@ -6,9 +6,6 @@ Requires writing to a database for config stuff
New method GetHoursSinceLastUpdate
Use this in the update icon
-*** use g_io_channel_* rather than read in PkSpawn for speed ***
-This should get rid of the polling forever, and get rid of that 1k block append
-
*** Add new callback for status ***
TimeRemaining()
commit 1a3dce4c2f24635686a4c49ce97e2a05d5665f09
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date: Thu Oct 18 14:19:17 2007 +0200
yum: make sure yum is unlocked on SIGQUIT
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 23ff0c6..eef882e 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -36,10 +36,21 @@ from yum.misc import prco_tuple_to_string, unique
import rpmUtils
import exceptions
import types
+import signal
+
+yumbase = None
class GPGKeyNotImported(exceptions.Exception):
pass
+def sigquit(signum, frame):
+ print >> sys.stderr, "Quit signal sent - exiting immediately"
+ if yumbase:
+ print >> sys.stderr, "unlocking Yum"
+ yumbase.closeRpmDB()
+ yumbase.doUnlock(YUM_PID_FILE)
+ sys.exit(1)
+
class PackageKitYumBackend(PackageKitBaseBackend):
# Packages there require a reboot
@@ -49,13 +60,14 @@ class PackageKitYumBackend(PackageKitBaseBackend):
def __init__(self,args,lock=True):
+ signal.signal(signal.SIGQUIT, sigquit)
PackageKitBaseBackend.__init__(self,args)
self.yumbase = PackageKitYumBase()
+ yumbase = self.yumbase
self._setup_yum()
if lock:
self.doLock()
-
-
+
def doLock(self):
''' Lock Yum'''
if not self.isLocked():
commit 9bc2ac899d55abec0a9bf90ffe229072543d55a7
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date: Thu Oct 18 13:47:11 2007 +0200
yum: close the rpmdb when unlocking
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index bafa3e9..23ff0c6 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -71,6 +71,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
''' Unlock Yum'''
if self.isLocked():
PackageKitBaseBackend.unLock(self)
+ self.yumbase.closeRpmDB()
self.yumbase.doUnlock(YUM_PID_FILE)
commit 98851b2d78b7ae4d9fd312ccc24c579708f817f2
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date: Thu Oct 18 13:32:47 2007 +0200
yum: Added locking
diff --git a/backends/yum/helpers/refresh-cache.py b/backends/yum/helpers/refresh-cache.py
index 4c1aca1..85de0f6 100755
--- a/backends/yum/helpers/refresh-cache.py
+++ b/backends/yum/helpers/refresh-cache.py
@@ -16,4 +16,5 @@ from yumBackend import PackageKitYumBackend
backend = PackageKitYumBackend(sys.argv[1:])
backend.refresh_cache()
+backend.unLock()
sys.exit(0)
diff --git a/backends/yum/helpers/remove.py b/backends/yum/helpers/remove.py
index 7536d05..4e360d3 100755
--- a/backends/yum/helpers/remove.py
+++ b/backends/yum/helpers/remove.py
@@ -19,4 +19,6 @@ package = sys.argv[2]
backend = PackageKitYumBackend(sys.argv[1:])
backend.remove(allowdeps, package)
+backend.unLock()
+
sys.exit(0)
diff --git a/backends/yum/helpers/resolve.py b/backends/yum/helpers/resolve.py
index bfb1216..57d9186 100755
--- a/backends/yum/helpers/resolve.py
+++ b/backends/yum/helpers/resolve.py
@@ -15,4 +15,5 @@ from yumBackend import PackageKitYumBackend
name=sys.argv[1]
backend = PackageKitYumBackend(sys.argv[1:])
backend.resolve(name)
+backend.unLock()
sys.exit(0)
diff --git a/backends/yum/helpers/search-details.py b/backends/yum/helpers/search-details.py
index e5e5ec1..4911157 100755
--- a/backends/yum/helpers/search-details.py
+++ b/backends/yum/helpers/search-details.py
@@ -17,7 +17,7 @@ searchterms = sys.argv[2]
from yumBackend import PackageKitYumBackend
-backend = PackageKitYumBackend(sys.argv[1:])
+backend = PackageKitYumBackend(sys.argv[1:],lock=False)
backend.search_details(options,searchterms)
sys.exit(0)
diff --git a/backends/yum/helpers/search-file.py b/backends/yum/helpers/search-file.py
index 8241aee..5b23cda 100755
--- a/backends/yum/helpers/search-file.py
+++ b/backends/yum/helpers/search-file.py
@@ -17,7 +17,7 @@ searchterms = sys.argv[2]
from yumBackend import PackageKitYumBackend
-backend = PackageKitYumBackend(sys.argv[1:])
+backend = PackageKitYumBackend(sys.argv[1:],lock=False)
backend.search_file(options,searchterms)
sys.exit(0)
diff --git a/backends/yum/helpers/search-group.py b/backends/yum/helpers/search-group.py
index 2066526..f86a8bb 100755
--- a/backends/yum/helpers/search-group.py
+++ b/backends/yum/helpers/search-group.py
@@ -17,7 +17,7 @@ searchterms = sys.argv[2]
from yumBackend import PackageKitYumBackend
-backend = PackageKitYumBackend(sys.argv[1:])
+backend = PackageKitYumBackend(sys.argv[1:],lock=False)
backend.search_group(options,searchterms)
sys.exit(0)
diff --git a/backends/yum/helpers/search-name.py b/backends/yum/helpers/search-name.py
index c1cc342..56a137b 100755
--- a/backends/yum/helpers/search-name.py
+++ b/backends/yum/helpers/search-name.py
@@ -17,7 +17,7 @@ searchterms = sys.argv[2]
from yumBackend import PackageKitYumBackend
-backend = PackageKitYumBackend(sys.argv[1:])
+backend = PackageKitYumBackend(sys.argv[1:],lock=False)
backend.search_name(options,searchterms)
sys.exit(0)
diff --git a/backends/yum/helpers/update-system.py b/backends/yum/helpers/update-system.py
index 243a5f6..6e95015 100755
--- a/backends/yum/helpers/update-system.py
+++ b/backends/yum/helpers/update-system.py
@@ -16,5 +16,6 @@ from yumBackend import PackageKitYumBackend
backend = PackageKitYumBackend(sys.argv[1:])
backend.update_system()
+backend.unLock()
sys.exit(0)
diff --git a/backends/yum/helpers/update.py b/backends/yum/helpers/update.py
index 3bc9d42..9d06ba3 100755
--- a/backends/yum/helpers/update.py
+++ b/backends/yum/helpers/update.py
@@ -17,4 +17,5 @@ from yumBackend import PackageKitYumBackend
package = sys.argv[1]
backend = PackageKitYumBackend(sys.argv[1:])
backend.update(package)
+backend.unLock()
sys.exit(0)
\ No newline at end of file
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 150ee38..bafa3e9 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -48,10 +48,32 @@ class PackageKitYumBackend(PackageKitBaseBackend):
"glibc", "hal", "dbus", "xen")
- def __init__(self,args):
+ def __init__(self,args,lock=True):
PackageKitBaseBackend.__init__(self,args)
self.yumbase = PackageKitYumBase()
self._setup_yum()
+ if lock:
+ self.doLock()
+
+
+ def doLock(self):
+ ''' Lock Yum'''
+ if not self.isLocked():
+ try: # Try to lock yum
+ self.yumbase.doLock( YUM_PID_FILE )
+ PackageKitBaseBackend.doLock(self)
+ except:
+ self.error(ERROR_INTERNAL_ERROR,'Yum is locked by another application')
+
+
+
+ def unLock(self):
+ ''' Unlock Yum'''
+ if self.isLocked():
+ PackageKitBaseBackend.unLock(self)
+ self.yumbase.doUnlock(YUM_PID_FILE)
+
+
def _get_package_ver(self,po):
''' return the a ver as epoch:version-release or version-release, if epoch=0'''
@@ -331,6 +353,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
else:
if self._installable(pkg):
self.package(id, INFO_AVAILABLE, pkg.summary)
+ self._unlock_yum()
def update_system(self):
@@ -345,6 +368,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self._runYumTransaction()
else:
self.error(ERROR_INTERNAL_ERROR,"Nothing to do")
+ self._unlock_yum()
def refresh_cache(self):
'''
@@ -420,6 +444,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.error(ERROR_PACKAGE_ALREADY_INSTALLED,msgs)
else:
self.error(ERROR_PACKAGE_ALREADY_INSTALLED,"Package was not found")
+ self._lock_yum()
def _localInstall(self, inst_file):
"""handles installs/updates of rpms provided on the filesystem in a
@@ -504,6 +529,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
'''
self.allow_interrupt(False);
self.percentage(0)
+ self._lock_yum()
pkgs_to_inst = []
self.yumbase.conf.gpgcheck=0
@@ -622,7 +648,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
'''
self.allow_interrupt(True)
self.percentage(None)
-
+ self._lock_yum()
pkg,inst = self._findPackage(package)
if pkg:
pkgver = self._get_package_ver(pkg)
@@ -662,7 +688,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
'''
self.allow_interrupt(True)
self.percentage(None)
-
+ self._lock_yum()
md = UpdateMetadata()
# Added extra Update Metadata
for repo in self.yumbase.repos.listEnabled():
@@ -702,6 +728,13 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.dnlCallback = DownloadCallback(self,showNames=True) # Download callback
self.yumbase.repos.setProgressBar( self.dnlCallback ) # Setup the download callback class
+ def _lock_yum(self):
+ self.yumbase.doLock( YUM_PID_FILE )
+
+
+ def _unlock_yum(self):
+ self.yumbase.doUnlock(YUM_PID_FILE)
+
class DownloadCallback( BaseMeter ):
""" Customized version of urlgrabber.progress.BaseMeter class """
def __init__(self,base,showNames = False):
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 88871f7..d89ca49 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -73,6 +73,18 @@ class PackageKitBaseBackend:
def __init__(self,cmds):
self.cmds = cmds
+ self._locked = False
+
+ def doLock(self):
+ ''' Generic locking, overide and extend in child class'''
+ self._locked = True
+
+ def unLock(self):
+ ''' Generic unlocking, overide and extend in child class'''
+ self._locked = False
+
+ def isLocked(self):
+ return self._locked
def percentage(self,percent=None):
'''
@@ -100,6 +112,8 @@ class PackageKitBaseBackend:
'''
print >> sys.stderr,"error\t%s\t%s" % (err,description)
if exit:
+ if self.isLocked():
+ self.unLock()
sys.exit(1)
def package(self,id,status,summary):
More information about the PackageKit
mailing list