puter/incubator/x86emu/v86starter.sh

43 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
ROOT_DIR="$(pwd)"
# This has to be something, that isn't wrapped by a repo with a package.json
VM_DIR="/tmp/vm"
mkdir -p "$VM_DIR"
cd "$ROOT_DIR/make_container" || exit
docker build . -t v86builder
docker run --name v86build v86builder
docker cp v86build:/app/v86 "$VM_DIR"
docker rm v86build
# Overwrite v86'd debian Dockerfile with our own
cat "$ROOT_DIR/imagegen/Dockerfile" > "$VM_DIR/v86/tools/docker/debian/Dockerfile"
# Navigate to the Dockerfile directory
cd "$VM_DIR/v86/tools/docker/debian" || exit
# Build the container which will be used to serve v86
chmod +x build-container.sh
./build-container.sh
# Build the state of the VM
chmod +x build-state.js
./build-state.js
# Make project directories
mkdir -p "$ROOT_DIR/www/third-party"
mkdir -p "$ROOT_DIR/www/static"
# Copy necessary files to deployment directory
cp "$VM_DIR/v86/build/libv86.js" "$ROOT_DIR/www/third-party/libv86.js"
cp "$VM_DIR/v86/build/v86.wasm" "$ROOT_DIR/www/third-party/v86.wasm"
cp "$VM_DIR/v86/images/debian-state-base.bin" "$ROOT_DIR/www/static/image.bin"
cp -r "$VM_DIR/v86/images/debian-9p-rootfs-flat/" "$ROOT_DIR/www/static/9p-rootfs/"
# Start a HTTP server
cd "$ROOT_DIR/www/" || exit
echo "Opening a server on localhost with port 8080"
python3 -m http.server -b 127.0.0.1 8080