From b5274624ac5bd79fe9a8441e63913773a621353d Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sat, 25 Dec 2010 18:06:18 +0200 Subject: [PATCH] Suggest python-simplejson | python (>= 2.7) and complain if they are missing in pull-debian-debdiff --- debian/control | 3 +-- pull-debian-debdiff | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/debian/control b/debian/control index 86fe8da..fa05060 100644 --- a/debian/control +++ b/debian/control @@ -16,7 +16,6 @@ Build-Depends: dctrl-tools, python-apt (>= 0.7.93~), python-debian (>= 0.1.15), python-gnupginterface, - python-simplejson, python-launchpadlib (>= 1.5.7), python-magic, python-setuptools, @@ -57,7 +56,7 @@ Recommends: bzr, python-magic, python-soappy, reportbug (>= 3.39ubuntu1) -Suggests: qemu-kvm-extras-static +Suggests: python-simplejson | python (>= 2.7), qemu-kvm-extras-static Breaks: ${python:Breaks} Description: useful tools for Ubuntu developers This is a collection of useful tools that Ubuntu developers use to make their diff --git a/pull-debian-debdiff b/pull-debian-debdiff index c8fafdd..a4388df 100755 --- a/pull-debian-debdiff +++ b/pull-debian-debdiff @@ -25,10 +25,6 @@ import sys import urllib2 import debian.changelog -try: - import json -except ImportError: - import simplejson as json from ubuntutools.config import UDTConfig from ubuntutools.logger import Logger @@ -63,6 +59,15 @@ def pull(package, version, unpack=False): def pull_from_snapshot(package, version, unpack=False): "Download Debian source package version version from snapshot.debian.org" + try: + import json + except ImportError: + import simplejson as json + except ImportError: + Logger.error("Require python-simplejson or python >= 2.7 to be " + "installed for snapshot.debian.org support") + sys.exit(1) + try: srcfiles = json.load(urllib2.urlopen( 'http://snapshot.debian.org/mr/package/%s/%s/srcfiles' @@ -71,6 +76,7 @@ def pull_from_snapshot(package, version, unpack=False): Logger.error('Version %s of %s not found on snapshot.debian.org', version, package) return False + for hash_ in srcfiles['result']: hash_ = hash_['hash'] @@ -167,6 +173,11 @@ def main(): version = args[1] distance = args[2] if len(args) > 2 else 1 + if not os.path.exists('/usr/bin/dget'): + Logger.error("dget is not installed. " + "Please install the 'devscripts' package.") + sys.exit(1) + config = UDTConfig(opts.no_conf) if opts.debian_mirror is None: opts.debian_mirror = config.get_value('DEBIAN_MIRROR')