#!/usr/bin/python import os import sys import ppaput from optparse import OptionParser USAGE = \ """Usage: ppaput [-n] [] [] 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 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) os.system("dch -a 'Fixes (LP: #%s)'" % bugnumber) if not ppaput.call_debuild(debuild_args): sys.exit(1) changesfile = "../%s_%s_source.changes" % (sourcepackage, version) if not os.path.exists(os.path.expanduser(changesfile)): 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()