mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 15:41:09 +00:00
pull-debian-source, pull-lp-source: Resolve the source package (via DDE),
if a binary package was requested (LP: #617349)
This commit is contained in:
parent
75067b3cf3
commit
9c20cc13a3
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -16,6 +16,8 @@ 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)
|
||||
|
@ -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']
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user