Files
mango/tools/mango.mkrescue
2024-11-02 11:31:51 +00:00

40 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
# vim: ft=python
# -*- mode: python -*-
import subprocess
import sys
import os
import shutil
kernel_src_path = os.path.join('build', 'mango_kernel')
grub_cfg_src_path = os.path.join('tools', 'boot-image', 'grub.cfg')
iso_build_dir = os.path.join('build', 'mango-kernel.iso-build')
iso_path = os.path.join('build', 'mango-kernel.iso')
def in_source_tree():
return os.path.isfile('tools/mango.sync')
if not in_source_tree():
print('This script must be executed from the root of the Mango source tree')
exit(-1)
if not os.path.isdir('build'):
print('Please build the Mango kernel before using this tool')
exit(-1)
if os.path.isdir(iso_build_dir):
shutil.rmtree(iso_build_dir)
os.mkdir(iso_build_dir)
os.mkdir(os.path.join(iso_build_dir, 'boot'))
os.mkdir(os.path.join(iso_build_dir, 'boot', 'grub'))
shutil.copyfile(kernel_src_path, os.path.join(iso_build_dir, 'boot', 'mango_kernel'))
shutil.copyfile(grub_cfg_src_path, os.path.join(iso_build_dir, 'boot', 'grub', 'grub.cfg'))
subprocess.run(['grub-mkrescue', '-o', iso_path, iso_build_dir])