summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2010-09-20 17:46:10 -0700
committerJesse Keating <jkeating@redhat.com>2010-09-20 17:49:56 -0700
commit5f8cc69168a725364733ca5a1259fd01a6987342 (patch)
tree3c668ebc506dc64228d58ae93b8ce327d7a845ed /src
parentdcdcc603823c45bf7cb223ceece463d677e03cc0 (diff)
downloadfedora-packager-5f8cc69168a725364733ca5a1259fd01a6987342.zip
fedora-packager-5f8cc69168a725364733ca5a1259fd01a6987342.tar.gz
fedora-packager-5f8cc69168a725364733ca5a1259fd01a6987342.tar.xz
Add a tag request function (Xavier Lamien)
This patch is manually applied and then adjusted by me. Adds the basic tag request functionality.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/fedpkg.py19
-rw-r--r--src/pyfedpkg/__init__.py62
2 files changed, 78 insertions, 3 deletions
diff --git a/src/fedpkg.py b/src/fedpkg.py
index 48fb1d4..20dc774 100755
--- a/src/fedpkg.py
+++ b/src/fedpkg.py
@@ -15,6 +15,7 @@ import pyfedpkg
import fedora_cert
import os
import sys
+import getpass
import logging
import koji
import xmlrpclib
@@ -705,8 +706,18 @@ def tag(args):
sys.exit(1)
def tagrequest(args):
- # not implimented
- log.warning('Not implimented yet, got %s' % args)
+ user = getuser(args.user)
+ passwd = getpass.getpass('Password for %s: ' % user)
+
+ if not args.desc:
+ args.desc = raw_input('\nAdd a description to your request: ')
+
+ try:
+ mymodule = pyfedpkg.PackageModule(args.path)
+ mymodule.new_ticket(user, passwd, args.desc, args.build)
+ except pyfedpkg.FedpkgError, e:
+ print('Could not request a tag release: %s' % e)
+ sys.exit(1)
def unusedfedpatches(args):
# not implimented; not planned
@@ -1138,7 +1149,9 @@ packages will be built sequentially.
# Create a releng tag request
parser_tagrequest = subparsers.add_parser('tag-request',
- help = 'Submit last build as a releng tag request')
+ help = 'Submit current build nvr as a releng tag request')
+ parser_tagrequest.add_argument('--desc', help="Description of tag request")
+ parser_tagrequest.add_argument('--build', help="Override the build n-v-r")
parser_tagrequest.set_defaults(command = tagrequest)
# Show unused Fedora patches; not planned
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index df788cb..474053c 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -28,6 +28,7 @@ import stat
import StringIO
import OpenSSL
import fnmatch
+import offtrac
# Define some global variables, put them here to make it easy to change
@@ -36,6 +37,7 @@ LOOKASIDEHASH = 'md5'
LOOKASIDE_CGI = 'https://pkgs.fedoraproject.org/repo/pkgs/upload.cgi'
GITBASEURL = 'ssh://%(user)s@pkgs.fedoraproject.org/%(module)s'
ANONGITURL = 'git://pkgs.fedoraproject.org/%(module)s'
+TRACBASEURL = 'https://%(user)s:%(password)s@fedorahosted.org/rel-eng/login/xmlrpc'
UPLOADEXTS = ['tar', 'gz', 'bz2', 'lzma', 'xz', 'Z', 'zip', 'tff', 'bin',
'tbz', 'tbz2', 'tlz', 'txz', 'pdf', 'rpm', 'jar', 'war', 'db',
'cpio', 'jisp', 'egg', 'gem']
@@ -1022,17 +1024,20 @@ class PackageModule:
self.dist = 'fc%s' % self.distval
self.target = 'dist-f%s-updates-candidate' % self.distval
self.mockconfig = 'fedora-%s-%s' % (self.distval, self.localarch)
+ self.override = 'dist-f%s-override' % self.distval
elif self.branch.startswith('el'):
self.distval = self.branch.split('el')[1]
self.distvar = 'rhel'
self.dist = 'el%s' % self.distval
self.target = 'dist-%sE-epel-testing-candidate' % self.distval
self.mockconfig = 'epel-%s-%s' % (self.distval, self.localarch)
+ self.override = 'dist-%sE-epel-override' % self.distval
elif self.branch.startswith('olpc'):
self.distval = self.branch.split('olpc')[1]
self.distvar = 'olpc'
self.dist = 'olpc%s' % self.distval
self.target = 'dist-olpc%s' % self.distval
+ self.override = 'dist-olpc%s-override' % self.distval
# If we don't match one of the above, assume master or a branch of
# master
else:
@@ -1042,6 +1047,7 @@ class PackageModule:
self.dist = 'fc%s' % self.distval
self.target = 'dist-rawhide'
self.mockconfig = 'fedora-devel-%s' % self.localarch
+ self.override = None
self.rpmdefines = ["--define '_sourcedir %s'" % path,
"--define '_specdir %s'" % path,
"--define '_builddir %s'" % path,
@@ -1491,6 +1497,62 @@ class PackageModule:
_run_command(cmd)
return
+ def new_ticket(self, username, passwd, desc, build=None):
+ """Open a new ticket on Rel-Eng trac instance.
+
+ Get ticket component and assignee from current branch
+
+ Create a new task ticket using username/password/desc
+
+ Discover build nvr from module or optional build argument
+
+ Return ticket number on success
+
+ """
+
+ override = self.override
+ if not override:
+ raise FedpkgError('Override tag is not required for %s' %
+ self.branch)
+
+ uri = TRACBASEURL % {'user': username, 'password': passwd}
+ self.trac = offtrac.TracServer(uri)
+
+ # Set trac's component and assignee from related distvar
+ if self.distvar == 'fedora':
+ component = 'koji'
+ #owner = 'rel-eng@lists.fedoraproject.org'
+ elif self.distvar == 'rhel':
+ component = 'epel'
+ #owner = 'releng-epel@lists.fedoraproject.org'
+
+ # Raise if people request a tag against something that self updates
+ self.init_koji(username)
+ build_target = self.kojisession.getBuildTarget(self.target)
+ if not build_target:
+ raise FedpkgError('Unknown build target: %s' % self.target)
+ dest_tag = self.kojisession.getTag(build_target['dest_tag_name'])
+ ancestors = self.kojisession.getFullInheritance(build_target['build_tag'])
+ if dest_tag['id'] in [build_target['build_tag']] + \
+ [ancestor['parent_id'] for
+ ancestor in ancestors]:
+ raise FedpkgError('Override tag is not required for %s' %
+ self.branch)
+
+ if not build:
+ build = self.nvr
+
+ summary = 'Tag request %s for %s' % (build, override)
+ type = 'task'
+ try:
+ ticket = self.trac.create_ticket(summary, desc, component=component,
+ notify=True)
+ except subprocess.CalledProcessError, e:
+ raise FedpkgError('Could not request tag %s: %s' % (build, e))
+
+ log.debug('Task %s created' % ticket)
+ return ticket
+
def upload(self, files, replace=False):
"""Upload source file(s) in the lookaside cache