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

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