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

Proposed by Michael Hudson-Doyle
Status: Needs review
Proposed branch: ~mwhudson/ubuntu-cdimage:simplify-germinate-output
Merge into: ubuntu-cdimage:main
Diff against target: 84 lines (+26/-6)
2 files modified
lib/cdimage/germinate.py (+19/-5)
lib/cdimage/tests/test_germinate.py (+7/-1)
Reviewer Review Type Date Requested Status
Ubuntu CD Image Team Pending
Review via email: mp+466016@code.launchpad.net

Commit message

write a per-arch list of packages to include in the pool

Currently the way cdimage tells debian-cd which packages to include in
the pool via this absurd mechanism involving the C preprocessor on the
debian-cd side. But cdimage knows exactly which packages to include, so
write a simple file with the list of packages we want (alongside the
current silliness, for now).

To post a comment you must log in.

Unmerged commits

0db52e1... by Michael Hudson-Doyle

write a per-arch list of packages to include in the pool

Currently the way cdimage tells debian-cd which packages to include in
the pool via this absurd mechanism involving the C preprocessor on the
debian-cd side. But cdimage knows exactly which packages to include, so
write a simple file with the list of packages we want (alongside the
current silliness, for now).

Succeeded
[SUCCEEDED] run-tests:0 (build)
[SUCCEEDED] lint:0 (build)
12 of 2 results

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 004e2a3..30e445c 100644
3--- a/lib/cdimage/germinate.py
4+++ b/lib/cdimage/germinate.py
5@@ -222,7 +222,11 @@ class GerminateOutput:
6 return os.path.join(self.directory, arch, seed)
7
8 def seed_packages(self, arch, seed):
9- with open(self.seed_path(arch, seed)) as seed_file:
10+ try:
11+ seed_file = open(self.seed_path(arch, seed))
12+ except FileNotFoundError:
13+ return []
14+ with seed_file:
15 lines = seed_file.read().splitlines()[2:-2]
16 return [line.split(None, 1)[0] for line in lines]
17
18@@ -241,9 +245,15 @@ class GerminateOutput:
19
20 def write_tasks(self):
21 output_dir = self.tasks_output_dir()
22- osextras.mkemptydir(self.tasks_output_dir())
23+ osextras.mkemptydir(output_dir)
24
25 for arch in self.config.arches:
26+ arch_packages = set()
27+ for seed in self.pool_seeds():
28+ arch_packages.update(self.seed_packages(arch, seed))
29+ with open(os.path.join(output_dir, f"{arch}-packages"), "w") as fp:
30+ for package in sorted(arch_packages):
31+ print(package, file=fp)
32 cpparch = arch.replace("+", "_").replace("-", "_")
33 for seed in self._seeds:
34 if not os.path.exists(self.seed_path(arch, seed)):
35@@ -261,9 +271,13 @@ class GerminateOutput:
36 def diff_tasks(self, output=None):
37 tasks_dir = self.tasks_output_dir()
38 previous_tasks_dir = "%s-previous" % tasks_dir
39- for seed in ["MASTER"] + list(self._seeds):
40- old = os.path.join(previous_tasks_dir, seed)
41- new = os.path.join(tasks_dir, seed)
42+ filenames = ["MASTER"] + list(self._seeds)
43+ for arch in self.config.arches:
44+ filenames.append(f"{arch}-packages")
45+
46+ for filename in filenames:
47+ old = os.path.join(previous_tasks_dir, filename)
48+ new = os.path.join(tasks_dir, filename)
49 if os.path.exists(old) and os.path.exists(new):
50 kwargs = {}
51 if output is not None:
52diff --git a/lib/cdimage/tests/test_germinate.py b/lib/cdimage/tests/test_germinate.py
53index 7b15027..ca556af 100644
54--- a/lib/cdimage/tests/test_germinate.py
55+++ b/lib/cdimage/tests/test_germinate.py
56@@ -434,6 +434,7 @@ class TestGerminateOutput(TestCase):
57 self.write_seed_output(arch, "minimal", ["adduser-%s" % arch])
58 self.write_seed_output(arch, "desktop", ["xterm", "firefox"])
59 self.write_seed_output(arch, "live", ["xterm"])
60+ self.write_seed_output(arch, "ship-live", ["pool-pkg-%s" % arch])
61 with mkfile(os.path.join(
62 seed_dir, "minimal.seedtext")) as seedtext:
63 print("Task-Seeds: required", file=seedtext)
64@@ -453,7 +454,8 @@ class TestGerminateOutput(TestCase):
65 self.temp_dir, "scratch", "ubuntu", "bionic", "daily-live",
66 "tasks")
67 self.assertCountEqual([
68- "required", "minimal", "desktop", "live",
69+ "required", "minimal", "desktop", "live", "ship-live",
70+ "amd64-packages", "i386-packages",
71 "MASTER",
72 ], os.listdir(output_dir))
73 with open(os.path.join(output_dir, "required")) as f:
74@@ -504,6 +506,10 @@ class TestGerminateOutput(TestCase):
75 f.read())
76 with open(os.path.join(output_dir, "MASTER")) as f:
77 self.assertEqual("#include <ubuntu/bionic/ship-live>\n", f.read())
78+ with open(os.path.join(output_dir, "amd64-packages")) as f:
79+ self.assertEqual("pool-pkg-amd64\n", f.read())
80+ with open(os.path.join(output_dir, "i386-packages")) as f:
81+ self.assertEqual("pool-pkg-i386\n", f.read())
82
83 @mock.patch("subprocess.call", return_value=1)
84 def test_diff_tasks(self, mock_call):

Subscribers

People subscribed via source and target branches