Merge ~mwhudson/ubuntu-cdimage:germinate-from-mirror-directly into ubuntu-cdimage:main

Proposed by Michael Hudson-Doyle
Status: Merged
Merged at revision: 1e7b6b7705974d53d6e7d0be37ca112a3d4ccae4
Proposed branch: ~mwhudson/ubuntu-cdimage:germinate-from-mirror-directly
Merge into: ubuntu-cdimage:main
Diff against target: 162 lines (+3/-81)
3 files modified
lib/cdimage/germinate.py (+1/-31)
lib/cdimage/tests/test_build.py (+1/-1)
lib/cdimage/tests/test_germinate.py (+1/-49)
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Review via email: mp+455459@code.launchpad.net

Commit message

pass the mirror directly to germinate

The previous code was broken when using a remote mirror and I have no
idea why it was like that. But it dates from 2006 so maybe there was a
reason then.

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/cdimage/germinate.py b/lib/cdimage/germinate.py
2index 5bd00e6..fe7c4ab 100644
3--- a/lib/cdimage/germinate.py
4+++ b/lib/cdimage/germinate.py
5@@ -19,7 +19,6 @@ from __future__ import print_function
6
7 from collections import OrderedDict, defaultdict
8 import errno
9-import gzip
10 import os
11 import re
12 import shutil
13@@ -111,20 +110,6 @@ class Germination:
14 else:
15 return self.prefer_vcs
16
17- def make_index(self, project, arch, rel_target, rel_paths):
18- target = os.path.join(self.output_dir(project), rel_target)
19- osextras.mkemptydir(os.path.dirname(target))
20- with gzip.GzipFile(target, "wb") as target_file:
21- for rel_path in rel_paths:
22- if os.path.isabs(rel_path):
23- abs_path = rel_path
24- else:
25- abs_path = os.path.join(
26- find_mirror(self.config, arch), rel_path)
27- if os.path.isfile(abs_path):
28- with gzip.GzipFile(abs_path, "rb") as source_file:
29- target_file.write(source_file.read())
30-
31 @property
32 def germinate_dists(self):
33 if self.config["GERMINATE_DISTS"]:
34@@ -162,21 +147,6 @@ class Germination:
35 def germinate_arch(self, project, arch):
36 cpuarch = arch.split("+")[0]
37
38- for dist in self.germinate_dists:
39- for suffix in (
40- "binary-%s/Packages.gz" % cpuarch,
41- "source/Sources.gz",
42- "debian-installer/binary-%s/Packages.gz" % cpuarch,
43- ):
44- files = [
45- "dists/%s/%s/%s" % (dist, component, suffix)
46- for component in self.components]
47- if self.config["LOCAL"]:
48- files.append(
49- "%s/dists/%s/local/%s" %
50- (self.config["LOCALDEBS"], dist, suffix))
51- self.make_index(project, arch, files[0], files)
52-
53 arch_output_dir = os.path.join(self.output_dir(project), arch)
54 osextras.mkemptydir(arch_output_dir)
55 if (self.config["GERMINATE_HINTS"] and
56@@ -187,7 +157,7 @@ class Germination:
57 command = [
58 self.germinate_path,
59 "--seed-source", ",".join(self.seed_sources(project)),
60- "--mirror", "file://%s/" % self.output_dir(project),
61+ "--mirror", find_mirror(project, arch),
62 "--seed-dist", self.seed_dist(project),
63 "--dist", ",".join(self.germinate_dists),
64 "--arch", cpuarch,
65diff --git a/lib/cdimage/tests/test_build.py b/lib/cdimage/tests/test_build.py
66index 247f9de..8df8a8e 100644
67--- a/lib/cdimage/tests/test_build.py
68+++ b/lib/cdimage/tests/test_build.py
69@@ -1097,7 +1097,7 @@ class TestBuildImageSet(TestCase):
70 return mock.call([
71 germinate_path,
72 "--seed-source", mock.ANY,
73- "--mirror", "file://%s/" % germinate_output,
74+ "--mirror", "http://ftpmaster.internal/ubuntu/",
75 "--seed-dist", "ubuntu.trusty",
76 "--dist", "trusty,trusty-security,trusty-updates",
77 "--arch", arch,
78diff --git a/lib/cdimage/tests/test_germinate.py b/lib/cdimage/tests/test_germinate.py
79index fa11aaf..bdfffa2 100644
80--- a/lib/cdimage/tests/test_germinate.py
81+++ b/lib/cdimage/tests/test_germinate.py
82@@ -36,7 +36,6 @@ from cdimage.germinate import (
83 GerminateOutput,
84 Germination,
85 NoMasterSeeds,
86- find_mirror
87 )
88 from cdimage.mail import text_file_type
89 from cdimage.tests.helpers import TestCase, mkfile, touch
90@@ -132,35 +131,6 @@ class TestGermination(TestCase):
91 self.germination.prefer_vcs = False
92 self.assertFalse(self.germination.use_vcs)
93
94- @mock.patch("cdimage.germinate.find_mirror")
95- def test_make_index(self, mock_find_mirror):
96- def side_effect(*args, **kwargs):
97- return os.path.join(args[0].root, "ftp")
98-
99- mock_find_mirror.side_effect = side_effect
100- self.config.root = self.use_temp_dir()
101- self.config["DIST"] = "trusty"
102- self.config["IMAGE_TYPE"] = "daily"
103- files = []
104- for component in "main", "restricted", "universe", "multiverse":
105- source_dir = os.path.join(
106- self.temp_dir, "ftp", "dists", "trusty", component, "source")
107- os.makedirs(source_dir)
108- with gzip.GzipFile(
109- os.path.join(source_dir, "Sources.gz"), "wb") as sources:
110- sources.write(component.encode("UTF-8"))
111- sources.write(b"\n")
112- files.append("dists/trusty/%s/source/Sources.gz" % component)
113- self.germination.make_index("ubuntu", "i386", files[0], files)
114- output_file = os.path.join(
115- self.temp_dir, "scratch", "ubuntu", "trusty", "daily", "germinate",
116- "dists", "trusty", "main", "source", "Sources.gz")
117- self.assertTrue(os.path.exists(output_file))
118- with gzip.GzipFile(output_file, "rb") as output_sources:
119- self.assertEqual(
120- b"main\nrestricted\nuniverse\nmultiverse\n",
121- output_sources.read())
122-
123 def test_germinate_dists_environment_override(self):
124 self.config["GERMINATE_DISTS"] = "sentinel,sentinel-updates"
125 self.assertEqual(
126@@ -218,35 +188,17 @@ class TestGermination(TestCase):
127 self.config["IMAGE_TYPE"] = "daily"
128
129 output_dir = "%s/scratch/ubuntu/trusty/daily/germinate" % self.temp_dir
130- expected_files = []
131-
132- for dist in "trusty", "trusty-security", "trusty-updates":
133- for suffix in (
134- "binary-amd64/Packages.gz",
135- "source/Sources.gz",
136- "debian-installer/binary-amd64/Packages.gz",
137- ):
138- for component in "main", "restricted":
139- path = os.path.join(
140- self.temp_dir, "ftp", "dists", dist, component, suffix)
141- os.makedirs(os.path.dirname(path))
142- with gzip.GzipFile(path, "wb"):
143- pass
144- expected_files.append(
145- os.path.join(output_dir, "dists", dist, "main", suffix))
146
147 def check_call_side_effect(*args, **kwargs):
148 touch(os.path.join(output_dir, "amd64+mac", "structure"))
149
150 mock_check_call.side_effect = check_call_side_effect
151 self.germination.germinate_arch("ubuntu", "amd64+mac")
152- for expected_file in expected_files:
153- self.assertTrue(os.path.exists(expected_file))
154 expected_command = [
155 germinate_path,
156 "--seed-source",
157 "https://git.launchpad.net/~ubuntu-core-dev/ubuntu-seeds/+git/",
158- "--mirror", "file://%s/" % output_dir,
159+ "--mirror", "http://ftpmaster.internal/ubuntu/",
160 "--seed-dist", "ubuntu.trusty",
161 "--dist", "trusty,trusty-security,trusty-updates",
162 "--arch", "amd64",

Subscribers

People subscribed via source and target branches