From 3587439e8bc2cf295b4508f2602aed921a79809c Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Wed, 12 Sep 2007 01:14:23 +1000 Subject: [PATCH] * Add requestsync and its manual page from devscripts. * Add Conflicts/Replaces against devscripts 2.10.7ubuntu3. --- debian/changelog | 7 ++ debian/control | 2 + doc/requestsync.1 | 34 +++++++++ requestsync | 180 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 223 insertions(+) create mode 100644 doc/requestsync.1 create mode 100755 requestsync diff --git a/debian/changelog b/debian/changelog index a491678..5699b9f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +ubuntu-dev-tools (0.5) gutsy; urgency=low + + * Add requestsync and its manual page from devscripts. + * Add Conflicts/Replaces against devscripts 2.10.7ubuntu3. + + -- Steve Kowalik Wed, 12 Sep 2007 01:14:04 +1000 + ubuntu-dev-tools (0.4) gutsy; urgency=low * revuput: added a tool to upload packages to PPA and file sponsoring bugs diff --git a/debian/control b/debian/control index f9bab2a..7423485 100644 --- a/debian/control +++ b/debian/control @@ -14,6 +14,8 @@ Architecture: all Section: devel Depends: ${python:Depends}, ${misc:Depends}, binutils, devscripts, sudo, python-launchpad-bugs (>= 0.2.9) Recommends: bzr, pbuilder +Conflicts: devscripts (<< 2.10.7ubuntu3) +Replaces: devscripts (<< 2.10.7ubuntu3) XB-Python-Version: ${python:Versions} Description: useful tools for Ubuntu developers This is a collection of useful tools that Ubuntu developers use to diff --git a/doc/requestsync.1 b/doc/requestsync.1 new file mode 100644 index 0000000..8996724 --- /dev/null +++ b/doc/requestsync.1 @@ -0,0 +1,34 @@ +.TH REQUESTSYNC "1" "6 August 2007" "devscripts" +.SH NAME +requestsync \- helper to file sync requests for Ubuntu +.SH SYNOPSIS +.B requestsync +.RI [\fI -n | -s \fR] " " <\fIsource\fR " " \fIpackage\fR> " " <\fItarget\fR " " \fIrelease\fR> " "[\fIbase\fR " " \fIversion\fR] +.SH DESCRIPTION +.PP +\fBrequestsync\fR looks at the versions of in Debian and Ubuntu, prompts for an explanation of why the Ubuntu changes (if there are any) should be dropped, downloads the changelog entry from packages.debian.org, and then prompts for your GPG passphrase so it can sign the mail and send it off, which files a sync request in the form of a bug report in Launchpad. +.SH OPTIONS +.PP +Listed below are the command line options for requestsync: +.TP +\fB\-n\fR +Specifies that the package is a new package, and requestsync should not attempt to look it up in Ubuntu since it will not exist. +.TP +\fB\-s\fR +Specifies that you require sponsorship. You need this option if you are not a member of ubuntu-dev for universe or multiverse, or ubuntu-core-dev for main or restricted. +.TP +\fB\fR +This is the source package that you would like to be synced from Debian. +.TP +\fB\fR +This is the release that you would like the source package to be synced into. This should always be the latest development release of Ubuntu, ie: gutsy. +.TP +\fB[base version]\fR +In some cases, the base version (where the Ubuntu package started differing from the Debian package) can not be automatically determined. Specify this option in this case. +.SH AUTHOR +.PP +This manual page was pieced together by Steve Kowalik. +.SH SEE ALSO +.PP +\fBrmadison\fP\fB(1)\fP +.UE diff --git a/requestsync b/requestsync new file mode 100755 index 0000000..9bf7ea7 --- /dev/null +++ b/requestsync @@ -0,0 +1,180 @@ +#!/usr/bin/python + +# (C) 2007 Canonical Ltd, Steve Kowalik +# Authors: +# Martin Pitt +# Steve Kowalik +# GPLv2, see /usr/share/common-licenses/GPL + +import os, os.path, sys, urllib, subprocess, smtplib, getopt + +changelog = 1 + +def cur_version_component(sourcepkg, release): + madison = subprocess.Popen(['rmadison', '-u', 'ubuntu', '-a', 'source', \ + '-s', release, sourcepkg], \ + stdout=subprocess.PIPE) + out = madison.communicate()[0] + assert (madison.returncode == 0) + + for l in out.splitlines(): + (pkg, version, rel, builds) = l.split('|') + component = 'main' + if rel.find('/') != -1: + component = rel.split('/')[1] + return (version.strip(), component.strip()) + + print "%s doesn't appear to exist in %s, specify -n for a package not in Ubuntu." % (sourcepkg, release) + sys.exit(1) + +def debian_changelog(sourcepkg, component, version): + '''Return the Debian changelog from the latest up to the given version + (exclusive).''' + + ch = '' + subdir = sourcepkg[0] + if sourcepkg.startswith('lib'): + subdir = 'lib%s' % sourcepkg[3] + for l in urllib.urlopen('http://packages.debian.org/changelogs/pool/%s/%s/%s/current/changelog.txt' % (component, subdir, sourcepkg)): + if l.startswith(sourcepkg) and l.find(version + ')') > 0: + break + ch += l + + return ch + +def debian_component(sourcepkg): + '''Return the Debian component for the source package.''' + madison = subprocess.Popen(['rmadison', '-a', 'source', '-s', 'unstable', \ + sourcepkg], stdout=subprocess.PIPE) + out = madison.communicate()[0] + assert (madison.returncode == 0) + + try: + assert out + except AssertionError: + print "%s doesn't appear to exist in Debian." % sourcepkg + sys.exit(1) + raw_comp = out.split(' | ')[2].split('/') + component = 'main' + if len(raw_comp) == 2: + component = raw_comp[1] + return component + +def usage(): + print """Usage: requestsync [-n|-s|-k ] [basever] + +In some cases, the base version (fork point from Debian) cannot be determined +automatically, and you'll get a complete Debian changelog. Specify the correct +base version in that case.""" + sys.exit(1) + +# +# entry point +# + +newsource = False +sponsorship = False +keyid = None +try: + opts, args = getopt.getopt(sys.argv[1:], 'nsk:') +except getopt.GetoptError: + usage() +for o, a in opts: + if o == "-n": + newsource = True + if o == "-s": + sponsorship = True + if o == "-k": + keyid = a + +if len(args) not in (2, 3): + usage() + +(srcpkg, release) = args[:2] +force_base_ver = None +if len(args) == 3: + force_base_ver = args[2] +(cur_ver, component) = ('0', 'universe') # Let's assume universe +if not newsource: + (cur_ver, component) = cur_version_component(srcpkg, release) + +debiancomponent = debian_component(srcpkg) + +# generate bug report +status = "confirmed" +subscribe = "ubuntu-archive" +if sponsorship: + status = "new" + if component in ['main', 'restricted']: + subscribe = "ubuntu-main-sponsors" + else: + subscribe = "ubuntu-universe-sponsors" + +affects = '/%s' % srcpkg +if newsource: + affects = '' + +report = ''' affects ubuntu%s + status %s + subscribe %s + +Please sync %s (%s) from Debian unstable (%s). +''' % (affects, status, subscribe, srcpkg, component, debiancomponent) + +base_ver = cur_ver +uidx = base_ver.find('ubuntu') +if uidx > 0: + base_ver = base_ver[:uidx] + + print 'Explanation of the Ubuntu delta and why it can be dropped:' + explanation = '\nExplanation of the Ubuntu delta and why it can be dropped:\n' + while (explanation[-2:] != '\n\n'): + explanation += sys.stdin.readline() + report += explanation + +if changelog: + uidx = base_ver.find('build') + if uidx > 0: + base_ver = base_ver[:uidx] + + if force_base_ver: + base_ver = force_base_ver + + report += 'Changelog since current %s version %s:\n\n' % (release, cur_ver) + report += debian_changelog(srcpkg, debiancomponent, base_ver) + '\n' + +# sign it +sign_command = 'gpg' +for cmd in ('gpg2', 'gnome-gpg'): + if os.access('/usr/bin/%s' % cmd, os.X_OK): + sign_command = cmd + +gpg_command = [sign_command, '--clearsign'] +if keyid: + gpg_command.extend(('-u', keyid)) + +gpg = subprocess.Popen(gpg_command, stdin=subprocess.PIPE, stdout=subprocess.PIPE) +signed_report = gpg.communicate(report)[0] +assert gpg.returncode == 0 + +# generate email +myemailaddr = os.getenv('DEBEMAIL') +if not myemailaddr: + print "The environment variable DEBEMAIL needs to be set to make use of this script." + sys.exit(1) +to = 'new@bugs.launchpad.net' + +mail = '''From: %s +To: %s +Subject: Please sync %s (%s) from Debian unstable (%s) + +%s''' % (myemailaddr, to, srcpkg, component, debiancomponent, signed_report) + +print mail + +print 'Press enter to file this bug, Control-C to abort' +sys.stdin.readline() + +s = smtplib.SMTP('fiordland.ubuntu.com') +s.sendmail(myemailaddr, to, mail) +s.quit()