#!/usr/bin/python # # update-tag.py - A utility to examine two tags and add builds found in first # tag that are missing in the second tag to the second tag. # # Copyright (c) 2007 Red Hat # # Authors: # Jesse Keating import koji import rpm import sys import os def usage(): print """ update-tag.py sourcetag desttag """ if len(sys.argv) > 1 and sys.argv[1] in ['-h', '--help', '-help', '--usage']: usage() sys.exit(0) elif len(sys.argv) < 3: usage() sys.exit(1) else: sourcetag, desttag = sys.argv[1:] kojisession = koji.ClientSession('http://koji.fedoraproject.org/kojihub') clientcert = os.path.join(os.path.expanduser('~'), '.fedora.cert') clientca = os.path.join(os.path.expanduser('~'), '.fedora-upload-ca.cert') serverca = os.path.join(os.path.expanduser('~'), '.fedora-server-ca.cert') kojisession.ssl_login(clientcert, clientca, serverca) sourcetagged = kojisession.listTagged(sourcetag, latest=True) desttagged = kojisession.listTagged(desttag, inherit=True, latest=True) sourcebuilds = [] destbuilds = [] missing = [] for build in desttagged: destbuilds.append(build['nvr']) for build in sourcetagged: if build['nvr'] not in destbuilds: missing.append(build['nvr']) print "%s is missing %s" % (desttag, build['nvr']) for build in missing: kojisession.tagBuildBypass(desttag, build, force=True) #print 'koji tag-pkg --force %s %s' % (desttag, build)