mirror of
				https://git.launchpad.net/ubuntu-dev-tools
				synced 2025-11-04 07:54:03 +00:00 
			
		
		
		
	buildd: Create a base to add code for the new v2 mode
This commit is contained in:
		
							parent
							
								
									cdb1292963
								
							
						
					
					
						commit
						4f97f5ba15
					
				
							
								
								
									
										204
									
								
								buildd
									
									
									
									
									
								
							
							
						
						
									
										204
									
								
								buildd
									
									
									
									
									
								
							@ -6,6 +6,7 @@
 | 
			
		||||
#   Authors:
 | 
			
		||||
#    - Martin Pitt <martin.pitt@canonical.com>
 | 
			
		||||
#    - Jonathan Davies <jpds@ubuntu.com>
 | 
			
		||||
#    - Michael Bienia <geser@ubuntu.com>
 | 
			
		||||
#
 | 
			
		||||
#   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
 | 
			
		||||
@ -73,115 +74,114 @@ optParser.add_option_group(v2options)
 | 
			
		||||
# Parse our options.
 | 
			
		||||
(options, args) = optParser.parse_args()
 | 
			
		||||
 | 
			
		||||
# 'help' called by itself - show our help.
 | 
			
		||||
try:
 | 
			
		||||
    if args[0].lower() in ("help") and len(args) == 1:
 | 
			
		||||
        optParser.print_help()
 | 
			
		||||
        sys.exit(0)
 | 
			
		||||
except IndexError:
 | 
			
		||||
    optParser.print_help()
 | 
			
		||||
    sys.exit(0)
 | 
			
		||||
 | 
			
		||||
# Check we have the correct number of arguments.
 | 
			
		||||
if len(args) < 3:
 | 
			
		||||
    optParser.error("Incorrect number of arguments.")
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    package = str(args[0]).lower()
 | 
			
		||||
    release = str(args[1]).lower()
 | 
			
		||||
    op      = str(args[2]).lower()
 | 
			
		||||
except IndexError:
 | 
			
		||||
    optParser.print_help()
 | 
			
		||||
    sys.exit(0)
 | 
			
		||||
 | 
			
		||||
# Check our operation.
 | 
			
		||||
if op not in ("rescore", "retry", "status"):
 | 
			
		||||
    print >> sys.stderr, "Invalid operation: %s." % op
 | 
			
		||||
    sys.exit(1)
 | 
			
		||||
 | 
			
		||||
# If the user has specified an architecture to build, we only wish to rebuild it
 | 
			
		||||
# and nothing else.
 | 
			
		||||
if op not in ("retry", 'rescore') and options.architecture:
 | 
			
		||||
    print >> sys.stderr, "Operation %s does not use the --arch option." % op
 | 
			
		||||
    sys.exit(1)
 | 
			
		||||
elif op in ("retry", "rescore") and options.architecture:
 | 
			
		||||
    if options.architecture not in validArchs:
 | 
			
		||||
        print >> sys.stderr, "Invalid architecture specified: %s." % options.architecture
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
    else:
 | 
			
		||||
        oneArch = True
 | 
			
		||||
else:
 | 
			
		||||
    oneArch = False
 | 
			
		||||
 | 
			
		||||
# split release and pocket
 | 
			
		||||
if '-' in release:
 | 
			
		||||
	(release, pocket) = release.split('-')
 | 
			
		||||
else:
 | 
			
		||||
	pocket = 'Release'
 | 
			
		||||
pocket = pocket.capitalize()
 | 
			
		||||
if pocket not in ('Release', 'Security', 'Updates', 'Proposed', 'Backports'):
 | 
			
		||||
	print 'Unknown pocket: %s' % pocket
 | 
			
		||||
if not len(args):
 | 
			
		||||
	optParser.print_help()
 | 
			
		||||
	sys.exit(1)
 | 
			
		||||
 | 
			
		||||
# Get an instance of the LP API wrapper
 | 
			
		||||
lpapiwrapper = LpApiWrapper()
 | 
			
		||||
# Get list of published sources for package in question.
 | 
			
		||||
try:
 | 
			
		||||
	sources = lpapiwrapper.getUbuntuSourcePackage(package, release, pocket)
 | 
			
		||||
except (SeriesNotFoundException, PackageNotFoundException), e:
 | 
			
		||||
    print e
 | 
			
		||||
    sys.exit(1)
 | 
			
		||||
# Get list of builds for that package.
 | 
			
		||||
builds = sources.getBuilds()
 | 
			
		||||
if not options.v2mode:
 | 
			
		||||
	# Check we have the correct number of arguments.
 | 
			
		||||
	if len(args) < 3:
 | 
			
		||||
	    optParser.error("Incorrect number of arguments.")
 | 
			
		||||
 | 
			
		||||
# Find out the version and component in given release.
 | 
			
		||||
version = sources.getVersion()
 | 
			
		||||
component = sources.getComponent()
 | 
			
		||||
	try:
 | 
			
		||||
	    package = str(args[0]).lower()
 | 
			
		||||
	    release = str(args[1]).lower()
 | 
			
		||||
	    op      = str(args[2]).lower()
 | 
			
		||||
	except IndexError:
 | 
			
		||||
	    optParser.print_help()
 | 
			
		||||
	    sys.exit(1)
 | 
			
		||||
 | 
			
		||||
# Operations that are remaining may only be done by Ubuntu developers (retry)
 | 
			
		||||
# or buildd admins (rescore). Check if the proper permissions are in place.
 | 
			
		||||
if op == "rescore": necessaryPrivs = lpapiwrapper.getMe().isLpTeamMember('launchpad-buildd-admins')
 | 
			
		||||
if op == "retry": necessaryPrivs = lpapiwrapper.canUploadPackage(package, release)
 | 
			
		||||
	# Check our operation.
 | 
			
		||||
	if op not in ("rescore", "retry", "status"):
 | 
			
		||||
	    print >> sys.stderr, "Invalid operation: %s." % op
 | 
			
		||||
	    sys.exit(1)
 | 
			
		||||
 | 
			
		||||
if op in ('rescore', 'retry') and not necessaryPrivs:
 | 
			
		||||
    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)
 | 
			
		||||
    sys.exit(1)
 | 
			
		||||
 | 
			
		||||
# Output details.
 | 
			
		||||
print "The source version for '%s' in %s (%s) is at %s." % (package,
 | 
			
		||||
    release.capitalize(), component, version)
 | 
			
		||||
 | 
			
		||||
print "Current build status for this package:"
 | 
			
		||||
 | 
			
		||||
# Output list of arches for package and their status.
 | 
			
		||||
done = False
 | 
			
		||||
for build in builds:
 | 
			
		||||
    if oneArch and build.arch_tag != options.architecture:
 | 
			
		||||
        # Skip this architecture.
 | 
			
		||||
	continue
 | 
			
		||||
 | 
			
		||||
    done = True
 | 
			
		||||
    print "%s: %s." % (build.arch_tag, build.buildstate)
 | 
			
		||||
    if op == 'rescore':
 | 
			
		||||
	if build.can_be_rescored:
 | 
			
		||||
	    # FIXME: make priority an option
 | 
			
		||||
	    priority = 5000
 | 
			
		||||
	    print 'Rescoring build %s to %d...' % (build.arch_tag, priority)
 | 
			
		||||
	    build.rescore(score = priority)
 | 
			
		||||
        else:
 | 
			
		||||
            print 'Cannot rescore build on %s.' % build.arch_tag
 | 
			
		||||
    if op == 'retry':
 | 
			
		||||
	if build.can_be_retried:
 | 
			
		||||
	    print 'Retrying build on %s...' % build.arch_tag
 | 
			
		||||
	    build.retry()
 | 
			
		||||
	# If the user has specified an architecture to build, we only wish to rebuild it
 | 
			
		||||
	# and nothing else.
 | 
			
		||||
	if op not in ("retry", 'rescore') and options.architecture:
 | 
			
		||||
	    print >> sys.stderr, "Operation %s does not use the --arch option." % op
 | 
			
		||||
	    sys.exit(1)
 | 
			
		||||
	elif op in ("retry", "rescore") and options.architecture:
 | 
			
		||||
	    if options.architecture not in validArchs:
 | 
			
		||||
		print >> sys.stderr, "Invalid architecture specified: %s." % options.architecture
 | 
			
		||||
		sys.exit(1)
 | 
			
		||||
	    else:
 | 
			
		||||
		oneArch = True
 | 
			
		||||
	else:
 | 
			
		||||
            print 'Cannot retry build on %s.' % build.arch_tag
 | 
			
		||||
	    oneArch = False
 | 
			
		||||
 | 
			
		||||
	# split release and pocket
 | 
			
		||||
	if '-' in release:
 | 
			
		||||
		(release, pocket) = release.split('-')
 | 
			
		||||
	else:
 | 
			
		||||
		pocket = 'Release'
 | 
			
		||||
	pocket = pocket.capitalize()
 | 
			
		||||
	if pocket not in ('Release', 'Security', 'Updates', 'Proposed', 'Backports'):
 | 
			
		||||
		print 'Unknown pocket: %s' % pocket
 | 
			
		||||
		sys.exit(1)
 | 
			
		||||
 | 
			
		||||
	# Get an instance of the LP API wrapper
 | 
			
		||||
	lpapiwrapper = LpApiWrapper()
 | 
			
		||||
	# Get list of published sources for package in question.
 | 
			
		||||
	try:
 | 
			
		||||
		sources = lpapiwrapper.getUbuntuSourcePackage(package, release, pocket)
 | 
			
		||||
	except (SeriesNotFoundException, PackageNotFoundException), e:
 | 
			
		||||
	    print e
 | 
			
		||||
	    sys.exit(1)
 | 
			
		||||
	# Get list of builds for that package.
 | 
			
		||||
	builds = sources.getBuilds()
 | 
			
		||||
 | 
			
		||||
	# Find out the version and component in given release.
 | 
			
		||||
	version = sources.getVersion()
 | 
			
		||||
	component = sources.getComponent()
 | 
			
		||||
 | 
			
		||||
	# Operations that are remaining may only be done by Ubuntu developers (retry)
 | 
			
		||||
	# or buildd admins (rescore). Check if the proper permissions are in place.
 | 
			
		||||
	if op == "rescore": necessaryPrivs = lpapiwrapper.getMe().isLpTeamMember('launchpad-buildd-admins')
 | 
			
		||||
	if op == "retry": necessaryPrivs = lpapiwrapper.canUploadPackage(package, release)
 | 
			
		||||
 | 
			
		||||
	if op in ('rescore', 'retry') and not necessaryPrivs:
 | 
			
		||||
	    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)
 | 
			
		||||
	    sys.exit(1)
 | 
			
		||||
 | 
			
		||||
	# Output details.
 | 
			
		||||
	print "The source version for '%s' in %s (%s) is at %s." % (package,
 | 
			
		||||
	    release.capitalize(), component, version)
 | 
			
		||||
 | 
			
		||||
	print "Current build status for this package:"
 | 
			
		||||
 | 
			
		||||
	# Output list of arches for package and their status.
 | 
			
		||||
	done = False
 | 
			
		||||
	for build in builds:
 | 
			
		||||
	    if oneArch and build.arch_tag != options.architecture:
 | 
			
		||||
		# Skip this architecture.
 | 
			
		||||
		continue
 | 
			
		||||
 | 
			
		||||
	    done = True
 | 
			
		||||
	    print "%s: %s." % (build.arch_tag, build.buildstate)
 | 
			
		||||
	    if op == 'rescore':
 | 
			
		||||
		if build.can_be_rescored:
 | 
			
		||||
		    # FIXME: make priority an option
 | 
			
		||||
		    priority = 5000
 | 
			
		||||
		    print 'Rescoring build %s to %d...' % (build.arch_tag, priority)
 | 
			
		||||
		    build.rescore(score = priority)
 | 
			
		||||
		else:
 | 
			
		||||
		    print 'Cannot rescore build on %s.' % build.arch_tag
 | 
			
		||||
	    if op == 'retry':
 | 
			
		||||
		if build.can_be_retried:
 | 
			
		||||
		    print 'Retrying build on %s...' % build.arch_tag
 | 
			
		||||
		    build.retry()
 | 
			
		||||
		else:
 | 
			
		||||
		    print 'Cannot retry build on %s.' % build.arch_tag
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# We are done
 | 
			
		||||
if done: sys.exit(0)
 | 
			
		||||
	# We are done
 | 
			
		||||
	if done: sys.exit(0)
 | 
			
		||||
 | 
			
		||||
print "No builds for '%s' found in the %s release - it may have been " \
 | 
			
		||||
      "built in a former release." % (package, release.capitalize())
 | 
			
		||||
	print "No builds for '%s' found in the %s release - it may have been " \
 | 
			
		||||
	      "built in a former release." % (package, release.capitalize())
 | 
			
		||||
	sys.exit(0)
 | 
			
		||||
 | 
			
		||||
# V2 mode
 | 
			
		||||
sys.exit(0)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user