#!/usr/bin/python # # Upstream at git://reducto.boston.redhat.com/www/git/fedora.git # Author Jesse Keating # # Copyright (c) 2007 Red Hat import os import commands import shutil import time import sys dest = '/mnt/rawhide/nightly/' trees = os.listdir(dest) trees.sort() for tree in trees: if not tree.startswith('rawhide-20'): # good for a few years trees.remove(tree) today = time.strftime('%Y%m%d', time.localtime()) newtree = os.path.join(dest, 'rawhide-%s' % today) rsync = ['/usr/bin/rsync', '-avH', '--stats', '--progress'] rsync.append('--link-dest=%s' % os.path.join(dest, trees[-1])) rsync.append('rsync://wallace.redhat.com/fedora-enchilada/linux/development/') rsync.append(newtree) # Keep no more than 5 trees if len(trees) > 4: for tree in trees[:-4]: treepath = os.path.join(dest, tree) # do some sanity checking, I'm paranoid if os.path.islink(treepath): print "Not removing symlink %s" % treepath continue if os.path.ismount(treepath): print "Not removing mount %s" % treepath continue # Say bye bye print "Removing %s" % treepath shutil.rmtree(treepath) # Sync the tree, using yesterday's for links (status, output) = commands.getstatusoutput(' '.join(rsync)) print output if not status == 0: print "Rsync failed!" sys.exit(1) # update rawhide-latest symlink os.unlink(os.path.join(dest, 'rawhide-latest')) os.symlink(os.path.basename(newtree), os.path.join(dest, 'rawhide-latest'))