Merge lp:~ubuntu-cdimage/ubuntu-cdimage/focal into lp:ubuntu-cdimage
- focal
- Merge into mainline
Proposed by
Iain Lane
Status: | Merged |
---|---|
Approved by: | Steve Langasek |
Approved revision: | 1878 |
Merged at revision: | 1879 |
Proposed branch: | lp:~ubuntu-cdimage/ubuntu-cdimage/focal |
Merge into: | lp:ubuntu-cdimage |
Diff against target: |
310 lines (+58/-53) 6 files modified
lib/cdimage/launchpad.py (+14/-1) lib/cdimage/sign.py (+9/-9) lib/cdimage/tests/test_checksums.py (+2/-1) lib/cdimage/tests/test_sign.py (+14/-17) lib/cdimage/tests/test_tree.py (+17/-17) lib/cdimage/tree.py (+2/-8) |
To merge this branch: | bzr merge lp:~ubuntu-cdimage/ubuntu-cdimage/focal |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Steve Langasek | Approve | ||
Review via email: mp+386317@code.launchpad.net |
Commit message
Description of the change
Various fixes to make cdimage work on focal (ancientminister, new cdimage host). I tried to retain compatibility with xenial (nusakan) - the changes have been tested there in isolation but I've not actually pulled an updated cdimage to test them end-to-end.
Mainly launchpadlib, gpg and bittorrent-related changes.
I could split this up into logical MPs if you want (but bzr...).
To post a comment you must log in.
Revision history for this message
Iain Lane (laney) wrote : | # |
Revision history for this message
Iain Lane (laney) wrote : | # |
Revision history for this message
Steve Langasek (vorlon) wrote : | # |
when you say they depend on each other, do you mean that they need to land together in order to not break builds on nusakan?
Revision history for this message
Steve Langasek (vorlon) : | # |
review:
Needs Fixing
Revision history for this message
Iain Lane (laney) wrote : | # |
Nah, that's not the best wording. It's more that they both need to land to work on focal.
Revision history for this message
Iain Lane (laney) : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/cdimage/launchpad.py' |
2 | --- lib/cdimage/launchpad.py 2019-01-11 17:45:45 +0000 |
3 | +++ lib/cdimage/launchpad.py 2020-06-29 11:27:35 +0000 |
4 | @@ -148,7 +148,20 @@ |
5 | |
6 | |
7 | def login(instance): |
8 | - return Launchpad.login_with("ubuntu-cdimage", instance, version="devel") |
9 | + try: |
10 | + import launchpadlib.credentials |
11 | + store = launchpadlib.credentials.KeyringCredentialStore(None, |
12 | + fallback=True) |
13 | + return Launchpad.login_with("ubuntu-cdimage", |
14 | + instance, |
15 | + version="devel", |
16 | + credential_store=store) |
17 | + except TypeError: |
18 | + # prior to focal (1.10.13), the fallback= kwarg didn't exist and |
19 | + # Launchpadlib worked under sudo |
20 | + return Launchpad.login_with("ubuntu-cdimage", |
21 | + instance, |
22 | + version="devel") |
23 | |
24 | |
25 | class _LaunchpadCache: |
26 | |
27 | === modified file 'lib/cdimage/sign.py' |
28 | --- lib/cdimage/sign.py 2015-11-11 20:06:02 +0000 |
29 | +++ lib/cdimage/sign.py 2020-06-29 11:27:35 +0000 |
30 | @@ -23,30 +23,30 @@ |
31 | |
32 | |
33 | def _gnupg_files(config): |
34 | + gpgdir = config["GNUPG_DIR"] |
35 | gpgconf = os.path.join(config["GNUPG_DIR"], "gpg.conf") |
36 | secring = os.path.join(config["GNUPG_DIR"], "secring.gpg") |
37 | + privkeydir = os.path.join(config["GNUPG_DIR"], "private-keys-v1.d") |
38 | pubring = os.path.join(config["GNUPG_DIR"], "pubring.gpg") |
39 | trustdb = os.path.join(config["GNUPG_DIR"], "trustdb.gpg") |
40 | - return gpgconf, secring, pubring, trustdb |
41 | + return gpgdir, gpgconf, secring, privkeydir, pubring, trustdb |
42 | |
43 | |
44 | def can_sign(config): |
45 | - gpgconf, secring, pubring, trustdb = _gnupg_files(config) |
46 | - if (not os.path.exists(secring) or not os.path.exists(pubring) or |
47 | - not os.path.exists(trustdb) or not config["SIGNING_KEYID"]): |
48 | + _, _, secring, privkeydir, pubring, trustdb = _gnupg_files(config) |
49 | + if (not (os.path.exists(privkeydir) or os.path.exists(secring)) or |
50 | + not os.path.exists(pubring) or not os.path.exists(trustdb) or |
51 | + not config["SIGNING_KEYID"]): |
52 | logger.warning("No keys found; not signing images.") |
53 | return False |
54 | return True |
55 | |
56 | |
57 | def _signing_command(config): |
58 | - gpgconf, secring, pubring, trustdb = _gnupg_files(config) |
59 | + gpgdir, gpgconf, _, _, _, _ = _gnupg_files(config) |
60 | cmd = [ |
61 | "gpg", "--options", gpgconf, |
62 | - "--no-default-keyring", |
63 | - "--secret-keyring", secring, |
64 | - "--keyring", pubring, |
65 | - "--trustdb-name", trustdb, |
66 | + "--homedir", gpgdir, |
67 | "--no-options", "--batch", "--no-tty", |
68 | "--armour", "--detach-sign", |
69 | # FBB75451 and EFE21092 have different digest preferences. GnuPG |
70 | |
71 | === modified file 'lib/cdimage/tests/test_checksums.py' |
72 | --- lib/cdimage/tests/test_checksums.py 2020-06-17 00:21:41 +0000 |
73 | +++ lib/cdimage/tests/test_checksums.py 2020-06-29 11:27:35 +0000 |
74 | @@ -88,7 +88,8 @@ |
75 | checksum_file = ChecksumFile( |
76 | self.config, self.temp_dir, "SHA256SUMS", hashlib.sha256) |
77 | self.assertEqual( |
78 | - hashlib.sha256(data).hexdigest(), checksum_file.checksum(entry_path)) |
79 | + hashlib.sha256(data).hexdigest(), |
80 | + checksum_file.checksum(entry_path)) |
81 | |
82 | def test_add(self): |
83 | entry_path = os.path.join(self.temp_dir, "entry") |
84 | |
85 | === modified file 'lib/cdimage/tests/test_sign.py' |
86 | --- lib/cdimage/tests/test_sign.py 2015-11-11 20:06:02 +0000 |
87 | +++ lib/cdimage/tests/test_sign.py 2020-06-29 11:27:35 +0000 |
88 | @@ -34,9 +34,12 @@ |
89 | def test_gnupg_files(self): |
90 | config = Config(read=False) |
91 | config["GNUPG_DIR"] = "/path" |
92 | - gpgconf, secring, pubring, trustdb = _gnupg_files(config) |
93 | + gpgdir, gpgconf, secring, privkeydir, pubring, trustdb = \ |
94 | + _gnupg_files(config) |
95 | + self.assertEqual("/path", gpgdir) |
96 | self.assertEqual("/path/gpg.conf", gpgconf) |
97 | self.assertEqual("/path/secring.gpg", secring) |
98 | + self.assertEqual("/path/private-keys-v1.d", privkeydir) |
99 | self.assertEqual("/path/pubring.gpg", pubring) |
100 | self.assertEqual("/path/trustdb.gpg", trustdb) |
101 | |
102 | @@ -47,10 +50,7 @@ |
103 | command = _signing_command(config) |
104 | self.assertEqual([ |
105 | "gpg", "--options", "/path/gpg.conf", |
106 | - "--no-default-keyring", |
107 | - "--secret-keyring", "/path/secring.gpg", |
108 | - "--keyring", "/path/pubring.gpg", |
109 | - "--trustdb-name", "/path/trustdb.gpg", |
110 | + "--homedir", "/path", |
111 | "--no-options", "--batch", "--no-tty", |
112 | "--armour", "--detach-sign", |
113 | "--digest-algo", "SHA512", |
114 | @@ -64,10 +64,7 @@ |
115 | command = _signing_command(config) |
116 | self.assertEqual([ |
117 | "gpg", "--options", "/path/gpg.conf", |
118 | - "--no-default-keyring", |
119 | - "--secret-keyring", "/path/secring.gpg", |
120 | - "--keyring", "/path/pubring.gpg", |
121 | - "--trustdb-name", "/path/trustdb.gpg", |
122 | + "--homedir", "/path", |
123 | "--no-options", "--batch", "--no-tty", |
124 | "--armour", "--detach-sign", |
125 | "--digest-algo", "SHA512", |
126 | @@ -97,7 +94,8 @@ |
127 | config = Config(read=False) |
128 | config["GNUPG_DIR"] = self.use_temp_dir() |
129 | config["SIGNING_KEYID"] = "01234567" |
130 | - gpgconf, secring, pubring, trustdb = _gnupg_files(config) |
131 | + gpgdir, gpgconf, secring, privkeydir, pubring, trustdb = \ |
132 | + _gnupg_files(config) |
133 | sign_path = os.path.join(self.temp_dir, "to-sign") |
134 | for path in gpgconf, secring, pubring, trustdb, sign_path: |
135 | touch(path) |
136 | @@ -106,10 +104,7 @@ |
137 | self.assertLogEqual([]) |
138 | expected_command = [ |
139 | "gpg", "--options", gpgconf, |
140 | - "--no-default-keyring", |
141 | - "--secret-keyring", secring, |
142 | - "--keyring", pubring, |
143 | - "--trustdb-name", trustdb, |
144 | + "--homedir", config["GNUPG_DIR"], |
145 | "--no-options", "--batch", "--no-tty", |
146 | "--armour", "--detach-sign", |
147 | "--digest-algo", "SHA512", |
148 | @@ -127,13 +122,15 @@ |
149 | config = Config(read=False) |
150 | config["GNUPG_DIR"] = self.use_temp_dir() |
151 | config["SIGNING_KEYID"] = "01234567" |
152 | - gpgconf, secring, pubring, trustdb = _gnupg_files(config) |
153 | + gpgdir, gpgconf, secring, privkeydir, pubring, trustdb = \ |
154 | + _gnupg_files(config) |
155 | sign_path = os.path.join(self.temp_dir, "to-sign") |
156 | for path in gpgconf, secring, pubring, trustdb, sign_path: |
157 | touch(path) |
158 | touch("%s.gpg" % sign_path) |
159 | self.capture_logging() |
160 | - self.assertRaises( |
161 | - subprocess.CalledProcessError, sign_cdimage, config, sign_path) |
162 | + with self.assertRaises(subprocess.CalledProcessError): |
163 | + sign_cdimage(config, sign_path) |
164 | + mock_check_call.assert_called() |
165 | self.assertLogEqual([]) |
166 | self.assertFalse(os.path.exists("%s.gpg" % sign_path)) |
167 | |
168 | === modified file 'lib/cdimage/tests/test_tree.py' |
169 | --- lib/cdimage/tests/test_tree.py 2020-06-19 00:57:47 +0000 |
170 | +++ lib/cdimage/tests/test_tree.py 2020-06-29 11:27:35 +0000 |
171 | @@ -2293,8 +2293,8 @@ |
172 | "preinstalled-netbook")) |
173 | |
174 | |
175 | -def call_btmakemetafile_zsyncmake(command, *args, **kwargs): |
176 | - if command[0] == "btmakemetafile": |
177 | +def call_mktorrent_zsyncmake(command, *args, **kwargs): |
178 | + if command[0] == "mktorrent": |
179 | touch("%s.torrent" % command[-1]) |
180 | elif command[0] == "zsyncmake": |
181 | for i in range(1, len(command)): |
182 | @@ -2396,7 +2396,7 @@ |
183 | self.assertLogEqual( |
184 | ["Creating torrent for %s ..." % path for path in paths]) |
185 | command_base = [ |
186 | - "btmakemetafile", "https://torrent.ubuntu.com/announce", |
187 | + "mktorrent", "-a", "https://torrent.ubuntu.com/announce", |
188 | "--comment", "Ubuntu CD cdimage.ubuntu.com", |
189 | ] |
190 | mock_check_call.assert_has_calls([ |
191 | @@ -2417,7 +2417,7 @@ |
192 | self.get_publisher(official="named").publish_release_prefixes()) |
193 | |
194 | @mock.patch("cdimage.osextras.find_on_path", return_value=True) |
195 | - @mock.patch("subprocess.call", side_effect=call_btmakemetafile_zsyncmake) |
196 | + @mock.patch("subprocess.call", side_effect=call_mktorrent_zsyncmake) |
197 | def test_publish_release_arch_ubuntu_desktop_named(self, mock_call, *args): |
198 | self.config["PROJECT"] = "ubuntu" |
199 | self.config["CAPPROJECT"] = "Ubuntu" |
200 | @@ -2461,7 +2461,7 @@ |
201 | "%s.iso" % target_base, |
202 | ]), |
203 | mock.call([ |
204 | - "btmakemetafile", mock.ANY, |
205 | + "mktorrent", mock.ANY, mock.ANY, |
206 | "--comment", "Ubuntu CD cdimage.ubuntu.com", |
207 | "%s.iso" % target_base, |
208 | ], stdout=mock.ANY), |
209 | @@ -2479,7 +2479,7 @@ |
210 | os.stat("%s.iso.torrent" % torrent_base)) |
211 | |
212 | @mock.patch("cdimage.osextras.find_on_path", return_value=True) |
213 | - @mock.patch("subprocess.call", side_effect=call_btmakemetafile_zsyncmake) |
214 | + @mock.patch("subprocess.call", side_effect=call_mktorrent_zsyncmake) |
215 | def test_publish_release_arch_ubuntu_desktop_no(self, mock_call, *args): |
216 | self.config["PROJECT"] = "ubuntu" |
217 | self.config["CAPPROJECT"] = "Ubuntu" |
218 | @@ -2512,7 +2512,7 @@ |
219 | self.assertFalse(os.path.islink("%s.iso" % target_base)) |
220 | self.assertFalse(os.path.islink("%s.manifest" % target_base)) |
221 | mock_call.assert_called_once_with([ |
222 | - "btmakemetafile", mock.ANY, |
223 | + "mktorrent", mock.ANY, mock.ANY, |
224 | "--comment", "Ubuntu CD cdimage.ubuntu.com", |
225 | "%s.iso" % target_base, |
226 | ], stdout=mock.ANY) |
227 | @@ -2527,7 +2527,7 @@ |
228 | os.stat("%s.iso.torrent" % torrent_base)) |
229 | |
230 | @mock.patch("cdimage.osextras.find_on_path", return_value=True) |
231 | - @mock.patch("subprocess.call", side_effect=call_btmakemetafile_zsyncmake) |
232 | + @mock.patch("subprocess.call", side_effect=call_mktorrent_zsyncmake) |
233 | def test_publish_release_kubuntu_desktop_named(self, mock_call, *args): |
234 | self.config["PROJECT"] = "kubuntu" |
235 | self.config["CAPPROJECT"] = "Kubuntu" |
236 | @@ -2685,10 +2685,9 @@ |
237 | publisher.make_torrents( |
238 | os.path.join(self.temp_dir, "dir"), "ubuntu-13.04") |
239 | command_base = [ |
240 | - "btmakemetafile", "https://torrent.ubuntu.com/announce", |
241 | - "--announce_list", |
242 | - ("https://torrent.ubuntu.com/announce|" |
243 | - "https://ipv6.torrent.ubuntu.com/announce"), |
244 | + "mktorrent", |
245 | + "-a", "https://torrent.ubuntu.com/announce", |
246 | + "-a", "https://ipv6.torrent.ubuntu.com/announce", |
247 | "--comment", "Ubuntu CD releases.ubuntu.com", |
248 | ] |
249 | mock_check_call.assert_has_calls([ |
250 | @@ -2708,7 +2707,7 @@ |
251 | self.get_publisher().publish_release_prefixes()) |
252 | |
253 | @mock.patch("cdimage.osextras.find_on_path", return_value=True) |
254 | - @mock.patch("subprocess.call", side_effect=call_btmakemetafile_zsyncmake) |
255 | + @mock.patch("subprocess.call", side_effect=call_mktorrent_zsyncmake) |
256 | def test_publish_release_arch_ubuntu_desktop_yes(self, mock_call, *args): |
257 | self.config["PROJECT"] = "ubuntu" |
258 | self.config["CAPPROJECT"] = "Ubuntu" |
259 | @@ -2766,8 +2765,9 @@ |
260 | "%s.iso" % pool_base, |
261 | ]), |
262 | mock.call([ |
263 | - "btmakemetafile", mock.ANY, |
264 | - "--announce_list", mock.ANY, |
265 | + "mktorrent", |
266 | + "-a", mock.ANY, |
267 | + "-a", mock.ANY, |
268 | "--comment", "Ubuntu CD releases.ubuntu.com", |
269 | "%s.iso" % target_base, |
270 | ], stdout=mock.ANY), |
271 | @@ -2785,7 +2785,7 @@ |
272 | os.stat("%s.iso.torrent" % torrent_base)) |
273 | |
274 | @mock.patch("cdimage.osextras.find_on_path", return_value=True) |
275 | - @mock.patch("subprocess.call", side_effect=call_btmakemetafile_zsyncmake) |
276 | + @mock.patch("subprocess.call", side_effect=call_mktorrent_zsyncmake) |
277 | def test_publish_release_arch_ubuntu_desktop_poolonly(self, mock_call, |
278 | *args): |
279 | self.config["PROJECT"] = "ubuntu" |
280 | @@ -2823,7 +2823,7 @@ |
281 | ]) |
282 | |
283 | @mock.patch("cdimage.osextras.find_on_path", return_value=True) |
284 | - @mock.patch("subprocess.call", side_effect=call_btmakemetafile_zsyncmake) |
285 | + @mock.patch("subprocess.call", side_effect=call_mktorrent_zsyncmake) |
286 | def test_publish_release_kubuntu_desktop_yes(self, mock_call, *args): |
287 | self.config["PROJECT"] = "kubuntu" |
288 | self.config["CAPPROJECT"] = "Kubuntu" |
289 | |
290 | === modified file 'lib/cdimage/tree.py' |
291 | --- lib/cdimage/tree.py 2020-06-19 00:57:47 +0000 |
292 | +++ lib/cdimage/tree.py 2020-06-29 11:27:35 +0000 |
293 | @@ -2971,15 +2971,9 @@ |
294 | if not self.dry_run: |
295 | logger.info("Creating torrent for %s ..." % path) |
296 | osextras.unlink_force("%s.torrent" % path) |
297 | - command = ["btmakemetafile", self.torrent_tracker] |
298 | + command = ["mktorrent", "-a", self.torrent_tracker] |
299 | if isinstance(self.tree, SimpleReleaseTree): |
300 | - # N.B.: Only the bittornado version of btmakemetafile has |
301 | - # the --announce_list flag. |
302 | - command.extend([ |
303 | - "--announce_list", |
304 | - "%s|%s" % ( |
305 | - self.torrent_tracker, self.ipv6_torrent_tracker), |
306 | - ]) |
307 | + command.extend(["-a", self.ipv6_torrent_tracker]) |
308 | command.extend([ |
309 | "--comment", |
310 | "%s CD %s" % (self.config.capproject, self.tree.site_name), |
This and https:/ /code.launchpad .net/~laney/ debian- cd/focal/ +merge/ 386316 depend on each other.