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
1=== modified file 'click/chroot.py'
2--- click/chroot.py 2014-03-31 11:11:26 +0000
3+++ click/chroot.py 2014-05-15 14:41:42 +0000
4@@ -156,16 +156,14 @@
5 for pocket in ['updates', 'security']:
6 pockets.append('%s-%s' % (series, pocket))
7 sources = []
8- if target_arch not in primary_arches:
9- for pocket in pockets:
10- sources.append("deb [arch=%s] %s %s %s" %
11- (target_arch, ports_mirror, pocket, components))
12- sources.append("deb-src %s %s %s" %
13- (ports_mirror, pocket, components))
14- if native_arch in primary_arches:
15- for pocket in pockets:
16- sources.append("deb [arch=%s] %s %s %s" %
17- (native_arch, self.archive, pocket, components))
18+ for arch in (target_arch, native_arch):
19+ if arch not in primary_arches:
20+ mirror = ports_mirror
21+ else:
22+ mirror = self.archive
23+ for pocket in pockets:
24+ sources.append("deb [arch=%s] %s %s %s" %
25+ (arch, mirror, pocket, components))
26 sources.append("deb-src %s %s %s" %
27 (self.archive, pocket, components))
28 return sources
29
30=== added file 'click/tests/test_chroot.py'
31--- click/tests/test_chroot.py 1970-01-01 00:00:00 +0000
32+++ click/tests/test_chroot.py 2014-05-15 14:41:42 +0000
33@@ -0,0 +1,94 @@
34+# Copyright (C) 2014 Canonical Ltd.
35+# Author: Michael Vogt
36+
37+# This program is free software: you can redistribute it and/or modify
38+# it under the terms of the GNU General Public License as published by
39+# the Free Software Foundation; version 3 of the License.
40+#
41+# This program is distributed in the hope that it will be useful,
42+# but WITHOUT ANY WARRANTY; without even the implied warranty of
43+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44+# GNU General Public License for more details.
45+#
46+# You should have received a copy of the GNU General Public License
47+# along with this program. If not, see <http://www.gnu.org/licenses/>.
48+
49+"""Unit tests for click.chroot."""
50+
51+from __future__ import print_function
52+
53+__metaclass__ = type
54+__all__ = [
55+ 'TestClickChroot',
56+ ]
57+
58+
59+from click.tests.helpers import TestCase
60+from click.chroot import (
61+ ClickChroot,
62+)
63+
64+
65+class TestClickChroot(TestCase):
66+ def test_gen_sources_archive_only(self):
67+ chroot = ClickChroot("amd64", "ubuntu-sdk-13.10", series="trusty")
68+ chroot.native_arch = "i386"
69+ sources = chroot._generate_sources(
70+ chroot.series, chroot.native_arch, chroot.target_arch,
71+ "main")
72+ self.assertEqual([
73+ 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu trusty main',
74+ 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
75+ 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu trusty-updates main',
76+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
77+ 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu trusty-security main',
78+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
79+ 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty main',
80+ 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
81+ 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-updates main',
82+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
83+ 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-security main',
84+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main'
85+ ], sources)
86+
87+ def test_gen_sources_mixed_archive_ports(self):
88+ chroot = ClickChroot("armhf", "ubuntu-sdk-13.10", series="trusty")
89+ chroot.native_arch = "i386"
90+ sources = chroot._generate_sources(
91+ chroot.series, chroot.native_arch, chroot.target_arch,
92+ "main")
93+ self.assertEqual([
94+ 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty main',
95+ 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
96+ 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
97+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
98+ 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
99+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
100+ 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty main',
101+ 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
102+ 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-updates main',
103+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
104+ 'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-security main',
105+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main'
106+ ], sources)
107+
108+ def test_gen_sources_ports_only(self):
109+ chroot = ClickChroot("armhf", "ubuntu-sdk-13.10", series="trusty")
110+ chroot.native_arch = "armel"
111+ sources = chroot._generate_sources(
112+ chroot.series, chroot.native_arch, chroot.target_arch,
113+ "main")
114+ self.assertEqual([
115+ 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty main',
116+ 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
117+ 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
118+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
119+ 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
120+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
121+ 'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty main',
122+ 'deb-src http://archive.ubuntu.com/ubuntu trusty main',
123+ 'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
124+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
125+ 'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
126+ 'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
127+ ], sources)

Subscribers

People subscribed via source and target branches

to all changes: