Move chroot transition script inside bootstrap.
This commit is contained in:
parent
35a7df58b7
commit
c6c8a1eb7f
15
rootfs.py
15
rootfs.py
|
@ -70,12 +70,13 @@ def main():
|
|||
|
||||
create_configuration_file(args)
|
||||
|
||||
system_c = SysC(arch=args.arch, preserve_tmp=args.preserve,
|
||||
tmpdir=args.tmpdir, chroot=args.chroot)
|
||||
system_b = SysB(arch=args.arch, preserve_tmp=args.preserve,
|
||||
tmpdir=args.tmpdir, chroot=args.chroot)
|
||||
system_a = SysA(arch=args.arch, preserve_tmp=args.preserve,
|
||||
tmpdir=args.tmpdir, chroot=args.chroot, sysb_tmp=system_b.tmp_dir)
|
||||
system_c = SysC(arch=args.arch, preserve_tmp=args.preserve,
|
||||
tmpdir=args.tmpdir, chroot=args.chroot)
|
||||
tmpdir=args.tmpdir, chroot=args.chroot,
|
||||
sysb_tmp=system_b.tmp_dir, sysc_tmp=system_c.tmp_dir)
|
||||
|
||||
bootstrap(args, system_a, system_b, system_c)
|
||||
|
||||
|
@ -92,14 +93,6 @@ print(shutil.which('chroot'))
|
|||
# sysa
|
||||
init = os.path.join(os.sep, 'bootstrap-seeds', 'POSIX', args.arch, 'kaem-optional-seed')
|
||||
run('sudo', 'env', '-i', 'PATH=/bin', chroot_binary, system_a.tmp_dir, init)
|
||||
# Perform the steps for sysa -> sysc transition that would occur within
|
||||
# qemu if we were running not in chroot
|
||||
# We skip sysb as that is only pertinent to "hardware" (not chroot)
|
||||
system_c.chroot_transition(system_a.tmp_dir)
|
||||
# sysc
|
||||
print(f"Bootstrapping {args.arch} -- SysC")
|
||||
init = os.path.join(os.sep, 'init')
|
||||
run('sudo', chroot_binary, system_c.tmp_dir, init)
|
||||
|
||||
elif args.minikernel:
|
||||
if os.path.isdir('kritis-linux'):
|
||||
|
|
12
sysa.py
12
sysa.py
|
@ -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_tmp):
|
||||
def __init__(self, arch, preserve_tmp, tmpdir, chroot, sysb_tmp, sysc_tmp):
|
||||
self.git_dir = os.path.dirname(os.path.join(__file__))
|
||||
self.arch = arch
|
||||
self.preserve_tmp = preserve_tmp
|
||||
|
@ -31,6 +31,8 @@ class SysA(SysGeneral):
|
|||
self.after_dir = os.path.join(self.tmp_dir, 'after')
|
||||
self.base_dir = self.after_dir
|
||||
self.sysb_tmp = sysb_tmp
|
||||
self.sysc_tmp = sysc_tmp
|
||||
self.chroot = chroot
|
||||
|
||||
self.prepare()
|
||||
|
||||
|
@ -52,11 +54,19 @@ class SysA(SysGeneral):
|
|||
# sysb must be added to sysa as it is another initramfs stage
|
||||
self.sysb()
|
||||
|
||||
if self.chroot:
|
||||
self.sysc()
|
||||
|
||||
def sysb(self):
|
||||
"""Copy in sysb files for sysb."""
|
||||
shutil.copytree(self.sysb_tmp, os.path.join(self.tmp_dir, 'sysb'),
|
||||
shutil.ignore_patterns('tmp'))
|
||||
|
||||
def sysc(self):
|
||||
"""Copy in sysc files for sysc."""
|
||||
shutil.copytree(self.sysc_tmp, os.path.join(self.tmp_dir, 'sysc'),
|
||||
shutil.ignore_patterns('tmp'))
|
||||
|
||||
def stage0_posix(self):
|
||||
"""Copy in all of the stage0-posix"""
|
||||
stage0_posix_base_dir = os.path.join(self.sys_dir, 'stage0-posix', 'src')
|
||||
|
|
|
@ -180,3 +180,8 @@ if [ "${CHROOT}" = False ]; then
|
|||
|
||||
go_sysb
|
||||
fi
|
||||
|
||||
# In chroot mode transition directly into System C.
|
||||
SYSC="/sysc"
|
||||
cp -R "${PREFIX}" "${SYSC}"
|
||||
exec chroot "${SYSC}" /init
|
||||
|
|
15
sysc.py
15
sysc.py
|
@ -73,21 +73,6 @@ class SysC(SysGeneral):
|
|||
if not self.chroot:
|
||||
umount(self.rootfs_dir)
|
||||
|
||||
def chroot_transition(self, original):
|
||||
"""
|
||||
For chroot, transition sysa -> sysc
|
||||
See create_sysc in sysb/run.sh
|
||||
We skip sysb when using chroot, as sysb is entirely irrelevant
|
||||
to chrooting (only for kernel shenanigans)
|
||||
Copy directories from /usr (sysa) -> /usr (sysc)
|
||||
"""
|
||||
run('sudo', 'chown', '-R', getpass.getuser(), original)
|
||||
run('sudo', 'chown', '-R', getpass.getuser(), self.rootfs_dir)
|
||||
shutil.copytree(os.path.join(original, 'usr'),
|
||||
os.path.join(self.rootfs_dir, 'usr'),
|
||||
ignore=shutil.ignore_patterns("src"),
|
||||
dirs_exist_ok=True, symlinks=True)
|
||||
|
||||
def deploy_scripts(self):
|
||||
"""Add the scripts to the chroot"""
|
||||
src_files = ['run.sh', 'run2.sh']
|
||||
|
|
Loading…
Reference in New Issue