Merge lp:~jelmer/bzr-builddeb/796853-apt-native into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 568
Proposed branch: lp:~jelmer/bzr-builddeb/796853-apt-native
Merge into: lp:bzr-builddeb
Diff against target: 165 lines (+60/-11)
3 files modified
debian/changelog (+5/-1)
tests/test_upstream.py (+48/-7)
upstream/__init__.py (+7/-3)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/796853-apt-native
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+64468@code.launchpad.net

Description of the change

Fix support for native packages with dashes in their version in sources.list.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi,

Looks good for fixing this bug.

Is there a trap in here waiting for someone to try with a package
with multiple upstream tarballs?

Thanks,

James

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On 13/06/11 23:48, James Westby wrote:
> Looks good for fixing this bug.
>
> Is there a trap in here waiting for someone to try with a package
> with multiple upstream tarballs?
Probably; although at the very least they will get a warning if they hit
a package with multiple upstream tarballs.

To support the use of multiple upstream tarballs, we'll need to change
the interface of UpstreamSource too.

Cheers,

Jelmer

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 2011-06-09 12:13:13 +0000
3+++ debian/changelog 2011-06-13 22:15:50 +0000
4@@ -8,7 +8,11 @@
5 * Use new set_commit_message() hook in bzr to set the commit
6 message from debian/changelog and set fixed bugs in tags. LP: #707274
7
8- -- Jonathan Riddell <jriddell@ubuntu.com> Fri, 03 Jun 2011 15:36:10 +0100
9+ [ Jelmer Vernooij ]
10+ * Fix support for native packages with dashes in their version in
11+ sources.list. LP: #796853
12+
13+ -- Jelmer Vernooij <jelmer@debian.org> Mon, 13 Jun 2011 23:10:20 +0100
14
15 bzr-builddeb (2.7.4) unstable; urgency=low
16
17
18=== modified file 'tests/test_upstream.py'
19--- tests/test_upstream.py 2011-06-03 12:17:42 +0000
20+++ tests/test_upstream.py 2011-06-13 22:15:50 +0000
21@@ -88,12 +88,14 @@
22
23 class MockSources(object):
24
25- def __init__(self, versions):
26+ def __init__(self, versions, files):
27 self.restart_called_times = 0
28 self.lookup_called_times = 0
29 self.lookup_package = None
30 self.versions = versions
31 self.version = None
32+ self.filess = files
33+ self.files = None
34
35 def restart(self):
36 self.restart_called_times += 1
37@@ -104,9 +106,11 @@
38 self.lookup_package = package
39 if self.lookup_called_times <= len(self.versions):
40 self.version = self.versions[self.lookup_called_times-1]
41+ self.files = self.filess[self.lookup_called_times-1]
42 return True
43 else:
44 self.version = None
45+ self.files = None
46 return False
47
48
49@@ -151,7 +155,7 @@
50
51 def test_apt_provider_no_package(self):
52 caller = MockAptCaller()
53- sources = MockSources([])
54+ sources = MockSources([], [])
55 apt_pkg = MockAptPkg(sources)
56 src = AptSource()
57 src._run_apt_source = caller.call
58@@ -166,7 +170,8 @@
59
60 def test_apt_provider_wrong_version(self):
61 caller = MockAptCaller()
62- sources = MockSources(["0.1-1"])
63+ sources = MockSources(["0.1-1"],
64+ [[("checksum", 0L, "apackage_0.1.orig.tar.gz", "tar")]])
65 apt_pkg = MockAptPkg(sources)
66 src = AptSource()
67 src._run_apt_source = caller.call
68@@ -179,14 +184,31 @@
69 self.assertEqual("apackage", sources.lookup_package)
70 self.assertEqual(0, caller.called)
71
72+ def test_apt_provider_right_version_bz2(self):
73+ caller = MockAptCaller(work=True)
74+ sources = MockSources(["0.1-1", "0.2-1"],
75+ [[("checksum", 0L, "apackage_0.1.orig.tar.gz", "tar")],
76+ [("checksum", 0L, "apackage_0.2.orig.tar.bz2", "tar")]])
77+ apt_pkg = MockAptPkg(sources)
78+ src = AptSource()
79+ src._run_apt_source = caller.call
80+ path = src.fetch_tarball("apackage", "0.2", "target",
81+ _apt_pkg=apt_pkg)
82+ self.assertEquals(path,
83+ "target/apackage_0.2.orig.tar.bz2")
84+
85 def test_apt_provider_right_version(self):
86 caller = MockAptCaller(work=True)
87- sources = MockSources(["0.1-1", "0.2-1"])
88+ sources = MockSources(["0.1-1", "0.2-1"],
89+ [[("checksum", 0L, "apackage_0.1.orig.tar.gz", "tar")],
90+ [("checksum", 0L, "apackage_0.2.orig.tar.gz", "tar")]])
91 apt_pkg = MockAptPkg(sources)
92 src = AptSource()
93 src._run_apt_source = caller.call
94- src.fetch_tarball("apackage", "0.2", "target",
95+ path = src.fetch_tarball("apackage", "0.2", "target",
96 _apt_pkg=apt_pkg)
97+ self.assertEquals(path,
98+ "target/apackage_0.2.orig.tar.gz")
99 self.assertEqual(1, apt_pkg.init_called_times)
100 self.assertEqual(1, apt_pkg.get_pkg_source_records_called_times)
101 self.assertEqual(1, sources.restart_called_times)
102@@ -200,7 +222,9 @@
103
104 def test_apt_provider_right_version_command_fails(self):
105 caller = MockAptCaller()
106- sources = MockSources(["0.1-1", "0.2-1"])
107+ sources = MockSources(["0.1-1", "0.2-1"],
108+ [[("checksum", 0L, "apackage_0.1.orig.tar.gz", "tar")],
109+ [("checksum", 0L, "apackage_0.2.orig.tar.gz", "tar")]])
110 apt_pkg = MockAptPkg(sources)
111 src = AptSource()
112 src._run_apt_source = caller.call
113@@ -211,13 +235,30 @@
114 self.assertEqual(1, apt_pkg.get_pkg_source_records_called_times)
115 self.assertEqual(1, sources.restart_called_times)
116 # Only called twice means it stops when the command fails.
117- self.assertEqual(2, sources.lookup_called_times)
118+ self.assertEqual(3, sources.lookup_called_times)
119 self.assertEqual("apackage", sources.lookup_package)
120 self.assertEqual(1, caller.called)
121 self.assertEqual("apackage", caller.package)
122 self.assertEqual("0.2-1", caller.version_str)
123 self.assertEqual("target", caller.target_dir)
124
125+ def test_apt_provider_right_version_is_native(self):
126+ caller = MockAptCaller(work=True)
127+ sources = MockSources(["0.1-1", "0.2-1"],
128+ [[("checksum", 0L, "apackage_0.1.orig.tar.gz", "tar")],
129+ [("checksum", 0L, "apackage_0.2-1.orig.tar.gz", "tar")]])
130+ apt_pkg = MockAptPkg(sources)
131+ src = AptSource()
132+ src._run_apt_source = caller.call
133+ self.assertRaises(PackageVersionNotPresent, src.fetch_tarball,
134+ "apackage", "0.2", "target", _apt_pkg=apt_pkg)
135+ self.assertEqual(1, apt_pkg.init_called_times)
136+ self.assertEqual(1, apt_pkg.get_pkg_source_records_called_times)
137+ self.assertEqual(1, sources.restart_called_times)
138+ self.assertEqual(3, sources.lookup_called_times)
139+ self.assertEqual("apackage", sources.lookup_package)
140+ self.assertEqual(0, caller.called)
141+
142
143 class RecordingSource(UpstreamSource):
144
145
146=== modified file 'upstream/__init__.py'
147--- upstream/__init__.py 2011-06-03 12:17:42 +0000
148+++ upstream/__init__.py 2011-06-13 22:15:50 +0000
149@@ -126,9 +126,13 @@
150 lookup = get_fn(sources, 'lookup', 'Lookup')
151 while lookup(package):
152 version = get_fn(sources, 'version', 'Version')
153- if upstream_version == Version(version).upstream_version:
154- if self._run_apt_source(package, version, target_dir):
155- return self._tarball_path(package, version, target_dir)
156+ for (checksum, size, filename, filekind) in sources.files:
157+ if filekind != "tar":
158+ continue
159+ filename = os.path.basename(filename)
160+ if filename.startswith("%s_%s.orig" % (package, upstream_version)):
161+ if self._run_apt_source(package, version, target_dir):
162+ return os.path.join(target_dir, filename)
163 break
164 note("apt could not find the needed tarball.")
165 raise PackageVersionNotPresent(package, upstream_version, self)

Subscribers

People subscribed via source and target branches