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

Proposed by Michael Vogt
Status: Superseded
Proposed branch: lp:~mvo/click/lp1319153-chroot-create
Merge into: lp:click
Diff against target: 127 lines (+102/-10)
2 files modified
click/chroot.py (+8/-10)
click/tests/test_chroot.py (+94/-0)
To merge this branch: bzr merge lp:~mvo/click/lp1319153-chroot-create
Reviewer Review Type Date Requested Status
click hackers Pending
Review via email: mp+219704@code.launchpad.net

This proposal has been superseded by 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.
426. By Michael Vogt

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

Unmerged revisions

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-03-31 11:11:26 +0000
+++ click/chroot.py 2014-05-15 14:41:42 +0000
@@ -156,16 +156,14 @@
156 for pocket in ['updates', 'security']:156 for pocket in ['updates', 'security']:
157 pockets.append('%s-%s' % (series, pocket))157 pockets.append('%s-%s' % (series, pocket))
158 sources = []158 sources = []
159 if target_arch not in primary_arches:159 for arch in (target_arch, native_arch):
160 for pocket in pockets:160 if arch not in primary_arches:
161 sources.append("deb [arch=%s] %s %s %s" %161 mirror = ports_mirror
162 (target_arch, ports_mirror, pocket, components))162 else:
163 sources.append("deb-src %s %s %s" %163 mirror = self.archive
164 (ports_mirror, pocket, components))164 for pocket in pockets:
165 if native_arch in primary_arches:165 sources.append("deb [arch=%s] %s %s %s" %
166 for pocket in pockets:166 (arch, mirror, pocket, components))
167 sources.append("deb [arch=%s] %s %s %s" %
168 (native_arch, self.archive, pocket, components))
169 sources.append("deb-src %s %s %s" %167 sources.append("deb-src %s %s %s" %
170 (self.archive, pocket, components))168 (self.archive, pocket, components))
171 return sources169 return sources
172170
=== 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-15 14:41:42 +0000
@@ -0,0 +1,94 @@
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-src http://archive.ubuntu.com/ubuntu trusty main',
42 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu trusty-updates main',
43 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
44 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu trusty-security main',
45 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
46 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty main',
47 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
48 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-updates main',
49 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
50 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-security main',
51 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main'
52 ], sources)
53
54 def test_gen_sources_mixed_archive_ports(self):
55 chroot = ClickChroot("armhf", "ubuntu-sdk-13.10", series="trusty")
56 chroot.native_arch = "i386"
57 sources = chroot._generate_sources(
58 chroot.series, chroot.native_arch, chroot.target_arch,
59 "main")
60 self.assertEqual([
61 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty main',
62 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
63 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
64 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
65 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
66 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
67 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty main',
68 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
69 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-updates main',
70 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
71 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-security main',
72 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main'
73 ], sources)
74
75 def test_gen_sources_ports_only(self):
76 chroot = ClickChroot("armhf", "ubuntu-sdk-13.10", series="trusty")
77 chroot.native_arch = "armel"
78 sources = chroot._generate_sources(
79 chroot.series, chroot.native_arch, chroot.target_arch,
80 "main")
81 self.assertEqual([
82 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty main',
83 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
84 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
85 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
86 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
87 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
88 'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty main',
89 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
90 'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
91 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
92 'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
93 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
94 ], sources)

Subscribers

People subscribed via source and target branches

to all changes: