---
lib/python/koji_utils.py | 51 ++++++++++++++++++++-------------------------
1 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/lib/python/koji_utils.py b/lib/python/koji_utils.py
index f8ac077..87b32e9 100644
--- a/lib/python/koji_utils.py
+++ b/lib/python/koji_utils.py
@@ -23,6 +23,7 @@ import time
import koji
from repoinfo import repoinfo
import rpmUtils.miscutils
+import sys
# XXX fetch from /etc/koji.conf, section 'koji'
kojiurl = 'http://koji.fedoraproject.org/kojihub'
@@ -101,40 +102,34 @@ class SimpleKojiClientSession(koji.ClientSession):
'''Get most recent releases of package in specified tag (inheritence
enabled). Returns dictionary in the format {tag: NVR object}. Optional
max_evr says that all returned release versions must be lesser then
- it. If you enable unstable_tags, then also 'testing' and
'candidate'
- tags are considered.
+ it. If you enable unstable_tags, then also '-testing' tags are
considered.
+
max_evr = (epoch, version, release)
'''
prev_rlss = {}
# minor hack - assume -candidate parents = stable+updates+testing
# TODO: provide this info in repoinfo instead
+ # since there's no repo for candidate builds, just look at -testing and
below
if tag.endswith('-updates-candidate'):
- testtag = tag.replace('-candidate','-testing')
- testrepo = repoinfo.getrepo_by_tag(testtag)
- # -testing parents = stable+updates. add -testing and we're good.
- parents = testrepo['parents'] + [testrepo['name']]
- else:
- parents = repoinfo.getrepo_by_tag(tag)['parents']
- if parents:
- for p in parents:
- ptag = repoinfo.get(p,'tag')
- if ('-testing' in ptag or '-candidate' in ptag) and \
- not unstable_tags:
- # skip unstable tags
- continue
- prev_rlss[ptag] = self.latest_by_tag(ptag, name, max_evr=max_evr)
- else:
- # NOTE: for tags with no parents (e.g. rawhide) we obviously can't
- # check the parent repos' tags to get the previously released
- # package NVRs. Instead we use koji's tagHistory command to find
- # the previous version of this package that had this tag.
- hist = self.tagHistory(tag=tag, package=name)
- # remove untagged builds
- hist = filter(lambda h: h['revoke_event'] is None, hist)
- # ensure sorting by time
- hist.sort(key=lambda h: h['create_ts'])
- # hist[-2] = not the currently-tagged build, the one before that
- prev_rlss[tag] = self.getBuild(hist[-2]['build_id'])
+ tag = tag.replace('-candidate','-testing')
+
+ testrepo = repoinfo.getrepo_by_tag(tag)
+ if testrepo is None:
+ print >> sys.stderr, "Error: There's no repo definition for
tag '%s'" % tag
+ return {}
+ parents = testrepo['parents']
+ repos = parents + [testrepo['name']]
+
+ if not unstable_tags:
+ for repo in repos[:]:
+ rtag = repoinfo.get(repo, 'tag')
+ if ('-testing' in rtag or '-candidate' in rtag):
+ # remove repo with unstable tag
+ repos.remove(repo)
+
+ for repo in repos:
+ rtag = repoinfo.get(repo, 'tag')
+ prev_rlss[rtag] = self.latest_by_tag(rtag, name, max_evr=max_evr)
return prev_rlss
def list_previous_release(self, name, tag, max_evr=None,
--
1.7.2.1
Show replies by date