diff --git a/buildd b/buildd index 6a0cb44..3e917ae 100755 --- a/buildd +++ b/buildd @@ -123,14 +123,19 @@ if op == 'status': # Leaving operations may only be done by Ubuntu developers (retry) or buildd # admins (rescore). Check if the proper permissions are in place. if op == "rescore": teamNeeded = "launchpad-buildd-admins" -if op == "retry": teamNeeded = "ubuntu-dev" +if op == "retry": + component = common.packageComponent(package, release) + + if component == "main": teamNeeded = "ubuntu-core-dev" + else: teamNeeded = "ubuntu-dev" necessaryPrivs = common.isLPTeamMember(teamNeeded) if not necessaryPrivs: - print >> sys.stderr, "You cannot perform the %s operation as you are not " \ - "a member of the '%s' team on Launchpad." % (op, teamNeeded) - print "If this is incorrect, please log in to Launchpad using Firefox, " \ + print >> sys.stderr, "You cannot perform the %s operation on a %s package " \ + "as you are not member of the '%s' team on Launchpad." % (op, component, + teamNeeded) + print "Should this is incorrect, please log in to Launchpad using Firefox, " \ "delete the ~/.lpcookie.txt file and rerun this script." sys.exit(1) diff --git a/common.py b/common.py index 86c8d27..15ea5e4 100644 --- a/common.py +++ b/common.py @@ -28,6 +28,7 @@ import cookielib import glob import os.path import re +import subprocess import sys import urllib2 @@ -95,7 +96,7 @@ def checkSourceExists(package, release): "exist in Ubuntu." % package else: # Other error code, probably Launchpad malfunction. print >> sys.stderr, "Error when checking Launchpad for package: " \ - "%s." % error + "%s." % error.code sys.exit(1) # Exit. Error encountered. @@ -233,3 +234,17 @@ def isLPTeamMember(team): return False return True + +def packageComponent(package, release): + madison = subprocess.Popen(['rmadison', '-u', 'ubuntu', '-a', 'source', \ + '-s', release, package], stdout = subprocess.PIPE) + out = madison.communicate()[0] + assert (madison.returncode == 0) + + for l in out.splitlines(): + (pkg, version, rel, builds) = l.split('|') + component = 'main' + if rel.find('/') != -1: + component = rel.split('/')[1] + + return component.strip() diff --git a/debian/changelog b/debian/changelog index aead7bc..0d3366e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,11 +6,15 @@ ubuntu-dev-tools (0.43ubuntu1) intrepid; urgency=low - Improve cookie file writing. - New function: isLPTeamMember() - checks if the user is a member of the Launchpad team using cookies for authentication. + - New function: packageComponent() - returns which component a package in + Ubuntu is in. * requestsync: - Return an error when the script is unable to connect to packages.debian.org (LP: #261916). - Adapt team checking with the function above. - * buildd: Adapt privilege checking code to the new function above. + * buildd: + - Adapt privilege checking code to the new function above. + - Check which component the package is in. [ Ryan Kavanagh ] * dgetlp.1: New manpage