[yum-commits] reposync.py

zpavlas at osuosl.org zpavlas at osuosl.org
Thu Jan 10 13:38:44 UTC 2013


 reposync.py |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

New commits:
commit 3a822df36859a56c02c084b2c423d9fea07d8d41
Author: Zdeněk Pavlas <zpavlas at redhat.com>
Date:   Wed Dec 5 17:02:03 2012 +0100

    reposync should lock. BZ 880722
    
    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

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:


More information about the Yum-commits mailing list