[Yum-devel] [PATCH] reposync should lock. BZ 880722

Zdeněk Pavlas zpavlas at redhat.com
Wed Dec 5 16:10:36 UTC 2012


reposync 	 => lock /var/tmp/yum-*/yum.pid
sudo reposync 	 => lock /var/run/yum.pid
sudo reposync -t => lock /var/tmp/yum-*/yum.pid
reposync -e dir	 => no locking
---
 reposync.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/reposync.py b/reposync.py
index 2e9db19..a749973 100755
--- a/reposync.py
+++ b/reposync.py
@@ -153,15 +153,21 @@ def main():
         opts.tempcache = True
 
     if opts.tempcache:
-        cachedir = getCacheDir()
-        if cachedir is None:
+        if not my.setCacheDir(force=True):
             print >> sys.stderr, "Error: Could not make cachedir, exiting"
             sys.exit(50)
-            
-        my.repos.setCacheDir(cachedir)
+        my.conf.uid = 1 # force locking of user cache
     elif opts.cachedir:
         my.repos.setCacheDir(opts.cachedir)
 
+    # Lock if they've not given an explicit cachedir
+    if not opts.cachedir:
+        try:
+            my.doLock()
+        except yum.Errors.LockError, e:
+            print >> sys.stderr, "Error: %s" % e
+            sys.exit(50)
+
     #  Use progress bar display when downloading repo metadata
     # and package files ... needs to be setup before .repos (ie. RHN/etc.).
     if not opts.quiet:
-- 
1.7.4.4



More information about the Yum-devel mailing list