extras-repoclosure rc-run.py,1.10,1.11

Michael Schwendt (mschwendt) fedora-extras-commits at redhat.com
Thu Jun 29 10:06:56 UTC 2006


Author: mschwendt

Update of /cvs/fedora/extras-repoclosure
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv28402

Modified Files:
	rc-run.py 
Log Message:
fix up access to mdcache tree by copy'n'move -- further comments inline


Index: rc-run.py
===================================================================
RCS file: /cvs/fedora/extras-repoclosure/rc-run.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- rc-run.py	24 Jun 2006 19:48:17 -0000	1.10
+++ rc-run.py	29 Jun 2006 10:06:53 -0000	1.11
@@ -7,6 +7,8 @@
 import datetime, time
 import tempfile
 
+signersgid = 100581  # signers group
+
 workdir = '/srv/rpmbuild/extras-repoclosure'
 cachedir = '/srv/rpmbuild/extras-repoclosure/mdcache'
 
@@ -96,9 +98,49 @@
 
 # Main.
 
+if os.getgid() != signersgid:
+    grpname = '(unknown)'
+    try:
+        import grp
+        grpname = grp.getgrgid(signersgid)[0]
+    except:
+        print 'WARNING: Could not get group name for gid %d' % signersgid
+    print 'ERROR: Change into the %s group before running this!  Use "newgrp %s".' % (grpname, grpname)
+    sys.exit(errno.EPERM)
+
 cwd = os.getcwd()
 os.chdir(workdir)
-#os.umask(0002)  # only for our /srv environment
+os.umask(0002)  # only for our /srv environment
+
+# Work around explicit mode 0755 in yum/repos.py and an utime access
+# denied problem in urlgrabber.
+# We copy the mdcache tree to a temporary directory in order to
+# become the owner of all files, then remove the copied tree and fix
+# up directory modes. For this to work flawlessly, all files must be
+# readable by our group.
+try:
+    tmpdir = tempfile.mkdtemp('','.mdcache.tmp',workdir)
+    if tmpdir == workdir: # paranoid, should never happen
+        raise Exception
+except:
+    sys.exit(errno.EIO)
+if os.path.isdir(cachedir):
+    tmpcachedir = os.path.join(tmpdir,'mdcache')
+    try:
+        shutil.copytree(src=cachedir,dst=tmpcachedir,symlinks=True)
+    except:
+        print 'FATAL ERROR: mdcache copytree failed'
+        print '%s must be writable\n%s must be readable' % (workdir, cachedir)
+        shutil.rmtree(tmpdir)
+        sys.exit(1)
+    for root, dirs, files in os.walk(tmpcachedir):
+        for file in files:
+            fullpath = os.path.join(root,file)
+            filemode = stat.S_IMODE( os.stat(fullpath).st_mode )
+            filemode |= stat.S_IWGRP
+            os.chmod(fullpath,filemode)
+    shutil.rmtree(cachedir)
+    shutil.move(src=tmpcachedir,dst=cachedir)
 
 # Delete old log files.
 import glob




More information about the fedora-extras-commits mailing list