diff --git a/tools/boot-image/grub.cfg b/tools/boot-image/grub.cfg new file mode 100644 index 0000000..f6e77ae --- /dev/null +++ b/tools/boot-image/grub.cfg @@ -0,0 +1,4 @@ +menuentry "Socks Kernel" { + multiboot /boot/socks_kernel + boot +} diff --git a/tools/socks.mkrescue b/tools/socks.mkrescue new file mode 100755 index 0000000..c665c36 --- /dev/null +++ b/tools/socks.mkrescue @@ -0,0 +1,39 @@ +#!/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])