Merge lp:~james-w/linaro-image-tools/architecture-support into lp:linaro-image-tools/11.11

Proposed by James Westby
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: 105
Merged at revision: 66
Proposed branch: lp:~james-w/linaro-image-tools/architecture-support
Merge into: lp:linaro-image-tools/11.11
Prerequisite: lp:~james-w/linaro-image-tools/add-packages-to-hwpack
Diff against target: 413 lines (+115/-56)
5 files modified
hwpack/hardwarepack.py (+4/-2)
hwpack/packages.py (+19/-5)
hwpack/testing.py (+2/-8)
hwpack/tests/test_hardwarepack.py (+30/-19)
hwpack/tests/test_packages.py (+60/-22)
To merge this branch: bzr merge lp:~james-w/linaro-image-tools/architecture-support
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle (community) Approve
Review via email: mp+34484@code.launchpad.net

This proposal supersedes a proposal from 2010-09-02.

Description of the change

Hi,

Here's a rather simple branch to add architecture support through the code
we have now.

I just updated the spec to state that ARCHITECTURE is a required field in
the metadata, so that's now a required argument to the constructor of the
corresponding class, and it is output in the __str__ method.

Also the Package classes get architecture as an ivar, such that we can
track which architecture they are for, which leads to the change in the
get_packages_file function, which can now stop hardcoding "all".

The dummy test package object defaults to "all" as that way the tests
will work on multiple architectures without updating.

However, that leaves a gap, so I added a couple of new tests to ensure
that we fetch packages from the right architecture.

In order to support cross-build of hardware packs I stole a trick from
the chdist tool, which allows us to tell apt to pretend it is on a
different architecture. I added a test to peek inside the implementation
and check we were writing the config correctly, but the two added tests
check that it has the desired effect.

There's still a gap, as noted in the spec, about how we specify the
architectures to build for, as I'm not sure whether it should be in
the configuration file or on the command line, or some combination
of the two. This will mainly depend on how we want to hook it in to
lexbuilder I think. At least now all the infrastructure is in place
to build for any arch that we like.

Thanks,

James

To post a comment you must log in.
105. By James Westby

Merge add-packages-to-hwpack in to architecture-support.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks fine to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hwpack/hardwarepack.py'
--- hwpack/hardwarepack.py 2010-09-02 23:07:45 +0000
+++ hwpack/hardwarepack.py 2010-09-02 23:07:46 +0000
@@ -26,8 +26,8 @@
26 :type support: str or None26 :type support: str or None
27 """27 """
2828
29 def __init__(self, name, version, origin=None, maintainer=None,29 def __init__(self, name, version, architecture, origin=None,
30 support=None):30 maintainer=None, support=None):
31 """Create the Metadata for a hardware pack.31 """Create the Metadata for a hardware pack.
3232
33 See the instance variables for a description of the arguments.33 See the instance variables for a description of the arguments.
@@ -37,11 +37,13 @@
37 self.origin = origin37 self.origin = origin
38 self.maintainer = maintainer38 self.maintainer = maintainer
39 self.support = support39 self.support = support
40 self.architecture = architecture
4041
41 def __str__(self):42 def __str__(self):
42 """Get the contents of the metadata file."""43 """Get the contents of the metadata file."""
43 metadata = "NAME=%s\n" % self.name44 metadata = "NAME=%s\n" % self.name
44 metadata += "VERSION=%s\n" % self.version45 metadata += "VERSION=%s\n" % self.version
46 metadata += "ARCHITECTURE=%s\n" % self.architecture
45 if self.origin is not None:47 if self.origin is not None:
46 metadata += "ORIGIN=%s\n" % self.origin48 metadata += "ORIGIN=%s\n" % self.origin
47 if self.maintainer is not None:49 if self.maintainer is not None:
4850
=== modified file 'hwpack/packages.py'
--- hwpack/packages.py 2010-09-02 23:07:45 +0000
+++ hwpack/packages.py 2010-09-02 23:07:46 +0000
@@ -23,7 +23,7 @@
23 parts.append('Filename: %s' % package.filename)23 parts.append('Filename: %s' % package.filename)
24 parts.append('Size: %d' % package.size)24 parts.append('Size: %d' % package.size)
25 # TODO: architecture support25 # TODO: architecture support
26 parts.append('Architecture: all')26 parts.append('Architecture: %s' % package.architecture)
27 parts.append('MD5sum: %s' % package.md5)27 parts.append('MD5sum: %s' % package.md5)
28 content += "\n".join(parts)28 content += "\n".join(parts)
29 content += "\n\n"29 content += "\n\n"
@@ -75,9 +75,13 @@
75 :ivar md5: the hex representation of the md5sum of the contents of75 :ivar md5: the hex representation of the md5sum of the contents of
76 the package.76 the package.
77 :type md5: str77 :type md5: str
78 :ivar architecture: the architecture that the package is for, may be
79 'all'.
80 :type architecture: str
78 """81 """
7982
80 def __init__(self, name, version, filename, content, size, md5):83 def __init__(self, name, version, filename, content, size, md5,
84 architecture):
81 """Create a FetchedPackage.85 """Create a FetchedPackage.
8286
83 See the instance variables for the arguments.87 See the instance variables for the arguments.
@@ -88,6 +92,7 @@
88 self.content = content92 self.content = content
89 self.size = size93 self.size = size
90 self.md5 = md594 self.md5 = md5
95 self.architecture = architecture
9196
92 def __eq__(self, other):97 def __eq__(self, other):
93 return (self.name == other.name98 return (self.name == other.name
@@ -95,7 +100,8 @@
95 and self.filename == other.filename100 and self.filename == other.filename
96 and self.content.read() == other.content.read()101 and self.content.read() == other.content.read()
97 and self.size == other.size102 and self.size == other.size
98 and self.md5 == other.md5)103 and self.md5 == other.md5
104 and self.architecture == other.architecture)
99105
100 def __hash__(self):106 def __hash__(self):
101 return hash(107 return hash(
@@ -105,7 +111,7 @@
105class PackageFetcher(object):111class PackageFetcher(object):
106 """A class to fetch packages from a defined list of sources."""112 """A class to fetch packages from a defined list of sources."""
107113
108 def __init__(self, sources):114 def __init__(self, sources, architecture=None):
109 """Create a PackageFetcher.115 """Create a PackageFetcher.
110116
111 Once created a PackageFetcher should have its `prepare` method117 Once created a PackageFetcher should have its `prepare` method
@@ -114,8 +120,11 @@
114 :param sources: a list of sources such that they can be prefixed120 :param sources: a list of sources such that they can be prefixed
115 with "deb " and fed to apt.121 with "deb " and fed to apt.
116 :type sources: an iterable of str122 :type sources: an iterable of str
123 :param architecture: the architecture to fetch packages for.
124 :type architecture: str
117 """125 """
118 self.sources = sources126 self.sources = sources
127 self.architecture = architecture
119 self.tempdir = None128 self.tempdir = None
120129
121 def prepare(self):130 def prepare(self):
@@ -143,6 +152,10 @@
143 with open(sources_list, 'w') as f:152 with open(sources_list, 'w') as f:
144 for source in self.sources:153 for source in self.sources:
145 f.write("deb %s\n" % source)154 f.write("deb %s\n" % source)
155 if self.architecture is not None:
156 apt_conf = os.path.join(self.tempdir, "etc", "apt", "apt.conf")
157 with open(apt_conf, 'w') as f:
158 f.write('Apt {\nArchitecture "%s";\n}\n' % self.architecture)
146 self.cache = Cache(rootdir=self.tempdir, memonly=True)159 self.cache = Cache(rootdir=self.tempdir, memonly=True)
147 self.cache.update()160 self.cache.update()
148 self.cache.open()161 self.cache.open()
@@ -183,6 +196,7 @@
183 (acqfile.destfile, acqfile.error_text))196 (acqfile.destfile, acqfile.error_text))
184 result_package = FetchedPackage(197 result_package = FetchedPackage(
185 candidate.package.name, candidate.version, base,198 candidate.package.name, candidate.version, base,
186 open(destfile), candidate.size, candidate.md5)199 open(destfile), candidate.size, candidate.md5,
200 candidate.architecture)
187 results.append(result_package)201 results.append(result_package)
188 return results202 return results
189203
=== modified file 'hwpack/testing.py'
--- hwpack/testing.py 2010-09-02 23:07:45 +0000
+++ hwpack/testing.py 2010-09-02 23:07:46 +0000
@@ -52,16 +52,10 @@
52 See FetchedPackage for the instance variables.52 See FetchedPackage for the instance variables.
53 """53 """
5454
55 def __init__(self, name, version):55 def __init__(self, name, version, architecture="all"):
56 """Create a DummyFetchedPackage.
57
58 :param name: the name of the package.
59 :type name: str
60 :param version: the version of the package.
61 :type version: str
62 """
63 self.name = name56 self.name = name
64 self.version = version57 self.version = version
58 self.architecture = architecture
6559
66 @property60 @property
67 def filename(self):61 def filename(self):
6862
=== modified file 'hwpack/tests/test_hardwarepack.py'
--- hwpack/tests/test_hardwarepack.py 2010-09-02 23:07:45 +0000
+++ hwpack/tests/test_hardwarepack.py 2010-09-02 23:07:46 +0000
@@ -12,56 +12,67 @@
12class MetadataTests(TestCase):12class MetadataTests(TestCase):
1313
14 def test_name(self):14 def test_name(self):
15 metadata = Metadata("ahwpack", "3")15 metadata = Metadata("ahwpack", "3", "armel")
16 self.assertEqual("ahwpack", metadata.name)16 self.assertEqual("ahwpack", metadata.name)
1717
18 def test_version(self):18 def test_version(self):
19 metadata = Metadata("ahwpack", "3")19 metadata = Metadata("ahwpack", "3", "armel")
20 self.assertEqual("3", metadata.version)20 self.assertEqual("3", metadata.version)
2121
22 def test_architecture(self):
23 metadata = Metadata("ahwpack", "3", "armel")
24 self.assertEqual("armel", metadata.architecture)
25
22 def test_default_origin_is_None(self):26 def test_default_origin_is_None(self):
23 metadata = Metadata("ahwpack", "4")27 metadata = Metadata("ahwpack", "4", "armel")
24 self.assertEqual(None, metadata.origin)28 self.assertEqual(None, metadata.origin)
2529
26 def test_origin(self):30 def test_origin(self):
27 metadata = Metadata("ahwpack", "4", origin="linaro")31 metadata = Metadata("ahwpack", "4", "armel", origin="linaro")
28 self.assertEqual("linaro", metadata.origin)32 self.assertEqual("linaro", metadata.origin)
2933
30 def test_default_maintainer_is_None(self):34 def test_default_maintainer_is_None(self):
31 metadata = Metadata("ahwpack", "4")35 metadata = Metadata("ahwpack", "4", "armel")
32 self.assertEqual(None, metadata.maintainer)36 self.assertEqual(None, metadata.maintainer)
3337
34 def test_maintainer(self):38 def test_maintainer(self):
35 metadata = Metadata("ahwpack", "4", maintainer="Some maintainer")39 metadata = Metadata(
40 "ahwpack", "4", "armel", maintainer="Some maintainer")
36 self.assertEqual("Some maintainer", metadata.maintainer)41 self.assertEqual("Some maintainer", metadata.maintainer)
3742
38 def test_default_support_is_None(self):43 def test_default_support_is_None(self):
39 metadata = Metadata("ahwpack", "4")44 metadata = Metadata("ahwpack", "4", "armel")
40 self.assertEqual(None, metadata.support)45 self.assertEqual(None, metadata.support)
4146
42 def test_support(self):47 def test_support(self):
43 metadata = Metadata("ahwpack", "4", support="supported")48 metadata = Metadata("ahwpack", "4", "armel", support="supported")
44 self.assertEqual("supported", metadata.support)49 self.assertEqual("supported", metadata.support)
4550
46 def test_str(self):51 def test_str(self):
47 metadata = Metadata("ahwpack", "4")52 metadata = Metadata("ahwpack", "4", "armel")
48 self.assertEqual("NAME=ahwpack\nVERSION=4\n", str(metadata))53 self.assertEqual(
54 "NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n", str(metadata))
4955
50 def test_str_with_origin(self):56 def test_str_with_origin(self):
51 metadata = Metadata("ahwpack", "4", origin="linaro")57 metadata = Metadata("ahwpack", "4", "armel", origin="linaro")
52 self.assertEqual(58 self.assertEqual(
53 "NAME=ahwpack\nVERSION=4\nORIGIN=linaro\n", str(metadata))59 "NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\nORIGIN=linaro\n",
60 str(metadata))
5461
55 def test_str_with_maintainer(self):62 def test_str_with_maintainer(self):
56 metadata = Metadata("ahwpack", "4", maintainer="Some Maintainer")63 metadata = Metadata(
64 "ahwpack", "4", "armel", maintainer="Some Maintainer")
57 self.assertEqual(65 self.assertEqual(
58 "NAME=ahwpack\nVERSION=4\nMAINTAINER=Some Maintainer\n",66 "NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
67 "MAINTAINER=Some Maintainer\n",
59 str(metadata))68 str(metadata))
6069
61 def test_str_with_support(self):70 def test_str_with_support(self):
62 metadata = Metadata("ahwpack", "4", support="unsupported")71 metadata = Metadata("ahwpack", "4", "armel", support="unsupported")
63 self.assertEqual(72 self.assertEqual(
64 "NAME=ahwpack\nVERSION=4\nSUPPORT=unsupported\n", str(metadata))73 "NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
74 "SUPPORT=unsupported\n",
75 str(metadata))
6576
6677
67class HardwarePackHasFile(TarfileHasFile):78class HardwarePackHasFile(TarfileHasFile):
@@ -111,7 +122,7 @@
111122
112 def setUp(self):123 def setUp(self):
113 super(HardwarePackTests, self).setUp()124 super(HardwarePackTests, self).setUp()
114 self.metadata = Metadata("ahwpack", 4)125 self.metadata = Metadata("ahwpack", 4, "armel")
115126
116 def test_format_is_1_0(self):127 def test_format_is_1_0(self):
117 hwpack = HardwarePack(self.metadata)128 hwpack = HardwarePack(self.metadata)
@@ -122,7 +133,7 @@
122 self.assertEqual("hwpack_ahwpack_4.tar.gz", hwpack.filename())133 self.assertEqual("hwpack_ahwpack_4.tar.gz", hwpack.filename())
123134
124 def test_filename_with_support(self):135 def test_filename_with_support(self):
125 metadata = Metadata("ahwpack", "4", support="supported")136 metadata = Metadata("ahwpack", "4", "armel", support="supported")
126 hwpack = HardwarePack(metadata)137 hwpack = HardwarePack(metadata)
127 self.assertEqual(138 self.assertEqual(
128 "hwpack_ahwpack_4_supported.tar.gz", hwpack.filename())139 "hwpack_ahwpack_4_supported.tar.gz", hwpack.filename())
@@ -144,7 +155,7 @@
144155
145 def test_creates_metadata_file(self):156 def test_creates_metadata_file(self):
146 metadata = Metadata(157 metadata = Metadata(
147 "ahwpack", "4", origin="linaro",158 "ahwpack", "4", "armel", origin="linaro",
148 maintainer="Some Maintainer", support="unsupported")159 maintainer="Some Maintainer", support="unsupported")
149 hwpack = HardwarePack(metadata)160 hwpack = HardwarePack(metadata)
150 tf = self.get_tarfile(hwpack)161 tf = self.get_tarfile(hwpack)
151162
=== modified file 'hwpack/tests/test_packages.py'
--- hwpack/tests/test_packages.py 2010-09-02 23:07:45 +0000
+++ hwpack/tests/test_packages.py 2010-09-02 23:07:46 +0000
@@ -19,13 +19,13 @@
19class GetPackagesFileTests(TestCase):19class GetPackagesFileTests(TestCase):
2020
21 def test_single_stanza(self):21 def test_single_stanza(self):
22 package = DummyFetchedPackage("foo", "1.1")22 package = DummyFetchedPackage("foo", "1.1", architecture="armel")
23 self.assertEqual(textwrap.dedent("""\23 self.assertEqual(textwrap.dedent("""\
24 Package: foo24 Package: foo
25 Version: 1.125 Version: 1.1
26 Filename: %(filename)s26 Filename: %(filename)s
27 Size: %(size)d27 Size: %(size)d
28 Architecture: all28 Architecture: armel
29 MD5sum: %(md5)s29 MD5sum: %(md5)s
30 \n""" % {30 \n""" % {
31 'filename': package.filename,31 'filename': package.filename,
@@ -45,68 +45,77 @@
4545
46 def test_attributes(self):46 def test_attributes(self):
47 package = FetchedPackage(47 package = FetchedPackage(
48 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")48 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa",
49 "armel")
49 self.assertEqual("foo", package.name)50 self.assertEqual("foo", package.name)
50 self.assertEqual("1.1", package.version)51 self.assertEqual("1.1", package.version)
51 self.assertEqual("foo_1.1.deb", package.filename)52 self.assertEqual("foo_1.1.deb", package.filename)
52 self.assertEqual("xxxx", package.content.read())53 self.assertEqual("xxxx", package.content.read())
53 self.assertEqual(4, package.size)54 self.assertEqual(4, package.size)
54 self.assertEqual("aaaa", package.md5)55 self.assertEqual("aaaa", package.md5)
56 self.assertEqual("armel", package.architecture)
5557
56 def test_equal(self):58 def test_equal(self):
57 package1 = FetchedPackage(59 package1 = FetchedPackage(
58 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")60 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
59 package2 = FetchedPackage(61 package2 = FetchedPackage(
60 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")62 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
61 self.assertEqual(package1, package2)63 self.assertEqual(package1, package2)
6264
63 def test_not_equal_different_name(self):65 def test_not_equal_different_name(self):
64 package1 = FetchedPackage(66 package1 = FetchedPackage(
65 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")67 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
66 package2 = FetchedPackage(68 package2 = FetchedPackage(
67 "bar", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")69 "bar", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
68 self.assertNotEqual(package1, package2)70 self.assertNotEqual(package1, package2)
6971
70 def test_not_equal_different_version(self):72 def test_not_equal_different_version(self):
71 package1 = FetchedPackage(73 package1 = FetchedPackage(
72 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")74 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
73 package2 = FetchedPackage(75 package2 = FetchedPackage(
74 "foo", "1.2", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")76 "foo", "1.2", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
75 self.assertNotEqual(package1, package2)77 self.assertNotEqual(package1, package2)
7678
77 def test_not_equal_different_filename(self):79 def test_not_equal_different_filename(self):
78 package1 = FetchedPackage(80 package1 = FetchedPackage(
79 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")81 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
80 package2 = FetchedPackage(82 package2 = FetchedPackage(
81 "foo", "1.1", "afoo_1.1.deb", StringIO("xxxx"), 4, "aaaa")83 "foo", "1.1", "afoo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
82 self.assertNotEqual(package1, package2)84 self.assertNotEqual(package1, package2)
8385
84 def test_not_equal_different_content(self):86 def test_not_equal_different_content(self):
85 package1 = FetchedPackage(87 package1 = FetchedPackage(
86 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")88 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
87 package2 = FetchedPackage(89 package2 = FetchedPackage(
88 "foo", "1.1", "foo_1.1.deb", StringIO("yyyy"), 4, "aaaa")90 "foo", "1.1", "foo_1.1.deb", StringIO("yyyy"), 4, "aaaa", "armel")
89 self.assertNotEqual(package1, package2)91 self.assertNotEqual(package1, package2)
9092
91 def test_not_equal_different_size(self):93 def test_not_equal_different_size(self):
92 package1 = FetchedPackage(94 package1 = FetchedPackage(
93 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")95 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
94 package2 = FetchedPackage(96 package2 = FetchedPackage(
95 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 5, "aaaa")97 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 5, "aaaa", "armel")
96 self.assertNotEqual(package1, package2)98 self.assertNotEqual(package1, package2)
9799
98 def test_not_equal_different_md5(self):100 def test_not_equal_different_md5(self):
99 package1 = FetchedPackage(101 package1 = FetchedPackage(
100 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")102 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
101 package2 = FetchedPackage(103 package2 = FetchedPackage(
102 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "bbbb")104 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "bbbb", "armel")
105 self.assertNotEqual(package1, package2)
106
107 def test_not_equal_different_architecture(self):
108 package1 = FetchedPackage(
109 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
110 package2 = FetchedPackage(
111 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "i386")
103 self.assertNotEqual(package1, package2)112 self.assertNotEqual(package1, package2)
104113
105 def test_equal_hash_equal(self):114 def test_equal_hash_equal(self):
106 package1 = FetchedPackage(115 package1 = FetchedPackage(
107 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")116 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
108 package2 = FetchedPackage(117 package2 = FetchedPackage(
109 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")118 "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
110 self.assertEqual(hash(package1), hash(package2))119 self.assertEqual(hash(package1), hash(package2))
111120
112121
@@ -177,8 +186,18 @@
177 open(os.path.join(186 open(os.path.join(
178 fetcher.tempdir, "etc", "apt", "sources.list")).read())187 fetcher.tempdir, "etc", "apt", "sources.list")).read())
179188
180 def get_fetcher(self, sources):189 def test_prepare_with_arch_creates_etc_apt_apt_conf(self):
181 fetcher = PackageFetcher([s.sources_entry for s in sources])190 fetcher = PackageFetcher([], architecture="arch")
191 self.addCleanup(fetcher.cleanup)
192 fetcher.prepare()
193 self.assertEqual(
194 'Apt {\nArchitecture "arch";\n}\n',
195 open(os.path.join(
196 fetcher.tempdir, "etc", "apt", "apt.conf")).read())
197
198 def get_fetcher(self, sources, architecture=None):
199 fetcher = PackageFetcher(
200 [s.sources_entry for s in sources], architecture=architecture)
182 self.addCleanup(fetcher.cleanup)201 self.addCleanup(fetcher.cleanup)
183 fetcher.prepare()202 fetcher.prepare()
184 return fetcher203 return fetcher
@@ -257,3 +276,22 @@
257 fetcher = self.get_fetcher([old_source, new_source])276 fetcher = self.get_fetcher([old_source, new_source])
258 fetched = fetcher.fetch_packages(["bar"])277 fetched = fetcher.fetch_packages(["bar"])
259 self.assertEqual(new_source_packages[0], fetched[0])278 self.assertEqual(new_source_packages[0], fetched[0])
279
280 def test_fetch_package_records_correct_architecture(self):
281 available_package = DummyFetchedPackage(
282 "foo", "1.0", architecture="nonexistant")
283 source = self.useFixture(AptSourceFixture([available_package]))
284 fetcher = self.get_fetcher([source], architecture="nonexistant")
285 self.assertEqual(
286 "nonexistant", fetcher.fetch_packages(["foo"])[0].architecture)
287
288 def test_fetch_package_fetches_from_correct_architecture(self):
289 wanted_package = DummyFetchedPackage(
290 "foo", "1.0", architecture="arch1")
291 unwanted_package = DummyFetchedPackage(
292 "foo", "1.1", architecture="arch2")
293 source = self.useFixture(
294 AptSourceFixture([wanted_package, unwanted_package]))
295 fetcher = self.get_fetcher([source], architecture="arch1")
296 self.assertEqual(
297 wanted_package, fetcher.fetch_packages(["foo"])[0])

Subscribers

People subscribed via source and target branches