Merge trunk

This commit is contained in:
Andreas Moog 2011-12-02 20:06:16 +01:00
commit 6c36b6dd6c
5 changed files with 109 additions and 16 deletions

6
debian/changelog vendored
View File

@ -16,12 +16,16 @@ ubuntu-dev-tools (0.137) UNRELEASED; urgency=low
* sponsor-patch: Check the bug's title, not the task, when determining
source series for syncs.
* mk-sbuild, pbuilder-dist, ubuntu-build: Add armhf.
* pull-debian-source, pull-lp-source: Resolve the source package (via DDE),
if a binary package was requested (LP: #617349)
[ Andreas Moog ]
* sponsor-patch: Check permission to unsubscribe sponsors-team (LP: #896884)
* grep-merges: We already require a UTF-8 enabled terminal, so encode
package and uploader name in UTF-8 (LP: #694388)
* requestsync: Give user option to retry in case of temporary error (LP: #850360)
-- Andreas Moog <amoog@ubuntu.com> Sun, 27 Nov 2011 22:13:22 +0100
-- Andreas Moog <amoog@ubuntu.com> Wed, 30 Nov 2011 21:04:39 +0100
ubuntu-dev-tools (0.136) unstable; urgency=low

View File

@ -60,7 +60,7 @@ def main():
pretty_uploader = ' '.join((author, uploader)).strip()
if (match is None or
match in package or match in author or match in uploader):
print '%s\t%s' % (package, pretty_uploader)
print '%s\t%s' % (package.encode("utf-8"), pretty_uploader.encode("utf-8"))
if __name__ == '__main__':
main()

View File

@ -16,8 +16,10 @@
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
import json
import optparse
import sys
import urllib2
from devscripts.logger import Logger
from distro_info import DebianDistroInfo
@ -25,6 +27,7 @@ from distro_info import DebianDistroInfo
from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison
from ubuntutools.config import UDTConfig
def is_suite(version):
"""If version could be considered to be a Debian suite, return the
canonical suite name. Otherwise None
@ -46,6 +49,23 @@ def is_suite(version):
return release
return None
def source_package_for(binary, release):
"""Query DDE to find the source package for a particular binary"""
release = DebianDistroInfo().codename(release, default=release)
url = ('http://dde.debian.net/dde/q/udd/dist/d:debian/r:%s/p:%s/?t=json'
% (release, binary))
try:
data = json.load(urllib2.urlopen(url))['r']
except urllib2.URLError, e:
Logger.error('Unable to retrieve package information from DDE: '
'%s (%s)', url, str(e))
return None
if not data:
return None
return data[0]['source']
def main():
usage = 'Usage: %prog <package> [release|version]'
parser = optparse.OptionParser(usage)
@ -85,9 +105,14 @@ def main():
if suite is not None:
line = list(rmadison('debian', package, suite, 'source'))
if not line:
Logger.error('Unable to find %s in Debian suite "%s".', package,
suite)
sys.exit(1)
source_package = source_package_for(package, suite)
if source_package != None and package != source_package:
package = source_package
line = list(rmadison('debian', package, suite, 'source'))
if not line:
Logger.error('Unable to find %s in Debian suite "%s".', package,
suite)
sys.exit(1)
line = line[-1]
version = line['version']
component = line['component']

View File

@ -23,8 +23,10 @@
# ##################################################################
import json
import os
import sys
import urllib2
from optparse import OptionParser
from devscripts.logger import Logger
@ -38,6 +40,24 @@ from ubuntutools.lp.udtexceptions import (SeriesNotFoundException,
PocketDoesNotExistError)
from ubuntutools.misc import split_release_pocket
def source_package_for(binary, release):
"""Query DDE to find the source package for a particular binary
Should really do this with LP, but it's not possible LP: #597041
"""
url = ('http://dde.debian.net/dde/q/udd/dist/d:ubuntu/r:%s/p:%s/?t=json'
% (release, binary))
try:
data = json.load(urllib2.urlopen(url))['r']
except urllib2.URLError, e:
Logger.error('Unable to retrieve package information from DDE: '
'%s (%s)', url, str(e))
return None
if not data:
return None
return data[0]['source']
def main():
usage = "Usage: %prog <package> [release|version]"
opt_parser = OptionParser(usage)
@ -66,7 +86,7 @@ def main():
package = str(args[0]).lower()
ubuntu_info = UbuntuDistroInfo()
if len(args) > 1: # Custom distribution specified.
if len(args) > 1: # Custom distribution specified.
version = str(args[1])
else:
version = os.getenv('DIST') or ubuntu_info.devel()
@ -80,13 +100,26 @@ def main():
except PocketDoesNotExistError, e:
pass
if release in ubuntu_info.all:
archive = Distribution('ubuntu').getArchive()
try:
spph = Distribution('ubuntu').getArchive().getSourcePackage(package,
release,
pocket)
except (SeriesNotFoundException, PackageNotFoundException), e:
spph = archive.getSourcePackage(package, release, pocket)
except SeriesNotFoundException, e:
Logger.error(str(e))
sys.exit(1)
except PackageNotFoundException, e:
source_package = source_package_for(package, release)
if source_package is not None and source_package != package:
try:
spph = archive.getSourcePackage(source_package, release,
pocket)
package = source_package
except PackageNotFoundException:
Logger.error(str(e))
sys.exit(1)
else:
Logger.error(str(e))
sys.exit(1)
version = spph.getVersion()
component = spph.getComponent()

View File

@ -42,6 +42,7 @@ from ubuntutools.lp.udtexceptions import (AlreadyLoggedInError,
__all__ = [
'Archive',
'BinaryPackagePublishingHistory',
'Build',
'Distribution',
'DistributionSourcePackage',
@ -277,7 +278,9 @@ class Archive(BaseWrapper):
resource_type = 'archive'
def __init__(self, *args):
# Don't share _srcpkgs between different Archives
# Don't share between different Archives
if '_binpkgs' not in self.__dict__:
self._binpkgs = dict()
if '_srcpkgs' not in self.__dict__:
self._srcpkgs = dict()
@ -295,6 +298,34 @@ class Archive(BaseWrapper):
If the requested source package doesn't exist a
PackageNotFoundException is raised.
'''
return self._getPublishedItem(name, series, pocket, cache=self._srcpkgs,
function='getPublishedSources',
name_key='source_name',
wrapper=SourcePackagePublishingHistory)
def getBinaryPackage(self, name, series=None, pocket=None):
'''
Returns a BinaryPackagePublishingHistory object for the most
recent source package in the distribution 'dist', series and
pocket.
series defaults to the current development series if not specified.
pocket may be a list, if so, the highest version will be returned.
It defaults to all pockets except backports.
If the requested binary package doesn't exist a
PackageNotFoundException is raised.
'''
return self._getPublishedItem(name, series, pocket, cache=self._binpkgs,
function='getPublishedBinaries',
name_key='binary_name',
wrapper=BinaryPackagePublishingHistory)
def _getPublishedItem(self, name, series, pocket, cache, function, name_key,
wrapper):
'''Common code between getSourcePackage and getBinaryPackage
'''
if pocket is None:
pockets = frozenset(('Proposed', 'Updates', 'Security', 'Release'))
elif isinstance(pocket, basestring):
@ -316,9 +347,9 @@ class Archive(BaseWrapper):
series = dist.getDevelopmentSeries()
index = (name, series.name, pockets)
if index not in self._srcpkgs:
if index not in cache:
params = {
'source_name': name,
name_key: name,
'distro_series': series(),
'status': 'Published',
'exact_match': True,
@ -326,7 +357,7 @@ class Archive(BaseWrapper):
if len(pockets) == 1:
params['pocket'] = list(pockets)[0]
records = self.getPublishedSources(**params)
records = getattr(self, function)(**params)
latest = None
for record in records:
@ -347,8 +378,8 @@ class Archive(BaseWrapper):
msg += " in " + ', '.join(pockets)
raise PackageNotFoundException(msg)
self._srcpkgs[index] = SourcePackagePublishingHistory(latest)
return self._srcpkgs[index]
cache[index] = wrapper(latest)
return cache[index]
def copyPackage(self, source_name, version, from_archive, to_pocket,
to_series=None, include_binaries=False):