Merge ~mwhudson/ubuntu-cdimage:simplify-germinate into ubuntu-cdimage:main

Proposed by Michael Hudson-Doyle
Status: Merged
Merged at revision: e5056baafa398e289c2774706cfece5be06bd2c0
Proposed branch: ~mwhudson/ubuntu-cdimage:simplify-germinate
Merge into: ubuntu-cdimage:main
Diff against target: 980 lines (+39/-628)
11 files modified
bin/cron.dvd (+2/-1)
dev/null (+0/-46)
lib/cdimage/build.py (+1/-12)
lib/cdimage/check_installable.py (+0/-17)
lib/cdimage/germinate.py (+25/-235)
lib/cdimage/livefs.py (+2/-5)
lib/cdimage/tests/test_build.py (+0/-10)
lib/cdimage/tests/test_check_installable.py (+1/-35)
lib/cdimage/tests/test_germinate.py (+6/-249)
lib/cdimage/tests/test_tree.py (+0/-4)
lib/cdimage/tree.py (+2/-14)
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Review via email: mp+460539@code.launchpad.net

Description of the change

This strips out I think all of the unnecessary complexity in ubuntu-cdimage's germinate code that can be stripped without making changes to the debian-cd end of things.

It is perhaps too much to land in one big hit but well. Look at that diffstat!!

Probably best to review commit by commit.

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) :
review: Needs Fixing
Revision history for this message
Michael Hudson-Doyle (mwhudson) :
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/bin/cron.daily b/bin/cron.daily
2deleted file mode 100755
3index d205b69..0000000
4--- a/bin/cron.daily
5+++ /dev/null
6@@ -1,46 +0,0 @@
7-#! /usr/bin/python3
8-
9-# Copyright (C) 2013 Canonical Ltd.
10-# Author: Colin Watson <cjwatson@ubuntu.com>
11-
12-# This program is free software: you can redistribute it and/or modify
13-# it under the terms of the GNU General Public License as published by
14-# the Free Software Foundation; version 3 of the License.
15-#
16-# This program is distributed in the hope that it will be useful,
17-# but WITHOUT ANY WARRANTY; without even the implied warranty of
18-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19-# GNU General Public License for more details.
20-#
21-# You should have received a copy of the GNU General Public License
22-# along with this program. If not, see <http://www.gnu.org/licenses/>.
23-
24-"""Build a set of alternate/server images."""
25-
26-from optparse import OptionParser
27-import os
28-import sys
29-
30-sys.path.insert(0, os.path.join(sys.path[0], os.pardir, "lib"))
31-
32-
33-def main():
34- from cdimage.build import build_image_set
35- from cdimage.config import Config
36-
37- parser = OptionParser("%prog")
38- parser.add_option(
39- "--live", default=False, action="store_true",
40- help="build live filesystems first")
41- options, _ = parser.parse_args()
42- config = Config(IMAGE_TYPE="daily")
43- config["CDIMAGE_INSTALL"] = "1"
44- project = config.project
45- if project == "ubuntu-server" and not config["CDIMAGE_NO_SQUASHFS_BASE"]:
46- config["CDIMAGE_SQUASHFS_BASE"] = "1"
47- if not build_image_set(config, options):
48- sys.exit(1)
49-
50-
51-if __name__ == "__main__":
52- main()
53diff --git a/bin/cron.dvd b/bin/cron.dvd
54index 3732b09..5566973 100755
55--- a/bin/cron.dvd
56+++ b/bin/cron.dvd
57@@ -36,7 +36,8 @@ def main():
58 config = Config(IMAGE_TYPE="dvd")
59 project = config.project
60 if project not in ("ubuntu", "ubuntustudio"):
61- config["CDIMAGE_INSTALL"] = "1"
62+ print("unsupported configuration!")
63+ sys.exit(1)
64 config["CDIMAGE_LIVE"] = "1"
65 config["CDIMAGE_DVD"] = "1"
66 if not build_image_set(config, options):
67diff --git a/lib/cdimage/build.py b/lib/cdimage/build.py
68index cbc07d4..edd53db 100644
69--- a/lib/cdimage/build.py
70+++ b/lib/cdimage/build.py
71@@ -30,7 +30,6 @@ import traceback
72
73 from cdimage import osextras
74 from cdimage.build_id import next_build_id
75-from cdimage.check_installable import check_installable
76 from cdimage.germinate import Germination
77 from cdimage.livefs import (
78 LiveBuildsFailed,
79@@ -88,9 +87,6 @@ def configure_for_project(config):
80 ):
81 config["CDIMAGE_UNSUPPORTED"] = "1"
82
83- if config["CDIMAGE_INSTALL"]:
84- config["CDIMAGE_INSTALL_BASE"] = "1"
85-
86
87 def open_log(config):
88 if config["DEBUG"] or config["CDIMAGE_NOLOG"]:
89@@ -661,7 +657,7 @@ def build_image_set_locked(config, options):
90 log_marker("Checking for other task changes")
91 germinate_output.update_tasks(date)
92
93- if (config["CDIMAGE_LIVE"] or config["CDIMAGE_SQUASHFS_BASE"]):
94+ if config["CDIMAGE_LIVE"]:
95 log_marker("Downloading live filesystem images")
96 download_live_filesystems(config, builds)
97
98@@ -671,13 +667,6 @@ def build_image_set_locked(config, options):
99 copy_netboot_tarballs(config)
100 fix_permissions(config)
101
102- # Temporarily turned off for live builds.
103- if (config["CDIMAGE_INSTALL_BASE"] and
104- not config["CDIMAGE_ADDON"] and
105- not config["CDIMAGE_PREINSTALLED"]):
106- log_marker("Producing installability report")
107- check_installable(config)
108-
109 if not config["DEBUG"] and not config["CDIMAGE_NOPUBLISH"]:
110 log_marker("Publishing")
111 tree = Tree.get_daily(config)
112diff --git a/lib/cdimage/check_installable.py b/lib/cdimage/check_installable.py
113index 62cbfc6..0aff60e 100644
114--- a/lib/cdimage/check_installable.py
115+++ b/lib/cdimage/check_installable.py
116@@ -60,23 +60,6 @@ def _prepare_check_installable(config):
117
118 packages = os.path.join(data, "Packages_%s" % arch)
119 with open(packages, "wb") as packages_file:
120- if config["CDIMAGE_SQUASHFS_BASE"]:
121- squashfs = os.path.join(live, "%s.squashfs" % fullarch)
122- if os.path.exists(squashfs):
123- _ensure_tempdir()
124- with open("/dev/null", "w") as devnull:
125- subprocess.check_call([
126- "unsquashfs",
127- "-d", os.path.join(_tempdir, fullarch),
128- squashfs, "/var/lib/dpkg/status",
129- ], stdout=devnull)
130- status_path = os.path.join(
131- _tempdir, fullarch, "var", "lib", "dpkg", "status")
132- with open(os.path.join(status_path)) as status:
133- subprocess.call([
134- "grep-dctrl", "-XFStatus", "install ok installed",
135- ], stdin=status, stdout=packages_file)
136-
137 for component in "main", "restricted", "universe", "multiverse":
138 packages_gz = os.path.join(
139 image_top, "%s-%s" % (config.series, fullarch), "CD1",
140diff --git a/lib/cdimage/germinate.py b/lib/cdimage/germinate.py
141index dcc5e88..004e2a3 100644
142--- a/lib/cdimage/germinate.py
143+++ b/lib/cdimage/germinate.py
144@@ -17,10 +17,7 @@
145
146 from __future__ import print_function
147
148-from collections import OrderedDict, defaultdict
149-import errno
150 import os
151-import re
152 import shutil
153 import subprocess
154 import traceback
155@@ -47,13 +44,9 @@ class Germination:
156
157 @property
158 def germinate_path(self):
159- paths = [
160- os.path.join(self.config.root, "germinate", "bin", "germinate"),
161- os.path.join(self.config.root, "germinate", "germinate.py"),
162- ]
163- for path in paths:
164- if os.access(path, os.X_OK):
165- return path
166+ path = os.path.join(self.config.root, "germinate", "bin", "germinate")
167+ if os.access(path, os.X_OK):
168+ return path
169 else:
170 raise GerminateNotInstalled(
171 "Please check out lp:germinate in %s." %
172@@ -192,12 +185,6 @@ class NoMasterSeeds(Exception):
173 pass
174
175
176-re_not_base = re.compile(
177- r"^(linux-(image|restricted|amd64|386|686|k7|power|"
178- r"imx51|dove|omap).*|"
179- r"nvidia-kernel-common|grub|yaboot|efibootmgr|elilo|silo|palo)$")
180-
181-
182 class GerminateOutput:
183 def __init__(self, config, directory):
184 self.config = config
185@@ -206,102 +193,30 @@ class GerminateOutput:
186 self._parse_structure()
187
188 def _parse_structure(self):
189- self._seeds = OrderedDict()
190+ self._seeds = []
191 with open(self.structure) as structure:
192 for line in structure:
193 line = line.strip()
194 if not line or line.startswith("#") or ":" not in line:
195 continue
196- seed, inherit = line.split(":", 1)
197- self._seeds[seed] = inherit.split()
198-
199- def _expand_inheritance(self, seed, inherit):
200- for s in self._seeds.get(seed, ()):
201- self._expand_inheritance(s, inherit)
202- if seed not in inherit:
203- inherit.append(seed)
204-
205- def _inheritance(self, seed):
206- inherit = []
207- self._expand_inheritance(seed, inherit)
208- return inherit
209-
210- def _without_inheritance(self, subtract, seeds):
211- subtract_inherit = self._inheritance(subtract)
212- remaining = set(seeds) - set(subtract_inherit)
213- return [seed for seed in seeds if seed in remaining]
214-
215- def list_seeds(self, mode):
216+ self._seeds.append(line.split(":", 1)[0])
217+
218+ def pool_seeds(self):
219+ if not (self.config["CDIMAGE_DVD"] or self.config["CDIMAGE_LIVE"]):
220+ raise NoMasterSeeds("No seeds found for master task!")
221 project = self.config.project
222- series = self.config["DIST"]
223
224- if mode == "all":
225- for seed in self._seeds:
226- yield seed
227- elif mode == "tasks":
228- ship = "ship"
229- if "ship-addon" in self._seeds:
230- ship = "ship-addon"
231- in_squashfs = None
232- if project == "ubuntu-server":
233- ship = "server-ship"
234- in_squashfs = ["minimal"]
235- seeds = self._inheritance(ship)
236- if (self.config["CDIMAGE_SQUASHFS_BASE"] and
237- in_squashfs is not None):
238- for subtract in in_squashfs:
239- seeds = self._without_inheritance(subtract, seeds)
240- for seed in seeds:
241- yield seed
242- if self.config["CDIMAGE_DVD"]:
243- # TODO cjwatson 2007-04-18: hideous hack to fix DVD tasks
244- yield "dns-server"
245- yield "lamp-server"
246- elif mode == "installer":
247- if self.config["CDIMAGE_INSTALL_BASE"]:
248- yield "installer"
249- elif mode == "debootstrap":
250- yield "required"
251- yield "minimal"
252- elif mode == "base":
253- yield "boot"
254- yield "required"
255- yield "minimal"
256- yield "standard"
257- elif mode == "ship-live":
258- if project == "lubuntu" and series == "bionic":
259- yield "ship-live-gtk"
260- yield "ship-live-share"
261- elif project == "lubuntu-next" and series == "bionic":
262- yield "ship-live-qt"
263- yield "ship-live-share"
264- elif project == "ubuntu-server" and series >= "bionic":
265- yield "server-ship-live"
266- elif project == "ubuntu" and self.config["SUBPROJECT"] == "canary":
267- # ubuntu-desktop-installer
268- yield "canary-ship-live"
269- # TODO: we will probably need a legacy-ship-live seed
270- else:
271- yield "ship-live"
272- elif mode == "addon":
273- ship = self._inheritance("ship")
274- ship_addon = self._inheritance("ship-addon")
275- for seed in ship_addon:
276- if seed not in ship:
277- yield seed
278- elif mode == "dvd":
279- if project == "ubuntu":
280- # no inheritance; most of this goes on the live filesystem
281- yield "usb-langsupport"
282- yield "usb-ship-live"
283- elif project == "ubuntustudio":
284- # no inheritance; most of this goes on the live filesystem
285- yield "dvd"
286- if series >= "bionic":
287- yield "ship-live"
288- else:
289- for seed in self._inheritance("dvd"):
290- yield seed
291+ if project == "ubuntustudio":
292+ yield "dvd"
293+ yield "ship-live"
294+ elif project == "ubuntu-server":
295+ yield "server-ship-live"
296+ elif project == "ubuntu" and self.config["SUBPROJECT"] == "canary":
297+ # ubuntu-desktop-installer
298+ yield "canary-ship-live"
299+ # TODO: will we need a legacy-ship-live seed?
300+ else:
301+ yield "ship-live"
302
303 def seed_path(self, arch, seed):
304 return os.path.join(self.directory, arch, seed)
305@@ -311,42 +226,12 @@ class GerminateOutput:
306 lines = seed_file.read().splitlines()[2:-2]
307 return [line.split(None, 1)[0] for line in lines]
308
309- def master_seeds(self):
310- if self.config["CDIMAGE_ADDON"]:
311- for seed in self.list_seeds("addon"):
312- yield seed
313- else:
314- for seed in self.list_seeds("installer"):
315- yield seed
316- if self.config["CDIMAGE_DVD"]:
317- for seed in self.list_seeds("dvd"):
318- if seed not in ("installer", "casper"):
319- yield seed
320- elif self.config["CDIMAGE_INSTALL"]:
321- for seed in self.list_seeds("tasks"):
322- if seed not in ("installer", "casper"):
323- yield seed
324- else:
325- if self.config.get("CDIMAGE_INSTALL_BASE") == "1":
326- for seed in self.list_seeds("base"):
327- if seed not in ("installer", "casper"):
328- yield seed
329- if self.config.get("CDIMAGE_LIVE") == "1":
330- for seed in self.list_seeds("ship-live"):
331- if seed not in ("installer", "casper"):
332- yield seed
333-
334 def master_task_entries(self):
335 project = self.config.project
336 series = self.config.series
337
338- found = False
339- for seed in self.master_seeds():
340+ for seed in self.pool_seeds():
341 yield "#include <%s/%s/%s>" % (project, series, seed)
342- found = True
343-
344- if not found:
345- raise NoMasterSeeds("No seeds found for master task!")
346
347 def tasks_output_dir(self):
348 return os.path.join(
349@@ -354,116 +239,21 @@ class GerminateOutput:
350 self.config.project, self.config.full_series,
351 self.config.image_type, "tasks")
352
353- def task_packages(self, arch, seed, seedsource):
354- """Like seed_packages, but with various special-case hacks."""
355- installer_seeds = set(self.list_seeds("installer"))
356-
357- for package in self.seed_packages(arch, seedsource):
358- # Hackily exclude kernel-image-* from the installer and casper
359- # tasks. Those udebs only exist to satisfy dependencies when
360- # building the debian-installer package.
361- if seed in installer_seeds and package.startswith("kernel-image-"):
362- continue
363-
364- # Force the use of live-installer rather than bootstrap-base on
365- # squashfs-base images. Seed expansion doesn't do the right
366- # thing here because the installer seed is expanded before
367- # considering server-ship.
368- if self.config["CDIMAGE_SQUASHFS_BASE"]:
369- if package == "bootstrap-base":
370- package = "live-installer"
371-
372- yield package
373-
374- def task_project(self):
375- # ubuntu-server really wants ubuntu-* tasks.
376- if self.config.project == "ubuntu-server":
377- return "ubuntu"
378- else:
379- return self.config.project
380-
381- def task_headers(self, arch, seed):
382- headers = {}
383- try:
384- with open("%s.seedtext" % self.seed_path(arch, seed)) as seedtext:
385- for line in seedtext:
386- if not line.lower().startswith("task-"):
387- continue
388- line = line.rstrip("\n")
389- key, value = line.split(":", 1)
390- key = key[5:].lower()
391- value = value.lstrip()
392- headers[key] = value
393- except IOError as e:
394- if e.errno != errno.ENOENT:
395- raise
396- return headers
397-
398- def seed_task_mapping(self, arch):
399- task_project = self.task_project()
400- for seed in self.list_seeds("all"):
401- # Tasks implemented via tasksel, with Task-Seeds to indicate
402- # task/seed mapping.
403- task = seed
404- headers = self.task_headers(arch, seed)
405- if not headers:
406- continue
407- input_seeds = [seed] + headers.get("seeds", "").split()
408- if "per-derivative" in headers:
409- task = "%s-%s" % (task_project, task)
410-
411- yield input_seeds, task
412-
413 def write_tasks(self):
414 output_dir = self.tasks_output_dir()
415 osextras.mkemptydir(self.tasks_output_dir())
416
417 for arch in self.config.arches:
418- packages = defaultdict(list)
419 cpparch = arch.replace("+", "_").replace("-", "_")
420- for seed in self.list_seeds("all"):
421- if seed == "supported":
422- seedsource = "%s+build-depends" % seed
423- else:
424- seedsource = seed
425- seed_path = self.seed_path(arch, seedsource)
426- if not os.path.exists(seed_path):
427+ for seed in self._seeds:
428+ if not os.path.exists(self.seed_path(arch, seed)):
429 continue
430 with open(os.path.join(output_dir, seed), "a") as task_file:
431 print("#ifdef ARCH_%s" % cpparch, file=task_file)
432- for package in sorted(
433- self.task_packages(arch, seed, seedsource)):
434- packages[seed].append(package)
435+ for package in sorted(self.seed_packages(arch, seed)):
436 print(package, file=task_file)
437 print("#endif /* ARCH_%s */" % cpparch, file=task_file)
438
439- tasks = defaultdict(list)
440- for input_seeds, task in self.seed_task_mapping(arch):
441- for input_seed in input_seeds:
442- for pkg in packages.get(input_seed, []):
443- tasks[pkg].append(task)
444-
445- # Help debian-cd to regenerate Task headers, to make sure that
446- # we don't accidentally end up out of sync with the archive and
447- # break the package installation step.
448- override_path = os.path.join(output_dir, "override.%s" % arch)
449- with open(override_path, "w") as override:
450- for pkg, tasknames in sorted(tasks.items()):
451- print(
452- "%s Task %s" % (pkg, ", ".join(tasknames)),
453- file=override)
454- # Help debian-cd to get priorities in sync with the current base
455- # system, so that debootstrap >= 0.3.1 can work out the correct
456- # set of packages to install.
457- important_path = os.path.join(output_dir, "important.%s" % arch)
458- with open(important_path, "w") as important_file:
459- important = []
460- for seed in self.list_seeds("debootstrap"):
461- important.extend(packages.get(seed, []))
462- for pkg in sorted(important):
463- if not re_not_base.match(pkg):
464- print(pkg, file=important_file)
465-
466 with open(os.path.join(output_dir, "MASTER"), "w") as master:
467 for entry in self.master_task_entries():
468 print(entry, file=master)
469@@ -471,7 +261,7 @@ class GerminateOutput:
470 def diff_tasks(self, output=None):
471 tasks_dir = self.tasks_output_dir()
472 previous_tasks_dir = "%s-previous" % tasks_dir
473- for seed in ["MASTER"] + list(self.list_seeds("all")):
474+ for seed in ["MASTER"] + list(self._seeds):
475 old = os.path.join(previous_tasks_dir, seed)
476 new = os.path.join(tasks_dir, seed)
477 if os.path.exists(old) and os.path.exists(new):
478diff --git a/lib/cdimage/livefs.py b/lib/cdimage/livefs.py
479index c1b475a..f361745 100644
480--- a/lib/cdimage/livefs.py
481+++ b/lib/cdimage/livefs.py
482@@ -724,8 +724,7 @@ def download_live_filesystems(config, builds):
483 output_dir = live_output_directory(config)
484 osextras.mkemptydir(output_dir)
485
486- if (config["CDIMAGE_LIVE"] or config["CDIMAGE_SQUASHFS_BASE"] or
487- config["CDIMAGE_PREINSTALLED"]):
488+ if config["CDIMAGE_LIVE"] or config["CDIMAGE_PREINSTALLED"]:
489 got_image = False
490 for arch in config.arches:
491 if config["CDIMAGE_PREINSTALLED"]:
492@@ -780,9 +779,7 @@ def download_live_filesystems(config, builds):
493 got_image = True
494 else:
495 continue
496- if (project != "ubuntu-base" and
497- not config["CDIMAGE_SQUASHFS_BASE"] and
498- config.subproject != "wubi"):
499+ if project != "ubuntu-base" and config.subproject != "wubi":
500 download_live_items(config, builds, arch, "kernel")
501 download_live_items(config, builds, arch, "initrd")
502 download_live_items(config, builds, arch, "kernel-efi-signed")
503diff --git a/lib/cdimage/tests/test_build.py b/lib/cdimage/tests/test_build.py
504index 1769f09..aac35e1 100644
505--- a/lib/cdimage/tests/test_build.py
506+++ b/lib/cdimage/tests/test_build.py
507@@ -449,16 +449,6 @@ class TestBuildImageSet(TestCase):
508 else:
509 self.assertNotIn("CDIMAGE_UNSUPPORTED", config)
510
511- def test_configure_install_base(self):
512- config = Config(read=False)
513- configure_for_project(config)
514- self.assertNotIn("CDIMAGE_INSTALL_BASE", config)
515-
516- config = Config(read=False)
517- config["CDIMAGE_INSTALL"] = "1"
518- configure_for_project(config)
519- self.assertEqual("1", config["CDIMAGE_INSTALL_BASE"])
520-
521 @mock.patch("os.open")
522 def test_open_log_debug(self, mock_open):
523 self.config["DEBUG"] = "1"
524diff --git a/lib/cdimage/tests/test_check_installable.py b/lib/cdimage/tests/test_check_installable.py
525index 902771e..a671e96 100644
526--- a/lib/cdimage/tests/test_check_installable.py
527+++ b/lib/cdimage/tests/test_check_installable.py
528@@ -21,8 +21,6 @@ from __future__ import print_function
529
530 import gzip
531 import os
532-import subprocess
533-from textwrap import dedent
534
535 from cdimage.check_installable import (
536 _check_installable_command,
537@@ -30,7 +28,7 @@ from cdimage.check_installable import (
538 _prepare_check_installable,
539 )
540 from cdimage.config import Config
541-from cdimage.tests.helpers import TestCase, mkfile
542+from cdimage.tests.helpers import TestCase
543
544
545 class TestCheckInstallable(TestCase):
546@@ -86,38 +84,6 @@ class TestCheckInstallable(TestCase):
547 with open(os.path.join(data, "Packages_i386")) as packages_file:
548 self.assertEqual("Package: foo\n\n", packages_file.read())
549
550- def test_prepare_squashfs_base(self):
551- self.config["CDIMAGE_SQUASHFS_BASE"] = "1"
552- _, image_top, live, data = _check_installable_dirs(self.config)
553- squashfs_dir = os.path.join(self.temp_dir, "squashfs")
554- status_path = os.path.join(
555- squashfs_dir, "var", "lib", "dpkg", "status")
556- fake_packages = dedent("""\
557- Package: base-files
558- Status: install ok installed
559- Version: 6.5
560-
561- Package: libc6
562- Status: install ok installed
563- Version: 2.15-1
564- Provides: glibc
565-
566- """)
567- with mkfile(status_path) as status:
568- print(fake_packages, end="", file=status)
569- os.makedirs(live)
570- with open("/dev/null", "w") as devnull:
571- subprocess.check_call(
572- ["mksquashfs", squashfs_dir,
573- os.path.join(live, "i386.squashfs")],
574- stdout=devnull)
575- self.capture_logging()
576- _prepare_check_installable(self.config)
577- self.assertLogEqual([])
578- self.assertCountEqual(["Packages_i386", "Sources"], os.listdir(data))
579- with open(os.path.join(data, "Packages_i386")) as packages_file:
580- self.assertEqual(fake_packages, packages_file.read())
581-
582 def test_command(self):
583 britney, _, _, data = _check_installable_dirs(self.config)
584 command = _check_installable_command(self.config)
585diff --git a/lib/cdimage/tests/test_germinate.py b/lib/cdimage/tests/test_germinate.py
586index f567eae..7b15027 100644
587--- a/lib/cdimage/tests/test_germinate.py
588+++ b/lib/cdimage/tests/test_germinate.py
589@@ -29,7 +29,7 @@ try:
590 except ImportError:
591 import mock
592
593-from cdimage.config import Config, all_series
594+from cdimage.config import Config
595 from cdimage.germinate import (
596 GerminateNotInstalled,
597 GerminateOutput,
598@@ -55,11 +55,6 @@ class TestGermination(TestCase):
599 GerminateNotInstalled, getattr, self.germination, "germinate_path")
600
601 germinate_dir = os.path.join(self.temp_dir, "germinate")
602- old_germinate = os.path.join(germinate_dir, "germinate.py")
603- touch(old_germinate)
604- os.chmod(old_germinate, 0o755)
605- self.assertEqual(old_germinate, self.germination.germinate_path)
606-
607 new_germinate = os.path.join(germinate_dir, "bin", "germinate")
608 touch(new_germinate)
609 os.chmod(new_germinate, 0o755)
610@@ -356,106 +351,6 @@ class TestGerminateOutput(TestCase):
611 ["active-ship-live", ["ship-live"]],
612 ])
613
614- def test_inheritance_recurses(self):
615- """_inheritance recurses properly."""
616- self.write_structure([["a", []], ["b", ["a"]], ["c", ["b"]]])
617- output = GerminateOutput(self.config, self.temp_dir)
618- self.assertEqual(["a"], output._inheritance("a"))
619- self.assertEqual(["a", "b"], output._inheritance("b"))
620- self.assertEqual(["a", "b", "c"], output._inheritance("c"))
621-
622- def test_inheritance_avoids_duplicates(self):
623- """_inheritance avoids adding a seed more than once."""
624- self.write_structure([["a", []], ["b", ["a"]], ["c", ["a", "b"]]])
625- output = GerminateOutput(self.config, self.temp_dir)
626- self.assertEqual(["a", "b", "c"], output._inheritance("c"))
627-
628- def test_without_inheritance(self):
629- self.write_structure(
630- [["a", []], ["b", ["a"]], ["c", ["b"]], ["d", ["a", "c"]]])
631- output = GerminateOutput(self.config, self.temp_dir)
632- inheritance = output._inheritance("d")
633- self.assertEqual(["a", "b", "c", "d"], inheritance)
634- self.assertEqual(
635- ["c", "d"], output._without_inheritance("b", inheritance))
636-
637- def test_list_seeds_all(self):
638- self.write_structure([["a", []], ["b", ["a"]], ["c", []]])
639- output = GerminateOutput(self.config, self.temp_dir)
640- self.assertEqual(["a", "b", "c"], list(output.list_seeds("all")))
641-
642- def test_list_seeds_tasks_ubuntu(self):
643- self.write_ubuntu_structure()
644- output = GerminateOutput(self.config, self.temp_dir)
645- self.config["PROJECT"] = "ubuntu"
646- self.config["DIST"] = "bionic"
647- expected = [
648- "boot", "installer", "required", "minimal", "standard",
649- "desktop-common", "desktop", "d-i-requirements", "ship",
650- ]
651- self.assertEqual(expected, list(output.list_seeds("tasks")))
652- self.config["CDIMAGE_DVD"] = "1"
653- expected.extend(["dns-server", "lamp-server"])
654- self.assertEqual(expected, list(output.list_seeds("tasks")))
655-
656- def test_list_seeds_tasks_ubuntu_server(self):
657- self.write_ubuntu_structure()
658- output = GerminateOutput(self.config, self.temp_dir)
659- self.config["PROJECT"] = "ubuntu-server"
660- expected = [
661- "boot", "installer", "required", "minimal", "standard",
662- "dns-server", "lamp-server", "openssh-server", "print-server",
663- "samba-server", "postgresql-server", "mail-server", "server",
664- "tomcat-server", "virt-host", "d-i-requirements", "server-ship",
665- ]
666- for series in all_series[4:]:
667- self.config["DIST"] = series
668- self.assertEqual(expected, list(output.list_seeds("tasks")))
669-
670- def test_list_seeds_task_ubuntu_server_squashfs(self):
671- self.write_ubuntu_structure()
672- output = GerminateOutput(self.config, self.temp_dir)
673- self.config["PROJECT"] = "ubuntu-server"
674- self.config["DIST"] = "bionic"
675- self.config["CDIMAGE_SQUASHFS_BASE"] = "1"
676- expected = [
677- "boot", "installer", "standard", "dns-server", "lamp-server",
678- "openssh-server", "print-server", "samba-server",
679- "postgresql-server", "mail-server", "server", "tomcat-server",
680- "virt-host", "d-i-requirements", "server-ship",
681- ]
682- self.assertEqual(expected, list(output.list_seeds("tasks")))
683-
684- def test_list_seeds_installer(self):
685- self.write_structure([["installer", []], ["casper", []]])
686- output = GerminateOutput(self.config, self.temp_dir)
687- self.config["CDIMAGE_INSTALL_BASE"] = "1"
688- self.assertEqual(["installer"], list(output.list_seeds("installer")))
689- del self.config["CDIMAGE_INSTALL_BASE"]
690- self.config["CDIMAGE_LIVE"] = "1"
691- self.config["DIST"] = "bionic"
692- self.assertEqual([], list(output.list_seeds("installer")))
693-
694- def test_list_seeds_debootstrap(self):
695- self.write_ubuntu_structure()
696- output = GerminateOutput(self.config, self.temp_dir)
697- for series in all_series[6:]:
698- self.config["DIST"] = series
699- self.assertEqual(
700- ["required", "minimal"],
701- list(output.list_seeds("debootstrap")))
702-
703- def test_list_seeds_base(self):
704- self.write_ubuntu_structure()
705- output = GerminateOutput(self.config, self.temp_dir)
706- for series in all_series[6:]:
707- self.config["DIST"] = series
708- self.assertEqual(
709- ["boot", "required", "minimal", "standard"],
710- list(output.list_seeds("base")))
711-
712- # TODO list_seeds ship-live/addon/dvd untested
713-
714 def test_seed_path(self):
715 self.write_ubuntu_structure()
716 output = GerminateOutput(self.config, self.temp_dir)
717@@ -495,43 +390,8 @@ class TestGerminateOutput(TestCase):
718 ["base-files", "base-passwd"],
719 output.seed_packages("i386", "base"))
720
721- # TODO: master_seeds addon untested
722-
723- def test_master_seeds_dvd_ubuntu_bionic(self):
724- self.write_ubuntu_structure()
725- output = GerminateOutput(self.config, self.temp_dir)
726- self.config["PROJECT"] = "ubuntu"
727- self.config["DIST"] = "bionic"
728- self.config["CDIMAGE_DVD"] = "1"
729- self.assertEqual(
730- ["usb-langsupport", "usb-ship-live"], list(output.master_seeds()))
731-
732- def test_master_seeds_install_ubuntu_bionic(self):
733- self.write_ubuntu_structure()
734- output = GerminateOutput(self.config, self.temp_dir)
735- self.config["PROJECT"] = "ubuntu"
736- self.config["DIST"] = "bionic"
737- self.config["CDIMAGE_INSTALL"] = "1"
738- self.config["CDIMAGE_INSTALL_BASE"] = "1"
739- self.assertEqual([
740- "installer", "boot", "required", "minimal", "standard",
741- "desktop-common", "desktop", "d-i-requirements", "ship",
742- ], list(output.master_seeds()))
743-
744- def test_master_seeds_live_ubuntu_bionic(self):
745- self.write_ubuntu_structure()
746- output = GerminateOutput(self.config, self.temp_dir)
747- self.config["PROJECT"] = "ubuntu"
748- self.config["DIST"] = "bionic"
749- self.config["CDIMAGE_INSTALL_BASE"] = "1"
750- self.config["CDIMAGE_LIVE"] = "1"
751- self.assertEqual([
752- "installer", "boot", "required", "minimal", "standard",
753- "ship-live",
754- ], list(output.master_seeds()))
755-
756- @mock.patch("cdimage.germinate.GerminateOutput.master_seeds")
757- def test_master_task_entries(self, mock_master_seeds):
758+ @mock.patch("cdimage.germinate.GerminateOutput.pool_seeds")
759+ def test_master_task_entries(self, mock_pool_seeds):
760 def side_effect():
761 yield "required"
762 yield "minimal"
763@@ -540,21 +400,19 @@ class TestGerminateOutput(TestCase):
764 output = GerminateOutput(self.config, self.temp_dir)
765 self.config["DIST"] = "bionic"
766 self.config["PROJECT"] = "ubuntu"
767- mock_master_seeds.side_effect = side_effect
768+ mock_pool_seeds.side_effect = side_effect
769 self.assertEqual([
770 "#include <ubuntu/bionic/required>",
771 "#include <ubuntu/bionic/minimal>",
772 ], list(output.master_task_entries()))
773
774- @mock.patch(
775- "cdimage.germinate.GerminateOutput.master_seeds", return_value=[])
776- def test_master_task_entries_no_seeds(self, mock_master_seeds):
777+ def test_pool_seeds_invalid_config(self):
778 self.write_ubuntu_structure()
779 output = GerminateOutput(self.config, self.temp_dir)
780 self.config["DIST"] = "bionic"
781 self.config["PROJECT"] = "ubuntu"
782 self.assertRaises(
783- NoMasterSeeds, list, output.master_task_entries())
784+ NoMasterSeeds, list, output.pool_seeds())
785
786 def test_tasks_output_dir(self):
787 self.write_ubuntu_structure()
788@@ -568,83 +426,6 @@ class TestGerminateOutput(TestCase):
789 "tasks"),
790 output.tasks_output_dir())
791
792- def test_task_packages_plain(self):
793- self.write_structure([["base", []]])
794- self.write_seed_output("i386", "base", ["base-files", "base-passwd"])
795- output = GerminateOutput(self.config, self.temp_dir)
796- self.assertEqual(
797- ["base-files", "base-passwd"],
798- list(output.task_packages("i386", "base", "base")))
799-
800- def test_task_packages_installer(self):
801- # kernel-image-* is excluded from the installer seed.
802- self.write_structure([["installer", []]])
803- self.write_seed_output(
804- "i386", "installer", [
805- "block-modules-3.8.0-6-generic-di",
806- "kernel-image-3.8.0-6-generic-di",
807- ])
808- self.config["CDIMAGE_INSTALL_BASE"] = "1"
809- output = GerminateOutput(self.config, self.temp_dir)
810- self.assertEqual(
811- ["block-modules-3.8.0-6-generic-di"],
812- list(output.task_packages("i386", "installer", "installer")))
813-
814- def test_task_packages_squashfs(self):
815- self.write_ubuntu_structure()
816- self.config["PROJECT"] = "ubuntu-server"
817- self.config["DIST"] = "bionic"
818- self.write_seed_output(
819- "i386", "installer", ["base-installer", "bootstrap-base"])
820- output = GerminateOutput(self.config, self.temp_dir)
821- self.assertEqual(
822- ["base-installer", "bootstrap-base"],
823- list(output.task_packages("i386", "installer", "installer")))
824- self.config["CDIMAGE_SQUASHFS_BASE"] = "1"
825- self.assertEqual(
826- ["base-installer", "live-installer"],
827- list(output.task_packages("i386", "installer", "installer")))
828-
829- # TODO: task_project untested
830-
831- def test_task_headers(self):
832- self.write_ubuntu_structure()
833- seedtext_path = os.path.join(self.temp_dir, "i386", "desktop.seedtext")
834- with mkfile(seedtext_path) as seedtext:
835- print(dedent("""\
836- Task-Per-Derivative: 1
837- Task-Key: ubuntu-desktop
838- Task-Seeds: desktop-common
839-
840- = Seed text starts here ="""), file=seedtext)
841- output = GerminateOutput(self.config, self.temp_dir)
842- expected = {
843- "per-derivative": "1",
844- "key": "ubuntu-desktop",
845- "seeds": "desktop-common",
846- }
847- self.assertEqual(expected, output.task_headers("i386", "desktop"))
848- self.assertEqual({}, output.task_headers("i386", "missing"))
849-
850- def test_seed_task_mapping(self):
851- self.write_ubuntu_structure()
852- seed_dir = os.path.join(self.temp_dir, "i386")
853- with mkfile(os.path.join(seed_dir, "standard.seedtext")) as seedtext:
854- print("Task-Key: ubuntu-standard", file=seedtext)
855- with mkfile(os.path.join(seed_dir, "desktop.seedtext")) as seedtext:
856- print(dedent("""\
857- Task-Per-Derivative: 1
858- Task-Seeds: desktop-common"""), file=seedtext)
859- self.config["DIST"] = "bionic"
860- self.config["PROJECT"] = "ubuntu"
861- output = GerminateOutput(self.config, self.temp_dir)
862- expected = [
863- (["standard"], "standard"),
864- (["desktop", "desktop-common"], "ubuntu-desktop"),
865- ]
866- self.assertEqual(
867- expected, list(output.seed_task_mapping("i386")))
868-
869 def test_write_tasks(self):
870 self.write_ubuntu_structure()
871 for arch in "amd64", "i386":
872@@ -673,8 +454,6 @@ class TestGerminateOutput(TestCase):
873 "tasks")
874 self.assertCountEqual([
875 "required", "minimal", "desktop", "live",
876- "override.amd64", "override.i386",
877- "important.amd64", "important.i386",
878 "MASTER",
879 ], os.listdir(output_dir))
880 with open(os.path.join(output_dir, "required")) as f:
881@@ -723,28 +502,6 @@ class TestGerminateOutput(TestCase):
882 #endif /* ARCH_i386 */
883 """),
884 f.read())
885- with open(os.path.join(output_dir, "override.amd64")) as f:
886- self.assertEqual(
887- dedent("""\
888- adduser-amd64 Task minimal
889- base-files-amd64 Task minimal
890- firefox Task ubuntu-desktop
891- xterm Task ubuntu-desktop, ubuntu-live
892- """),
893- f.read())
894- with open(os.path.join(output_dir, "override.i386")) as f:
895- self.assertEqual(
896- dedent("""\
897- adduser-i386 Task minimal
898- base-files-i386 Task minimal
899- firefox Task ubuntu-desktop
900- xterm Task ubuntu-desktop, ubuntu-live
901- """),
902- f.read())
903- with open(os.path.join(output_dir, "important.amd64")) as f:
904- self.assertEqual("adduser-amd64\nbase-files-amd64\n", f.read())
905- with open(os.path.join(output_dir, "important.i386")) as f:
906- self.assertEqual("adduser-i386\nbase-files-i386\n", f.read())
907 with open(os.path.join(output_dir, "MASTER")) as f:
908 self.assertEqual("#include <ubuntu/bionic/ship-live>\n", f.read())
909
910diff --git a/lib/cdimage/tests/test_tree.py b/lib/cdimage/tests/test_tree.py
911index c5e3665..63a5840 100644
912--- a/lib/cdimage/tests/test_tree.py
913+++ b/lib/cdimage/tests/test_tree.py
914@@ -1866,7 +1866,6 @@ class TestDailyTreePublisher(TestCase):
915 @mock.patch("cdimage.tree.DailyTreePublisher.post_qa")
916 def test_publish(self, mock_post_qa, *args):
917 self.config["ARCHES"] = "i386"
918- self.config["CDIMAGE_INSTALL_BASE"] = "1"
919 publisher = self.make_publisher("ubuntu", "daily-live")
920 source_dir = publisher.image_output("i386")
921 touch(os.path.join(
922@@ -1900,7 +1899,6 @@ class TestDailyTreePublisher(TestCase):
923 "%s-desktop-i386.iso" % self.config.series,
924 "%s-desktop-i386.list" % self.config.series,
925 "%s-desktop-i386.manifest" % self.config.series,
926- "report.html",
927 ], os.listdir(target_dir))
928 self.assertCountEqual(
929 [".htaccess", "20120807", "current", "pending"],
930@@ -1921,7 +1919,6 @@ class TestDailyTreePublisher(TestCase):
931 def test_publish_subtree(self, mock_post_qa, *args):
932 self.config.subtree = "subtree/test"
933 self.config["ARCHES"] = "i386"
934- self.config["CDIMAGE_INSTALL_BASE"] = "1"
935 publisher = self.make_publisher("ubuntu", "daily-live")
936 source_dir = publisher.image_output("i386")
937 touch(os.path.join(
938@@ -1960,7 +1957,6 @@ class TestDailyTreePublisher(TestCase):
939 "%s-desktop-i386.iso" % self.config.series,
940 "%s-desktop-i386.list" % self.config.series,
941 "%s-desktop-i386.manifest" % self.config.series,
942- "report.html",
943 ], os.listdir(target_dir))
944 self.assertCountEqual(
945 [".htaccess", "20120807", "current", "pending"],
946diff --git a/lib/cdimage/tree.py b/lib/cdimage/tree.py
947index 0e9ad71..6fac63b 100644
948--- a/lib/cdimage/tree.py
949+++ b/lib/cdimage/tree.py
950@@ -2084,13 +2084,7 @@ class DailyTreePublisher(Publisher):
951 else:
952 osextras.unlink_force("%s.manifest" % target_prefix)
953
954- if (self.config["CDIMAGE_SQUASHFS_BASE"] and
955- os.path.exists("%s.squashfs" % source_prefix)):
956- logger.info("Publishing %s squashfs ..." % arch)
957- shutil.move(
958- "%s.squashfs" % source_prefix, "%s.squashfs" % target_prefix)
959- else:
960- osextras.unlink_force("%s.squashfs" % target_prefix)
961+ osextras.unlink_force("%s.squashfs" % target_prefix)
962
963 if os.path.exists("%s.custom.tar.gz" % source_prefix):
964 logger.info("Publishing %s custom tarball ..." % arch)
965@@ -2616,14 +2610,8 @@ class DailyTreePublisher(Publisher):
966 logger.warning("No images produced!")
967 return
968
969- source_report = os.path.join(
970- self.britney_report, "%s_probs.html" % self.config.series)
971 target_report = os.path.join(self.publish_base, date, "report.html")
972- if (self.config["CDIMAGE_INSTALL_BASE"] and
973- os.path.exists(source_report)):
974- shutil.copy2(source_report, target_report)
975- else:
976- osextras.unlink_force(target_report)
977+ osextras.unlink_force(target_report)
978
979 self.polish_directory(date)
980 self.link(date, "pending")

Subscribers

People subscribed via source and target branches