Skip to content

Commit

Permalink
Builds: Purge builds older than 12 weeks
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 29, 2011
1 parent 41a4a08 commit 6c14dc2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions distrib/build_event.py
Expand Up @@ -79,6 +79,17 @@ def find_newest_build():
if newest is None:
return {'tag': None, 'time': time.time()}
return {'tag': newest[1], 'time': newest[0]}


def find_old_builds(atLeastSecs):
result = []
now = time.time()
for fn in os.listdir(EVENT_DIR):
if fn[:5] != 'build': continue
bt = build_timestamp(fn)
if now - bt >= atLeastSecs:
result.append({'time':bt, 'tag':fn})
return result


def builds_by_time():
Expand Down Expand Up @@ -434,6 +445,23 @@ def rebuild_apt_repository():
os.remove("Release.gpg")
os.system("gpg --output Release.gpg -ba Release")
os.system("~/Dropbox/Scripts/mirror-tree.py %s %s" % (aptDir, os.path.join(EVENT_DIR, 'apt')))


def purge_apt_repository():
pass


def purge_obsolete():
# Also purge the apt repository if one has been specified.
if APT_REPO_DIR:
purge_apt_repository()

# Purge the old events.
print 'Deleting build events older than 12 weeks...'
for bld in find_old_builds(3600 * 24 * 7 * 12):
print bld['tag']
shutil.rmtree(os.path.join(EVENT_DIR, bld['tag']))
print 'Purge done.'


if sys.argv[1] == 'create':
Expand All @@ -451,6 +479,9 @@ def rebuild_apt_repository():
elif sys.argv[1] == 'changes':
update_changes()

elif sys.argv[1] == 'purge':
purge_obsolete()

else:
print 'Unknown command:', sys.argv[1]
sys.exit(1)

0 comments on commit 6c14dc2

Please sign in to comment.