From 823d499e4f57151b8ded478727b102b53941436f Mon Sep 17 00:00:00 2001 From: kartofen Date: Sun, 30 Apr 2023 17:39:21 +0300 Subject: like 350 lines total of scripts and makefile --- vm.sh | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'vm.sh') diff --git a/vm.sh b/vm.sh index cd0d725..2d6194d 100755 --- a/vm.sh +++ b/vm.sh @@ -2,7 +2,7 @@ function run { - # st \ + st \ qemu-system-x86_64 \ -kernel "$BIND/$KERNEL_NAME" \ -initrd "$BIND/$INITFS_NAME" \ @@ -21,15 +21,39 @@ function initramfs ln -sf busybox $DIR/bin/dmesg ln -sf busybox $DIR/bin/mount - # copy the things + # copy the files in bin mkdir -p "$DIR/usr" find "$BIND" -maxdepth 1 -mindepth 1 \ ! -name "*initramfs*" \ ! -name "*kernel*" \ -exec cp -r {} "$DIR/usr" \; - # copy the script and the bin - cp $2 $DIR/init + # copy a bunch of kernel modules + MODULES="usbhid usbcore hid" + modinfo -F filename $MODULES | while read mod; do + if [ "$mod" = "(builtin)" ]; then continue; fi + + mkdir -p "$DIR/$(dirname $mod)" + + # uncompress if compressed + if [[ $mod == *.ko.zst ]]; then + zstd -d -c "$mod" > "$DIR/$(dirname $mod)/$(basename $mod .zst)" + else + cp "$mod" "$DIR/$mod" + fi + done + + # make the init script + cat < "$DIR/init" +#!/bin/sh +# modproble all modules +for mod in $MODULES; do + modprobe "\$mod" +done +EOF + + # append the script written in src/ + cat $2 >> "$DIR/init" chmod +x $DIR/init # make image and delete folder -- cgit v1.2.3