83 lines
2.3 KiB
Plaintext
Raw Normal View History

#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2007, Canonical, Daniel Holbach
# License: GPLv3
#
# Builds a source package from the source tree you're currently in,
# uploads it to PPA and follow up on a bug report, subscribe the right
# sponsors and sets the right status - if you pass "-n" it will file a
# bug report and add "(LP: #....)" and to the changelog.
import os
import sys
from optparse import OptionParser
try:
import ppaput
except ImportError:
print 'You need python-ubuntu-utils installed to use ppaput.'
sys.exit(1)
2007-09-07 11:54:03 +02:00
USAGE = \
2007-09-13 14:36:09 +02:00
"""Usage: ppaput [-n] [<location>] [<debuild options>]
2007-09-07 11:54:03 +02:00
See debuild(1) for more information on debuild options."""
parser = OptionParser(usage=USAGE)
parser.add_option('-n', action='store_true', dest='new_bug', help='File a new bug on Launchpad', default=False)
parser.disable_interspersed_args()
(options, args) = parser.parse_args()
def check_arguments():
location = 'default'
debuild_args = []
try:
if args[0].startswith("-"):
debuild_args = args
2007-10-01 16:13:47 +02:00
else:
location = args[0]
debuild_args = args[1:]
except IndexError:
print "No location or arguments given, using defaults"
return (location, debuild_args)
def main():
(location, debuild_args) = check_arguments()
print location
print debuild_args
(sourcepackage, version, \
section, release) = ppaput.get_name_version_section_and_release()
if options.new_bug:
bugnumber = ppaput.file_bug(sourcepackage, version)
2007-10-01 16:13:47 +02:00
os.system("dch -a 'Fixes (LP: #%s)'" % bugnumber)
if not ppaput.call_debuild(debuild_args):
2007-10-01 16:13:47 +02:00
sys.exit(1)
changesfile = "../%s_%s_source.changes" % (sourcepackage, version)
if not os.path.exists(os.path.expanduser(changesfile)):
2007-10-01 16:13:47 +02:00
print >> sys.stderr, "%s does not exist." % \
os.path.expanduser(changesfile)
sys.exit(1)
host = ppaput.lookup_dput_host(location)
(dput_res, incoming) = ppaput.call_dput(location, changesfile)
if not dput_res:
print >> sys.stderr, "%s was not uploaded." % changesfile
sys.exit(1)
fixed_lp_bugs = ppaput.find_fixed_launchpad_bug(changesfile)
if fixed_lp_bugs:
deal_with_bugreport(fixed_lp_bugs, host, section, incoming,
sourcepackage, version, release)
if __name__ == '__main__':
main()