Merge lp:~mvo/click/lp1319153-chroot-create into lp:click/devel

Proposed by Michael Vogt
Status: Merged
Approved by: Colin Watson
Approved revision: 426
Merged at revision: 438
Proposed branch: lp:~mvo/click/lp1319153-chroot-create
Merge into: lp:click/devel
Diff against target: 126 lines (+99/-12)
2 files modified
click/chroot.py (+14/-12)
click/tests/test_chroot.py (+85/-0)
To merge this branch: bzr merge lp:~mvo/click/lp1319153-chroot-create
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+219719@code.launchpad.net

This proposal supersedes a proposal from 2014-05-15.

Description of the change

This branch fixes ClickChroot._generate_sources(). Right now it will only generate a valid sources.list if the target arch is on ports.ubuntu.com and the native arch on archive.ubuntu.com.
Note that this is the common case (I'm not even sure we have a supported case that requires something different).

This branch fixes it and adds a test.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

Doesn't this result in duplicate deb-src lines? I think it would be better to accumulate the necessary mirrors and emit deb-src lines at the end, for each pocket.

review: Needs Fixing
426. By Michael Vogt

don't duplicate deb-src lines (thanks to Colin)

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks Colin! I fixed this in my branch and updated the tests.

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'click/chroot.py'
--- click/chroot.py 2014-05-19 09:27:58 +0000
+++ click/chroot.py 2014-05-20 06:30:53 +0000
@@ -170,18 +170,20 @@
170 for pocket in ['updates', 'security']:170 for pocket in ['updates', 'security']:
171 pockets.append('%s-%s' % (series, pocket))171 pockets.append('%s-%s' % (series, pocket))
172 sources = []172 sources = []
173 if target_arch not in primary_arches:173 # write binary lines
174 for pocket in pockets:174 for arch in (target_arch, native_arch):
175 sources.append("deb [arch=%s] %s %s %s" %175 if arch not in primary_arches:
176 (target_arch, ports_mirror, pocket, components))176 mirror = ports_mirror
177 sources.append("deb-src %s %s %s" %177 else:
178 (ports_mirror, pocket, components))178 mirror = self.archive
179 if native_arch in primary_arches:179 for pocket in pockets:
180 for pocket in pockets:180 sources.append("deb [arch=%s] %s %s %s" %
181 sources.append("deb [arch=%s] %s %s %s" %181 (arch, mirror, pocket, components))
182 (native_arch, self.archive, pocket, components))182 # write source lines
183 sources.append("deb-src %s %s %s" %183 for pocket in pockets:
184 (self.archive, pocket, components))184 sources.append("deb-src %s %s %s" %
185 (self.archive, pocket, components))
186
185 return sources187 return sources
186188
187 @property189 @property
188190
=== added file 'click/tests/test_chroot.py'
--- click/tests/test_chroot.py 1970-01-01 00:00:00 +0000
+++ click/tests/test_chroot.py 2014-05-20 06:30:53 +0000
@@ -0,0 +1,85 @@
1# Copyright (C) 2014 Canonical Ltd.
2# Author: Michael Vogt
3
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; version 3 of the License.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16"""Unit tests for click.chroot."""
17
18from __future__ import print_function
19
20__metaclass__ = type
21__all__ = [
22 'TestClickChroot',
23 ]
24
25
26from click.tests.helpers import TestCase
27from click.chroot import (
28 ClickChroot,
29)
30
31
32class TestClickChroot(TestCase):
33 def test_gen_sources_archive_only(self):
34 chroot = ClickChroot("amd64", "ubuntu-sdk-13.10", series="trusty")
35 chroot.native_arch = "i386"
36 sources = chroot._generate_sources(
37 chroot.series, chroot.native_arch, chroot.target_arch,
38 "main")
39 self.assertEqual([
40 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu trusty main',
41 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu trusty-updates main',
42 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu trusty-security main',
43 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty main',
44 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-updates main',
45 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-security main',
46 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
47 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
48 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
49 ], sources)
50
51 def test_gen_sources_mixed_archive_ports(self):
52 chroot = ClickChroot("armhf", "ubuntu-sdk-13.10", series="trusty")
53 chroot.native_arch = "i386"
54 sources = chroot._generate_sources(
55 chroot.series, chroot.native_arch, chroot.target_arch,
56 "main")
57 self.assertEqual([
58 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty main',
59 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
60 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
61 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty main',
62 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-updates main',
63 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-security main',
64 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
65 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
66 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
67 ], sources)
68
69 def test_gen_sources_ports_only(self):
70 chroot = ClickChroot("armhf", "ubuntu-sdk-13.10", series="trusty")
71 chroot.native_arch = "armel"
72 sources = chroot._generate_sources(
73 chroot.series, chroot.native_arch, chroot.target_arch,
74 "main")
75 self.assertEqual([
76 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty main',
77 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
78 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
79 'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty main',
80 'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
81 'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
82 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
83 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
84 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
85 ], sources)

Subscribers

People subscribed via source and target branches

to all changes: