aboutsummaryrefslogtreecommitdiff
path: root/vm.sh
diff options
context:
space:
mode:
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