Improve Debian build info (#696)

This commit is contained in:
Николай Шангин 2022-06-24 16:30:27 +08:00 committed by GitHub
parent cbe5e63201
commit 558e0f9d7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 8 deletions

26
examples/debian.html Normal file
View file

@ -0,0 +1,26 @@
<!doctype html>
<title>Debian</title>
<script src="../build/libv86.js"></script>
<script>
"use strict";
window.onload = function()
{
var emulator = new V86Starter({
wasm_path: "../build/v86.wasm",
memory_size: 512 * 1024 * 1024,
vga_memory_size: 8 * 1024 * 1024,
screen_container: document.getElementById("screen_container"),
initial_state: { url: "../images/debian-state-base.bin" },
filesystem: { baseurl: "../images/debian-9p-rootfs-flat/" },
autostart: true,
});
};
</script>
<!-- A minimal structure for the ScreenAdapter defined in browser/screen.js -->
<div id="screen_container">
<div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
<canvas style="display: none"></canvas>
</div>

View file

@ -2,7 +2,24 @@ You can build a Linux image for use with v86:
1. Run `./build-container.sh` to build the Docker container and v86 images (requires dockerd)
2. Run `./build-state.js` to build a state image in order to skip the boot process
3. Optionally, compress the `debian-state-base.bin` file using zstd (v86 automatically detects the zstd magic and decompresses on the fly)
4. Run a webserver serving repo root and go to `examples/debian.html` in a browser
Go to `debug.html?profile=debian` to start the generated container.
If you want to see more info you can run it in a debug mode, to do so add a new profile in the `src/browser/main.js` file to the `oses` variable like so:
```js
var oses = [
{
id: "debian",
name: "Debian",
memory_size: 512 * 1024 * 1024,
vga_memory_size: 8 * 1024 * 1024,
state: { url: host + "debian-state-base.bin" },
filesystem: { "baseurl": host + "debian-9p-rootfs-flat/" }
},
...
```
Save it and go to `debug.html?profile=debian` to start the generated container.
You can modify the `Dockerfile` to customize the generated Linux image.

View file

@ -1,22 +1,24 @@
#!/usr/bin/env bash
set -veu
OUT_ROOTFS_TAR=$(dirname "$0")/../../../images/debian-9p-rootfs.tar
OUT_ROOTFS_FLAT=$(dirname "$0")/../../../images/debian-9p-rootfs-flat
OUT_FSJSON=$(dirname "$0")/../../../images/debian-base-fs.json
IMAGES="$(dirname "$0")"/../../../images
OUT_ROOTFS_TAR="$IMAGES"/debian-9p-rootfs.tar
OUT_ROOTFS_FLAT="$IMAGES"/debian-9p-rootfs-flat
OUT_FSJSON="$IMAGES"/debian-base-fs.json
CONTAINER_NAME=debian-full
IMAGE_NAME=i386/debian-full
docker build . --rm --tag "$IMAGE_NAME"
mkdir -p "$IMAGES"
docker build . --platform linux/386 --rm --tag "$IMAGE_NAME"
docker rm "$CONTAINER_NAME" || true
docker create -t -i --name "$CONTAINER_NAME" "$IMAGE_NAME" bash
docker create --platform linux/386 -t -i --name "$CONTAINER_NAME" "$IMAGE_NAME" bash
docker export "$CONTAINER_NAME" > "$OUT_ROOTFS_TAR"
$(dirname "$0")/../../../tools/fs2json.py --out "$OUT_FSJSON" "$OUT_ROOTFS_TAR"
"$(dirname "$0")"/../../../tools/fs2json.py --out "$OUT_FSJSON" "$OUT_ROOTFS_TAR"
# Note: Not deleting old files here
mkdir -p "$OUT_ROOTFS_FLAT"
$(dirname "$0")/../../../tools/copy-to-sha256.py "$OUT_ROOTFS_TAR" "$OUT_ROOTFS_FLAT"
"$(dirname "$0")"/../../../tools/copy-to-sha256.py "$OUT_ROOTFS_TAR" "$OUT_ROOTFS_FLAT"
echo "$OUT_ROOTFS_TAR", "$OUT_ROOTFS_FLAT" and "$OUT_FSJSON" created.