[yum-commits] Branch 'yum-3_2_X' - 3 commits - yum/__init__.py yummain.py
James Antill
james at osuosl.org
Fri Jan 14 16:23:05 UTC 2011
yum/__init__.py | 11 +++++++----
yummain.py | 7 ++++++-
2 files changed, 13 insertions(+), 5 deletions(-)
New commits:
commit 8e444d79c58aca2ff6e43756d09455e7d6b812e8
Author: James Antill <james at and.org>
Date: Fri Jan 14 10:52:14 2011 -0500
Don't try to lock as a normal user, if we are using root's cachedir.
diff --git a/yum/__init__.py b/yum/__init__.py
index 8fd0710..fca6ab4 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1674,8 +1674,11 @@ class YumBase(depsolve.Depsolve):
def doLock(self, lockfile = YUM_PID_FILE):
"""perform the yum locking, raise yum-based exceptions, not OSErrors"""
- # if we're not root then lock the cache
if self.conf.uid != 0:
+ # If we are a user, assume we are using the root cache ... so don't
+ # bother locking.
+ if self.conf.cache:
+ return
root = self.conf.cachedir
# Don't want <cachedir>/var/run/yum.pid ... just: <cachedir>/yum.pid
lockfile = os.path.basename(lockfile)
commit 1fb0418ac9f73a03cbf6cc29f6b417fd026e0038
Author: James Antill <james at and.org>
Date: Fri Jan 14 10:51:49 2011 -0500
Specify errno.EPERM instead of just using "1". Make the pid an int.
diff --git a/yum/__init__.py b/yum/__init__.py
index f6e8a6b..8fd0710 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1690,7 +1690,7 @@ class YumBase(depsolve.Depsolve):
fd = open(lockfile, 'r')
except (IOError, OSError), e:
msg = _("Could not open lock %s: %s") % (lockfile, e)
- raise Errors.LockError(1, msg)
+ raise Errors.LockError(errno.EPERM, msg)
try: oldpid = int(fd.readline())
except ValueError:
@@ -1707,7 +1707,7 @@ class YumBase(depsolve.Depsolve):
else:
# Whoa. What the heck happened?
msg = _('Unable to check if PID %s is active') % oldpid
- raise Errors.LockError(1, msg, oldpid)
+ raise Errors.LockError(errno.EPERM, msg, oldpid)
else:
# Another copy seems to be running.
msg = _('Existing lock %s: another copy is running as pid %s.') % (lockfile, oldpid)
@@ -1752,7 +1752,7 @@ class YumBase(depsolve.Depsolve):
if not msg.errno == errno.EEXIST:
# Whoa. What the heck happened?
errmsg = _('Could not create lock at %s: %s ') % (filename, str(msg))
- raise Errors.LockError(msg.errno, errmsg, contents)
+ raise Errors.LockError(msg.errno, errmsg, int(contents))
return 0
else:
os.write(fd, contents)
commit 83c983221cedc8ea32a53fa18ee4bff4567d92dd
Author: James Antill <james at and.org>
Date: Fri Jan 14 10:50:34 2011 -0500
If we _can't_ create the lock file, don't keep trying.
diff --git a/yummain.py b/yummain.py
index c64b140..9f9b7d4 100755
--- a/yummain.py
+++ b/yummain.py
@@ -23,6 +23,7 @@ import os.path
import sys
import logging
import time
+import errno
from yum import Errors
from yum import plugins
@@ -99,12 +100,16 @@ def main(args):
if exception2msg(e) != lockerr:
lockerr = exception2msg(e)
logger.critical(lockerr)
- if not base.conf.exit_on_lock:
+ if (e.errno not in (errno.EPERM, errno.EACCES) and
+ not base.conf.exit_on_lock):
logger.critical(_("Another app is currently holding the yum lock; waiting for it to exit..."))
tm = 0.1
if show_lock_owner(e.pid, logger):
tm = 2
time.sleep(tm)
+ elif e.errno in (errno.EPERM, errno.EACCES):
+ logger.critical(_("Can't create lock file; exiting"))
+ return 1
else:
logger.critical(_("Another app is currently holding the yum lock; exiting as configured by exit_on_lock"))
return 1
More information about the Yum-commits
mailing list