commit: d5d234225ee0afc36e560154af9e53c7a248f2af
parent ce5fff784cc426b381bff8aa8c74ac8501e32f68
Author: fosslinux <fosslinux@aussies.space>
Date: Mon, 11 Oct 2021 08:39:55 +1100
Merge pull request #138 from stikonas/chroot
Chroot
Diffstat:
7 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/rootfs.py b/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'):
diff --git a/sysa.py b/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')
diff --git a/sysa/coreutils-5.0/checksums/pass2 b/sysa/coreutils-5.0/checksums/pass2
@@ -1,6 +1,7 @@
fafa676fe85f662f753bb5257ba6575086c6d4d7b8b27a952624db08e136b1ac /usr/bin/basename
8b4e2b1ea346298b6534894e85cfa3ac4ee9bd1900da1d044a45c366d143dbf0 /usr/bin/cat
24b11f735c4dcbd28e0defcef6208f419ebb3a7f33a5f7addb41d7df9e021bc1 /usr/bin/chmod
+e19bd087a5e70f9319a81eae9d38513df68fb69769ca49e3f135f45d8b29c0e9 /usr/bin/chroot
8dd096b3a2973c4e3652e6bfffc30d2d85e8cb9b7f6cbbb2079cdb00a465589f /usr/bin/cksum
6e9c29ae39dc9cc13925fe4066ab1867d0623bc704b2b1be6e242dc27b6c8ea1 /usr/bin/cp
220ee0e1e19ad52403794872fd879619c25e2bf6b22d9616799250f76f8b9960 /usr/bin/csplit
diff --git a/sysa/coreutils-5.0/mk/pass2.mk b/sysa/coreutils-5.0/mk/pass2.mk
@@ -83,7 +83,7 @@ CFLAGS = -I . -I lib \
SRC_DIR=src
-COREUTILS = basename cat chmod cksum comm csplit cut dd dirname echo env expand expr factor false fmt fold head id join kill link ln logname mkfifo mkdir mknod nl od paste pathchk printf ptx pwd readlink rmdir seq sleep sort split sum sync tail tee tr tsort uname unexpand uniq unlink wc whoami test true yes
+COREUTILS = basename cat chmod chroot cksum comm csplit cut dd dirname echo env expand expr factor false fmt fold head id join kill link ln logname mkfifo mkdir mknod nl od paste pathchk printf ptx pwd readlink rmdir seq sleep sort split sum sync tail tee tr tsort uname unexpand uniq unlink wc whoami test true yes
BINARIES = $(addprefix $(SRC_DIR)/, $(COREUTILS))
diff --git a/sysa/run.sh b/sysa/run.sh
@@ -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
diff --git a/sysc.py b/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']
diff --git a/sysc/init b/sysc/init
@@ -8,4 +8,4 @@ set -e
# Begin sysc bootstrapping process
cd /usr/src
-./run.sh
+exec ./run.sh