mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-10 08:21:29 +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
|
* sponsor-patch: Check the bug's title, not the task, when determining
|
||||||
source series for syncs.
|
source series for syncs.
|
||||||
* mk-sbuild, pbuilder-dist, ubuntu-build: Add armhf.
|
* 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 ]
|
[ Andreas Moog ]
|
||||||
* sponsor-patch: Check permission to unsubscribe sponsors-team (LP: #896884)
|
* 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
|
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
import json
|
||||||
import optparse
|
import optparse
|
||||||
import sys
|
import sys
|
||||||
|
import urllib2
|
||||||
|
|
||||||
from devscripts.logger import Logger
|
from devscripts.logger import Logger
|
||||||
from distro_info import DebianDistroInfo
|
from distro_info import DebianDistroInfo
|
||||||
@ -25,6 +27,7 @@ from distro_info import DebianDistroInfo
|
|||||||
from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison
|
from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison
|
||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
|
|
||||||
|
|
||||||
def is_suite(version):
|
def is_suite(version):
|
||||||
"""If version could be considered to be a Debian suite, return the
|
"""If version could be considered to be a Debian suite, return the
|
||||||
canonical suite name. Otherwise None
|
canonical suite name. Otherwise None
|
||||||
@ -46,6 +49,23 @@ def is_suite(version):
|
|||||||
return release
|
return release
|
||||||
return None
|
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():
|
def main():
|
||||||
usage = 'Usage: %prog <package> [release|version]'
|
usage = 'Usage: %prog <package> [release|version]'
|
||||||
parser = optparse.OptionParser(usage)
|
parser = optparse.OptionParser(usage)
|
||||||
@ -84,6 +104,11 @@ def main():
|
|||||||
suite = is_suite(version)
|
suite = is_suite(version)
|
||||||
if suite is not None:
|
if suite is not None:
|
||||||
line = list(rmadison('debian', package, suite, 'source'))
|
line = list(rmadison('debian', package, suite, 'source'))
|
||||||
|
if not line:
|
||||||
|
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:
|
if not line:
|
||||||
Logger.error('Unable to find %s in Debian suite "%s".', package,
|
Logger.error('Unable to find %s in Debian suite "%s".', package,
|
||||||
suite)
|
suite)
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
# ##################################################################
|
# ##################################################################
|
||||||
|
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import urllib2
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
from devscripts.logger import Logger
|
from devscripts.logger import Logger
|
||||||
@ -38,6 +40,24 @@ from ubuntutools.lp.udtexceptions import (SeriesNotFoundException,
|
|||||||
PocketDoesNotExistError)
|
PocketDoesNotExistError)
|
||||||
from ubuntutools.misc import split_release_pocket
|
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():
|
def main():
|
||||||
usage = "Usage: %prog <package> [release|version]"
|
usage = "Usage: %prog <package> [release|version]"
|
||||||
opt_parser = OptionParser(usage)
|
opt_parser = OptionParser(usage)
|
||||||
@ -80,13 +100,26 @@ def main():
|
|||||||
except PocketDoesNotExistError, e:
|
except PocketDoesNotExistError, e:
|
||||||
pass
|
pass
|
||||||
if release in ubuntu_info.all:
|
if release in ubuntu_info.all:
|
||||||
|
archive = Distribution('ubuntu').getArchive()
|
||||||
try:
|
try:
|
||||||
spph = Distribution('ubuntu').getArchive().getSourcePackage(package,
|
spph = archive.getSourcePackage(package, release, pocket)
|
||||||
release,
|
except SeriesNotFoundException, e:
|
||||||
pocket)
|
|
||||||
except (SeriesNotFoundException, PackageNotFoundException), e:
|
|
||||||
Logger.error(str(e))
|
Logger.error(str(e))
|
||||||
sys.exit(1)
|
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()
|
version = spph.getVersion()
|
||||||
component = spph.getComponent()
|
component = spph.getComponent()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user