diff --git a/debian/changelog b/debian/changelog index 912bf8a..d4815ff 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,10 @@ ubuntu-dev-tools (0.142) UNRELEASED; urgency=low (LP: #979117) * pbuilder-dist: Don't try to enable -updates for Debian testing (LP: #993006) + * pbuilder-dist, pull-debian-source, pull-lp-source, requestsync, + reverse-depends, submittodebian, syncpackage: + Handle outdated distro-info data. Fall back to sane defaults where + possible. -- Stefano Rivera Wed, 25 Apr 2012 17:38:58 +0200 diff --git a/pbuilder-dist b/pbuilder-dist index 8757678..347289c 100755 --- a/pbuilder-dist +++ b/pbuilder-dist @@ -33,7 +33,7 @@ import os import sys from devscripts.logger import Logger -from distro_info import DebianDistroInfo, UbuntuDistroInfo +from distro_info import DebianDistroInfo, UbuntuDistroInfo, DistroDataOutdated import ubuntutools.misc from ubuntutools.config import UDTConfig @@ -266,8 +266,11 @@ class PbuilderDist: othermirrors = [] if self.target_distro in self._debian_distros: debian_info = DebianDistroInfo() - codename = debian_info.codename(self.target_distro, - default=self.target_distro) + try: + codename = debian_info.codename(self.target_distro, + default=self.target_distro) + except DistroDataOutdated, e: + Logger.warn(e) if codename in (debian_info.devel(), 'experimental'): self.enable_security = False self.enable_updates = False @@ -286,7 +289,13 @@ class PbuilderDist: othermirrors.append('deb %s %s-proposed-updates %s' % (mirror, self.target_distro, components)) else: - if self.target_distro == UbuntuDistroInfo().devel(): + try: + dev_release = self.target_distro == UbuntuDistroInfo().devel() + except DistroDataOutdated, e: + Logger.warn(e) + dev_release = True + + if dev_release: self.enable_security = False self.enable_updates = False self.enable_proposed = False diff --git a/pull-debian-source b/pull-debian-source index 176cee9..36a9caf 100755 --- a/pull-debian-source +++ b/pull-debian-source @@ -22,7 +22,7 @@ import sys import urllib2 from devscripts.logger import Logger -from distro_info import DebianDistroInfo +from distro_info import DebianDistroInfo, DistroDataOutdated from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison from ubuntutools.config import UDTConfig @@ -52,7 +52,10 @@ def is_suite(version): def source_package_for(binary, release): """Query DDE to find the source package for a particular binary""" - release = DebianDistroInfo().codename(release, default=release) + try: + release = DebianDistroInfo().codename(release, default=release) + except DistroDataOutdated, e: + Logger.warn(e) url = ('http://dde.debian.net/dde/q/udd/dist/d:debian/r:%s/p:%s/?t=json' % (release, binary)) try: diff --git a/pull-lp-source b/pull-lp-source index 38efbef..bd3d48a 100755 --- a/pull-lp-source +++ b/pull-lp-source @@ -30,7 +30,7 @@ import urllib2 from optparse import OptionParser from devscripts.logger import Logger -from distro_info import UbuntuDistroInfo +from distro_info import UbuntuDistroInfo, DistroDataOutdated from ubuntutools.archive import UbuntuSourcePackage, DownloadError from ubuntutools.config import UDTConfig @@ -89,7 +89,11 @@ def main(): if len(args) > 1: # Custom distribution specified. version = str(args[1]) else: - version = os.getenv('DIST') or ubuntu_info.devel() + try: + version = os.getenv('DIST') or ubuntu_info.devel() + except DistroDataOutdated, e: + Logger.warn("%s\nOr specify a distribution.", e) + sys.exit(1) component = None # Release, not package version number: diff --git a/requestsync b/requestsync index c6b01c0..f5956b9 100755 --- a/requestsync +++ b/requestsync @@ -31,7 +31,7 @@ import os import sys from debian.changelog import Version -from distro_info import UbuntuDistroInfo +from distro_info import UbuntuDistroInfo, DistroDataOutdated from ubuntutools.config import UDTConfig, ubu_email from ubuntutools.lp import udtexceptions @@ -45,8 +45,11 @@ from ubuntutools.question import confirmation_prompt, EditBugReport def main(): ubu_info = UbuntuDistroInfo() DEFAULT_SOURCE = 'unstable' - if ubu_info.is_lts(ubu_info.devel()): - DEFAULT_SOURCE = 'testing' + try: + if ubu_info.is_lts(ubu_info.devel()): + DEFAULT_SOURCE = 'testing' + except DistroDataOutdated, e: + print >> sys.stderr, str(e) # Our usage options. usage = ('Usage: %prog [options] ' diff --git a/reverse-depends b/reverse-depends index d54857b..89d7ef0 100755 --- a/reverse-depends +++ b/reverse-depends @@ -18,6 +18,7 @@ import optparse import sys from devscripts.logger import Logger +from distro_info import DistroDataOutdated from ubuntutools.misc import (system_distribution, vendor_to_distroinfo, codename_to_distribution) @@ -26,15 +27,21 @@ from ubuntutools.rdepends import query_rdepends, RDependsException def main(): system_distro_info = vendor_to_distroinfo(system_distribution())() + try: + default_release = system_distro_info.devel() + except DistroDataOutdated, e: + Logger.warn(e) + default_release = 'unstable' + parser = optparse.OptionParser('%prog [options] package', description="List reverse-dependencies of package. " "If the package name is prefixed with src: then the " "reverse-dependencies of all the binary packages that " "the specified source package builds will be listed.") parser.add_option('-r', '--release', metavar='RELEASE', - default=system_distro_info.devel(), + default=default_release, help='Query dependencies in RELEASE. ' - 'Default: %s' % system_distro_info.devel()) + 'Default: %s' % default_release) parser.add_option('-R', '--without-recommends', action='store_false', dest='recommends', default=True, help='Only consider Depends relationships, ' @@ -76,8 +83,12 @@ def main(): if not distribution: parser.error('Unknown release codename %s' % options.release) distro_info = vendor_to_distroinfo(distribution)() - options.release = distro_info.codename(options.release, - default=options.release) + try: + options.release = distro_info.codename(options.release, + default=options.release) + except DistroDataOutdated: + # We already printed a warning + pass try: data = query_rdepends(package, options.release, options.arch, **opts) diff --git a/submittodebian b/submittodebian index 6085bf4..d1fe8d5 100755 --- a/submittodebian +++ b/submittodebian @@ -29,7 +29,7 @@ import shutil import sys from tempfile import mkdtemp -from distro_info import UbuntuDistroInfo +from distro_info import UbuntuDistroInfo, DistroDataOutdated from ubuntutools.config import ubu_email from ubuntutools.question import YesNoQuestion, EditFile @@ -119,7 +119,11 @@ def check_file(fname, critical = True): sys.exit(1) def submit_bugreport(body, debdiff, deb_version, changelog): - devel = UbuntuDistroInfo().devel() + try: + devel = UbuntuDistroInfo().devel() + except DistroDataOutdated, e: + print str(e) + devel = '' if os.path.dirname(sys.argv[0]).startswith('/usr/bin'): editor_path = '/usr/share/ubuntu-dev-tools' diff --git a/syncpackage b/syncpackage index acefbbe..e028cb6 100755 --- a/syncpackage +++ b/syncpackage @@ -31,7 +31,7 @@ import urllib import debian.debian_support from devscripts.logger import Logger -from distro_info import UbuntuDistroInfo +from distro_info import UbuntuDistroInfo, DistroDataOutdated from lazr.restfulclient.errors import HTTPError from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage, @@ -294,7 +294,15 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release, if dist is None: ubu_info = UbuntuDistroInfo() - dist = 'testing' if ubu_info.is_lts(ubu_info.devel()) else 'unstable' + try: + if ubu_info.is_lts(ubu_info.devel()): + dist = 'testing' + else: + dist = 'unstable' + except DistroDataOutdated, e: + Logger.warn(e) + dist = 'unstable' + requested_version = version if type(version) == str: version = Version(version) diff --git a/ubuntutools/requestsync/lp.py b/ubuntutools/requestsync/lp.py index 7addb9c..70f1df1 100644 --- a/ubuntutools/requestsync/lp.py +++ b/ubuntutools/requestsync/lp.py @@ -24,7 +24,7 @@ import re from debian.deb822 import Changes from devscripts.logger import Logger -from distro_info import DebianDistroInfo +from distro_info import DebianDistroInfo, DistroDataOutdated from httplib2 import Http, HttpLib2Error from ubuntutools.lp.lpapicache import (Launchpad, Distribution, PersonTeam, @@ -35,7 +35,10 @@ def get_debian_srcpkg(name, release): debian = Distribution('debian') debian_archive = debian.getArchive() - release = DebianDistroInfo().codename(release, None, release) + try: + release = DebianDistroInfo().codename(release, None, release) + except DistroDataOutdated, e: + Logger.warn(e) return debian_archive.getSourcePackage(name, release) diff --git a/ubuntutools/requestsync/mail.py b/ubuntutools/requestsync/mail.py index 1d94876..9b78884 100644 --- a/ubuntutools/requestsync/mail.py +++ b/ubuntutools/requestsync/mail.py @@ -29,7 +29,7 @@ import tempfile from debian.changelog import Changelog, Version from devscripts.logger import Logger -from distro_info import DebianDistroInfo +from distro_info import DebianDistroInfo, DistroDataOutdated from ubuntutools.archive import rmadison, FakeSPPH from ubuntutools.question import confirmation_prompt, YesNoQuestion @@ -49,7 +49,10 @@ def _get_srcpkg(distro, name, release): if distro == 'debian': # Canonicalise release: debian_info = DebianDistroInfo() - release = debian_info.codename(release, default=release) + try: + release = debian_info.codename(release, default=release) + except DistroDataOutdated, e: + Logger.warn(e) lines = list(rmadison(distro, name, suite=release, arch='source')) if not lines: