mirror of
				https://git.launchpad.net/ubuntu-dev-tools
				synced 2025-11-04 07:54:03 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			92 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/python
 | 
						|
#
 | 
						|
#    submittodebian - tool to submit patches to Debian's bts
 | 
						|
#    Copyright (C) 2007 Canonical Ltd.
 | 
						|
#    Author: Soren Hansen <soren@ubuntu.com>
 | 
						|
#
 | 
						|
#    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
 | 
						|
#    the Free Software Foundation; either version 2 of the License, or
 | 
						|
#    (at your option) any later version.
 | 
						|
#
 | 
						|
#    This program is distributed in the hope that it will be useful,
 | 
						|
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
						|
#    GNU General Public License for more details.
 | 
						|
#
 | 
						|
#    You should have received a copy of the GNU General Public License along
 | 
						|
#    with this program; if not, write to the Free Software Foundation, Inc.,
 | 
						|
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
						|
 | 
						|
 | 
						|
from debian_bundle.changelog import Changelog
 | 
						|
import re, os, sys
 | 
						|
from tempfile import mkstemp
 | 
						|
 | 
						|
def get_most_recent_debian_version(changelog):
 | 
						|
	for v in changelog.get_versions():
 | 
						|
		if not re.search('(ubuntu|build)', v.full_version):
 | 
						|
			return v.full_version
 | 
						|
 | 
						|
def get_bug_body(changelog):
 | 
						|
	return '''In Ubuntu, we've applied the attached patch to achieve the following:
 | 
						|
%s
 | 
						|
We thought you might be interested in doing the same. 
 | 
						|
''' % ("\n".join([a for a in changelog._blocks[0].changes()]))
 | 
						|
 | 
						|
def gen_debdiff(changelog):
 | 
						|
	pkg = changelog.package
 | 
						|
 | 
						|
	oldver = changelog._blocks[1].version
 | 
						|
	newver = changelog._blocks[0].version
 | 
						|
 | 
						|
	olddsc = '../%s_%s.dsc' % (pkg, oldver)
 | 
						|
	newdsc = '../%s_%s.dsc' % (pkg, newver)
 | 
						|
 | 
						|
	check_file(olddsc)
 | 
						|
	check_file(newdsc)
 | 
						|
 | 
						|
	print "Generating debdiff between %s and %s" % (oldver, newver)
 | 
						|
	(fd, debdiff) = mkstemp()
 | 
						|
	os.close(fd)
 | 
						|
	cmd = 'debdiff %s %s | filterdiff -x "*changelog*" > %s' % (olddsc, newdsc, debdiff)
 | 
						|
	run_cmd(cmd)
 | 
						|
 | 
						|
	return debdiff
 | 
						|
 | 
						|
def check_file(fname):
 | 
						|
	if not os.path.exists(fname):
 | 
						|
		print "Couldn't find %s\n" % fname
 | 
						|
		sys.exit(1)
 | 
						|
	
 | 
						|
def edit_debdiff(debdiff):
 | 
						|
	cmd = 'sensible-editor %s' % (debdiff)
 | 
						|
	run_cmd(cmd)
 | 
						|
 | 
						|
def submit_bugreport(body, debdiff, changelog):
 | 
						|
	cmd = 'reportbug -A %s -B debian -i %s -V %s %s' % (debdiff, body, deb_version, changelog.package)
 | 
						|
	run_cmd(cmd)
 | 
						|
 | 
						|
def run_cmd(cmd):
 | 
						|
	if os.getenv('DEBUG'):
 | 
						|
		print "%s\n" % cmd
 | 
						|
	os.system(cmd)
 | 
						|
 | 
						|
check_file('debian/changelog')
 | 
						|
 | 
						|
changelog = Changelog(file('debian/changelog').read())
 | 
						|
 | 
						|
deb_version = get_most_recent_debian_version(changelog)
 | 
						|
bug_body = get_bug_body(changelog)
 | 
						|
 | 
						|
fd, body = mkstemp()
 | 
						|
fp = os.fdopen(fd, 'w')
 | 
						|
fp.write(bug_body)
 | 
						|
fp.close()
 | 
						|
 | 
						|
debdiff = gen_debdiff(changelog)
 | 
						|
edit_debdiff(debdiff)
 | 
						|
submit_bugreport(body, debdiff, changelog)
 | 
						|
os.unlink(body)
 | 
						|
os.unlink(debdiff)
 |