summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Macken <lmacken@redhat.com>2010-07-30 16:45:25 -0400
committerLuke Macken <lmacken@redhat.com>2010-08-09 15:00:59 -0400
commitf0ea3257597f05103484c78eaf99b36f412f63da (patch)
treeaf56bb4d8227390c558cabe0a1367336f0697e3d
parent09cdb43fc776b9e9b26045f1c4e9d57ed6ee6bc6 (diff)
downloadfedora-packager-f0ea3257597f05103484c78eaf99b36f412f63da.tar.gz
fedora-packager-f0ea3257597f05103484c78eaf99b36f412f63da.tar.xz
fedora-packager-f0ea3257597f05103484c78eaf99b36f412f63da.zip
Initial implementation of the `fedpkg update` command.
-rwxr-xr-xsrc/fedpkg.py75
1 files changed, 73 insertions, 2 deletions
diff --git a/src/fedpkg.py b/src/fedpkg.py
index 08d3274..2219a38 100755
--- a/src/fedpkg.py
+++ b/src/fedpkg.py
@@ -21,6 +21,9 @@ import xmlrpclib
import time
import random
import string
+import re
+import hashlib
+import textwrap
# Define packages which belong to specific secondary arches
# This is ugly and should go away. A better way to do this is to have a list
@@ -627,8 +630,76 @@ def unusedpatches(args):
print('\n'.join(unused))
def update(args):
- # not implimented
- log.warning('Not implimented yet, got %s' % args)
+ """Submit a new update to bodhi"""
+ mymodule = pyfedpkg.PackageModule(args.path)
+ nvr = '%s-%s-%s' % (mymodule.module, mymodule.ver, mymodule.rel)
+ template = """\
+ [ %(nvr)s ]
+
+ # bugfix, security, enhancement, newpackage (required)
+ type=
+
+ # testing, stable
+ request=testing
+
+ # Bug numbers: 1234,9876
+ bugs=%(bugs)s
+
+ # Description of your update
+ notes=Here is where you
+ give an explanation of
+ your update.
+
+ # Enable request automation based on the stable/unstable karma thresholds
+ autokarma=True
+ stable_karma=3
+ unstable_karma=-3
+
+ # Automatically close bugs when this marked as stable
+ close_bugs=True
+
+ # Suggest that users restart after update
+ suggest_reboot=False\
+ """
+ args = {'nvr': nvr, 'bugs': ''}
+
+ # Extract bug numbers from the latest changelog entry
+ mymodule.clog()
+ clog = file('clog').read()
+ bugs = re.findall(r'#([0-9]*)', clog)
+ if bugs:
+ args['bugs'] = ','.join(bugs)
+
+ template = textwrap.dedent(template) % args
+
+ # Calculate the hash of the unaltered template
+ orig_hash = hashlib.new('sha1')
+ orig_hash.update(template)
+ orig_hash = orig_hash.hexdigest()
+
+ # Write out the template
+ out = file('bodhi.template', 'w')
+ out.write(template)
+ out.close()
+
+ # Open the template in a text editor
+ editor = os.getenv('EDITOR', 'vi')
+ pyfedpkg._run_command([editor, 'bodhi.template'], shell=True)
+
+ # If the template was changed, submit it to bodhi
+ hash = pyfedpkg._hash_file('bodhi.template', 'sha1')
+ if hash != orig_hash:
+ cmd = ['bodhi', '--new', '--release', mymodule.branch, '--file',
+ 'bodhi.template', nvr, '--username',
+ os.getenv('BODHI_USER', os.getenv('USER'))]
+ pyfedpkg._run_command(cmd, shell=True)
+ else:
+ log.info('Bodhi update aborted!')
+
+ # Clean up
+ os.unlink('bodhi.template')
+ os.unlink('clog')
+
def verrel(args):
try: