commit: 32ec57d62ddf533bfb713b5223bafc94ad1defb0
parent 5148a8e0dafd6dbd6107fdc8a8d15158405f68b0
Author: Andrius Štikonas <andrius@stikonas.eu>
Date: Wed, 20 Oct 2021 21:11:48 +0100
Unhardcode x86 from initial steps.
Diffstat:
7 files changed, 171 insertions(+), 144 deletions(-)
diff --git a/lib/sysgeneral.py b/lib/sysgeneral.py
@@ -165,3 +165,7 @@ class SysGeneral:
"--directory", self.tmp_dir],
stdin=subprocess.PIPE, stdout=initramfs)
cpio.communicate(input='\n'.join(file_list).encode())
+
+stage0_arch_map = {
+ "amd64": "AMD64",
+}
diff --git a/rootfs.py b/rootfs.py
@@ -20,6 +20,7 @@ from sysa import SysA
from sysb import SysB
from sysc import SysC
from lib.utils import run
+from lib.sysgeneral import stage0_arch_map
def create_configuration_file(args):
"""
@@ -123,8 +124,10 @@ print(shutil.which('chroot'))
"""
chroot_binary = run('sudo', 'python3', '-c', find_chroot,
capture_output=True).stdout.decode().strip()
+
# 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)
elif args.minikernel:
diff --git a/sysa.py b/sysa.py
@@ -9,7 +9,7 @@ import os
from distutils.dir_util import copy_tree
import shutil
-from lib.sysgeneral import SysGeneral
+from lib.sysgeneral import SysGeneral, stage0_arch_map
# pylint: disable=consider-using-with
class SysA(SysGeneral):
@@ -72,14 +72,18 @@ class SysA(SysGeneral):
stage0_posix_base_dir = os.path.join(self.sys_dir, 'stage0-posix', 'src')
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',
- 'POSIX', self.arch, 'kaem-optional-seed')
+ 'POSIX', arch, 'kaem-optional-seed')
shutil.copy2(kaem_optional_seed, os.path.join(self.tmp_dir, 'init'))
# 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'))
+ shutil.copy2(os.path.join(self.sys_dir, 'run.kaem'),
+ os.path.join(self.tmp_dir, 'run.kaem'))
+
def after(self):
"""
Prepare sources in /after directory.
diff --git a/sysa/after.kaem b/sysa/after.kaem
@@ -1,140 +0,0 @@
-#!/bin/sh
-
-# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
-# SPDX-FileCopyrightText: 2021 Paul Dersey <pdersey@gmail.com>
-# SPDX-FileCopyrightText: 2020-2021 fosslinux <fosslinux@aussies.space>
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-
-set -ex
-
-ARCH=x86
-
-PATH=/${ARCH}/bin
-
-# Set commonly used variables
-sources=/after
-prefix=/usr
-bindir=${prefix}/bin
-libdir=${prefix}/lib
-incdir=${prefix}/include
-tmpdir=/tmp # tmpdir is needed for patch to work
-
-# Environmental variables needed for mes
-NYACC_PKG=nyacc-1.00.2
-MES_PKG=mes
-MES_PREFIX=${sources}/${MES_PKG}/src/mes-m2-7fa2f99bf9bba2d79bd9d15c579be8905520d960
-GUILE_LOAD_PATH=${MES_PREFIX}/mes/module:${MES_PREFIX}/module:${sources}/${MES_PKG}/src/${NYACC_PKG}/module
-mkdir ${prefix} ${bindir} ${libdir} ${incdir} ${tmpdir}
-cd ${prefix}
-
-# Remove remaining dependencies on /bin (stage0-posix directory)
-cp /${ARCH}/bin/blood-elf bin/blood-elf
-cp /${ARCH}/bin/catm bin/catm
-cp /${ARCH}/bin/chmod bin/chmod
-cp /${ARCH}/bin/get_machine bin/get_machine
-cp /${ARCH}/bin/hex2 bin/hex2
-cp /${ARCH}/bin/kaem bin/kaem
-cp /${ARCH}/bin/match bin/match
-cp /${ARCH}/bin/M1 bin/M1
-cp /${ARCH}/bin/M2-Planet bin/M2-Planet
-cp /${ARCH}/bin/mkdir bin/mkdir
-cp /${ARCH}/bin/sha256sum bin/sha256sum
-cp /${ARCH}/bin/ungz bin/ungz
-cp /${ARCH}/bin/untar bin/untar
-cp /${ARCH}/bin/cp bin/cp
-
-chmod 755 bin/blood-elf
-chmod 755 bin/catm
-chmod 755 bin/chmod
-chmod 755 bin/cp
-chmod 755 bin/get_machine
-chmod 755 bin/hex2
-chmod 755 bin/kaem
-chmod 755 bin/match
-chmod 755 bin/M1
-chmod 755 bin/M2-Planet
-chmod 755 bin/mkdir
-chmod 755 bin/sha256sum
-chmod 755 bin/ungz
-chmod 755 bin/untar
-
-PATH=${bindir}
-
-cd ${sources}
-
-# mes
-pkg=${MES_PKG}
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ${sources}
-
-# tcc 0.9.26
-pkg="tcc-0.9.26"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-libdir=${libdir}/mes
-
-# gzip
-pkg="gzip-1.2.4"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-# tar
-pkg="tar-1.12"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-# sed
-pkg="sed-4.0.9"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-# patch
-pkg="patch-2.5.9"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-# make
-pkg="make-3.80"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-# bzip2
-pkg="bzip2-1.0.8"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-# tcc 0.9.27
-pkg="tcc-0.9.27"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-# coreutils
-pkg="coreutils-5.0"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-# heirloom-devtools
-pkg="heirloom-devtools-070527"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-# bash
-pkg="bash-2.05b"
-cd ${pkg}
-kaem --file ${pkg}.kaem
-cd ..
-
-exec bash run.sh
diff --git a/sysa/after.kaem.amd64 b/sysa/after.kaem.amd64
@@ -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
diff --git a/sysa/after.kaem.x86 b/sysa/after.kaem.x86
@@ -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
diff --git a/sysa/run.kaem b/sysa/run.kaem
@@ -0,0 +1,138 @@
+#!/bin/sh
+
+# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
+# SPDX-FileCopyrightText: 2021 Paul Dersey <pdersey@gmail.com>
+# SPDX-FileCopyrightText: 2020-2021 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+set -ex
+
+PATH=/${STAGE0_ARCH}/bin
+
+# Set commonly used variables
+sources=/after
+prefix=/usr
+bindir=${prefix}/bin
+libdir=${prefix}/lib
+incdir=${prefix}/include
+tmpdir=/tmp # tmpdir is needed for patch to work
+
+# Environmental variables needed for mes
+NYACC_PKG=nyacc-1.00.2
+MES_PKG=mes
+MES_PREFIX=${sources}/${MES_PKG}/src/mes-m2-7fa2f99bf9bba2d79bd9d15c579be8905520d960
+GUILE_LOAD_PATH=${MES_PREFIX}/mes/module:${MES_PREFIX}/module:${sources}/${MES_PKG}/src/${NYACC_PKG}/module
+mkdir ${prefix} ${bindir} ${libdir} ${incdir} ${tmpdir}
+cd ${prefix}
+
+# Remove remaining dependencies on /bin (stage0-posix directory)
+cp /${STAGE0_ARCH}/bin/blood-elf bin/blood-elf
+cp /${STAGE0_ARCH}/bin/catm bin/catm
+cp /${STAGE0_ARCH}/bin/chmod bin/chmod
+cp /${STAGE0_ARCH}/bin/get_machine bin/get_machine
+cp /${STAGE0_ARCH}/bin/hex2 bin/hex2
+cp /${STAGE0_ARCH}/bin/kaem bin/kaem
+cp /${STAGE0_ARCH}/bin/match bin/match
+cp /${STAGE0_ARCH}/bin/M1 bin/M1
+cp /${STAGE0_ARCH}/bin/M2-Planet bin/M2-Planet
+cp /${STAGE0_ARCH}/bin/mkdir bin/mkdir
+cp /${STAGE0_ARCH}/bin/sha256sum bin/sha256sum
+cp /${STAGE0_ARCH}/bin/ungz bin/ungz
+cp /${STAGE0_ARCH}/bin/untar bin/untar
+cp /${STAGE0_ARCH}/bin/cp bin/cp
+
+chmod 755 bin/blood-elf
+chmod 755 bin/catm
+chmod 755 bin/chmod
+chmod 755 bin/cp
+chmod 755 bin/get_machine
+chmod 755 bin/hex2
+chmod 755 bin/kaem
+chmod 755 bin/match
+chmod 755 bin/M1
+chmod 755 bin/M2-Planet
+chmod 755 bin/mkdir
+chmod 755 bin/sha256sum
+chmod 755 bin/ungz
+chmod 755 bin/untar
+
+PATH=${bindir}
+
+cd ${sources}
+
+# mes
+pkg=${MES_PKG}
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ${sources}
+
+# tcc 0.9.26
+pkg="tcc-0.9.26"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+libdir=${libdir}/mes
+
+# gzip
+pkg="gzip-1.2.4"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+# tar
+pkg="tar-1.12"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+# sed
+pkg="sed-4.0.9"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+# patch
+pkg="patch-2.5.9"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+# make
+pkg="make-3.80"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+# bzip2
+pkg="bzip2-1.0.8"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+# tcc 0.9.27
+pkg="tcc-0.9.27"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+# coreutils
+pkg="coreutils-5.0"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+# heirloom-devtools
+pkg="heirloom-devtools-070527"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+# bash
+pkg="bash-2.05b"
+cd ${pkg}
+kaem --file ${pkg}.kaem
+cd ..
+
+exec bash run.sh