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(a)fedoraproject.org>
+# Dan Horák <dan(a)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()
--
1.7.7.6