40 lines
1.1 KiB
Python
Executable File
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', 'socks_kernel')
|
|
grub_cfg_src_path = os.path.join('tools', 'boot-image', 'grub.cfg')
|
|
iso_build_dir = os.path.join('build', 'socks-kernel.iso-build')
|
|
iso_path = os.path.join('build', 'socks-kernel.iso')
|
|
|
|
|
|
def in_source_tree():
|
|
return os.path.isfile('tools/socks.sync')
|
|
|
|
|
|
if not in_source_tree():
|
|
print('This script must be executed from the root of the Socks source tree')
|
|
exit(-1)
|
|
|
|
if not os.path.isdir('build'):
|
|
print('Please build the Socks 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', 'socks_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])
|