extras-buildsys/utils extras-push-new,1.22,1.23

Michael Schwendt (mschwendt) fedora-extras-commits at redhat.com
Fri Jun 2 22:06:25 UTC 2006


Author: mschwendt

Update of /cvs/fedora/extras-buildsys/utils
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22350

Modified Files:
	extras-push-new 
Log Message:
implement repodir locking and cleaning up of empty directories in repodir


Index: extras-push-new
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/extras-push-new,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- extras-push-new	2 Jun 2006 22:05:20 -0000	1.22
+++ extras-push-new	2 Jun 2006 22:06:23 -0000	1.23
@@ -32,9 +32,13 @@
 
 stagesdir = '/srv/rpmbuild/repodir'
 treedir = '/srv/rpmbuild/%s/tree/%s' % (project, project)
-# Where we store mails to be sent, lockfiles.
+# Where we store mails to be sent and our main lockfile.
 rundir = '/srv/rpmbuild/extras-push-rundir'
 
+# Lockfile name supported by plague for mutual exclusion during
+# access to needsign repository (i.e. 'stagesdir').
+REPO_LOCKFILE_NAME = '.repo-update.lock'
+
 project_hr = 'Fedora Extras'
 mail_from = 'buildsys at fedoraproject.org'
 mail_to = 'fedora-extras-list at redhat.com'
@@ -186,8 +190,8 @@
             continue
         # Every version-release is stored in an own sub-dir.
         pkgreldirs = os.listdir(pkgroot)
-        debugprint( '%s releases for %s: %s' % (len(pkgreldirs),name,' '.join(pkgreldirs)) )
-        if len(pkgreldirs) < 2: # only one release
+        debugprint( '%s release(s) for %s: %s' % (len(pkgreldirs),name,' '.join(pkgreldirs)) )
+        if len(pkgreldirs) < 2: # only one release or empty dir
             continue
         # We assume this release to be the newest.
         relroot = os.path.join(pkgroot,pkgreldirs[0])
@@ -316,6 +320,16 @@
 
     distdir = '%s-%s-%s' % (distro, dist, project)
     needsign = os.path.join(stagesdir, distdir)
+    
+    repolockname = os.path.join(needsign,REPO_LOCKFILE_NAME)
+    print repolockname
+    repolock = LockFile(name=repolockname,blocking=True)
+    try:
+        repolock.lock()
+    except IOError, (errno, strerr):
+        print "ERROR: lockfile %s failure: %s (error %d)" % (repolockname, strerr, errno)
+        sys.exit(errno)
+        
     prune_needsign_tree(needsign)
     files = find_files(needsign)
     rpms = files['rpm'] + files['srpm'] + files['debuginfo']    
@@ -334,6 +348,7 @@
     rpms = files['rpm'] + files['srpm'] + files['debuginfo']
     if len(rpms) == 0:
         print '%s: nothing to sign' % dist
+        repolock.unlock()
         return 0
 
     print "Signing Packages:"
@@ -341,6 +356,7 @@
         result = sign_pkgs(rpms)
         if result:
             print "Error signing packages"
+            repolock.unlock()
             return result
 
     print "Moving Packages into Place"
@@ -438,12 +454,24 @@
     # clean up the crap
     print "Cleaning Up"
     for file in files['log'] + files['md5sum'] + files['spec']:
-        debugprint('removing %s' % file)
+        debugprint('Removing %s' % file)
         if not DEBUG:
             os.unlink(file)
         
-    # FIXME clean up empty dirs, too.
-    
+    # clean up empty dirs, too.
+    for root, dirs, files in os.walk(needsign,topdown=False):
+        if 'repodata' in dirs:
+            dirs.remove('repodata')
+        for dir in dirs:
+            path = os.path.join(root,dir)
+            try:
+                if not DEBUG:
+                    os.rmdir(path)
+                debugprint('Removing directory %s' % path)
+            except:
+                pass
+
+    repolock.unlock()
     return(0)
 
 # ====================================================================




More information about the fedora-extras-commits mailing list