aboutsummaryrefslogtreecommitdiff
path: root/vm.sh
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2023-04-30 17:39:21 +0300
committerkartofen <mladenovnasko0@gmail.com>2023-04-30 17:39:21 +0300
commit823d499e4f57151b8ded478727b102b53941436f (patch)
treeec5223bb59d023e07ef18a97b5e7bc669dd48086 /vm.sh
parentd42853496fc976ef3d067af421a1a3811660033d (diff)
like 350 lines total of scripts and makefileHEADmaster
Diffstat (limited to 'vm.sh')
-rwxr-xr-xvm.sh32
1 files changed, 28 insertions, 4 deletions
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 <<EOF > "$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