Unhardcode x86 from initial steps.
This commit is contained in:
parent
5148a8e0da
commit
32ec57d62d
|
@ -165,3 +165,7 @@ class SysGeneral:
|
||||||
"--directory", self.tmp_dir],
|
"--directory", self.tmp_dir],
|
||||||
stdin=subprocess.PIPE, stdout=initramfs)
|
stdin=subprocess.PIPE, stdout=initramfs)
|
||||||
cpio.communicate(input='\n'.join(file_list).encode())
|
cpio.communicate(input='\n'.join(file_list).encode())
|
||||||
|
|
||||||
|
stage0_arch_map = {
|
||||||
|
"amd64": "AMD64",
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ from sysa import SysA
|
||||||
from sysb import SysB
|
from sysb import SysB
|
||||||
from sysc import SysC
|
from sysc import SysC
|
||||||
from lib.utils import run
|
from lib.utils import run
|
||||||
|
from lib.sysgeneral import stage0_arch_map
|
||||||
|
|
||||||
def create_configuration_file(args):
|
def create_configuration_file(args):
|
||||||
"""
|
"""
|
||||||
|
@ -123,8 +124,10 @@ print(shutil.which('chroot'))
|
||||||
"""
|
"""
|
||||||
chroot_binary = run('sudo', 'python3', '-c', find_chroot,
|
chroot_binary = run('sudo', 'python3', '-c', find_chroot,
|
||||||
capture_output=True).stdout.decode().strip()
|
capture_output=True).stdout.decode().strip()
|
||||||
|
|
||||||
# sysa
|
# sysa
|
||||||
init = os.path.join(os.sep, 'bootstrap-seeds', 'POSIX', args.arch, 'kaem-optional-seed')
|
arch = stage0_arch_map.get(args.arch, args.arch)
|
||||||
|
init = os.path.join(os.sep, 'bootstrap-seeds', 'POSIX', arch, 'kaem-optional-seed')
|
||||||
run('sudo', 'env', '-i', 'PATH=/bin', chroot_binary, system_a.tmp_dir, init)
|
run('sudo', 'env', '-i', 'PATH=/bin', chroot_binary, system_a.tmp_dir, init)
|
||||||
|
|
||||||
elif args.minikernel:
|
elif args.minikernel:
|
||||||
|
|
10
sysa.py
10
sysa.py
|
@ -9,7 +9,7 @@ import os
|
||||||
from distutils.dir_util import copy_tree
|
from distutils.dir_util import copy_tree
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from lib.sysgeneral import SysGeneral
|
from lib.sysgeneral import SysGeneral, stage0_arch_map
|
||||||
|
|
||||||
# pylint: disable=consider-using-with
|
# pylint: disable=consider-using-with
|
||||||
class SysA(SysGeneral):
|
class SysA(SysGeneral):
|
||||||
|
@ -72,14 +72,18 @@ class SysA(SysGeneral):
|
||||||
stage0_posix_base_dir = os.path.join(self.sys_dir, 'stage0-posix', 'src')
|
stage0_posix_base_dir = os.path.join(self.sys_dir, 'stage0-posix', 'src')
|
||||||
copy_tree(stage0_posix_base_dir, self.tmp_dir)
|
copy_tree(stage0_posix_base_dir, self.tmp_dir)
|
||||||
|
|
||||||
|
arch = stage0_arch_map.get(self.arch, self.arch)
|
||||||
kaem_optional_seed = os.path.join(self.sys_dir, 'stage0-posix', 'src', 'bootstrap-seeds',
|
kaem_optional_seed = os.path.join(self.sys_dir, 'stage0-posix', 'src', 'bootstrap-seeds',
|
||||||
'POSIX', self.arch, 'kaem-optional-seed')
|
'POSIX', arch, 'kaem-optional-seed')
|
||||||
shutil.copy2(kaem_optional_seed, os.path.join(self.tmp_dir, 'init'))
|
shutil.copy2(kaem_optional_seed, os.path.join(self.tmp_dir, 'init'))
|
||||||
|
|
||||||
# stage0-posix hook to continue running live-bootstrap
|
# stage0-posix hook to continue running live-bootstrap
|
||||||
shutil.copy2(os.path.join(self.sys_dir, 'after.kaem'),
|
shutil.copy2(os.path.join(self.sys_dir, f"after.kaem.{self.arch}"),
|
||||||
os.path.join(self.tmp_dir, 'after.kaem'))
|
os.path.join(self.tmp_dir, 'after.kaem'))
|
||||||
|
|
||||||
|
shutil.copy2(os.path.join(self.sys_dir, 'run.kaem'),
|
||||||
|
os.path.join(self.tmp_dir, 'run.kaem'))
|
||||||
|
|
||||||
def after(self):
|
def after(self):
|
||||||
"""
|
"""
|
||||||
Prepare sources in /after directory.
|
Prepare sources in /after directory.
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
ARCH=amd64
|
||||||
|
STAGE0_ARCH=AMD64
|
||||||
|
exec /${STAGE0_ARCH}/bin/kaem --verbose --file run.kaem
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
ARCH=x86
|
||||||
|
STAGE0_ARCH=x86
|
||||||
|
exec /${ARCH}/bin/kaem --verbose --file run.kaem
|
|
@ -8,9 +8,7 @@
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
ARCH=x86
|
PATH=/${STAGE0_ARCH}/bin
|
||||||
|
|
||||||
PATH=/${ARCH}/bin
|
|
||||||
|
|
||||||
# Set commonly used variables
|
# Set commonly used variables
|
||||||
sources=/after
|
sources=/after
|
||||||
|
@ -29,20 +27,20 @@ mkdir ${prefix} ${bindir} ${libdir} ${incdir} ${tmpdir}
|
||||||
cd ${prefix}
|
cd ${prefix}
|
||||||
|
|
||||||
# Remove remaining dependencies on /bin (stage0-posix directory)
|
# Remove remaining dependencies on /bin (stage0-posix directory)
|
||||||
cp /${ARCH}/bin/blood-elf bin/blood-elf
|
cp /${STAGE0_ARCH}/bin/blood-elf bin/blood-elf
|
||||||
cp /${ARCH}/bin/catm bin/catm
|
cp /${STAGE0_ARCH}/bin/catm bin/catm
|
||||||
cp /${ARCH}/bin/chmod bin/chmod
|
cp /${STAGE0_ARCH}/bin/chmod bin/chmod
|
||||||
cp /${ARCH}/bin/get_machine bin/get_machine
|
cp /${STAGE0_ARCH}/bin/get_machine bin/get_machine
|
||||||
cp /${ARCH}/bin/hex2 bin/hex2
|
cp /${STAGE0_ARCH}/bin/hex2 bin/hex2
|
||||||
cp /${ARCH}/bin/kaem bin/kaem
|
cp /${STAGE0_ARCH}/bin/kaem bin/kaem
|
||||||
cp /${ARCH}/bin/match bin/match
|
cp /${STAGE0_ARCH}/bin/match bin/match
|
||||||
cp /${ARCH}/bin/M1 bin/M1
|
cp /${STAGE0_ARCH}/bin/M1 bin/M1
|
||||||
cp /${ARCH}/bin/M2-Planet bin/M2-Planet
|
cp /${STAGE0_ARCH}/bin/M2-Planet bin/M2-Planet
|
||||||
cp /${ARCH}/bin/mkdir bin/mkdir
|
cp /${STAGE0_ARCH}/bin/mkdir bin/mkdir
|
||||||
cp /${ARCH}/bin/sha256sum bin/sha256sum
|
cp /${STAGE0_ARCH}/bin/sha256sum bin/sha256sum
|
||||||
cp /${ARCH}/bin/ungz bin/ungz
|
cp /${STAGE0_ARCH}/bin/ungz bin/ungz
|
||||||
cp /${ARCH}/bin/untar bin/untar
|
cp /${STAGE0_ARCH}/bin/untar bin/untar
|
||||||
cp /${ARCH}/bin/cp bin/cp
|
cp /${STAGE0_ARCH}/bin/cp bin/cp
|
||||||
|
|
||||||
chmod 755 bin/blood-elf
|
chmod 755 bin/blood-elf
|
||||||
chmod 755 bin/catm
|
chmod 755 bin/catm
|
Loading…
Reference in New Issue