|
12 | 12 | import fcntl |
13 | 13 | import glob |
14 | 14 | import hashlib |
| 15 | +import io |
15 | 16 | import json |
16 | 17 | import os |
17 | 18 | import platform |
@@ -276,27 +277,60 @@ def start(self): |
276 | 277 | stderr=self.subprocess_output(), |
277 | 278 | ) |
278 | 279 |
|
279 | | - # Start emulator |
280 | | - self.log_info("Starting emulator...") |
281 | | - product_bundle = "terminal.qemu-" + self.triple_to_arch(self.target) |
| 280 | + # Look up the product bundle transfer manifest. |
| 281 | + self.log_info("Looking up the product bundle transfer manifest...") |
| 282 | + product_name = "minimal." + self.triple_to_arch(self.target) |
| 283 | + fuchsia_version = "14.20230811.2.1" |
| 284 | + |
| 285 | + # FIXME: We should be able to replace this with the machine parsable |
| 286 | + # `ffx --machine json product lookup ...` once F15 is released. |
| 287 | + out = subprocess.check_output( |
| 288 | + [ |
| 289 | + ffx_path, |
| 290 | + "product", |
| 291 | + "lookup", |
| 292 | + product_name, |
| 293 | + fuchsia_version, |
| 294 | + "--base-url", |
| 295 | + "gs://fuchsia/development/" + fuchsia_version, |
| 296 | + ], |
| 297 | + env=ffx_env, |
| 298 | + stderr=self.subprocess_output(), |
| 299 | + ) |
| 300 | + |
| 301 | + self.log_debug(out) |
| 302 | + |
| 303 | + for line in io.BytesIO(out): |
| 304 | + if line.startswith(b"gs://"): |
| 305 | + transfer_manifest_url = line.rstrip() |
| 306 | + break |
| 307 | + else: |
| 308 | + raise Exception("Unable to parse transfer manifest") |
| 309 | + |
| 310 | + # Download the product bundle. |
| 311 | + product_bundle_dir = os.path.join(self.tmp_dir(), 'product-bundle') |
282 | 312 | subprocess.check_call( |
283 | 313 | [ |
284 | 314 | ffx_path, |
285 | | - "product-bundle", |
286 | | - "get", |
287 | | - product_bundle, |
| 315 | + "product", |
| 316 | + "download", |
| 317 | + transfer_manifest_url, |
| 318 | + product_bundle_dir, |
| 319 | + "--force", |
288 | 320 | ], |
289 | 321 | env=ffx_env, |
290 | 322 | stdout=self.subprocess_output(), |
291 | 323 | stderr=self.subprocess_output(), |
292 | 324 | ) |
| 325 | + |
| 326 | + # Start emulator |
293 | 327 | # FIXME: condition --accel hyper on target arch matching host arch |
294 | 328 | subprocess.check_call( |
295 | 329 | [ |
296 | 330 | ffx_path, |
297 | 331 | "emu", |
298 | 332 | "start", |
299 | | - product_bundle, |
| 333 | + product_bundle_dir, |
300 | 334 | "--headless", |
301 | 335 | "--log", |
302 | 336 | self.emulator_log_path(), |
|
0 commit comments