2007-09-05 16:04:37 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2008-02-15 12:22:35 -05:00
|
|
|
import ppaput
|
|
|
|
from optparse import OptionParser
|
2007-09-05 18:15:23 +02:00
|
|
|
|
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
|
|
|
|
2008-02-15 12:22:35 -05:00
|
|
|
See debuild(1) for more information on debuild options."""
|
|
|
|
parser = OptionParser(usage=USAGE)
|
2007-09-05 16:04:37 +02:00
|
|
|
|
2008-02-15 12:22:35 -05:00
|
|
|
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()
|
2007-09-05 16:04:37 +02:00
|
|
|
|
2008-02-15 12:22:35 -05:00
|
|
|
def check_arguments():
|
2007-09-07 11:47:06 +02:00
|
|
|
location = 'default'
|
2008-02-15 12:22:35 -05:00
|
|
|
debuild_args = []
|
2007-09-05 16:04:37 +02:00
|
|
|
|
2008-02-15 12:22:35 -05:00
|
|
|
try:
|
|
|
|
if args[0].startswith("-"):
|
|
|
|
debuild_args = args
|
2007-10-01 16:13:47 +02:00
|
|
|
else:
|
2008-02-15 12:22:35 -05:00
|
|
|
location = args[0]
|
|
|
|
debuild_args = args[1:]
|
|
|
|
except IndexError:
|
|
|
|
print "No location or arguments given, using defaults"
|
2007-09-07 11:47:06 +02:00
|
|
|
|
2008-02-15 12:22:35 -05:00
|
|
|
return (location, debuild_args)
|
2007-09-05 16:04:37 +02:00
|
|
|
|
2008-02-15 12:22:35 -05:00
|
|
|
def main():
|
2007-09-07 12:31:52 +02:00
|
|
|
|
2008-02-15 12:22:35 -05:00
|
|
|
(location, debuild_args) = check_arguments()
|
|
|
|
print location
|
|
|
|
print debuild_args
|
2007-09-05 16:04:37 +02:00
|
|
|
|
2007-10-01 17:21:56 +02:00
|
|
|
(sourcepackage, version, \
|
2008-02-15 12:22:35 -05:00
|
|
|
section, release) = ppaput.get_name_version_section_and_release()
|
2007-10-01 16:58:29 +02:00
|
|
|
|
2008-02-15 12:22:35 -05:00
|
|
|
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)
|
2008-02-15 12:22:35 -05:00
|
|
|
if not ppaput.call_debuild(debuild_args):
|
2007-10-01 16:13:47 +02:00
|
|
|
sys.exit(1)
|
2007-09-05 16:04:37 +02:00
|
|
|
|
|
|
|
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)
|
2007-09-05 16:04:37 +02:00
|
|
|
|
2008-02-15 12:22:35 -05:00
|
|
|
host = ppaput.lookup_dput_host(location)
|
|
|
|
(dput_res, incoming) = ppaput.call_dput(location, changesfile)
|
2007-09-06 17:44:31 +02:00
|
|
|
if not dput_res:
|
2007-10-01 16:58:29 +02:00
|
|
|
print >> sys.stderr, "%s was not uploaded." % changesfile
|
|
|
|
sys.exit(1)
|
2007-09-05 16:04:37 +02:00
|
|
|
|
2008-02-15 12:22:35 -05:00
|
|
|
fixed_lp_bugs = ppaput.find_fixed_launchpad_bug(changesfile)
|
|
|
|
if fixed_lp_bugs:
|
2007-10-01 16:58:29 +02:00
|
|
|
deal_with_bugreport(fixed_lp_bugs, host, section, incoming,
|
2007-10-01 17:21:56 +02:00
|
|
|
sourcepackage, version, release)
|
2007-09-05 16:04:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
2008-02-15 12:22:35 -05:00
|
|
|
|