
From: Simon Glass <sjg@chromium.org> Both scripts allow booting from an ISO containing an OS, so move this handling into the common helper. Signed-off-by: Simon Glass <sjg@chromium.org> --- scripts/build-efi | 11 ----------- scripts/build-qemu | 12 ------------ scripts/build_helper.py | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/scripts/build-efi b/scripts/build-efi index 5dc58f1512e..0ec1e63c950 100755 --- a/scripts/build-efi +++ b/scripts/build-efi @@ -113,17 +113,6 @@ class BuildEfi: if self.args.kvm: extra.extend(['-enable-kvm', '-cpu', 'host']) - os_path = None - if self.args.os == 'ubuntu': - img_name = f'{self.args.os}-{self.args.release}-desktop-{self.helper.os_arch}.iso' - os_path = self.imagedir / self.args.os / img_name - if not os_path.exists(): - tout.error(f'OS image {os_path} specified but not found') - else: - extra.extend([ - '-drive', - f'if=virtio,file={os_path},format=raw,id=hd0,readonly=on']) - img_fname = Path(self.args.disk) if self.args.disk else None if img_fname: if img_fname.exists(): diff --git a/scripts/build-qemu b/scripts/build-qemu index ac077203e39..a6676eca350 100755 --- a/scripts/build-qemu +++ b/scripts/build-qemu @@ -69,7 +69,6 @@ class BuildQemu: self.helper = build_helper.Helper(args) self.helper.read_settings() - self.imagedir = Path(self.helper.get_setting('image_dir', '~/dev')) self.ubdir = Path(self.helper.get_setting('build_dir', '/tmp/b')) self.sctdir = Path(self.helper.get_setting('sct_dir', '~/dev/efi/sct')) self.tiano = Path(self.helper.get_setting('tianocore_dir', @@ -159,11 +158,6 @@ class BuildQemu: else: raise ValueError(f"Invalid arch '{args.arch}'") - self.os_path = None - if args.os == 'ubuntu': - img_name = (f'{args.os}-{args.release}-desktop-{self.helper.os_arch}.iso') - self.os_path = self.imagedir / args.os / img_name - self.build_dir = self.ubdir / self.board self.bios = (bios_override if bios_override else self.build_dir / default_bios) @@ -289,12 +283,6 @@ class BuildQemu: # Add other parameters gathered from options qemu_cmd.extend(self.qemu_extra) - if self.os_path: - if not self.os_path.exists(): - tout.error(f'OS image {self.os_path} specified but not found') - qemu_cmd.extend([ - '-drive', - f'if=virtio,file={self.os_path},format=raw,id=hd0,readonly=on']) if self.img_fname: if self.img_fname.exists(): diff --git a/scripts/build_helper.py b/scripts/build_helper.py index d00ccb86328..09fac2d2335 100644 --- a/scripts/build_helper.py +++ b/scripts/build_helper.py @@ -7,6 +7,7 @@ import configparser import contextlib import os +from pathlib import Path import shutil import subprocess import sys @@ -22,6 +23,7 @@ sys.path.insert(2, os.path.join(OUR1_PATH, 'test/py/tests')) from u_boot_pylib import command from u_boot_pylib import tools +from u_boot_pylib import tout import fs_helper @@ -75,6 +77,7 @@ sct_dir = ~/dev/efi/sct sct_mnt = /mnt/sct ''', binary=False) self.settings.read(fname) + self.imagedir = Path(self.get_setting('image_dir', '~/dev')) def get_setting(self, name, fallback=None): """Get a setting by name @@ -146,6 +149,17 @@ sct_mnt = /mnt/sct if cmdline: cmd.extend(['-append'] + [' '.join(cmdline)]) + os_path = None + if args.os == 'ubuntu': + img_name = f'{args.os}-{args.release}-desktop-{self.os_arch}.iso' + os_path = self.imagedir / args.os / img_name + if not os_path.exists(): + tout.error(f'OS image {os_path} specified but not found') + else: + cmd.extend([ + '-drive', + f'if=virtio,file={os_path},format=raw,id=hd0,readonly=on']) + def add_common_args(parser): """Add some arguments which are common to build-efi/qemu scripts -- 2.43.0