The secondary arch to run sync on and the list of tags need to be provided on the command line now. --- scripts/sync-tagged-primary.py | 130 ++++++++++++++++++++------------------- 1 files changed, 67 insertions(+), 63 deletions(-)
diff --git a/scripts/sync-tagged-primary.py b/scripts/sync-tagged-primary.py index ab66ac6..1b89755 100755 --- a/scripts/sync-tagged-primary.py +++ b/scripts/sync-tagged-primary.py @@ -1,4 +1,5 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- # # synd-tagged-primary.py - A utility to sync tagged packages in primary koji # to a secondary arch @@ -7,6 +8,7 @@ # # Authors: # Dennis Gilmore ausil@fedoraproject.org +# Dan Horák dan@danny.cz # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -28,12 +30,15 @@ import tempfile import shutil import rpm
-# Set some variables -# Some of these could arguably be passed in as args. -tags = ['f17-updates', 'f17-updates-testing', - 'f18-updates', 'f18-updates-testing'] # tag to check in koji +# get architecture and tags from command line +if len(sys.argv) > 2: + arch = sys.argv[1] + tags = sys.argv[2:] +else: + print("Synchronize tagged packages between primary and secondary koji") + print("Usage: %s <arch> <tag> ...<tag-N>" % sys.argv[0]) + exit(0)
-arches = ['arm', 'ppc', 's390']
# Should probably set these from a koji config file SERVERCA = os.path.expanduser('~/.fedora-server-ca.cert') @@ -64,61 +69,60 @@ def rpmvercmp ((e1, v1, r1), (e2, v2, r2)): return -1
-for arch in arches: - print "=== Working on arch: %s ====" % arch - # Create a koji session - kojisession = koji.ClientSession('https://koji.fedoraproject.org/kojihub') - seckojisession = koji.ClientSession('https://%s.koji.fedoraproject.org/kojihub' % arch ) - seckojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA) - - for tag in tags: - print "=== Working on tag: %s ====" % tag - secblocked = [] # holding for blocked pkgs - totag = [] - tountag = [] - pripkgnvrs = [] - secpkgnvrs = [] - - pripkgs = getTagged(kojisession, tag) - secpkgs = getTagged(seckojisession, tag) - - for pkg in pripkgs: - pripkgnvrs.append(pkg['nvr']) - for pkg in secpkgs: - secpkgnvrs.append(pkg['nvr']) - - for pkg in pripkgs: - if pkg['nvr'] not in secpkgnvrs: - secpkg = seckojisession.getBuild(pkg['nvr']) - # see if we have the build on secondary koji and make sure its complete - if not secpkg is None and secpkg['state'] == 1 : - totag.append(pkg['nvr']) - print "need to tag %s" % pkg['nvr'] - - for pkg in secpkgs: - if pkg['nvr'] not in pripkgnvrs: - # make sure we have had a build of the package on primary tagged into the tag - pripkg = kojisession.tagHistory(tag=tag, package=pkg['name']) - if pripkg == []: - # if the package only exists on secondary let it be - print "Secondary arch only package %s" % pkg['nvr'] - # secondary arch evr is higher than primary untag ours - elif pripkg[0]['active'] == None: - # get the latest build from primary in the tag - pripkg = kojisession.listTagged(tag, latest=True, package=pkg['name']) - if pripkg == [] or rpmvercmp((str(pkg['epoch']), pkg['version'], pkg['release']), (str(pripkg[0]['epoch']), pripkg[0]['version'], pripkg[0]['release'])) == 1: - tountag.append(pkg['nvr']) - print "need to untag %s" % pkg['nvr'] - - seckojisession.multicall = True - for pkg in totag: - print "Tagging: Arch: %s Tag: %s Package: %s" % (arch, tag, pkg) - seckojisession.tagBuildBypass(tag, pkg) - - for pkg in tountag: - print "Untagging: Arch: %s Tag: %s Package: %s" % (arch, tag, pkg) - seckojisession.untagBuildBypass(tag, pkg) - - listings = seckojisession.multiCall() - - seckojisession.logout() +print "=== Working on arch: %s ====" % arch +# Create a koji session +kojisession = koji.ClientSession('https://koji.fedoraproject.org/kojihub') +seckojisession = koji.ClientSession('https://%s.koji.fedoraproject.org/kojihub' % arch ) +seckojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA) + +for tag in tags: + print "=== Working on tag: %s ====" % tag + secblocked = [] # holding for blocked pkgs + totag = [] + tountag = [] + pripkgnvrs = [] + secpkgnvrs = [] + + pripkgs = getTagged(kojisession, tag) + secpkgs = getTagged(seckojisession, tag) + + for pkg in pripkgs: + pripkgnvrs.append(pkg['nvr']) + for pkg in secpkgs: + secpkgnvrs.append(pkg['nvr']) + + for pkg in pripkgs: + if pkg['nvr'] not in secpkgnvrs: + secpkg = seckojisession.getBuild(pkg['nvr']) + # see if we have the build on secondary koji and make sure its complete + if not secpkg is None and secpkg['state'] == 1 : + totag.append(pkg['nvr']) + print "need to tag %s" % pkg['nvr'] + + for pkg in secpkgs: + if pkg['nvr'] not in pripkgnvrs: + # make sure we have had a build of the package on primary tagged into the tag + pripkg = kojisession.tagHistory(tag=tag, package=pkg['name']) + if pripkg == []: + # if the package only exists on secondary let it be + print "Secondary arch only package %s" % pkg['nvr'] + # secondary arch evr is higher than primary untag ours + elif pripkg[0]['active'] == None: + # get the latest build from primary in the tag + pripkg = kojisession.listTagged(tag, latest=True, package=pkg['name']) + if pripkg == [] or rpmvercmp((str(pkg['epoch']), pkg['version'], pkg['release']), (str(pripkg[0]['epoch']), pripkg[0]['version'], pripkg[0]['release'])) == 1: + tountag.append(pkg['nvr']) + print "need to untag %s" % pkg['nvr'] + + seckojisession.multicall = True + for pkg in totag: + print "Tagging: Arch: %s Tag: %s Package: %s" % (arch, tag, pkg) + seckojisession.tagBuildBypass(tag, pkg) + + for pkg in tountag: + print "Untagging: Arch: %s Tag: %s Package: %s" % (arch, tag, pkg) + seckojisession.untagBuildBypass(tag, pkg) + + listings = seckojisession.multiCall() + +seckojisession.logout()
--- scripts/sync-tagged-primary.py | 23 ++++++++++------------- 1 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/scripts/sync-tagged-primary.py b/scripts/sync-tagged-primary.py index 1b89755..b1448f4 100755 --- a/scripts/sync-tagged-primary.py +++ b/scripts/sync-tagged-primary.py @@ -29,16 +29,13 @@ import sys import tempfile import shutil import rpm +import argparse
# get architecture and tags from command line -if len(sys.argv) > 2: - arch = sys.argv[1] - tags = sys.argv[2:] -else: - print("Synchronize tagged packages between primary and secondary koji") - print("Usage: %s <arch> <tag> ...<tag-N>" % sys.argv[0]) - exit(0) - +parser = argparse.ArgumentParser() +parser.add_argument("arch", help="secondary arch to sync") +parser.add_argument("tag", nargs="+", help="tag to sync") +args = parser.parse_args()
# Should probably set these from a koji config file SERVERCA = os.path.expanduser('~/.fedora-server-ca.cert') @@ -69,13 +66,13 @@ def rpmvercmp ((e1, v1, r1), (e2, v2, r2)): return -1
-print "=== Working on arch: %s ====" % arch +print "=== Working on arch: %s ====" % args.arch # Create a koji session kojisession = koji.ClientSession('https://koji.fedoraproject.org/kojihub') -seckojisession = koji.ClientSession('https://%s.koji.fedoraproject.org/kojihub' % arch ) +seckojisession = koji.ClientSession('https://%s.koji.fedoraproject.org/kojihub' % args.arch) seckojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)
-for tag in tags: +for tag in args.tag: print "=== Working on tag: %s ====" % tag secblocked = [] # holding for blocked pkgs totag = [] @@ -116,11 +113,11 @@ for tag in tags:
seckojisession.multicall = True for pkg in totag: - print "Tagging: Arch: %s Tag: %s Package: %s" % (arch, tag, pkg) + print "Tagging: Arch: %s Tag: %s Package: %s" % (args.arch, tag, pkg) seckojisession.tagBuildBypass(tag, pkg)
for pkg in tountag: - print "Untagging: Arch: %s Tag: %s Package: %s" % (arch, tag, pkg) + print "Untagging: Arch: %s Tag: %s Package: %s" % (args.arch, tag, pkg) seckojisession.untagBuildBypass(tag, pkg)
listings = seckojisession.multiCall()
--- scripts/sync-tagged-primary.py | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/scripts/sync-tagged-primary.py b/scripts/sync-tagged-primary.py index b1448f4..33f3105 100755 --- a/scripts/sync-tagged-primary.py +++ b/scripts/sync-tagged-primary.py @@ -33,6 +33,7 @@ import argparse
# get architecture and tags from command line parser = argparse.ArgumentParser() +parser.add_argument("--dry-run", help="no changes will be made", action="store_true") parser.add_argument("arch", help="secondary arch to sync") parser.add_argument("tag", nargs="+", help="tag to sync") args = parser.parse_args() @@ -111,6 +112,9 @@ for tag in args.tag: tountag.append(pkg['nvr']) print "need to untag %s" % pkg['nvr']
+ if args.dry_run: + continue + seckojisession.multicall = True for pkg in totag: print "Tagging: Arch: %s Tag: %s Package: %s" % (args.arch, tag, pkg)
--- scripts/sync-tagged-primary | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) create mode 100755 scripts/sync-tagged-primary
diff --git a/scripts/sync-tagged-primary b/scripts/sync-tagged-primary new file mode 100755 index 0000000..ba4a37f --- /dev/null +++ b/scripts/sync-tagged-primary @@ -0,0 +1,10 @@ +#!/bin/sh + +tags_updates="f17-updates f18-updates" +tags_testing="f17-updates-testing f18-updates-testing" + +for arch in arm ppc s390 +do + ./sync-tagged-primary.py $arch $tags_updates + ./sync-tagged-primary.py $arch $tags_testing +done
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
El Thu, 28 Feb 2013 15:40:54 +0100 Dan Horák dan@danny.cz escribió:
The secondary arch to run sync on and the list of tags need to be provided on the command line now.
I have applied this series thanks
Dennis
buildsys@lists.fedoraproject.org