diff options
| author | kartofen <mladenovnasko0@gmail.com> | 2023-04-30 17:39:21 +0300 | 
|---|---|---|
| committer | kartofen <mladenovnasko0@gmail.com> | 2023-04-30 17:39:21 +0300 | 
| commit | 823d499e4f57151b8ded478727b102b53941436f (patch) | |
| tree | ec5223bb59d023e07ef18a97b5e7bc669dd48086 /vm.sh | |
| parent | d42853496fc976ef3d067af421a1a3811660033d (diff) | |
Diffstat (limited to 'vm.sh')
| -rwxr-xr-x | vm.sh | 32 | 
1 files changed, 28 insertions, 4 deletions
@@ -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  | 
