mirror of
				https://git.launchpad.net/ubuntu-dev-tools
				synced 2025-10-30 21:44:14 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			91 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/python
 | |
| #
 | |
| # Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
 | |
| #
 | |
| # Permission to use, copy, modify, and/or distribute this software for any
 | |
| # purpose with or without fee is hereby granted, provided that the above
 | |
| # copyright notice and this permission notice appear in all copies.
 | |
| #
 | |
| # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 | |
| # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 | |
| # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 | |
| # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 | |
| # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 | |
| # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 | |
| # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 | |
| 
 | |
| import optparse
 | |
| import os
 | |
| import sys
 | |
| 
 | |
| from ubuntutools.builder import getBuilder
 | |
| from ubuntutools.logger import Logger
 | |
| from ubuntutools.sponsor_patch.main import main
 | |
| 
 | |
| script_name = os.path.basename(sys.argv[0])
 | |
| usage = "%s [options] <bug number>" % (script_name)
 | |
| epilog = "See %s(1) for more info." % (script_name)
 | |
| parser = optparse.OptionParser(usage=usage, epilog=epilog)
 | |
| 
 | |
| if "SPONSOR_PATCH_WORKDIR" in os.environ:
 | |
|     default_workdir = os.path.abspath(os.environ["SPONSOR_PATCH_WORKDIR"])
 | |
| else:
 | |
|     default_workdir = os.getcwd()
 | |
| 
 | |
| if "SPONSOR_PATCH_BUILDER" in os.environ:
 | |
|     default_builder = os.environ["SPONSOR_PATCH_BUILDER"]
 | |
| else:
 | |
|     default_builder = None
 | |
| 
 | |
| parser.add_option("-b", "--build", dest="build",
 | |
|                   help="Build the package with the specified builder.",
 | |
|                   action="store_true", default=False)
 | |
| parser.add_option("-B", "--builder", dest="builder",
 | |
|                   help="Specify the package builder (default pbuilder)",
 | |
|                   default=default_builder)
 | |
| parser.add_option("-e", "--edit",
 | |
|                   help="launch sub-shell to allow editing of the patch",
 | |
|                   dest="edit", action="store_true", default=False)
 | |
| parser.add_option("-k", "--key", dest="keyid", default=None,
 | |
|                   help="Specify the key ID to be used for signing.")
 | |
| parser.add_option("-s", "--sponsor", help="sponsoring; equals -b -u ubuntu",
 | |
|                   dest="sponsoring", action="store_true", default=False)
 | |
| parser.add_option("-u", "--upload", dest="upload", default=None,
 | |
|                   help="Specify an upload destination (default none).")
 | |
| parser.add_option("-U", "--update", dest="update", default=False,
 | |
|                   action="store_true",
 | |
|                   help="Update the build environment before building.")
 | |
| parser.add_option("-v", "--verbose", help="print more information",
 | |
|                   dest="verbose", action="store_true", default=False)
 | |
| parser.add_option("-w", "--workdir", dest="workdir",
 | |
|                   default=default_workdir,
 | |
|                   help="Specify a working directory.")
 | |
| 
 | |
| (options, args) = parser.parse_args()
 | |
| Logger.set_verbosity(options.verbose)
 | |
| 
 | |
| if len(args) == 0:
 | |
|     Logger.error("No bug number specified.")
 | |
|     sys.exit(1)
 | |
| elif len(args) > 1:
 | |
|     Logger.error("Multiple bug numbers specified: %s" % (", ".join(args)))
 | |
|     sys.exit(1)
 | |
| 
 | |
| bug_number = args[0]
 | |
| if bug_number.isdigit():
 | |
|     bug_number = int(bug_number)
 | |
| else:
 | |
|     Logger.error("Invalid bug number specified: %s" % (bug_number))
 | |
|     sys.exit(1)
 | |
| 
 | |
| builder = getBuilder(options.builder)
 | |
| if not builder:
 | |
|     sys.exit(1)
 | |
| 
 | |
| if options.sponsoring:
 | |
|     options.build = True
 | |
|     options.upload = "ubuntu"
 | |
| 
 | |
| main(bug_number, options.update, options.build, options.edit, options.keyid,
 | |
|      options.upload, options.workdir, builder, options.verbose)
 |