bodhi/tools/tagcheck.py | 46 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
New commits:
commit 62b73d99adb297d8556331a50cb386c07b2eb372
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Feb 13 02:34:31 2009 -0500
Add a --fix flag to the bodhi-tagcheck script
diff --git a/bodhi/tools/tagcheck.py b/bodhi/tools/tagcheck.py
index e0f05f3..3794f78 100755
--- a/bodhi/tools/tagcheck.py
+++ b/bodhi/tools/tagcheck.py
@@ -5,25 +5,32 @@ Verify that all builds that are tagged as updates in koji have the
correct status within bodhi
"""
+import sys
+
from sqlobject import SQLObjectNotFound
from turbogears.database import PackageHub
from bodhi.util import load_config
from bodhi.model import PackageBuild, PackageUpdate, Release
-from bodhi.buildsys import get_session
+from bodhi.buildsys import get_session, wait_for_tasks
def main():
load_config()
__connection__ = hub = PackageHub("bodhi")
koji = get_session()
+ tasks = []
+ broke = set()
# Check for testing updates that aren't tagged properly
for update in PackageUpdate.select(PackageUpdate.q.status=='testing'):
for build in update.builds:
tags = [tag['name'] for tag in koji.listTags(build=build.nvr)]
- if '%s-updates-testing' % update.release.dist_tag not in tags:
+ dest_tag = '%s-updates-testing' % update.release.dist_tag
+ if dest_tag not in tags:
print "%s marked as testing, but tagged with %s" % (build.nvr,
tags)
+ if '--fix' in sys.argv:
+ broke.add((tags[0], dest_tag, build.nvr))
# Check all candidate updates to see if they are in a different bodhi state
for release in Release.select():
@@ -37,6 +44,13 @@ def main():
print "%s %s but tagged as %s" % (nvr,
update.status,
tag)
+ if '--fix' in sys.argv:
+ dest = '%s-updates-testing' % release.dist_tag
+ if update.status == 'stable':
+ dest = '%s-updates' % release.dist_tag
+ elif update.status == 'obsolete':
+ dest = '%s-updates-candidate' % release.dist_tag
+ broke.add((tag, dest, nvr))
except SQLObjectNotFound:
pass
@@ -59,6 +73,34 @@ def main():
if update.status != status:
print "%s is %s in bodhi but tagged as %s in koji" % (
update.title, update.status, tag)
+ if '--fix' in sys.argv:
+ dest = '%s-updates-testing' % release.dist_tag
+ if update.status == 'stable':
+ dest = '%s-updates' % release.dist_tag
+ elif update.status == 'obsolete':
+ dest = '%s-updates-candidate' % release.dist_tag
+ for b in update.builds:
+ broke.add((tag, dest, b.nvr))
+
+ if broke:
+ print " ** Fixing broken tags! **"
+ koji.multicall = True
+ for tag, dest, build in broke:
+ print "Moving %s from %s to %s" % (build, tag, dest)
+ koji.moveBuild(tag, dest, build, force=True)
+ print "Running koji.multiCall()"
+ results = koji.multiCall()
+ success = False
+ print "Waiting for tasks"
+ bad_tasks = wait_for_tasks([task[0] for task in results])
+ if bad_tasks == 0:
+ success = True
+ if success:
+ print "Tags successfully moved!"
+ else:
+ print "Error moving tags!"
+ print "bad_tasks = %r" % bad_tasks
+
if __name__ == '__main__':
Show replies by date