mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-08 15:31:29 +00:00
* buildd: Use LP API for retrying or rescoring of builds.
This commit is contained in:
parent
fa2a6f3dce
commit
f760b4e845
138
buildd
138
buildd
@ -99,118 +99,84 @@ else:
|
|||||||
|
|
||||||
# ubuntu-dev-tools modules
|
# ubuntu-dev-tools modules
|
||||||
# Import here to improve speed perception parsing options for user.
|
# Import here to improve speed perception parsing options for user.
|
||||||
import ubuntutools.lp.cookie as lp_cookie
|
|
||||||
import ubuntutools.lp.functions as lp_functions
|
import ubuntutools.lp.functions as lp_functions
|
||||||
import ubuntutools.lp.urlopener as lp_urlopener
|
import ubuntutools.lp.udtexceptions
|
||||||
from ubuntutools import packages
|
|
||||||
# https_proxy fix
|
|
||||||
import ubuntutools.common
|
|
||||||
|
|
||||||
# Prepare Launchpad cookie.
|
# split release and pocket
|
||||||
launchpadCookie = lp_cookie.prepareLaunchpadCookie()
|
if '-' in release:
|
||||||
urlopener = lp_urlopener.setupLaunchpadUrlOpener(launchpadCookie)
|
(release, pocket) = release.split('-')
|
||||||
|
else:
|
||||||
# Check the release exists.
|
pocket = 'Release'
|
||||||
try:
|
pocket = pocket.capitalize()
|
||||||
lp_functions.doesUbuntuReleaseExist(release)
|
if pocket not in ('Release', 'Security', 'Updates', 'Proposed', 'Backports'):
|
||||||
except ubuntutools.lp.udtexceptions.SeriesNotFoundException, e:
|
print 'Unknown pocket: %s' % pocket
|
||||||
print e
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Initialize ubuntu distribution collection.
|
# Initialize ubuntu distribution collection.
|
||||||
ubuntuDist = lp_functions.getUbuntuDistribution()
|
ubuntuDist = lp_functions.getUbuntuDistribution()
|
||||||
# Get main Ubuntu archive.
|
# Get main Ubuntu archive.
|
||||||
archive = ubuntuDist.main_archive
|
archive = ubuntuDist.main_archive
|
||||||
release_series = lp_functions.doesUbuntuReleaseExist(release)
|
# Check the release exists.
|
||||||
|
try:
|
||||||
|
release_series = lp_functions.doesUbuntuReleaseExist(release)
|
||||||
|
except ubuntutools.lp.udtexceptions.SeriesNotFoundException, e:
|
||||||
|
print e
|
||||||
|
sys.exit(1)
|
||||||
# Get list of published sources for package in question.
|
# Get list of published sources for package in question.
|
||||||
sources = archive.getPublishedSources(source_name = package,
|
sources = lp_functions._ubuntuSourcePackage(package, release, pocket)
|
||||||
status = 'Published', distro_series = release_series)
|
|
||||||
# Get list of builds for that package.
|
# Get list of builds for that package.
|
||||||
builds = sources[0].getBuilds()
|
builds = sources.getBuilds()
|
||||||
|
|
||||||
# Find out the version in given release.
|
# Find out the version in given release.
|
||||||
(page, version) = packages.checkSourceExists(package, release)
|
version = sources.source_package_version
|
||||||
|
|
||||||
# Get the component the package is in.
|
# Get the component the package is in.
|
||||||
component = lp_functions.packageComponent(package, release)
|
component = sources.component_name
|
||||||
|
|
||||||
|
# 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 = lp_functions.isLPTeamMember('launchpad-buildd-admins')
|
||||||
|
if op == "retry": necessaryPrivs = lp_functions.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.
|
# 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)
|
||||||
|
|
||||||
# Parse out build URLs, states, and arches.
|
|
||||||
buildstats = {}
|
|
||||||
page = urlopener.open('https://launchpad.net/ubuntu/+source/%s/%s' % (package, version))
|
|
||||||
url = page.geturl()
|
|
||||||
page = page.read()
|
|
||||||
release = release.split('-')[0] # strip off pocket
|
|
||||||
|
|
||||||
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
|
||||||
for build in builds:
|
for build in builds:
|
||||||
print "%s: %s." % (build.arch_tag, build.buildstate)
|
if oneArch and build.arch_tag != options.archictecture:
|
||||||
|
|
||||||
for m in re.finditer('"/ubuntu/\+source/%s/%s(/\+build/\d+)"[^\n]+\n\s*(\w+).*?<span>(\w+)</span>.*?</a>\s*([^\n]+)\n' %
|
|
||||||
(package.replace('+', '\+'), version.replace('+', '\+')), page, re.S):
|
|
||||||
if m.group(2) == release:
|
|
||||||
buildstats[url + m.group(1)] = [m.group(3).strip(), m.group(4).strip()]
|
|
||||||
|
|
||||||
# Check that there actually are builds for that release.
|
|
||||||
if len(buildstats) == 0:
|
|
||||||
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)
|
|
||||||
|
|
||||||
# Operations.
|
|
||||||
if op == 'status':
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
# Check if the package in question is architecture independent, and if so; that
|
|
||||||
# i386 has been set as the architecture.
|
|
||||||
if len(buildstats) == 1 and options.architecture != "i386" and oneArch:
|
|
||||||
print "Overriding architecture setting to i386 for architecture " \
|
|
||||||
"independent package..."
|
|
||||||
options.architecture = "i386"
|
|
||||||
|
|
||||||
# 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 = lp_functions.isLPTeamMember('launchpad-buildd-admins')
|
|
||||||
if op == "retry":
|
|
||||||
necessaryPrivs = lp_functions.canUploadPackage(package, release)
|
|
||||||
|
|
||||||
if 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)
|
|
||||||
print "Should this be incorrect, please log in to Launchpad using Firefox, " \
|
|
||||||
"delete the ~/.lpcookie.txt file and rerun this script."
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
for build, (arch, status) in buildstats.iteritems():
|
|
||||||
if oneArch and not options.architecture == arch:
|
|
||||||
# Skip this architecture.
|
# Skip this architecture.
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if op in ('rescore'):
|
done = True
|
||||||
if status in ('Needs building'):
|
print "%s: %s." % (build.arch_tag, build.buildstate)
|
||||||
print 'Rescoring', build, '(%s).' % arch
|
if op == 'rescore':
|
||||||
|
if build.can_be_rescored:
|
||||||
try:
|
# FIXME: make priority an option
|
||||||
urlopener.open(build + '/+rescore', urlencode(
|
priority = 5000
|
||||||
{'field.priority': '5000', 'field.actions.rescore': '1'}))
|
print 'Rescoring build %s to %d' % (build.arch_tag, priority)
|
||||||
except:
|
build.recore(score = priority)
|
||||||
print >> sys.stderr, "Unable to request rescore on %s." % arch
|
|
||||||
else:
|
else:
|
||||||
print "Not rescoring on %s; status is: %s." % (arch, status.lower())
|
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
|
||||||
|
|
||||||
if op in ('retry'): # Retry requested.
|
|
||||||
if status in ('Failed to build', 'Chroot problem', 'Failed to upload'):
|
|
||||||
print 'Retrying:', build, '(%s).' % arch
|
|
||||||
|
|
||||||
try:
|
# We are done
|
||||||
urlopener.open(build + '/+retry', urlencode(
|
if done: sys.exit(0)
|
||||||
{'RETRY': '1'}))
|
|
||||||
except: # Error encountered while submitting request.
|
print "No builds for '%s' found in the %s release - it may have been " \
|
||||||
print >> sys.stderr, "Unable to request retry on %s." % arch
|
"built in a former release." % (package, release.capitalize())
|
||||||
else: # The package does not require rebuilding.
|
sys.exit(0)
|
||||||
print "Not retrying on %s; status is %s." % (arch, status.lower())
|
|
||||||
|
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,8 +1,10 @@
|
|||||||
ubuntu-dev-tools (0.75) UNRELEASED; urgency=low
|
ubuntu-dev-tools (0.75) UNRELEASED; urgency=low
|
||||||
|
|
||||||
*
|
[ Michael Bienia ]
|
||||||
|
* buildd:
|
||||||
|
+ Use the LP API for retrying or rescoring builds.
|
||||||
|
|
||||||
-- Nathan Handler <nhandler@ubuntu.com> Sat, 23 May 2009 20:46:13 +0000
|
-- Michael Bienia <geser@ubuntu.com> Tue, 09 Jun 2009 10:31:03 +0200
|
||||||
|
|
||||||
ubuntu-dev-tools (0.74) karmic; urgency=low
|
ubuntu-dev-tools (0.74) karmic; urgency=low
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ def _ubuntuSeries(name):
|
|||||||
|
|
||||||
raise SeriesNotFoundException("Error: Unknown Ubuntu release: '%s'." % name)
|
raise SeriesNotFoundException("Error: Unknown Ubuntu release: '%s'." % name)
|
||||||
|
|
||||||
def _ubuntuSourcePackage(package, series):
|
def _ubuntuSourcePackage(package, series, pocket = 'Release'):
|
||||||
""" Finds an Ubuntu source package on LP
|
""" Finds an Ubuntu source package on LP
|
||||||
|
|
||||||
returns LP API repr of the source package
|
returns LP API repr of the source package
|
||||||
@ -77,7 +77,7 @@ def _ubuntuSourcePackage(package, series):
|
|||||||
u_archive = ubuntu.main_archive
|
u_archive = ubuntu.main_archive
|
||||||
|
|
||||||
component = u_archive.getPublishedSources(source_name=package, status="Published",
|
component = u_archive.getPublishedSources(source_name=package, status="Published",
|
||||||
exact_match=True, distro_series=lpseries)[0]
|
exact_match=True, distro_series=lpseries, pocket = pocket)[0]
|
||||||
|
|
||||||
return component
|
return component
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user