Blame SOURCES/BZ-1130939-dont-create-lockdir-directories.patch

65829f
commit ffb40e6a1b9c3f4b5b08151a04a5922fc5a9b521
65829f
Author: James Antill <james@and.org>
65829f
Date:   Wed Jan 29 16:04:18 2014 -0500
65829f
65829f
    Don't create lockdir directories, as they are magic now. BZ 975864
65829f
65829f
diff --git a/yum/__init__.py b/yum/__init__.py
65829f
index 222a378..0604d63 100644
65829f
--- a/yum/__init__.py
65829f
+++ b/yum/__init__.py
65829f
@@ -2136,7 +2136,11 @@ much more problems).
65829f
         lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
65829f
         
65829f
         mypid=str(os.getpid())    
65829f
-        while not self._lock(lockfile, mypid, 0644):
65829f
+        while True:
65829f
+            ret = self._lock(lockfile, mypid, 0644)
65829f
+            if ret:
65829f
+                break
65829f
+
65829f
             oldpid = self._get_locker(lockfile)
65829f
             if not oldpid:
65829f
                 # Invalid locker: unlink lockfile and retry
65829f
@@ -2147,6 +2151,13 @@ much more problems).
65829f
             # Another copy seems to be running.
65829f
             msg = _('Existing lock %s: another copy is running as pid %s.') % (lockfile, oldpid)
65829f
             raise Errors.LockError(0, msg, oldpid)
65829f
+
65829f
+        if ret == 2:
65829f
+            #  Means lockdir isn't setup, out of bad options just run without
65829f
+            # locks.
65829f
+            return
65829f
+
65829f
+        assert ret == 1
65829f
         # We've got the lock, store it so we can auto-unlock on __del__...
65829f
         self._lockfile = lockfile
65829f
     
65829f
@@ -2186,7 +2197,12 @@ much more problems).
65829f
         lockdir = os.path.dirname(filename)
65829f
         try:
65829f
             if not os.path.exists(lockdir):
65829f
-                os.makedirs(lockdir, mode=0755)
65829f
+                #  We used to os.makedirs(lockdir, mode=0755) ... but that
65829f
+                # causes problems now due to /var/run being a magic systemd dir.
65829f
+                #  So we now just give up and run, hopefully nobody runs N
65829f
+                # instances before the magic dir. is activate.
65829f
+                return 2
65829f
+
65829f
             fd = os.open(filename, os.O_EXCL|os.O_CREAT|os.O_WRONLY, mode)    
65829f
             os.write(fd, contents)
65829f
             os.close(fd)