buildd: Create a base to add code for the new v2 mode

This commit is contained in:
Michael Bienia 2009-07-29 14:49:06 +02:00
parent cdb1292963
commit 4f97f5ba15

96
buildd
View File

@ -6,6 +6,7 @@
# Authors: # Authors:
# - Martin Pitt <martin.pitt@canonical.com> # - Martin Pitt <martin.pitt@canonical.com>
# - Jonathan Davies <jpds@ubuntu.com> # - Jonathan Davies <jpds@ubuntu.com>
# - Michael Bienia <geser@ubuntu.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -73,90 +74,86 @@ optParser.add_option_group(v2options)
# Parse our options. # Parse our options.
(options, args) = optParser.parse_args() (options, args) = optParser.parse_args()
# 'help' called by itself - show our help. if not len(args):
try:
if args[0].lower() in ("help") and len(args) == 1:
optParser.print_help() optParser.print_help()
sys.exit(0) sys.exit(1)
except IndexError:
optParser.print_help()
sys.exit(0)
# Check we have the correct number of arguments. if not options.v2mode:
if len(args) < 3: # Check we have the correct number of arguments.
if len(args) < 3:
optParser.error("Incorrect number of arguments.") optParser.error("Incorrect number of arguments.")
try: try:
package = str(args[0]).lower() package = str(args[0]).lower()
release = str(args[1]).lower() release = str(args[1]).lower()
op = str(args[2]).lower() op = str(args[2]).lower()
except IndexError: except IndexError:
optParser.print_help() optParser.print_help()
sys.exit(0) sys.exit(1)
# Check our operation. # Check our operation.
if op not in ("rescore", "retry", "status"): if op not in ("rescore", "retry", "status"):
print >> sys.stderr, "Invalid operation: %s." % op print >> sys.stderr, "Invalid operation: %s." % op
sys.exit(1) sys.exit(1)
# If the user has specified an architecture to build, we only wish to rebuild it # If the user has specified an architecture to build, we only wish to rebuild it
# and nothing else. # and nothing else.
if op not in ("retry", 'rescore') and options.architecture: if op not in ("retry", 'rescore') and options.architecture:
print >> sys.stderr, "Operation %s does not use the --arch option." % op print >> sys.stderr, "Operation %s does not use the --arch option." % op
sys.exit(1) sys.exit(1)
elif op in ("retry", "rescore") and options.architecture: elif op in ("retry", "rescore") and options.architecture:
if options.architecture not in validArchs: if options.architecture not in validArchs:
print >> sys.stderr, "Invalid architecture specified: %s." % options.architecture print >> sys.stderr, "Invalid architecture specified: %s." % options.architecture
sys.exit(1) sys.exit(1)
else: else:
oneArch = True oneArch = True
else: else:
oneArch = False oneArch = False
# split release and pocket # split release and pocket
if '-' in release: if '-' in release:
(release, pocket) = release.split('-') (release, pocket) = release.split('-')
else: else:
pocket = 'Release' pocket = 'Release'
pocket = pocket.capitalize() pocket = pocket.capitalize()
if pocket not in ('Release', 'Security', 'Updates', 'Proposed', 'Backports'): if pocket not in ('Release', 'Security', 'Updates', 'Proposed', 'Backports'):
print 'Unknown pocket: %s' % pocket print 'Unknown pocket: %s' % pocket
sys.exit(1) sys.exit(1)
# Get an instance of the LP API wrapper # Get an instance of the LP API wrapper
lpapiwrapper = LpApiWrapper() lpapiwrapper = LpApiWrapper()
# Get list of published sources for package in question. # Get list of published sources for package in question.
try: try:
sources = lpapiwrapper.getUbuntuSourcePackage(package, release, pocket) sources = lpapiwrapper.getUbuntuSourcePackage(package, release, pocket)
except (SeriesNotFoundException, PackageNotFoundException), e: except (SeriesNotFoundException, PackageNotFoundException), e:
print e print e
sys.exit(1) sys.exit(1)
# Get list of builds for that package. # Get list of builds for that package.
builds = sources.getBuilds() builds = sources.getBuilds()
# Find out the version and component in given release. # Find out the version and component in given release.
version = sources.getVersion() version = sources.getVersion()
component = sources.getComponent() component = sources.getComponent()
# Operations that are remaining may only be done by Ubuntu developers (retry) # Operations that are remaining may only be done by Ubuntu developers (retry)
# or buildd admins (rescore). Check if the proper permissions are in place. # or buildd admins (rescore). Check if the proper permissions are in place.
if op == "rescore": necessaryPrivs = lpapiwrapper.getMe().isLpTeamMember('launchpad-buildd-admins') if op == "rescore": necessaryPrivs = lpapiwrapper.getMe().isLpTeamMember('launchpad-buildd-admins')
if op == "retry": necessaryPrivs = lpapiwrapper.canUploadPackage(package, release) if op == "retry": necessaryPrivs = lpapiwrapper.canUploadPackage(package, release)
if op in ('rescore', 'retry') and not necessaryPrivs: if op in ('rescore', 'retry') and not necessaryPrivs:
print >> sys.stderr, "You cannot perform the %s operation on a %s package " \ print >> sys.stderr, "You cannot perform the %s operation on a %s package " \
"as you do not have the permissions to do this action." % (op, component) "as you do not have the permissions to do this action." % (op, component)
sys.exit(1) sys.exit(1)
# Output details. # Output details.
print "The source version for '%s' in %s (%s) is at %s." % (package, print "The source version for '%s' in %s (%s) is at %s." % (package,
release.capitalize(), component, version) release.capitalize(), component, version)
print "Current build status for this package:" print "Current build status for this package:"
# Output list of arches for package and their status. # Output list of arches for package and their status.
done = False done = False
for build in builds: for build in builds:
if oneArch and build.arch_tag != options.architecture: if oneArch and build.arch_tag != options.architecture:
# Skip this architecture. # Skip this architecture.
continue continue
@ -179,9 +176,12 @@ for build in builds:
print 'Cannot retry build on %s.' % build.arch_tag print 'Cannot retry build on %s.' % build.arch_tag
# We are done # We are done
if done: sys.exit(0) if done: sys.exit(0)
print "No builds for '%s' found in the %s release - it may have been " \ print "No builds for '%s' found in the %s release - it may have been " \
"built in a former release." % (package, release.capitalize()) "built in a former release." % (package, release.capitalize())
sys.exit(0)
# V2 mode
sys.exit(0) sys.exit(0)