mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-08-07 12:04:03 +00:00
Use subprocess and EditFile in submittodebian
This commit is contained in:
parent
629fbd14ad
commit
1f91b015ab
@ -30,7 +30,8 @@ from tempfile import mkstemp
|
|||||||
from distro_info import UbuntuDistroInfo
|
from distro_info import UbuntuDistroInfo
|
||||||
|
|
||||||
from ubuntutools.config import ubu_email
|
from ubuntutools.config import ubu_email
|
||||||
from ubuntutools.question import YesNoQuestion
|
from ubuntutools.question import YesNoQuestion, EditFile
|
||||||
|
from ubuntutools.subprocess import call, check_call, Popen, PIPE
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from debian.changelog import Changelog
|
from debian.changelog import Changelog
|
||||||
@ -75,13 +76,12 @@ def gen_debdiff(changelog):
|
|||||||
oldver = next(changelog_it).version
|
oldver = next(changelog_it).version
|
||||||
|
|
||||||
(fd, debdiff) = mkstemp()
|
(fd, debdiff) = mkstemp()
|
||||||
os.close(fd)
|
debdiff_f = os.fdopen(fd, 'w')
|
||||||
|
|
||||||
if os.system('bzr diff -r tag:%s > /dev/null 2>&1' % oldver) == 256:
|
devnull = open('/dev/null', 'w')
|
||||||
|
diff_cmd = ['bzr', 'diff', '-r', 'tag:' + str(oldver)]
|
||||||
|
if call(diff_cmd, stdout=devnull, stderr=devnull) == 1:
|
||||||
print "Extracting bzr diff between %s and %s" % (oldver, newver)
|
print "Extracting bzr diff between %s and %s" % (oldver, newver)
|
||||||
cmd = 'bzr diff -r tag:%s | filterdiff -x "*changelog*" > %s' % \
|
|
||||||
(oldver, debdiff)
|
|
||||||
run_cmd(cmd)
|
|
||||||
else:
|
else:
|
||||||
if oldver.epoch is not None:
|
if oldver.epoch is not None:
|
||||||
oldver = str(oldver)[str(oldver).index(":")+1:]
|
oldver = str(oldver)[str(oldver).index(":")+1:]
|
||||||
@ -95,9 +95,15 @@ def gen_debdiff(changelog):
|
|||||||
check_file(newdsc)
|
check_file(newdsc)
|
||||||
|
|
||||||
print "Generating debdiff between %s and %s" % (oldver, newver)
|
print "Generating debdiff between %s and %s" % (oldver, newver)
|
||||||
cmd = 'debdiff %s %s | filterdiff -x "*changelog*" > %s' % \
|
diff_cmd = ['debdiff', olddsc, newdsc]
|
||||||
(olddsc, newdsc, debdiff)
|
|
||||||
run_cmd(cmd)
|
diff = Popen(diff_cmd, stdout=PIPE)
|
||||||
|
filterdiff = Popen(['filterdiff', '-x', '*changelog*'],
|
||||||
|
stdin=diff.stdout, stdout=debdiff_f)
|
||||||
|
diff.stdout.close()
|
||||||
|
filterdiff.wait()
|
||||||
|
debdiff_f.close()
|
||||||
|
devnull.close()
|
||||||
|
|
||||||
return debdiff
|
return debdiff
|
||||||
|
|
||||||
@ -110,22 +116,13 @@ def check_file(fname, critical = True):
|
|||||||
print u"Couldn't find «%s».\n" % fname
|
print u"Couldn't find «%s».\n" % fname
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def edit_debdiff(debdiff):
|
|
||||||
cmd = 'sensible-editor %s' % (debdiff)
|
|
||||||
run_cmd(cmd)
|
|
||||||
|
|
||||||
def submit_bugreport(body, debdiff, deb_version, changelog):
|
def submit_bugreport(body, debdiff, deb_version, changelog):
|
||||||
cmd = ('reportbug -P "User: ubuntu-devel@lists.ubuntu.com" '
|
devel = UbuntuDistroInfo().devel()
|
||||||
'-P "Usertags: origin-ubuntu %s ubuntu-patch" -T patch -A %s '
|
cmd = ('reportbug', '-P', 'User: ubuntu-devel@lists.ubuntu.com',
|
||||||
'-B debian -i %s -V %s %s') % \
|
'-P', 'Usertags: origin-ubuntu %s ubuntu-patch' % devel,
|
||||||
(UbuntuDistroInfo().devel(), debdiff, body, deb_version,
|
'-T', 'patch', '-A', debdiff, '-B', 'debian', '-i', body,
|
||||||
changelog.package)
|
'-V', deb_version, changelog.package)
|
||||||
run_cmd(cmd)
|
check_call(cmd)
|
||||||
|
|
||||||
def run_cmd(cmd):
|
|
||||||
if os.getenv('DEBUG'):
|
|
||||||
print "%s\n" % cmd
|
|
||||||
os.system(cmd)
|
|
||||||
|
|
||||||
def check_reportbug_config():
|
def check_reportbug_config():
|
||||||
fn = os.path.expanduser('~/.reportbugrc')
|
fn = os.path.expanduser('~/.reportbugrc')
|
||||||
@ -182,7 +179,10 @@ def main():
|
|||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
debdiff = gen_debdiff(changelog)
|
debdiff = gen_debdiff(changelog)
|
||||||
edit_debdiff(debdiff)
|
EditFile(debdiff, 'debdiff').edit(optional=True)
|
||||||
|
EditFile(body, 'bug report', [
|
||||||
|
re.compile('.*REPLACE THIS WITH ACTUAL INFORMATION.*')
|
||||||
|
]).edit()
|
||||||
submit_bugreport(body, debdiff, deb_version, changelog)
|
submit_bugreport(body, debdiff, deb_version, changelog)
|
||||||
os.unlink(body)
|
os.unlink(body)
|
||||||
os.unlink(debdiff)
|
os.unlink(debdiff)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user