Call prepare() externally to the sysa and sysc classes

This keeps the prepartion and bootstrap initiation logic in the same
place for each bootstrap mode, and allows each mode to specify its
own requirements and expectations from the different bootstrap steps.
This commit is contained in:
Dor Askayo 2022-05-23 14:18:52 +03:00
parent a7c7ddf977
commit 6d357226a9
3 changed files with 20 additions and 8 deletions

View File

@ -109,10 +109,10 @@ def main():
pass
system_c = SysC(arch=args.arch, preserve_tmp=args.preserve,
tmpdir=args.tmpdir, chroot=args.chroot)
tmpdir=args.tmpdir)
system_b = SysB(arch=args.arch, preserve_tmp=args.preserve)
system_a = SysA(arch=args.arch, preserve_tmp=args.preserve,
tmpdir=args.tmpdir, chroot=args.chroot,
tmpdir=args.tmpdir,
sysb_dir=system_b.sys_dir, sysc_tmp=system_c.tmp_dir)
bootstrap(args, system_a, system_b, system_c)
@ -128,6 +128,10 @@ print(shutil.which('chroot'))
chroot_binary = run('sudo', 'python3', '-c', find_chroot,
capture_output=True).stdout.decode().strip()
system_c.prepare(create_disk_image=False)
system_a.prepare(copy_sysc=True,
create_initramfs=False)
# sysa
arch = stage0_arch_map.get(args.arch, args.arch)
init = os.path.join(os.sep, 'bootstrap-seeds', 'POSIX', arch, 'kaem-optional-seed')
@ -137,6 +141,10 @@ print(shutil.which('chroot'))
if os.path.isdir('kritis-linux'):
shutil.rmtree('kritis-linux')
system_c.prepare(create_disk_image=True)
system_a.prepare(copy_sysc=False,
create_initramfs=True)
run('git', 'clone',
'--depth', '1', '--branch', 'v0.7',
'https://github.com/bittorf/kritis-linux.git')
@ -154,11 +162,19 @@ print(shutil.which('chroot'))
'--log', '/tmp/bootstrap.log')
elif args.bare_metal:
system_c.prepare(create_disk_image=True)
system_a.prepare(copy_sysc=False,
create_initramfs=True)
print("Please:")
print(" 1. Take sysa/tmp/initramfs and your kernel, boot using this.")
print(" 2. Take sysc/tmp/disk.img and put this on a writable storage medium.")
else:
system_c.prepare(create_disk_image=True)
system_a.prepare(copy_sysc=False,
create_initramfs=True)
run(args.qemu_cmd,
'-enable-kvm',
'-m', str(args.qemu_ram) + 'M',

View File

@ -17,7 +17,7 @@ class SysA(SysGeneral):
Class responsible for preparing sources for System A.
"""
# pylint: disable=too-many-instance-attributes,too-many-arguments
def __init__(self, arch, preserve_tmp, tmpdir, chroot, sysb_dir, sysc_tmp):
def __init__(self, arch, preserve_tmp, tmpdir, sysb_dir, sysc_tmp):
self.git_dir = os.path.dirname(os.path.join(__file__))
self.arch = arch
self.preserve_tmp = preserve_tmp
@ -34,8 +34,6 @@ class SysA(SysGeneral):
self.sysb_dir = sysb_dir
self.sysc_tmp = sysc_tmp
self.prepare(chroot, not chroot)
def prepare(self, copy_sysc, create_initramfs):
"""
Prepare directory structure for System A.

View File

@ -20,7 +20,7 @@ class SysC(SysGeneral):
dev_name = None
# pylint: disable=too-many-instance-attributes
def __init__(self, arch, preserve_tmp, tmpdir, chroot):
def __init__(self, arch, preserve_tmp, tmpdir):
self.git_dir = os.path.dirname(os.path.join(__file__))
self.arch = arch
self.preserve_tmp = preserve_tmp
@ -33,8 +33,6 @@ class SysC(SysGeneral):
self.tmp_dir = os.path.join(tmpdir, 'sysc')
os.mkdir(self.tmp_dir)
self.prepare(not chroot)
def __del__(self):
if not self.preserve_tmp:
if self.dev_name is not None: