diff --git a/buildd b/buildd
index 199f927..746445a 100755
--- a/buildd
+++ b/buildd
@@ -99,118 +99,84 @@ else:
# ubuntu-dev-tools modules
# 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.urlopener as lp_urlopener
-from ubuntutools import packages
-# https_proxy fix
-import ubuntutools.common
+import ubuntutools.lp.udtexceptions
-# Prepare Launchpad cookie.
-launchpadCookie = lp_cookie.prepareLaunchpadCookie()
-urlopener = lp_urlopener.setupLaunchpadUrlOpener(launchpadCookie)
-
-# Check the release exists.
-try:
- lp_functions.doesUbuntuReleaseExist(release)
-except ubuntutools.lp.udtexceptions.SeriesNotFoundException, e:
- print e
- sys.exit(1)
+# 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)
# Initialize ubuntu distribution collection.
ubuntuDist = lp_functions.getUbuntuDistribution()
# Get main Ubuntu 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.
-sources = archive.getPublishedSources(source_name = package,
- status = 'Published', distro_series = release_series)
+sources = lp_functions._ubuntuSourcePackage(package, release, pocket)
# Get list of builds for that package.
-builds = sources[0].getBuilds()
+builds = sources.getBuilds()
# 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.
-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.
print "The source version for '%s' in %s (%s) is at %s." % (package,
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:"
# Output list of arches for package and their status.
+done = False
for build in builds:
- print "%s: %s." % (build.arch_tag, build.buildstate)
-
-for m in re.finditer('"/ubuntu/\+source/%s/%s(/\+build/\d+)"[^\n]+\n\s*(\w+).*?(\w+).*?\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:
+ if oneArch and build.arch_tag != options.archictecture:
# Skip this architecture.
- continue
+ continue
- if op in ('rescore'):
- if status in ('Needs building'):
- print 'Rescoring', build, '(%s).' % arch
-
- try:
- urlopener.open(build + '/+rescore', urlencode(
- {'field.priority': '5000', 'field.actions.rescore': '1'}))
- except:
- print >> sys.stderr, "Unable to request rescore on %s." % arch
+ 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.recore(score = priority)
else:
- print "Not rescoring on %s; status is: %s." % (arch, status.lower())
-
- if op in ('retry'): # Retry requested.
- if status in ('Failed to build', 'Chroot problem', 'Failed to upload'):
- print 'Retrying:', build, '(%s).' % arch
+ 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
- try:
- urlopener.open(build + '/+retry', urlencode(
- {'RETRY': '1'}))
- except: # Error encountered while submitting request.
- print >> sys.stderr, "Unable to request retry on %s." % arch
- else: # The package does not require rebuilding.
- print "Not retrying on %s; status is %s." % (arch, status.lower())
+
+# 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())
+sys.exit(0)
diff --git a/debian/changelog b/debian/changelog
index cfb2dae..a726a0f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,10 @@
ubuntu-dev-tools (0.75) UNRELEASED; urgency=low
- *
+ [ Michael Bienia ]
+ * buildd:
+ + Use the LP API for retrying or rescoring builds.
- -- Nathan Handler Sat, 23 May 2009 20:46:13 +0000
+ -- Michael Bienia Tue, 09 Jun 2009 10:31:03 +0200
ubuntu-dev-tools (0.74) karmic; urgency=low
diff --git a/ubuntutools/lp/functions.py b/ubuntutools/lp/functions.py
index 8f2a55b..be17a46 100644
--- a/ubuntutools/lp/functions.py
+++ b/ubuntutools/lp/functions.py
@@ -62,7 +62,7 @@ def _ubuntuSeries(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
returns LP API repr of the source package
@@ -77,7 +77,7 @@ def _ubuntuSourcePackage(package, series):
u_archive = ubuntu.main_archive
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