commit 4021550
chld
·
2025-12-21 02:54:30 +0000 UTC
parent 5b91543
updates
5 files changed,
+127,
-35
+4,
-9
1@@ -17,7 +17,7 @@ in this repository is a set of shell scripts that are used to
2
3 ### goals
4 * unified `/bin`
5-* hybird userland
6+* hybrid userland
7 ( using [baseutils](https://github.com/xplshn/baseutils) )
8 * agnosticity
9
10@@ -26,12 +26,7 @@ a working **input**+**drm** stack without:
11 * `eudev`
12
13 ### status
14-* tested _(not installed)_
15+* tested
16
17-**update:** all scripts run successfully and create tarballs
18-
19-as of now, none of the `setup-*` scripts have
20-been used to install `mwakat`.
21-
22-to reach the **tested** state, i need to reinstall
23-`mwakat` from these scripts.
24+i have personally been able to
25+install `mwakat` from the scripts provided!
+94,
-0
1@@ -0,0 +1,94 @@
2+#!/bin/sh
3+# Enter a kiss chroot
4+
5+log() {
6+ printf '\033[32m->\033[m %s.\n' "$*"
7+}
8+
9+die() {
10+ log "$*" >&2
11+ exit 1
12+}
13+
14+run() {
15+ printf '%s\n' "$*"
16+ "$@" || return "${_ret:=0}"
17+}
18+
19+clean() {
20+ log Unmounting host paths; {
21+ run umount "$1/dev/shm" 2>/dev/null
22+ run umount "$1/dev/pts"
23+ run umount "$1/dev"
24+ run umount "$1/proc"
25+ run umount "$1/run"
26+ run umount "$1/sys/firmware/efi/efivars" 2>/dev/null
27+ run umount "$1/sys"
28+ run umount "$1/tmp"
29+ run umount "$1/etc/resolv.conf"
30+ }
31+}
32+
33+mounted() {
34+ # This is a pure shell mountpoint implementation. We're dealing
35+ # with basic (and fixed/known) input so this doesn't need to
36+ # handle more complex cases.
37+ [ -e "$1" ] || return 1
38+ [ -e /proc/mounts ] || return 1
39+
40+ while read -r _ target _; do
41+ [ "$target" = "$1" ] && return 0
42+ done < /proc/mounts
43+
44+ return 1
45+}
46+
47+mmount() {
48+ dest=$1
49+ shift
50+ mounted "$dest" || run mount "$@" "$dest"
51+}
52+
53+main() {
54+ # Ensure input does not end in '/'.
55+ set -- "${1%"${1##*[!/]}"}"
56+
57+ [ "$1" ] || die Need a path to the chroot
58+ [ -d "$1" ] || die Given path does not exist
59+ [ "$(id -u)" = 0 ] || die Script needs to be run as root
60+
61+ # Intended behaviour.
62+ # shellcheck disable=SC2064
63+ trap "clean ${1%"${1##*[!/]}"}" EXIT INT
64+
65+ log Mounting host paths; {
66+ mmount "$1/dev" -o bind /dev
67+ mmount "$1/dev/pts" -o bind /dev/pts
68+ mmount "$1/dev/shm" -t tmpfs shmfs 2>/dev/null
69+ mmount "$1/proc" -t proc proc
70+ mmount "$1/run" -t tmpfs tmpfs
71+ mmount "$1/sys" -t sysfs sys
72+ mmount "$1/sys/firmware/efi/efivars" -t efivarfs efivarfs 2>/dev/null
73+ mmount "$1/tmp" -o mode=1777,nosuid,nodev -t tmpfs tmpfs
74+
75+ touch "$1/etc/resolv.conf"
76+ mmount "$1/etc/resolv.conf" -o bind /etc/resolv.conf
77+ }
78+
79+ log Entering chroot; {
80+ _ret=1
81+
82+ run chroot "$1" /usr/bin/env -i \
83+ HOME=/root \
84+ TERM="$TERM" \
85+ SHELL=/bin/sh \
86+ USER=root \
87+ LOGNAME=root \
88+ CFLAGS="${CFLAGS:--march=x86-64 -mtune=generic -pipe -O2}" \
89+ CXXFLAGS="${CXXFLAGS:--march=x86-64 -mtune=generic -pipe -O2}" \
90+ MAKEFLAGS="${MAKEFLAGS:--j$(nproc 2>/dev/null || echo 1)}" \
91+ /bin/sh -l
92+ } || die chroot failed
93+}
94+
95+main "$1"
+1,
-5
1@@ -10,14 +10,10 @@ sh ./util/kiss-mount $m
2
3 _inc '
4 rm -f /var/db/kiss/installed/kiss/depends
5- kiss r b3sum
6- kiss r git
7- kiss r linux-headers
8+ kiss r b3sum git linux-headers
9 kiss r libmpc gmp mpfr gcc
10 kiss r binutils bison m4 flex pigz xz make
11 kiss r baselayout
12-'
13-_inc '
14 kiss r curl zlib
15 '
16
+23,
-3
1@@ -11,12 +11,32 @@ wget \
2
3 tar -xvf kiss.tar.xz -C $m
4
5-# mwakatize the rootfs
6+# set up situation init
7+wget \
8+ https://codeberg.org/derivelinux/situation/raw/branch/main/situation \
9+ -O $m/bin/situation
10+
11+chmod 755 $m/bin/situation # make situation a executable or kernel panic
12+ln -sf $m/bin/situation $m/bin/init # make sure kern knows situation is init
13+
14+# mwakatizing the rootfs
15 rm -f $m/etc/fstab
16-# swap out KISS os-release for mwakat
17 rm -f $m/etc/os-release
18 cp ./rootfs/os-release $m/etc/os-release
19
20+cp ./rootfs/kiss-chroot $m/bin/kiss-chroot
21+chmod 755 $m/bin/kiss-chroot
22+
23 rm -f $m/etc/mdev.conf # change later?
24
25-#sh util/kiss-mount /mnt
26+# unlink /sbin due to udevadm errors
27+unlink /mnt/sbin
28+
29+# further remove traces of KISS
30+rm -rf /mnt/root/.cache
31+rm -rf /mnt/usr/share/doc
32+
33+# copy KISS no-perl.patch for the linux kernel
34+mkdir -p /mnt/usr
35+mkdir /mnt/usr/src
36+cp ./rootfs/no-perl.patch /mnt/usr/src/no-perl.patch
+5,
-18
1@@ -8,15 +8,6 @@
2
3 set -x
4
5-# lets setup situation init
6-wget \
7- https://codeberg.org/derivelinux/situation/raw/branch/main/situation \
8- -O $m/bin/situation
9-
10-chmod 755 $m/bin/situation # make situation a executable or kernel panic
11-ln -sf $m/bin/situation $m/bin/init # make sure kern knows situation is init
12-ln -sf $m/bin/situation $m/sbin/init
13-
14 # (re)add tools
15 _inc '
16 apk add busybox-static
17@@ -31,15 +22,11 @@ _inc '
18 apk fix musl
19 apk add musl-dev
20 apk del musl-dev
21+'
22+# remove leftover libraries left by kiss
23+_inc '
24 apk add openssl openssl-dev
25 apk del openssl openssl-dev
26+ apk add libbz2 libcrypto3
27+ apk del libbz2 libcrypto3
28 '
29-
30-# further remove traces of KISS
31-rm -rf /mnt/root/.cache
32-rm -rf /mnt/usr/share/doc
33-
34-# copy KISS no-perl.patch for the linux kernel
35-mkdir -p /mnt/usr
36-mkdir /mnt/usr/src
37-cp ./rootfs/no-perl.patch /mnt/usr/src/no-perl.patch