diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..80170d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +stage +logs diff --git a/configs/etc_group b/configs/etc_group new file mode 100644 index 0000000..fbff040 --- /dev/null +++ b/configs/etc_group @@ -0,0 +1,34 @@ +root:x:0: +bin:x:1:daemon +sys:x:2: +kmem:x:3: +tape:x:4: +tty:x:5: +daemon:x:6: +floppy:x:7: +disk:x:8: +lp:x:9: +dialout:x:10: +audio:x:11: +video:x:12: +utmp:x:13: +usb:x:14: +cdrom:x:15: +adm:x:16: +messagebus:x:18: +systemd-journal:x:23: +input:x:24: +mail:x:34: +kvm:x:61: +systemd-journal-gateway:x:73: +systemd-journal-remote:x:74: +systemd-journal-upload:x:75: +systemd-network:x:76: +systemd-resolve:x:77: +systemd-timesync:x:78: +systemd-coredump:x:79: +uuidd:x:80: +systemd-oom:x:81: +wheel:x:97: +users:x:999: +nogroup:x:65534: diff --git a/configs/etc_passwd b/configs/etc_passwd new file mode 100644 index 0000000..f57e249 --- /dev/null +++ b/configs/etc_passwd @@ -0,0 +1,14 @@ +root:x:0:0:root:/root:/bin/bash +bin:x:1:1:bin:/dev/null:/usr/bin/false +daemon:x:6:6:Daemon User:/dev/null:/usr/bin/false +messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/usr/bin/false +systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/usr/bin/false +systemd-journal-remote:x:74:74:systemd Journal Remote:/:/usr/bin/false +systemd-journal-upload:x:75:75:systemd Journal Upload:/:/usr/bin/false +systemd-network:x:76:76:systemd Network Management:/:/usr/bin/false +systemd-resolve:x:77:77:systemd Resolver:/:/usr/bin/false +systemd-timesync:x:78:78:systemd Time Synchronization:/:/usr/bin/false +systemd-coredump:x:79:79:systemd Core Dumper:/:/usr/bin/false +uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/usr/bin/false +systemd-oom:x:81:81:systemd Out Of Memory Daemon:/:/usr/bin/false +nobody:x:65534:65534:Unprivileged User:/dev/null:/usr/bin/false diff --git a/make.project/arm_chroot.sh b/make.project/arm_chroot.sh index 6a79875..60fa169 100755 --- a/make.project/arm_chroot.sh +++ b/make.project/arm_chroot.sh @@ -1,7 +1,7 @@ #!/bin/bash APPNAME="CHROOT VFS SETUP" T_SYSROOT=${dir_sysroot} - +set -a assert_zero() { if [[ "$1" -eq 0 ]]; then return @@ -51,12 +51,15 @@ logprint "mounting proc filesystem from to chroot sysroot..." is_mounted ${T_SYSROOT}/proc || mount -v -t proc proc ${T_SYSROOT}/proc assert_zero $? +logprint "mounting shm" # not a symlink on ubuntu if [ -h ${T_SYSROOT}/dev/shm ]; then - mkdir -vp ${T_SYSROOT}/$(readlink ${T_SYSROOT})/dev/shm + mkdir -vp ${T_SYSROOT}/$(readlink "${T_SYSROOT}/dev/shm") assert_zero $? else - mount -t tmpfs -o nosuid,nodev tmpfs ${T_SYSROOT}/dev/shm + is_mounted ${T_SYSROOT}/dev/shm || mount -t tmpfs -o nosuid,nodev tmpfs ${T_SYSROOT}/dev/shm fi - +logprint "mounting rex_embedded for stage3 capability" +mkdir -p ${T_SYSROOT}/rex_embedded +is_mounted ${T_SYSROOT}/rex_embedded || mount -v --bind ${project_root} ${T_SYSROOT}/rex_embedded diff --git a/make.project/build_stage3.sh b/make.project/build_stage3.sh new file mode 100755 index 0000000..1bc52b5 --- /dev/null +++ b/make.project/build_stage3.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# fix an issue with open files limit on some hosts +ulimit -l unlimited + +#ulimit -n 10240 +ulimit -c unlimited + + +# closely aligns with LFS Ch 5, 6 +T_SYSROOT=${dir_sysroot} + +project_root=/rex_embedded + +echo "Bootstrapping from MAKE to REX..." +dir_rex=/rex_embedded/rex.project + +# Executes rex from within the chroot. +/usr/sbin/chroot "${T_SYSROOT}" /usr/bin/env -i \ + HOME="/" \ + TERM="$TERM" \ + COLORTERM=$COLORTERM \ + PS1='\n(Dark Horse Linux) [ \u @ \H ] << \w >>\n\n[- ' \ + PATH=/usr/bin:/usr/sbin \ + project_root="${project_root}" \ + dir_rex="${dir_rex}" \ + dir_logs="/${project_root}/logs" \ + /rex_embedded/stage/rex/rex -v -c ${dir_rex}/x86_64/rex.config -p ${dir_rex}/x86_64/plans/stage3.plan + + +retVal=$? +echo "Rex exited with error code '$retVal'." diff --git a/make.project/disarm_chroot.sh b/make.project/disarm_chroot.sh index a928315..60770f3 100755 --- a/make.project/disarm_chroot.sh +++ b/make.project/disarm_chroot.sh @@ -46,7 +46,10 @@ is_mounted ${T_SYSROOT}/proc && umount -l ${T_SYSROOT}/proc # not a symlink on ubuntu logprint "Unmounting ${T_SYSROOT}/dev/shm" -ismounted ${T_SYSROOT}/dev/shm && umount -l {${T_SYSROOT}/dev/shm +is_mounted ${T_SYSROOT}/dev/shm && umount -l ${T_SYSROOT}/dev/shm + +logprint "Unmounting pyrois inside of chroot" +is_mounted ${T_SYSROOT}/rex_embedded && umount -l ${T_SYSROOT}/rex_embedded echo logprint "You can now safely delete the chroot." diff --git a/rex.project/x86_64/components/stage2/populate_ug.bash b/rex.project/x86_64/components/stage2/populate_ug.bash new file mode 100755 index 0000000..26eced3 --- /dev/null +++ b/rex.project/x86_64/components/stage2/populate_ug.bash @@ -0,0 +1,29 @@ +#!/bin/bash +# Prepares sysroot ownership and perms for chrooting +# print to stdout, print to log +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment + +APPNAME="CHROOT PASSWD/GROUPS" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the file to log to +LOGFILE="${APPNAME}.log" + +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + + +logprint "Installing initial users and groups to chroot..." +cp -f ${dir_configs}/etc_passwd ${T_SYSROOT}/etc/passwd +assert_zero $? + +cp -f ${dir_configs}/etc_group ${T_SYSROOT}/etc/group +assert_zero $? diff --git a/rex.project/x86_64/components/stage2/prepare_vkfs.bash b/rex.project/x86_64/components/stage2/prepare_vkfs.bash index d8ffb9a..af04b51 100755 --- a/rex.project/x86_64/components/stage2/prepare_vkfs.bash +++ b/rex.project/x86_64/components/stage2/prepare_vkfs.bash @@ -46,6 +46,11 @@ logprint "mounting proc filesystem from to chroot sysroot..." is_mounted ${T_SYSROOT}/proc || mount -v -t proc proc ${T_SYSROOT}/proc assert_zero $? +logprint "mounting pyrois inside of chroot" +mkdir -p ${T_SYSROOT}/rex_embedded +is_mounted ${project_root} || mount -v --bind ${project_root} ${T_SYSROOT}/rex_embedded +assert_zero $? + # not a symlink on ubuntu if [ -h ${T_SYSROOT}/dev/shm ]; then mkdir -vp ${T_SYSROOT}/$(readlink ${T_SYSROOT})/dev/shm diff --git a/rex.project/x86_64/components/stage3/welcome.bash b/rex.project/x86_64/components/stage3/welcome.bash new file mode 100755 index 0000000..762d070 --- /dev/null +++ b/rex.project/x86_64/components/stage3/welcome.bash @@ -0,0 +1,48 @@ +HORSE=$(cat <<'EOH' +⠀⠀⠀⠀⠀⠀⢀⠀⠀⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠘⣦⡀⠘⣆⠈⠛⠻⣗⠶⣶⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠈⣿⠀⠈⠳⠄⠀⠈⠙⠶⣍⡻⢿⣷⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⣰⣿⣧⠀⠀⠀⠀⠀⠀⠀⠈⠻⣮⡹⣿⣿⣷⣦⣄⣀⠀⠀⢀⣸⠃⠀⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⢠⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣮⢿⣿⣿⣿⣿⣿⣿⣿⠟⠀⢰⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⢀⣾⣿⠀⠀⠀⠀⠀⠀⠀⣷⠀⢷⠀⠀⠀⠙⢷⣿⣿⣿⣿⣟⣋⣀⣤⣴⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⢀⣼⢿⣿⡀⠀⠀⢀⣀⣴⣾⡟⠀⠈⣇⠀⠀⠀⠈⢻⡙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⣼⡏⠸⣿⣿⣶⣾⣿⡿⠟⠋⠀⠀⠀⢹⡆⠀⠀⠀⠀⠹⡽⣿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⣰⣿⠀⠀⠀⣀⡿⠛⠉⠀⠀⢿⠀⠀⠀⠘⣿⡄⠀⠀⠀⠀⠑⢹⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⣿⣿⣷⣶⣾⠏⠀⠀⠀⠀⠀⠘⣇⠀⠀⠀⢻⡇⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⡿⠃⠀⣠⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠈⠙⠿⠿⠋⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⢸⣷⠀⠀⠀⠀⠀⢀⠀⠹⣿⣿⣿⣿⣷⣶⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⠀⠀⠀⢸⣿⠀⠀⠀⠀⢀⡞⠀⠀⠈⠛⠻⠿⠿⠯⠥⠤⢄⣀⣀⢀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⠀⠀⠀⢸⡇⠀⠀⠀⢀⡼⠃⠀⠀⠀⠀⠀⣄⠀⠀⠀⠀⠀⠀⠈⠙⠂⠙⠳⢤⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⠇⠀⠀⠀⡾⠁⠀⠀⣠⡿⠃⠀⠀⠀⠀⠀⠀⠸⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠀⠀⠀⡸⠃⠀⢀⣴⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣷⣶⣶⣦⣤⣀⡀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⠇⠀⠀⠀⠃⢀⣴⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣿⣿⣶⣤⡀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠏⠀⠀⠀⠀⣰⡟⠁⠀⠀⠀ ⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣧⠙⠻⣿⣿⣿⣿⣿⣿⣦⡀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⢀⡖⢰⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠟⠀⠀⠀⢸⣿⠀⠀⠈⢿⣿⣿⣿⣿⣿⡿ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⡇⠀⠀⣼⠁⠼⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠋⠀⠀⠀⠀⣼⡇⠀⠀⣠⣾⣿⣿⣿⣿⠟⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠘⣇⠀⠀⢻⡄⢠⡄⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⡴⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⠟⠁⠀⠀⠀⢀⣼⠏⠀⣠⣾⣿⣿⡿⣿⡿⠁⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⠁⠀⠘⠂⠀⠀⢳⠀⢳⡀⠀⠀⠀⠀⠀⠀⢀⡼⠁⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣾⣿⠃⠀⠀⠀⠀⣠⣾⠃⣠⣾⣿⣿⠿⠋⢰⡟⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⢠⣿⠃⠀⠀⠀⢀⣀⡴⠞⠙⠲⣷⡄⠀⠀⠀⠀⢠⡾⠁⠀⠀⠀⢀⣀⣠⣤⣶⠿⠟⠋⠀⡾⠀⠀⠀⢀⣴⠟⠁⢠⡟⢱⡿⠃⠀⠀⠸⣇⡀⠀⠀⠀ +⠀⠀⠀⠀⠀⢀⡴⠟⠁⠀⣀⡤⠖⠋⠁⠀⠀⠀⠀⣸⠇⠀⠀⠀⣤⠟⠑⠋⠉⣿⠋⠉⠉⠉⠁⣠⠞⠀⠀⠀⡇⠀⠀⢠⡿⠋⠀⠀⠈⠁⡿⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀ +⠀⠀⠀⢀⣾⣏⣤⣶⡾⠛⠉⠀⠀⠀⠀⠀⠀⢀⡼⠃⠀⠀⣠⠞⠁⠀⠀⠀⠀⣿⠀⠀⠀⢀⡼⠃⠀⠀⠀⢸⠇⠀⣰⠟⠀⠀⠀⠀⠀⠐⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⢀⣿⣿⡿⠛⠁⠀⠀⠀⠀⠀⠀⠀⢀⣴⠏⠀⠀⣠⠞⠁⠀⠀⠀⠀⠀⠀⣿⠀⠀⢀⡾⠃⠀⠀⠀⢀⡞⠀⣼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⣼⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⣿⣶⣶⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⣾⠇⠀⠀⠀⢀⣾⣣⣾⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⢠⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⠀⢠⡟⠀⠀⠀⢀⣾⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⢀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⡄⢀⣀⡀⠀⠀⠀⠀⠀⠀⢸⡇⠀⣾⠇⠀⠀⣰⣿⣿⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⢸⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⣾⠀⣰⠟⠀⢀⣼⣿⣿⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⢸⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠿⠿⠿⠿⠿⠿⠃⠀⠀⠀⢸⣿⣶⠏⢀⣴⣿⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⢸⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⣿⠃⢠⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⢿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⢃⣴⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠈⠛⠛⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣧⣾⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⡟⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⠁⠀⠀⠈⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠿⠿⠿⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +EOH +) + +echo +echo +echo -e "\e[31m$HORSE\e[0m" +echo +echo "Welcome to Pyrois, the build system for Dark Horse Linux." +echo +echo "Stage 3, Inside-Out Linux" +echo diff --git a/rex.project/x86_64/environments/stage3.env.bash b/rex.project/x86_64/environments/stage3.env.bash new file mode 100755 index 0000000..2b7e98e --- /dev/null +++ b/rex.project/x86_64/environments/stage3.env.bash @@ -0,0 +1,71 @@ +set -a +# We now do paths relative to / since we are INSIDE $T_SYSROOT + +TERM=xterm-256color +COLORTERM=truecolor +LC_ALL=C + +function echofail() { + echo + echo "FAILED: $1" + echo + exit 1 +} + +rex_dir="/rex_embedded" + +# keeps talking about T_SYSROOT as $LFS +# wants $LFS path to be a mount +# needs to be set for any user including root + +#2.6 +# sourced from project_config +T_SYSROOT="/" +LFS=${T_SYSROOT} + +# 4.3 we skip user and group creation, it's expected to be done before +# you start if you want a different user than you're running as +# == after that, configure the rex unit for dir creation to use that user + +if [ "$(id -u)" -ne 0 ]; then + echo "Not running as root." +fi + +# 4.4 + +# The set +h command turns off bash's hash function, which affects caching of paths for executables +set +h + +# ensures newly created files and directories are only writable by their owner, but are readable and executable by anyone +umask 022 + +# sets a comptabile machine name description for use when building crosstools that isn't going to be what the host system is using +# $LFS_TGT is what LFS uses for this +T_TRIPLET=x86_64-dhl-linux-gnu + +# prevents some configure scripts from looking in the wrong place for config.site +CONFIG_SITE=/usr/share/config.site + +# 4.5 +MAKEFLAGS="-j$(nproc)" + +# where the cross-compiler gets installed ($LFS/tools) +CROSSTOOLS_DIR=/xtools +TEMP_STAGE_DIR=/source_stage +# from project_config +SOURCES_DIR=/rex_embedded/stage/sources +PATCHES_DIR=/rex_embedded/stage/patches +LOGS_ROOT=/rex_embedded/logs + +# fail the unit in the event of a non-zero value passed +# used primarily to check exit codes on previous commands +# also a great convenient place to add in a "press any key to continue" +assert_zero() { + if [[ "$1" -eq 0 ]]; then + return + else + exit $1 + fi +} +ARCHLIB_DIR=/lib64 +PATH=/usr/bin:/usr/sbin diff --git a/rex.project/x86_64/plans/stage2.plan b/rex.project/x86_64/plans/stage2.plan index 198ce98..2eb1ca2 100644 --- a/rex.project/x86_64/plans/stage2.plan +++ b/rex.project/x86_64/plans/stage2.plan @@ -2,7 +2,7 @@ "plan": [ { - "name": "welcome", + "name": "welcome 2", "dependencies": [ null ], "comment": "greet the user" }, @@ -100,6 +100,11 @@ "name": "preparing virtual kernel file systems", "dependencies": [ null ], "comment": "LFS 11.3-systemd-rc1 Ch. 7.3 (chroot)" + }, + { + "name": "populate initial users and groups", + "dependencies": [ null ], + "comment": "OOO: LFS 11.3-systemd-rc1 Ch. 7.6 (chroot)" } ] } diff --git a/rex.project/x86_64/plans/stage3.plan b/rex.project/x86_64/plans/stage3.plan new file mode 100644 index 0000000..d6a342d --- /dev/null +++ b/rex.project/x86_64/plans/stage3.plan @@ -0,0 +1,10 @@ +{ + "plan": + [ + { + "name": "welcome 3", + "dependencies": [ null ], + "comment": "greet the user" + } + ] +} diff --git a/rex.project/x86_64/units/stage2.units b/rex.project/x86_64/units/stage2.units index 3887a15..82d9f16 100644 --- a/rex.project/x86_64/units/stage2.units +++ b/rex.project/x86_64/units/stage2.units @@ -1,7 +1,7 @@ { "units": [ { - "name": "welcome", + "name": "welcome 2", "target": "components/stage2/welcome.bash", "is_shell_command": true, "shell_definition": "bash", @@ -359,6 +359,24 @@ "group": "root", "supply_environment": true, "environment": "environments/stage2.env.bash" + }, + { + "name": "populate initial users and groups", + "target": "components/stage2/populate_ug.bash", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage2.env.bash" } ] } diff --git a/rex.project/x86_64/units/stage3.units b/rex.project/x86_64/units/stage3.units new file mode 100644 index 0000000..2b9424b --- /dev/null +++ b/rex.project/x86_64/units/stage3.units @@ -0,0 +1,22 @@ +{ + "units": [ + { + "name": "welcome 3", + "target": "components/stage3/welcome.bash", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage3.env.bash" + } + ] +}