Merge lp:~jelmer/bzr-builddeb/opt-distro-info into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 712
Proposed branch: lp:~jelmer/bzr-builddeb/opt-distro-info
Merge into: lp:bzr-builddeb
Diff against target: 111 lines (+39/-14)
3 files modified
debian/changelog (+3/-1)
debian/control (+2/-2)
util.py (+34/-11)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/opt-distro-info
Reviewer Review Type Date Requested Status
Bzr-builddeb-hackers Pending
Review via email: mp+91063@code.launchpad.net

Description of the change

Drop python-distro-info from a hard dependency to a recommendation.

This makes porting a bit easier, since distro-info isn't available on e.g. lucid.

This change also defers the import, so that most operations that involved bzr-builddeb don't have to import distro_info and parse the relevant files.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-01-30 13:38:04 +0000
3+++ debian/changelog 2012-02-01 12:38:21 +0000
4@@ -1,8 +1,10 @@
5 bzr-builddeb (2.8.3) UNRELEASED; urgency=low
6
7 * Fix patch unapplying from DirStateRevisionTrees. LP: #923688
8+ * Bump distro-info dependency back to a recommends, to ease
9+ backporting.
10
11- -- Jelmer Vernooij <jelmer@debian.org> Mon, 30 Jan 2012 14:37:51 +0100
12+ -- Jelmer Vernooij <jelmer@debian.org> Wed, 01 Feb 2012 13:20:49 +0100
13
14 bzr-builddeb (2.8.2) unstable; urgency=low
15
16
17=== modified file 'debian/control'
18--- debian/control 2012-01-16 02:08:24 +0000
19+++ debian/control 2012-02-01 12:38:21 +0000
20@@ -12,8 +12,8 @@
21
22 Package: bzr-builddeb
23 Architecture: all
24-Depends: bzr (>= 2.1~), python-debian (>= 0.1.11), python-apt, ${python:Depends}, dpkg-dev, fakeroot, devscripts (>= 2.10.59), patchutils, pristine-tar, ${misc:Depends}, python-distro-info
25-Recommends: python-launchpadlib, libalgorithm-merge-perl
26+Depends: bzr (>= 2.1~), python-debian (>= 0.1.11), python-apt, ${python:Depends}, dpkg-dev, fakeroot, devscripts (>= 2.10.59), patchutils, pristine-tar, ${misc:Depends}
27+Recommends: python-launchpadlib, libalgorithm-merge-perl, python-distro-info
28 Suggests: bzr-svn (>= 0.4.10), python-lzma
29 Provides: bzr-buildpackage
30 Description: bzr plugin for Debian package management
31
32=== modified file 'util.py'
33--- util.py 2012-01-05 16:09:21 +0000
34+++ util.py 2012-02-01 12:38:21 +0000
35@@ -29,8 +29,6 @@
36 import os
37 import re
38
39-from distro_info import DebianDistroInfo, UbuntuDistroInfo
40-
41 from bzrlib.trace import mutter
42
43 try:
44@@ -76,11 +74,36 @@
45 UnparseableChangelog,
46 )
47
48-
49-DEBIAN_RELEASES = DebianDistroInfo().all
50-DEBIAN_RELEASES.extend(['stable', 'testing', 'unstable', 'frozen'])
51+_DEBIAN_RELEASES = None
52+_UBUNTU_RELEASES = None
53+
54+def _get_release_names():
55+ try:
56+ from distro_info import DebianDistroInfo, UbuntuDistroInfo
57+ except ImportError:
58+ warning("distro_info not available. Unable to retrieve current "
59+ "list of releases.")
60+ _DEBIAN_RELEASES = []
61+ _UBUNTU_RELEASES = []
62+ else:
63+ # distro info is not available
64+ _DEBIAN_RELEASES = DebianDistroInfo().all
65+ _UBUNTU_RELEASES = UbuntuDistroInfo().all
66+
67+ _DEBIAN_RELEASES.extend(['stable', 'testing', 'unstable', 'frozen'])
68+
69+
70+def debian_releases():
71+ if _DEBIAN_RELEASES is None:
72+ _get_release_names()
73+ return _DEBIAN_RELEASES
74+
75+def ubuntu_releases():
76+ if _UBUNTU_RELEASES is None:
77+ _get_release_names()
78+ return _UBUNTU_RELEASES
79+
80 DEBIAN_POCKETS = ('', '-security', '-proposed-updates', '-backports')
81-UBUNTU_RELEASES = UbuntuDistroInfo().all
82 UBUNTU_POCKETS = ('', '-proposed', '-updates', '-security', '-backports')
83
84
85@@ -246,8 +269,8 @@
86 :return: "debian", "ubuntu", or None if the distribution couldn't be
87 inferred.
88 """
89- all_debian = [r + t for r in DEBIAN_RELEASES for t in DEBIAN_POCKETS]
90- all_ubuntu = [r + t for r in UBUNTU_RELEASES for t in UBUNTU_POCKETS]
91+ all_debian = [r + t for r in debian_releases() for t in DEBIAN_POCKETS]
92+ all_ubuntu = [r + t for r in ubuntu_releases() for t in UBUNTU_POCKETS]
93 if suite in all_debian:
94 return "debian"
95 if suite in all_ubuntu:
96@@ -616,12 +639,12 @@
97 :raise NoPreviousUpload: Raised when there is no previous upload
98 """
99 current_target = find_last_distribution(cl)
100- all_debian = [r + t for r in DEBIAN_RELEASES for t in DEBIAN_POCKETS]
101- all_ubuntu = [r + t for r in UBUNTU_RELEASES for t in UBUNTU_POCKETS]
102+ all_debian = [r + t for r in debian_releases() for t in DEBIAN_POCKETS]
103+ all_ubuntu = [r + t for r in ubuntu_releases() for t in UBUNTU_POCKETS]
104 if current_target in all_debian:
105 match_targets = (current_target,)
106 elif current_target in all_ubuntu:
107- match_targets = UBUNTU_RELEASES
108+ match_targets = ubuntu_releases()
109 if "-" in current_target:
110 match_targets += tuple([current_target.split("-", 1)[0]
111 + t for t in UBUNTU_POCKETS])

Subscribers

People subscribed via source and target branches