diff --git a/debian/changelog b/debian/changelog index 8e67921..ae42a82 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,9 @@ ubuntu-dev-tools (0.113) UNRELEASED; urgency=low * debian-distro-info, distro-info, ubuntu-distro-info: New tools. + * Use new ubuntutools.distro_info in various scripts. - -- Benjamin Drung Fri, 21 Jan 2011 18:22:23 +0100 + -- Benjamin Drung Fri, 21 Jan 2011 19:19:01 +0100 ubuntu-dev-tools (0.112) unstable; urgency=low diff --git a/pbuilder-dist b/pbuilder-dist index 95c76ed..8566569 100755 --- a/pbuilder-dist +++ b/pbuilder-dist @@ -33,11 +33,9 @@ import os import subprocess import sys +from ubuntutools.distro_info import DebianDistroInfo import ubuntutools.misc -DEBIAN_DISTROS = ['etch', 'lenny', 'squeeze', 'sid', 'stable', 'testing', - 'unstable', 'experimental'] - class PbuilderDist: def __init__(self, builder): # Base directory where pbuilder will put all the files it creates. @@ -76,6 +74,10 @@ class PbuilderDist: # Builder self.builder = builder + self._debian_distros = DebianDistroInfo().all + \ + ['stable', 'testing', 'unstable', 'experimental'] + + # Ensure that the used builder is installed paths = set(os.environ['PATH'].split(':')) paths |= set(('/sbin', '/usr/sbin', '/usr/local/sbin')) @@ -133,7 +135,7 @@ class PbuilderDist: if os.path.isdir('/usr/share/debootstrap/scripts/'): # Debian experimental doesn't have a debootstrap file but # should work nevertheless. - if distro not in DEBIAN_DISTROS: + if distro not in self._debian_distros: answer = ask(('Warning: Unknown distribution "%s". Do you ' 'want to continue [y/N]? ') % distro) if answer not in ('y', 'Y'): @@ -235,7 +237,7 @@ class PbuilderDist: 'deb file:///var/cache/archive/ %s/' % self.target_distro, ] - if self.target_distro in DEBIAN_DISTROS: + if self.target_distro in self._debian_distros: arguments += ['--mirror', 'http://ftp.debian.org/debian'] components = 'main' if self.extra_components: @@ -255,7 +257,7 @@ class PbuilderDist: # Work around LP:#599695 if (ubuntutools.misc.system_distribution() == 'Debian' - and self.target_distro not in DEBIAN_DISTROS): + and self.target_distro not in self._debian_distros): if not os.path.exists( '/usr/share/keyrings/ubuntu-archive-keyring.gpg'): print >> sys.stderr, 'Error: ubuntu-keyring not installed' @@ -265,7 +267,7 @@ class PbuilderDist: '--keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg', ] elif (ubuntutools.misc.system_distribution() == 'Ubuntu' - and self.target_distro in DEBIAN_DISTROS): + and self.target_distro in self._debian_distros): if not os.path.exists( '/usr/share/keyrings/debian-archive-keyring.gpg'): print >> sys.stderr, ('Error: debian-archive-keyring not ' diff --git a/requestsync b/requestsync index fc26ba2..0f8872f 100755 --- a/requestsync +++ b/requestsync @@ -33,6 +33,7 @@ import sys from debian.changelog import Version from ubuntutools.config import UDTConfig, ubu_email +from ubuntutools.distro_info import UbuntuDistroInfo from ubuntutools.lp import udtexceptions from ubuntutools.requestsync.common import (edit_report, getDebianChangelog, raw_input_exit_on_ctrlc) @@ -145,7 +146,7 @@ def main(): if lpapi: release = Distribution('ubuntu').getDevelopmentSeries().name else: - release = 'natty' + release = UbuntuDistroInfo().devel() print >> sys.stderr, 'W: Target release missing - assuming %s' % release elif len(args) == 2: release = args[1] diff --git a/submittodebian b/submittodebian index 47c4347..be6f883 100755 --- a/submittodebian +++ b/submittodebian @@ -25,6 +25,8 @@ import re, os, sys from tempfile import mkstemp +from ubuntutools.distro_info import UbuntuDistroInfo + try: from debian.changelog import Changelog except ImportError: @@ -106,9 +108,10 @@ def edit_debdiff(debdiff): def submit_bugreport(body, debdiff, deb_version, changelog): cmd = ('reportbug -P "User: ubuntu-devel@lists.ubuntu.com" ' - '-P "Usertags: origin-ubuntu natty ubuntu-patch" -T patch -A %s ' + '-P "Usertags: origin-ubuntu %s ubuntu-patch" -T patch -A %s ' '-B debian -i %s -V %s %s') % \ - (debdiff, body, deb_version, changelog.package) + (UbuntuDistroInfo().devel(), debdiff, body, deb_version, + changelog.package) run_cmd(cmd) def run_cmd(cmd): diff --git a/ubuntutools/distro_info.py b/ubuntutools/distro_info.py index 88d2d5f..e2b6128 100644 --- a/ubuntutools/distro_info.py +++ b/ubuntutools/distro_info.py @@ -113,6 +113,20 @@ class DebianDistroInfo(DistroInfo): def __init__(self): super(DebianDistroInfo, self).__init__("debian") + def codename(self, release, date=None, default=None): + """Map 'unstable', 'testing', etc. to their codenames.""" + if release == "unstable": + codename = self.devel(date) + elif release == "testing": + codename = self.testing(date) + elif release == "stable": + codename = self.stable(date) + elif release == "old": + codename = self.old(date) + else: + codename = default + return codename + def old(self, date=None): """Get old (stable) Debian distribution based on the given date.""" if date is None: diff --git a/ubuntutools/requestsync/lp.py b/ubuntutools/requestsync/lp.py index 1be7339..b38fe0d 100644 --- a/ubuntutools/requestsync/lp.py +++ b/ubuntutools/requestsync/lp.py @@ -20,6 +20,7 @@ # Please see the /usr/share/common-licenses/GPL-2 file for the full text # of the GNU General Public License license. +from ubuntutools.distro_info import DebianDistroInfo from ubuntutools.requestsync.common import raw_input_exit_on_ctrlc from ubuntutools.lp.lpapicache import (Launchpad, Distribution, PersonTeam, DistributionSourcePackage) @@ -29,12 +30,7 @@ def getDebianSrcPkg(name, release): debian = Distribution('debian') debian_archive = debian.getArchive() - # Map 'unstable' and 'testing' to their codenames as LP knows only them - codenames = { - 'unstable': 'sid', - 'testing': 'squeeze', # Needs updating after each Debian release - } - release = codenames.get(release, release) + release = DebianDistroInfo().codenames(release, None, release) return debian_archive.getSourcePackage(name, release) diff --git a/ubuntutools/sponsor_patch/bugtask.py b/ubuntutools/sponsor_patch/bugtask.py index 916f8f8..1f1f4d4 100644 --- a/ubuntutools/sponsor_patch/bugtask.py +++ b/ubuntutools/sponsor_patch/bugtask.py @@ -21,6 +21,7 @@ import urllib import debian.debian_support +from ubuntutools.distro_info import DebianDistroInfo from ubuntutools.logger import Logger class BugTask(object): @@ -96,10 +97,9 @@ class BugTask(object): if "experimental" in title: series = "experimental" elif "testing" in title: - # TODO: Do not hard code series! - series = "squeeze" + series = DebianDistroInfo().testing() else: - series = "sid" + series = DebianDistroInfo().devel() status = "Pending" else: project = self.project