Skip to content

Commit 0e417cb

Browse files
aero.py: download prebuilt OVMF for aarch64
Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
1 parent 31f9154 commit 0e417cb

File tree

1 file changed

+20
-38
lines changed

1 file changed

+20
-38
lines changed

aero.py

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,32 @@
2929
from typing import List
3030

3131

32+
def log_info(msg):
33+
"""
34+
Logs a message with info log level.
35+
"""
36+
print(f"\033[1m\033[92minfo\033[0m: {msg}")
37+
38+
39+
def log_error(msg):
40+
"""
41+
Logs a message with error log level.
42+
"""
43+
print(f"\033[1m\033[91merror\033[0m: {msg}")
44+
45+
3246
# Make sure requests is installed
3347
try:
3448
import requests
3549
import xbstrap
3650
except ImportError:
37-
print('Please install required libraires using the following command:')
38-
print(' - python3 -m pip install requests xbstrap')
51+
log_error('Please install required libraires using the following command:')
52+
log_error(' - python3 -m pip install requests xbstrap')
3953

4054
sys.exit(0)
4155

42-
import requests
43-
import xbstrap
44-
4556

46-
OVMF_URL = 'https://github.com/rust-osdev/ovmf-prebuilt/releases/latest/download'
57+
OVMF_URL = 'https://github.com/aero-os/ovmf-prebuilt'
4758
LIMINE_URL = 'https://github.com/limine-bootloader/limine'
4859

4960
BUILD_DIR = 'build'
@@ -52,7 +63,6 @@
5263
EXTRA_FILES = 'extra-files'
5364
SYSROOT_CARGO_HOME = os.path.join(SYSROOT_DIR, 'cargo-home')
5465
BASE_FILES_DIR = 'base-files'
55-
OVMF_FILES = ['OVMF-pure-efi.fd']
5666

5767
LIMINE_TEMPLATE = """
5868
TIMEOUT=0
@@ -81,20 +91,6 @@ def __init__(self, target_arch: str, args: argparse.Namespace):
8191
self.args = args
8292

8393

84-
def log_info(msg):
85-
"""
86-
Logs a message with info log level.
87-
"""
88-
print(f"\033[1m\033[92minfo\033[0m: {msg}")
89-
90-
91-
def log_error(msg):
92-
"""
93-
Logs a message with error log level.
94-
"""
95-
print(f"\033[1m\033[91merror\033[0m: {msg}")
96-
97-
9894
def download_userland_host_rust():
9995
out_file = os.path.join(BUNDLED_DIR, "host-rust-prebuilt.tar.gz")
10096

@@ -235,16 +231,7 @@ def download_bundled():
235231
limine_path = os.path.join(BUNDLED_DIR, 'limine')
236232

237233
if not os.path.exists(ovmf_path):
238-
os.makedirs(ovmf_path)
239-
240-
for ovmf_file in OVMF_FILES:
241-
file_path = os.path.join(ovmf_path, ovmf_file)
242-
243-
if not os.path.exists(file_path):
244-
with open(file_path, 'wb') as file:
245-
response = requests.get(f'{OVMF_URL}/{ovmf_file}')
246-
247-
file.write(response.content)
234+
run_command(['git', 'clone', '--depth', '1', OVMF_URL, ovmf_path])
248235

249236
if not os.path.exists(limine_path):
250237
run_command(['git', 'clone', '--branch', 'v4.x-branch-binary',
@@ -536,13 +523,8 @@ def run_in_emulator(build_info: BuildInfo, iso_path):
536523
'-serial', 'stdio']
537524

538525
if args.bios == 'uefi':
539-
if build_info.target_arch == "aarch64":
540-
qemu_args += ['-bios', 'bundled/ovmf/OVMF.fd']
541-
elif build_info.target_arch == "x86_64":
542-
qemu_args += ['-bios', 'bundled/ovmf/OVMF-pure-efi.fd']
543-
else:
544-
log_error("unknown target architecture")
545-
exit(1)
526+
qemu_args += ['-bios',
527+
f'bundled/ovmf/ovmf-{build_info.target_arch}/OVMF.fd']
546528

547529
cmdline = args.remaining
548530

0 commit comments

Comments
 (0)