bodhi/model.py | 32 ++++++++------
bodhi/tools/clean-testing.py | 96 ++++++++++++++++++++++++++++---------------
2 files changed, 83 insertions(+), 45 deletions(-)
New commits:
commit 861641fcbb3eba93e9a169f9634c92795e85a77e
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Sep 10 16:06:52 2010 -0400
Re-write our clean-testing script to catch more problems (#464)
This will now check all of the latest builds tagged as testing against
all other testing builds and stable builds. It will also look at all
testing updates to make sure they are the latest in the testing koji tag.
diff --git a/bodhi/tools/clean-testing.py b/bodhi/tools/clean-testing.py
index 25ad427..18a3ae8 100755
--- a/bodhi/tools/clean-testing.py
+++ b/bodhi/tools/clean-testing.py
@@ -10,55 +10,85 @@ import rpm
import turbomail
import turbogears
-from sqlobject import SQLObjectNotFound
+from sqlobject import SQLObjectNotFound, AND
from turbogears.database import PackageHub
from bodhi.util import load_config
-from bodhi.model import Release, PackageBuild
+from bodhi.model import Release, PackageBuild, PackageUpdate
from bodhi.buildsys import get_session
+def compare_builds(testing_build, stable_build, untag):
+ if stable_build['package_name'] == testing_build['package_name']:
+ if rpm.labelCompare((str(testing_build['epoch']),
+ testing_build['version'],
+ testing_build['release']),
+ (str(stable_build['epoch']),
+ stable_build['version'],
+ stable_build['release'])) < 0:
+ print "%s is older than %s" % (testing_build['nvr'],
+ stable_build['nvr'])
+ try:
+ build = PackageBuild.byNvr(testing_build['nvr'])
+ for update in build.updates:
+ if update.status != 'testing':
+ print "%s not testing in bodhi!" % update.title
+ raise SQLObjectNotFound
+ else:
+ if untag:
+ print "Obsoleting via bodhi"
+ update.obsolete(newer=stable_build['nvr'])
+ else:
+ print "Need to obsolete via bodhi"
+ except SQLObjectNotFound:
+ if untag:
+ print "Untagging via koji"
+ koji.untagBuild(release.testing_tag,
+ testing_build['nvr'],
+ force=True)
+ else:
+ print "Need to untag koji build %s" %
testing_build['nvr']
+
+
def clean_testing_builds(untag=False):
koji = get_session()
for release in Release.select():
stable_builds = koji.listTagged(release.stable_tag, latest=True)
+ stable_nvrs = [build['nvr'] for build in stable_builds]
print "Fetched %d builds tagged with %s" % (
len(stable_builds), release.stable_tag)
testing_builds = koji.listTagged(release.testing_tag, latest=True)
print "Fetched %d builds tagged with %s" % (
len(testing_builds), release.testing_tag)
+ testing_nvrs = [build['nvr'] for build in testing_builds]
for testing_build in testing_builds:
- for stable_build in stable_builds:
- if stable_build['package_name'] ==
testing_build['package_name']:
- if rpm.labelCompare((str(testing_build['epoch']),
- testing_build['version'],
- testing_build['release']),
- (str(stable_build['epoch']),
- stable_build['version'],
- stable_build['release'])) < 0:
- print "%s is older than %s" %
(testing_build['nvr'],
- stable_build['nvr'])
- try:
- build = PackageBuild.byNvr(testing_build['nvr'])
- for update in build.updates:
- if update.status != 'testing':
- print "%s not testing in bodhi!" %
update.title
- raise SQLObjectNotFound
- else:
- if untag:
- print "Obsoleting via bodhi"
-
update.obsolete(newer=stable_build['nvr'])
- else:
- print "Need to obsolete via bodhi"
- except SQLObjectNotFound:
- if untag:
- print "Untagging via koji"
- koji.untagBuild(release.testing_tag,
- testing_build['nvr'],
- force=True)
- else:
- print "Need to untag koji build %s" %
testing_build['nvr']
+ for build in testing_builds:
+ compare_builds(testing_build, build, untag)
+ for build in stable_builds:
+ compare_builds(testing_build, build, untag)
+
+ # Find testing updates that aren't in the list of latest builds
+ for update in PackageUpdate.select(AND(PackageUpdate.q.releaseID==release.id,
+
PackageUpdate.q.status=='testing',
+ PackageUpdate.q.request==None)):
+ for build in update.builds:
+ if build.nvr not in testing_nvrs:
+ latest_testing = None
+ latest_stable = None
+ for testing in testing_nvrs:
+ if testing.startswith(build.package.name + '-'):
+ latest_testing = testing
+ break
+ for stable in stable_nvrs:
+ if stable.startswith(build.package.name + '-'):
+ latest_stable = stable
+ break
+ print "%s in testing, latest_testing = %s, latest_stable =
%s" % (
+ update.title, latest_testing, latest_stable)
+ if untag:
+ print "Obsoleting %s" % update.title
+ assert latest_testing
+ update.obsolete(newer=latest_testing)
- print
if __name__ == '__main__':
load_config()
commit 6f085a0613c6daedb3062589c032332d4f5b4b7f
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Sep 10 13:57:32 2010 -0400
Refactor our PackageUpdate.unpush method.
This method will now handle adding a new candidate tag to builds
that have been untagged completely. It will also now query koji
for the actual tags of the builds, as opposed to guessing.
diff --git a/bodhi/model.py b/bodhi/model.py
index e721782..f88824f 100644
--- a/bodhi/model.py
+++ b/bodhi/model.py
@@ -841,22 +841,30 @@ class PackageUpdate(SQLObject):
def unpush(self):
""" Move this update back to its dist-fX-updates-candidate tag
"""
+ log.debug("Unpushing %s" % self.title)
koji = buildsys.get_session()
tasks = []
- newtag = self.release.candidate_tag
- curtag = self.get_build_tag()
- if curtag == self.release.candidate_tag:
- log.debug("%s already unpushed" % self.title)
- return
- log.debug("Unpushing %s" % self.title)
for build in self.builds:
- if build.inherited:
- log.debug("Removing %s tag from inherited build %s" % (
- curtag, build.nvr))
- koji.untagBuild(curtag, build.nvr, force=True)
+ curtag = build.get_tags()
+ if curtag:
+ if self.release.testing_tag in curtag:
+ curtag = self.release.testing_tag
+ if build.inherited:
+ log.debug("Removing %s tag from inherited build %s" %
(
+ curtag, build.nvr))
+ koji.untagBuild(curtag, build.nvr, force=True)
+ else:
+ log.debug("Moving %s from %s to %s" % (build.nvr,
curtag,
+ self.release.candidate_tag))
+ task = koji.moveBuild(curtag, self.release.candidate_tag,
+ build.nvr, force=True)
+ tasks.append(task)
+ else:
+ # Could be stable or candidate already... so don't do anything
+ pass
else:
- log.debug("Moving %s from %s to %s" % (build.nvr, curtag,
newtag))
- task = koji.moveBuild(curtag, newtag, build.nvr, force=True)
+ # Build is untagged
+ task = koji.tagBuild(self.release.candidate_tag,build.nvr,force=True)
tasks.append(task)
if tasks:
if buildsys.wait_for_tasks(tasks, sleep=1):