buninu-linux 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSES/Apache-2.0.txt +202 -0
- package/LICENSES/BSD-3-Clause-Skia.txt +29 -0
- package/LICENSES/Bitstream-Vera.txt +44 -0
- package/LICENSES/MIT-xterm.js.txt +21 -0
- package/LICENSES/OFL-1.1.txt +91 -0
- package/NOTICE.md +18 -1
- package/README.md +226 -22
- package/fetch-alpine.sh +9 -4
- package/graphics.md +213 -0
- package/initramfs/bin/bunterm +66 -0
- package/initramfs/bin/ip +2 -1
- package/initramfs/bin/mount +2 -1
- package/initramfs/bin/poweroff +6 -27
- package/initramfs/bin/ps +256 -0
- package/initramfs/bin/reboot +10 -0
- package/initramfs/bin/tar +169 -0
- package/initramfs/bin/top +129 -0
- package/initramfs/bin/umount +2 -1
- package/initramfs/buninu/CHANGELOG.md +40 -0
- package/initramfs/buninu/apps/bunmsh/CHANGELOG.md +36 -0
- package/initramfs/buninu/apps/bunmsh/README.md +7 -0
- package/initramfs/buninu/apps/bunmsh/package.json +1 -1
- package/initramfs/buninu/apps/bunmsh/src/fancy-ls.js +29 -14
- package/initramfs/buninu/apps/bunmsh/src/line-edit.js +43 -0
- package/initramfs/buninu/apps/bunmsh/src/main.js +15 -1
- package/initramfs/buninu/apps/bunmsh/src/mouse.js +29 -4
- package/initramfs/buninu/apps/bunmsh/src/shell.js +9 -1
- package/initramfs/buninu/apps/bunmsh/test/shell1.test.js +70 -0
- package/initramfs/buninu/apps/jsgotty/gotty.js +4 -3
- package/initramfs/buninu/apps/jsgotty/package.json +1 -1
- package/initramfs/buninu/apps/jsmdcui/CHANGELOG.md +10 -0
- package/initramfs/buninu/apps/jsmdcui/README.md +2 -0
- package/initramfs/buninu/apps/jsmdcui/package.json +1 -1
- package/initramfs/buninu/apps/jsmdcui/runtime/help/commands.md +4 -1
- package/initramfs/buninu/apps/jsmdcui/runtime/help/help.md +2 -0
- package/initramfs/buninu/apps/jsmdcui/src/index.js +40 -13
- package/initramfs/buninu/package.json +1 -1
- package/initramfs/init.js +6 -0
- package/initramfs/lib/bunterm/glyphs.js +446 -0
- package/initramfs/lib/bunterm/images.js +225 -0
- package/initramfs/lib/bunterm/input.js +140 -0
- package/initramfs/lib/bunterm/renderer.js +424 -0
- package/initramfs/lib/bunterm/terminal.js +203 -0
- package/initramfs/lib/canvas.js +181 -0
- package/initramfs/lib/canvaskit/LICENSE +29 -0
- package/initramfs/lib/canvaskit/canvaskit.js +264 -0
- package/initramfs/lib/canvaskit/canvaskit.wasm +0 -0
- package/initramfs/lib/dlopen.js +14 -11
- package/initramfs/lib/document.js +6 -0
- package/initramfs/lib/fbdev.js +581 -0
- package/initramfs/lib/power.js +35 -0
- package/initramfs/lib/xterm/LICENSE +21 -0
- package/initramfs/lib/xterm/addon-unicode-graphemes.mjs +44 -0
- package/initramfs/lib/xterm/xterm-headless.mjs +46 -0
- package/initramfs/usr/share/doc/buninu-linux/bunterm.md +83 -0
- package/initramfs/usr/share/doc/buninu-linux/canvas.md +91 -0
- package/initramfs/usr/share/doc/buninu-linux/fbdev.md +113 -0
- package/initramfs/usr/share/doc/buninu-linux/ps.md +94 -0
- package/initramfs/usr/share/doc/buninu-linux/reboot.md +15 -0
- package/initramfs/usr/share/doc/buninu-linux/tar.md +73 -0
- package/initramfs/usr/share/doc/buninu-linux/top.md +23 -0
- package/initramfs/usr/share/fonts/DejaVuSansMono-Bold.ttf +0 -0
- package/initramfs/usr/share/fonts/DejaVuSansMono.ttf +0 -0
- package/initramfs/usr/share/fonts/LICENSE-Apache-2.0.txt +202 -0
- package/initramfs/usr/share/fonts/LICENSE-DejaVu.txt +44 -0
- package/initramfs/usr/share/fonts/LICENSE-OFL-1.1.txt +91 -0
- package/initramfs/usr/share/fonts/NotoColorEmoji.ttf +0 -0
- package/initramfs/usr/share/fonts/NotoColorEmojiFlags.ttf +0 -0
- package/initramfs/usr/share/fonts/NotoSansCJK-Regular.ttc +0 -0
- package/initramfs/usr/share/fonts/NotoSansSymbols-Regular-Subsetted.ttf +0 -0
- package/initramfs/usr/share/fonts/NotoSansSymbols-Regular-Subsetted2.ttf +0 -0
- package/initramfs/usr/share/fonts/Roboto-Regular.ttf +0 -0
- package/initramfs/usr/share/fonts/fonts.json +28 -0
- package/package.json +2 -2
- package/run-qemu.sh +1 -1
package/README.md
CHANGED
|
@@ -25,14 +25,18 @@
|
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
|
+
- [Table of contents](#contents)
|
|
29
|
+
- .
|
|
28
30
|
- Still in the early stages
|
|
29
31
|
- [Video here](https://www.reddit.com/r/bun/comments/1wkpraj/buninu_linux_a_distro_with_bun_as_pid_1): Booted successfully on real x86-64 UEFI hardware with `--real`:
|
|
30
32
|
* Bun reaches its interactive REPL
|
|
31
33
|
* start() starts the Buninu userspace shell
|
|
32
34
|
* `cfg.disk` + shell `mount` mounts local disks
|
|
33
|
-
* `cfg.net` loads common wired NIC drivers
|
|
35
|
+
* `cfg.net` loads common wired NIC and Android USB-tethering drivers
|
|
36
|
+
* Android phone USB tethering over RNDIS has been tested successfully, allowing Buninu Linux to access the Internet through an Android phone
|
|
34
37
|
* IP addresses and routes are configured manually because the image does not yet include a DHCP client.
|
|
35
|
-
* The bundled `jmi` editor,
|
|
38
|
+
* The bundled `jmi` editor, jsmdcui editor/terminal multitasking, and local JavaScript execution also work.
|
|
39
|
+
* The graphical terminal `bunterm` draws on the framebuffer with CJK, colour emoji and kitty images; see [Showing images](#showing-images)
|
|
36
40
|
|
|
37
41
|
---
|
|
38
42
|
|
|
@@ -130,20 +134,20 @@ whitespace-only line prints the welcome and current `cfg.*` getter list again.
|
|
|
130
134
|
Load only the subsystem needed, then enter the Buninu shell:
|
|
131
135
|
|
|
132
136
|
```js
|
|
133
|
-
cfg.net // wired NIC drivers
|
|
137
|
+
cfg.net // wired NIC and Android USB-tethering drivers
|
|
134
138
|
cfg.disk // SATA/NVMe/USB storage drivers and detected block devices
|
|
135
139
|
cfg.power // battery, AC, button and thermal drivers
|
|
136
140
|
start()
|
|
137
141
|
```
|
|
138
142
|
|
|
139
143
|
There is no DHCP client yet; configure a detected wired interface with `ip` as
|
|
140
|
-
described under [
|
|
144
|
+
described under [Basic configuration](#basic-configuration). Run `poweroff` for a synced
|
|
141
145
|
shutdown. After editing the initramfs, `bun ./index.js -b --real --export` rebuilds the
|
|
142
146
|
image; `-h` lists all flags.
|
|
143
147
|
|
|
144
|
-
##
|
|
148
|
+
## Using Buninu Linux
|
|
145
149
|
|
|
146
|
-
###
|
|
150
|
+
### Basic configuration
|
|
147
151
|
|
|
148
152
|
Real hardware is the primary target. Boot the USB drive with Secure Boot
|
|
149
153
|
disabled unless you have signed the UKI yourself. The physical display and USB
|
|
@@ -157,7 +161,7 @@ cfg.disk
|
|
|
157
161
|
cfg.power
|
|
158
162
|
```
|
|
159
163
|
|
|
160
|
-
`cfg.net` loads the packaged wired-network drivers and prints detected
|
|
164
|
+
`cfg.net` loads the packaged wired-network and Android USB-tethering drivers and prints detected
|
|
161
165
|
interfaces and MAC addresses. There is no DHCP client yet, so configure the
|
|
162
166
|
interface manually after entering the Buninu shell with `start()`:
|
|
163
167
|
|
|
@@ -178,6 +182,8 @@ mount -fv /dev/sda1 /mnt
|
|
|
178
182
|
|
|
179
183
|
Run `poweroff` for a synced shutdown.
|
|
180
184
|
|
|
185
|
+
### Editor quick start
|
|
186
|
+
|
|
181
187
|
The bundled `jmi` terminal editor works without a network connection:
|
|
182
188
|
|
|
183
189
|
```sh
|
|
@@ -203,19 +209,140 @@ After leaving the editor with `Ctrl-Q`, run it locally:
|
|
|
203
209
|
bun hlw.js
|
|
204
210
|
```
|
|
205
211
|
|
|
206
|
-
|
|
212
|
+
If `Enter` is not recognized in a particular terminal, try `Ctrl-J` or
|
|
213
|
+
`Ctrl-M`.
|
|
214
|
+
|
|
215
|
+
### Panes, terminals, and tabs
|
|
216
|
+
|
|
217
|
+
`jmi` and jsmdcui can keep editors and terminal sessions open together. Press
|
|
218
|
+
`Ctrl-E`, type `term`, and press `Enter` to open the default Buninu shell in a
|
|
219
|
+
terminal pane. `term COMMAND` starts a specific command instead. Use `vsplit`,
|
|
220
|
+
`hsplit`, or `tab` from the same `Ctrl-E` command prompt to create another
|
|
221
|
+
editor pane or tab; each command optionally accepts a filename. From an editor
|
|
222
|
+
pane, `Ctrl-T` is the direct shortcut for a new empty tab.
|
|
223
|
+
|
|
224
|
+
#### Pane and tab controls
|
|
225
|
+
|
|
226
|
+
| Input | Result |
|
|
227
|
+
| --- | --- |
|
|
228
|
+
| Click a pane | Focus that editor or terminal pane. |
|
|
229
|
+
| `Ctrl-T` in an editor pane | Open a new empty tab. |
|
|
230
|
+
| `Ctrl-W` once | Move to the next pane in the current tab, from either an editor or terminal pane. |
|
|
231
|
+
| `Alt-T` | Move to the next tab. |
|
|
232
|
+
| **`Ctrl-W` twice quickly** | **Important escape hatch:** move to the next tab like `Alt-T`, or create an editor tab when needed. See the detailed explanation below. |
|
|
233
|
+
| `Esc` in a terminal pane | Close that terminal pane and return to its previous editor buffer |
|
|
234
|
+
| `Ctrl-Q` or `Alt-Q` in an editor pane | Close the current editor UI. |
|
|
235
|
+
|
|
236
|
+
**Why this escape hatch is important:** A terminal pane must forward almost every key combination unchanged to the
|
|
237
|
+
shell or application running inside it. `Ctrl-W` is therefore the one
|
|
238
|
+
multitasking escape key that jsmdcui intercepts: it lets you leave the active
|
|
239
|
+
terminal without terminating the work inside it. Press it once to move to the
|
|
240
|
+
next pane in the current tab. Press it twice quickly to move to the next tab.
|
|
241
|
+
|
|
242
|
+
The double press is especially important in an all-terminal workspace. When
|
|
243
|
+
the current tab is the rightmost tab and every existing tab contains only
|
|
244
|
+
terminal panes, it creates a new editor tab instead of wrapping back to the
|
|
245
|
+
first terminal tab. In every other case it performs the normal next-tab cycle.
|
|
246
|
+
Use `Esc` only when you actually want to close the current terminal pane.
|
|
247
|
+
|
|
248
|
+
### Using Bun Modern Shell
|
|
249
|
+
|
|
250
|
+
bunmsh is the dependency-free, mksh-inspired shell bundled with Buninu. Its
|
|
251
|
+
main features are:
|
|
252
|
+
|
|
253
|
+
- Lines beginning with `Bun.*` run as JavaScript; returned values are printed
|
|
254
|
+
and promises are awaited automatically. Use `Bun.e;` or `Bun.e,` for
|
|
255
|
+
arbitrary JavaScript.
|
|
256
|
+
- Lightweight cwd tabs keep several working directories ready. In bunmsh,
|
|
257
|
+
`Ctrl-T` creates or cycles right through tabs, while `Alt-T` cycles left.
|
|
258
|
+
* Also useful cmds: `tab n`, `tab c`(Alt-C)
|
|
259
|
+
- Shell variables and JavaScript share a live variable table by `$.`, and `Bun.sha`
|
|
260
|
+
can retain JavaScript values across commands and cwd tabs.
|
|
261
|
+
- Saved history, Bash/Fish history import, completions, and ghost suggestions
|
|
262
|
+
are available interactively.
|
|
263
|
+
- `serve [directory]` starts a browsable HTTP file server. Together with
|
|
264
|
+
Android USB tethering, it provides a simple way to transfer files between
|
|
265
|
+
Buninu Linux and the connected phone.
|
|
266
|
+
- Cross-platform builtins and PATH-fallback commands.
|
|
267
|
+
- `Ctrl-U` removes and saves the text before the cursor; press it again at the
|
|
268
|
+
beginning of the line to restore it. `Ctrl-K` independently toggles the text
|
|
269
|
+
after the cursor when at the end of the line.
|
|
270
|
+
- Unquoted pathname patterns use `Bun.Glob` and follow directory symbolic
|
|
271
|
+
links used as intermediate path components, as traditional shells do. This
|
|
272
|
+
matters for sysfs, where class entries are normally links. For example:
|
|
207
273
|
|
|
208
|
-
|
|
274
|
+
```sh
|
|
275
|
+
ls /sys/class/net/*/device
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
For a readable process overview, run:
|
|
279
|
+
|
|
280
|
+
```sh
|
|
281
|
+
pspac
|
|
282
|
+
|
|
283
|
+
# Kernel threads show as [name]; filter them out to see only userspace
|
|
284
|
+
pspac | grep -v '\[[a-z]'
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
`pspac` shows the real `PID COMMAND` process table and highlights each command
|
|
288
|
+
line as shell syntax with micro's Monokai colours. Leading directories are
|
|
289
|
+
dimmed so the program name stands out. Use `pspa` for the same table as plain
|
|
290
|
+
text.
|
|
291
|
+
|
|
292
|
+
See the [bunmsh repository](https://github.com/jjtseng93/bunmsh) for its full
|
|
293
|
+
syntax, interactive controls, builtins, and current compatibility details.
|
|
294
|
+
|
|
295
|
+
### Showing images
|
|
296
|
+
|
|
297
|
+
The Linux text console cannot draw pictures, so first start `bunterm`, the
|
|
298
|
+
graphical terminal on the framebuffer, and run the image commands inside it:
|
|
299
|
+
|
|
300
|
+
```sh
|
|
301
|
+
# Start the graphical terminal on this virtual console (or name one: bunterm /dev/tty1)
|
|
302
|
+
bunterm
|
|
303
|
+
|
|
304
|
+
# Show an image with the kitty graphics protocol (jsgotty --viu)
|
|
305
|
+
showimg /buninu/icon.png
|
|
209
306
|
|
|
210
|
-
|
|
211
|
-
|
|
307
|
+
# Render README.md with glow, then show icon.png
|
|
308
|
+
buninu-help
|
|
309
|
+
|
|
310
|
+
# Markdown view with its images in place
|
|
311
|
+
# cfg.net first to show that GitHub image
|
|
312
|
+
jsmdcui --allow-url README.md
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
`bunterm` draws with Skia (CanvasKit) and understands the kitty graphics
|
|
316
|
+
protocol, so anything that speaks it — `showimg`, `jsmdcui`, `kitten icat`,
|
|
317
|
+
`timg` — shows images, alongside CJK text and colour emoji. The cursor moves
|
|
318
|
+
below a shown image, and images scroll with the text. When the program you
|
|
319
|
+
started exits, the console returns to text mode. `bunterm --help` has the
|
|
320
|
+
options; [graphics.md](graphics.md) describes how it is built. The image
|
|
321
|
+
needs a kernel with a framebuffer: build with `--linux-lts` or `--real`
|
|
322
|
+
(the default `linux-virt` builds one only as modules the image omits).
|
|
323
|
+
|
|
324
|
+
## Commands inside /bin
|
|
212
325
|
|
|
213
326
|
| command | does | manual |
|
|
214
327
|
| --- | --- | --- |
|
|
215
328
|
| `mount` | `mount(2)` with type detection, `-o` parsing, `LABEL=`/`UUID=`, bind/move/remount; loads required filesystem and disk modules | `mount --help` → `/usr/share/doc/buninu-linux/mount.md` |
|
|
216
329
|
| `umount` | `umount2(2)` with `-l`, `-f`, `-R` | `umount --help` |
|
|
217
330
|
| `ip` | iproute2 grammar over `SIOC*` ioctls and `/proc/net`: `link`, `addr`, `route`, `neigh` | `ip --help` |
|
|
331
|
+
| `ps` | composable process fields from `/proc`; also exports its snapshot and single-row formatter for other commands | `ps --help` |
|
|
332
|
+
| `top` | periodically refreshes the process snapshot and rows supplied by `ps` | `top --help` |
|
|
218
333
|
| `poweroff` | sync pending writes and power off through the Linux reboot system call | `poweroff --help` |
|
|
334
|
+
| `reboot` | sync pending writes and restart through the shared Linux reboot logic | `reboot --help` |
|
|
335
|
+
| `tar` | create, extract, or list tar archives with gzip and zstd compression through `Bun.Archive` | `tar --help` |
|
|
336
|
+
| `bunterm` | a graphical terminal on the framebuffer: Skia (CanvasKit) text with CJK, colour emoji, seamless box drawing, kitty graphics images; xterm.js's emulator core over Bun's built-in PTY | `bunterm --help` |
|
|
337
|
+
|
|
338
|
+
Besides `bun` (and `sh`/`node` pointing at it), `/bin` includes nine commands
|
|
339
|
+
implemented as Bun scripts.
|
|
340
|
+
|
|
341
|
+
The small `tar` follows the current `Bun.Archive` boundary: extraction
|
|
342
|
+
restores directories and symbolic links, while hard links are skipped by Bun
|
|
343
|
+
1.4.3. Creation stores regular files but not Unix metadata, links, or empty
|
|
344
|
+
directories, and listing reports regular files only. It supports gzip and
|
|
345
|
+
Bun's built-in zstd, not xz or bzip2.
|
|
219
346
|
|
|
220
347
|
`--help` renders each Markdown manual in the terminal. Common examples:
|
|
221
348
|
|
|
@@ -224,6 +351,8 @@ mount /dev/sda1 /mnt --mkdir
|
|
|
224
351
|
mount -fv /dev/sda1 /mnt
|
|
225
352
|
mount -t tmpfs -o size=64M tmpfs /tmp/x
|
|
226
353
|
mount -t ntfs3 -o force /dev/sda3 /mnt/windows
|
|
354
|
+
umount /mnt
|
|
355
|
+
umount -R /mnt
|
|
227
356
|
|
|
228
357
|
ip link set eth0 up
|
|
229
358
|
ip addr add 192.168.1.50/24 dev eth0
|
|
@@ -233,9 +362,32 @@ ip -br addr && ip route
|
|
|
233
362
|
ip addr replace 192.168.1.50/24 dev eth0
|
|
234
363
|
ip route replace default via 192.168.1.1
|
|
235
364
|
|
|
365
|
+
ps -eo pid,args
|
|
366
|
+
ps -ef
|
|
367
|
+
ps aux
|
|
368
|
+
pspac
|
|
369
|
+
top
|
|
370
|
+
top -b -n 1
|
|
371
|
+
|
|
236
372
|
poweroff
|
|
373
|
+
reboot
|
|
374
|
+
|
|
375
|
+
tar cvf /tmp/buninu.tar README.md package.json
|
|
376
|
+
tar tvf /tmp/buninu.tar
|
|
377
|
+
mkdir -p /tmp/buninu-copy
|
|
378
|
+
tar xvf /tmp/buninu.tar -C /tmp/buninu-copy
|
|
379
|
+
|
|
380
|
+
# Add z to create a gzip-compressed archive
|
|
381
|
+
tar czvf /tmp/buninu.tar.gz README.md package.json
|
|
382
|
+
|
|
383
|
+
# On a virtual console: a graphical terminal with CJK, emoji and images
|
|
384
|
+
bunterm
|
|
385
|
+
bunterm /dev/tty1 --font-size 20 -e bun /buninu/apps/jsmdcui/src/index.js --demo
|
|
237
386
|
```
|
|
238
387
|
|
|
388
|
+
The graphics stack behind `bunterm` — the framebuffer module, CanvasKit,
|
|
389
|
+
the fonts and the terminal — is described in [graphics.md](graphics.md).
|
|
390
|
+
|
|
239
391
|
## Environment and dependencies
|
|
240
392
|
|
|
241
393
|
### Build environment
|
|
@@ -340,6 +492,8 @@ bun ./index.js -fb --real --export
|
|
|
340
492
|
`index.js` is the single entry point (`npm run fetch` and `npm run pack` call
|
|
341
493
|
it too). Its physical-image stages run as fetch → build:
|
|
342
494
|
|
|
495
|
+
#### Build flags
|
|
496
|
+
|
|
343
497
|
| flag | runs | use it when |
|
|
344
498
|
| --- | --- | --- |
|
|
345
499
|
| `-f`, `--fetch` | `fetch-alpine.sh`, `fetch-bun.sh` | first clone, or after bumping a pinned version |
|
|
@@ -356,8 +510,8 @@ bun x buninu-linux -fb --real --export
|
|
|
356
510
|
|
|
357
511
|
`--linux-lts` selects Alpine's general-purpose LTS kernel. `--real` implies
|
|
358
512
|
`--linux-lts` and builds for physical hardware: it makes `tty0` the primary
|
|
359
|
-
console and includes xHCI/USB HID, common wired
|
|
360
|
-
modules needed by typical laptops and desktops.
|
|
513
|
+
console and includes xHCI/USB HID, common wired NIC, Android USB-tethering,
|
|
514
|
+
storage and ACPI power modules needed by typical laptops and desktops.
|
|
361
515
|
|
|
362
516
|
For real hardware, `-fb --real` is the complete image pipeline and
|
|
363
517
|
`-b --real` is the edit-and-rebuild loop. Before starting, `index.js` checks
|
|
@@ -396,6 +550,8 @@ The primary `bun ./index.js -fb --real` pipeline runs the steps below in order;
|
|
|
396
550
|
each writes files the next one reads. When selected, `--export` runs afterward
|
|
397
551
|
and copies the final `vda.img` to the invocation directory.
|
|
398
552
|
|
|
553
|
+
##### Pipeline inputs and outputs
|
|
554
|
+
|
|
399
555
|
| script | reads | writes |
|
|
400
556
|
| --- | --- | --- |
|
|
401
557
|
| `fetch-alpine.sh` | Alpine CDN | `kernel/vmlinuz-lts`, `kernel/linuxx64.efi.stub`, musl, and the selected network, storage, input, power and filesystem modules with trimmed module indexes |
|
|
@@ -423,6 +579,8 @@ boot.
|
|
|
423
579
|
`build-uki.sh` appends sections to systemd's `linuxx64.efi.stub` with
|
|
424
580
|
`objcopy`, at hand-picked VMAs because `objcopy` will not lay them out for you:
|
|
425
581
|
|
|
582
|
+
##### UKI sections
|
|
583
|
+
|
|
426
584
|
| section | offset from image base | contents | size |
|
|
427
585
|
| --- | --- | --- | --- |
|
|
428
586
|
| `.text` | +0x0 | the stub itself | 66 KB |
|
|
@@ -589,7 +747,7 @@ Which modules the image carries is the list in `fetch-alpine.sh`; the
|
|
|
589
747
|
`select_module` helper there pulls in dependencies from Alpine's
|
|
590
748
|
`modules.dep`, and `--real` adds common storage paths (`sd_mod`, `ahci`,
|
|
591
749
|
`ata_generic`, `pata_acpi`, `nvme`, Intel `vmd`, `usb-storage` and `uas`),
|
|
592
|
-
the wired NICs and the ACPI power drivers. Alpine's
|
|
750
|
+
the wired NICs, Android USB-tethering drivers and the ACPI power drivers. Alpine's
|
|
593
751
|
kernels build all of these as modules; a self-built kernel with them `=y`
|
|
594
752
|
works the same way, the loaders just find nothing to load.
|
|
595
753
|
|
|
@@ -685,8 +843,10 @@ loads the packaged SATA/PATA/SCSI, NVMe/VMD and USB storage stacks so
|
|
|
685
843
|
their disks and partitions appear in `/dev`, then lists `/sys/class/block`. `cfg.all`
|
|
686
844
|
unconditionally attempts every packaged module and recursively loads its
|
|
687
845
|
declared dependencies. `--real` ships Intel `e1000`/`e1000e`/`igb`/`igc`,
|
|
688
|
-
Realtek `r8169`, Atheros `alx`, Broadcom `tg3
|
|
689
|
-
`cdc_ether`
|
|
846
|
+
Realtek `r8169`, Atheros `alx`, Broadcom `tg3`, common USB dongles, and
|
|
847
|
+
`rndis_host`/`cdc_ether`/`cdc_ncm`/`cdc_eem`/`cdc_subset`/`zaurus` for Android
|
|
848
|
+
USB tethering. `cfg.net` unconditionally attempts all of these packaged
|
|
849
|
+
network modules. `cfg.power` loads the ACPI
|
|
690
850
|
`battery`, `ac`, `button` and `thermal` modules through `/lib/modprobe.js`
|
|
691
851
|
and lists `/sys/class/power_supply` (a desktop without a battery simply
|
|
692
852
|
reports nothing registered). Nothing loads them at boot. PID 1 also installs
|
|
@@ -694,12 +854,49 @@ reports nothing registered). Nothing loads them at boot. PID 1 also installs
|
|
|
694
854
|
`Promise.reject()` at the prompt makes Bun exit, which is a kernel panic
|
|
695
855
|
(`Attempted to kill init!`).
|
|
696
856
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
857
|
+
`start()` launches the bundled Buninu userspace and its bunmsh (Bun Modern Shell) with
|
|
858
|
+
the current process environment preserved, while overriding `PATH` and `HOME`
|
|
859
|
+
for the userspace session.
|
|
860
|
+
|
|
861
|
+
## Contents
|
|
862
|
+
|
|
863
|
+
- [Quick start](#quick-start)
|
|
864
|
+
* [Steps](#steps)
|
|
865
|
+
+ [Build directly with bun x](#build-directly-with-bun-x)
|
|
866
|
+
+ [Or build from a source checkout](#or-build-from-a-source-checkout)
|
|
867
|
+
+ [Write the image to a USB drive](#write-the-image-to-a-usb-drive)
|
|
868
|
+
+ [Booting from the USB drive](#booting-from-the-usb-drive)
|
|
869
|
+
- [Using Buninu Linux](#using-buninu-linux)
|
|
870
|
+
* [Basic configuration](#basic-configuration)
|
|
871
|
+
* [Editor quick start](#editor-quick-start)
|
|
872
|
+
* [Panes, terminals, and tabs](#panes-terminals-and-tabs)
|
|
873
|
+
+ [Pane and tab controls](#pane-and-tab-controls)
|
|
874
|
+
* [Using Bun Modern Shell](#using-bun-modern-shell)
|
|
875
|
+
* [Showing images](#showing-images)
|
|
876
|
+
- [Commands inside /bin](#commands-inside-bin)
|
|
877
|
+
- [Environment and dependencies](#environment-and-dependencies)
|
|
878
|
+
* [Build environment](#build-environment)
|
|
879
|
+
* [Buninu Linux (Section 2)](#buninu-linux-section-2)
|
|
880
|
+
* [Hello world (Section 1)](#hello-world-section-1)
|
|
881
|
+
* [Retired native bootstrap](#retired-native-bootstrap)
|
|
882
|
+
- [Implementation details](#implementation-details)
|
|
883
|
+
* [1. Hello world](#1-hello-world)
|
|
884
|
+
* [2. Buninu Linux – Bun as PID 1](#2-buninu-linux-bun-as-pid-1)
|
|
885
|
+
+ [Build flags](#build-flags)
|
|
886
|
+
+ [Build pipeline](#build-pipeline)
|
|
887
|
+
- [Pipeline inputs and outputs](#pipeline-inputs-and-outputs)
|
|
888
|
+
+ [UKI layout](#uki-layout)
|
|
889
|
+
- [UKI sections](#uki-sections)
|
|
890
|
+
+ [Disk layout](#disk-layout)
|
|
891
|
+
+ [Real-hardware boot details](#real-hardware-boot-details)
|
|
892
|
+
+ [QEMU development](#qemu-development)
|
|
893
|
+
- [QEMU networking](#qemu-networking)
|
|
894
|
+
+ [Command implementation](#command-implementation)
|
|
895
|
+
+ [Reaching JavaScript with nothing mounted](#reaching-javascript-with-nothing-mounted)
|
|
896
|
+
+ [What init.js does](#what-initjs-does)
|
|
897
|
+
- [Authorship](#authorship)
|
|
898
|
+
- [License](#license)
|
|
899
|
+
* [Bundled component licenses](#bundled-component-licenses)
|
|
703
900
|
|
|
704
901
|
## Authorship
|
|
705
902
|
|
|
@@ -721,6 +918,8 @@ The repository also commits four third-party platform binaries under
|
|
|
721
918
|
`initramfs/lib/`, and the built image redistributes several more. Each stays
|
|
722
919
|
under its own terms, with the full texts in [`LICENSES/`](LICENSES/):
|
|
723
920
|
|
|
921
|
+
### Bundled component licenses
|
|
922
|
+
|
|
724
923
|
| Component | License | Where |
|
|
725
924
|
|---|---|---|
|
|
726
925
|
| musl (`ld-musl-x86_64.so.1`, `libc.musl-x86_64.so.1`) | MIT | committed |
|
|
@@ -728,6 +927,11 @@ under its own terms, with the full texts in [`LICENSES/`](LICENSES/):
|
|
|
728
927
|
| Linux kernels and networking, storage, xHCI, USB and HID modules | GPL-2.0-only with the Linux syscall note | image only |
|
|
729
928
|
| systemd EFI stub | LGPL-2.1-or-later | image only |
|
|
730
929
|
| Bun | MIT, plus the licenses of what it statically links | image only |
|
|
930
|
+
| CanvasKit 0.41.1 (`initramfs/lib/canvaskit/`, Skia compiled to WebAssembly) | BSD-3-Clause (`LICENSES/BSD-3-Clause-Skia.txt`) | committed |
|
|
931
|
+
| xterm.js 6.0.0 headless core and unicode-graphemes addon (`initramfs/lib/xterm/`); box-drawing shape tables in `initramfs/lib/bunterm/glyphs.js` | MIT (`LICENSES/MIT-xterm.js.txt`) | committed |
|
|
932
|
+
| DejaVu Sans Mono (`initramfs/usr/share/fonts/DejaVuSansMono*.ttf`) | Bitstream Vera (`LICENSES/Bitstream-Vera.txt`) | committed |
|
|
933
|
+
| Noto Sans CJK, Noto Color Emoji (+ Flags), Noto Sans Symbols (`initramfs/usr/share/fonts/Noto*`) | SIL OFL 1.1 (`LICENSES/OFL-1.1.txt`) | committed |
|
|
934
|
+
| Roboto (`initramfs/usr/share/fonts/Roboto-Regular.ttf`) | Apache-2.0 (`LICENSES/Apache-2.0.txt`) | committed |
|
|
731
935
|
|
|
732
936
|
One component is worth naming here rather than leaving to be found: the two
|
|
733
937
|
GCC runtime libraries are **GPL-3.0 with the GCC Runtime Library Exception**
|
package/fetch-alpine.sh
CHANGED
|
@@ -79,10 +79,15 @@ if [ "${REAL_MACHINE:-}" = 1 ]; then
|
|
|
79
79
|
select_module "$module"
|
|
80
80
|
done
|
|
81
81
|
# Wired NICs: Intel (e1000/e1000e/igb/igc), Realtek (r8169 plus its PHY
|
|
82
|
-
# driver), Qualcomm Atheros (alx), Broadcom (tg3), and USB dongles
|
|
83
|
-
#
|
|
84
|
-
#
|
|
85
|
-
|
|
82
|
+
# driver), Qualcomm Atheros (alx), Broadcom (tg3), and USB dongles.
|
|
83
|
+
# Android USB tethering commonly presents RNDIS, CDC ECM/NCM/EEM, or an
|
|
84
|
+
# older CDC subset/zaurus-compatible gadget. Selecting the leaf drivers
|
|
85
|
+
# recursively includes usbnet, mii, usbcore and usb-common from
|
|
86
|
+
# modules.dep. cfg.net unconditionally attempts every packaged
|
|
87
|
+
# kernel/drivers/net module, then matches USB and PCI modaliases.
|
|
88
|
+
for module in e1000 e1000e igb igc r8169 realtek alx tg3 \
|
|
89
|
+
r8152 ax88179_178a cdc_ether rndis_host cdc_ncm cdc_eem \
|
|
90
|
+
cdc_subset zaurus; do
|
|
86
91
|
select_module "$module"
|
|
87
92
|
done
|
|
88
93
|
fi
|
package/graphics.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# The Buninu Linux graphics stack
|
|
2
|
+
|
|
3
|
+
Buninu Linux draws on the screen without X11, Wayland, a GPU or any native
|
|
4
|
+
graphics library: the Linux framebuffer is mapped into Bun, Skia (compiled to
|
|
5
|
+
WebAssembly as CanvasKit) rasterizes into it, and `bunterm` puts an
|
|
6
|
+
xterm-compatible terminal on top. Everything is JavaScript or WebAssembly
|
|
7
|
+
except the kernel's `/dev/fb0`, reached through a few `ioctl`s and one `mmap`
|
|
8
|
+
via Bun FFI.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
┌──────────────────────────────────────────────────────────────────────┐
|
|
12
|
+
│ programs on a PTY: bunmsh, jsmdcui, bun scripts, kitten icat … │
|
|
13
|
+
└───────────────▲───────────────────────────────┬──────────────────────┘
|
|
14
|
+
keyboard │ (raw console bytes) │ output bytes + kitty APC
|
|
15
|
+
┌───────────────┴───────────────────────────────▼──────────────────────┐
|
|
16
|
+
│ /bin/bunterm → /lib/bunterm/terminal.js │
|
|
17
|
+
│ BunPtyBackend (jsgotty) ─ Bun.spawn({ terminal }) ← Bun's PTY │
|
|
18
|
+
│ KittyGraphicsParser (jsgotty) ─ splits ESC _ G … ESC \ packets │
|
|
19
|
+
│ @xterm/headless Terminal ─ VT parser, screen buffer, attributes │
|
|
20
|
+
│ images.js ─ kitty placements as Skia images anchored to lines │
|
|
21
|
+
│ input.js ─ /dev/ttyN raw mode, console→xterm key sequences │
|
|
22
|
+
│ renderer.js ─ cells → glyphs (fonts) or vectors (glyphs.js) │
|
|
23
|
+
└───────────────────────────────────────────────┬──────────────────────┘
|
|
24
|
+
│ Skia draw calls
|
|
25
|
+
┌───────────────────────────────────────────────▼──────────────────────┐
|
|
26
|
+
│ /lib/canvas.js ─ CanvasKit 0.41.1 (Skia in wasm, /lib/canvaskit/) │
|
|
27
|
+
│ openCanvas(): MakeRasterDirectSurface in the framebuffer's own │
|
|
28
|
+
│ pixel format (BGRA_8888 / RGBA_8888 / RGB_565) inside the wasm heap │
|
|
29
|
+
│ loadFontSet(): /usr/share/fonts/fonts.json → Typefaces + FontMgr │
|
|
30
|
+
└───────────────────────────────────────────────┬──────────────────────┘
|
|
31
|
+
│ one memcpy per frame
|
|
32
|
+
┌───────────────────────────────────────────────▼──────────────────────┐
|
|
33
|
+
│ /lib/fbdev.js ─ Framebuffer: FBIOGET_*SCREENINFO, mmap, KDSETMODE │
|
|
34
|
+
│ runGraphics(): graphics mode + restore on exit/signal │
|
|
35
|
+
│ JS drawing (drawLine, fillPolygon …) and blitImageData() fallback │
|
|
36
|
+
└───────────────────────────────────────────────┬──────────────────────┘
|
|
37
|
+
│ ioctl / mmap (bun:ffi, /lib/dlopen.js)
|
|
38
|
+
┌───────────────────────────────────────────────▼──────────────────────┐
|
|
39
|
+
│ Linux: /dev/fb0 (efifb / simpledrm from the UEFI GOP), /dev/ttyN │
|
|
40
|
+
└──────────────────────────────────────────────────────────────────────┘
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Layers
|
|
44
|
+
|
|
45
|
+
### 1. Framebuffer — `/lib/fbdev.js`
|
|
46
|
+
|
|
47
|
+
`Framebuffer` opens `/dev/fb0`, reads the variable and fixed screen info
|
|
48
|
+
(size, stride, bits per pixel, the red/green/blue bit offsets) and `mmap`s
|
|
49
|
+
the device. Drawing goes to a JavaScript back buffer laid out exactly like
|
|
50
|
+
the device; `flush()` copies it row by row into the mapping. Nothing draws
|
|
51
|
+
straight into the mapping: on efifb the memory is write-combining, reads are
|
|
52
|
+
very slow, and drawing there would tear.
|
|
53
|
+
|
|
54
|
+
`runGraphics(draw)` wraps a graphical program: it switches the virtual
|
|
55
|
+
console to `KD_GRAPHICS` (otherwise the kernel's text console keeps
|
|
56
|
+
overwriting the screen), runs `draw`, and restores `KD_TEXT` whether the
|
|
57
|
+
call returns, throws, exits, or is killed by a catchable signal. Given a
|
|
58
|
+
specific `/dev/ttyN`, it `VT_ACTIVATE`s that console first and switches
|
|
59
|
+
back to the previous one at the end; while drawing it takes `VT_PROCESS`
|
|
60
|
+
mode, so Ctrl-Alt-Fn still switches consoles and `onAcquire` lets the
|
|
61
|
+
program repaint when its console returns.
|
|
62
|
+
|
|
63
|
+
Manual: `fbdev --help` / `initramfs/usr/share/doc/buninu-linux/fbdev.md`.
|
|
64
|
+
|
|
65
|
+
### 2. Skia — `/lib/canvas.js` and `/lib/canvaskit/`
|
|
66
|
+
|
|
67
|
+
CanvasKit is Google's Skia compiled to WebAssembly (the same npm package the
|
|
68
|
+
browser uses). WebAssembly can only write its own linear memory, so Skia
|
|
69
|
+
cannot draw into the `mmap` directly. Instead `openCanvas()` allocates a
|
|
70
|
+
buffer in the wasm heap and creates a `MakeRasterDirectSurface` on it in the
|
|
71
|
+
framebuffer's native pixel layout (`pickColorType()` maps the kernel's
|
|
72
|
+
bitfields to `BGRA_8888` for the usual XRGB8888, or `RGBA_8888` /
|
|
73
|
+
`RGB_565`). The `Framebuffer`'s `pixels` view is pointed at that buffer, so
|
|
74
|
+
`flush()` is the same single `memcpy` as before and the JavaScript drawing
|
|
75
|
+
functions keep working on the same frame. A 24-bit or paletted device falls
|
|
76
|
+
back to CanvasKit's HTML-canvas emulation plus `blitImageData()`, which
|
|
77
|
+
converts per pixel.
|
|
78
|
+
|
|
79
|
+
Skia is CPU-only here (no GPU, no WebGL); the whole 1080p frame is a few
|
|
80
|
+
milliseconds to copy and cells are cached by Skia's glyph cache. The wasm
|
|
81
|
+
heap starts at 128 MiB and grows as fonts are loaded into it, which is why
|
|
82
|
+
QEMU is now started with `-m 1G`.
|
|
83
|
+
|
|
84
|
+
`loadFontSet()` reads `/usr/share/fonts/fonts.json` and builds the typefaces
|
|
85
|
+
and a `FontMgr` for a named set (`terminal`, `ui`). Noto Sans CJK is a
|
|
86
|
+
collection; the manager registers all five faces and the set's preferred
|
|
87
|
+
face (`Noto Sans CJK TC`) is the one handed out, so Taiwanese glyph forms
|
|
88
|
+
are used without relying on `locl`.
|
|
89
|
+
|
|
90
|
+
Manual: `initramfs/usr/share/doc/buninu-linux/canvas.md`.
|
|
91
|
+
|
|
92
|
+
### 3. Fonts — `/usr/share/fonts/`
|
|
93
|
+
|
|
94
|
+
| File | Role | License |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `DejaVuSansMono.ttf`, `-Bold.ttf` | terminal grid font: 0.6 em wide, 1.16 em tall, box drawing, arrows, `☐☒✓`, Braille-free but everything jsmdcui draws | Bitstream Vera |
|
|
97
|
+
| `NotoSansCJK-Regular.ttc` | 32 MiB variable collection: JP/KR/SC/TC/HK faces, ~21 000 unified ideographs, ext. A, part of ext. B, kana, bopomofo, hangul, full-width forms | OFL 1.1 |
|
|
98
|
+
| `NotoColorEmoji.ttf`, `NotoColorEmojiFlags.ttf` | CBDT bitmap colour emoji; Skia's FreeType port renders them in colour | OFL 1.1 |
|
|
99
|
+
| `NotoSansSymbols-Regular-Subsetted.ttf`, `-Subsetted2.ttf` | arrows, math, geometric shapes, dingbats, Braille, musical symbols, cards | OFL 1.1 |
|
|
100
|
+
| `Roboto-Regular.ttf` | variable Latin/Greek/Cyrillic for non-terminal UI (`ui` set) | Apache 2.0 |
|
|
101
|
+
|
|
102
|
+
The Noto and Roboto files are the ones Android ships; DejaVu comes from
|
|
103
|
+
Debian. Each license text sits next to the fonts and in `LICENSES/`.
|
|
104
|
+
|
|
105
|
+
### 4. Terminal — `/bin/bunterm` and `/lib/bunterm/`
|
|
106
|
+
|
|
107
|
+
`bunterm` reuses three finished components instead of writing a terminal
|
|
108
|
+
from scratch:
|
|
109
|
+
|
|
110
|
+
- **PTY**: jsgotty's `BunPtyBackend`, which is `Bun.spawn(cmd, { terminal:
|
|
111
|
+
{ cols, rows, data, exit } })` — Bun's built-in pseudo-terminal, no
|
|
112
|
+
node-pty, no FFI. jsgotty now exports the class for this.
|
|
113
|
+
- **Emulation**: `@xterm/headless`, the xterm.js core (VT parser, screen
|
|
114
|
+
and scrollback buffers, SGR attributes, terminal replies, markers) with
|
|
115
|
+
its DOM renderer removed. `@xterm/addon-unicode-graphemes` makes 🇹🇼,
|
|
116
|
+
ZWJ sequences and combining marks occupy one cell.
|
|
117
|
+
- **Images**: jsgotty's `KittyGraphicsParser`, which splits the kitty
|
|
118
|
+
graphics APC packets out of the byte stream, reassembles chunked
|
|
119
|
+
transfers, inflates `o=z`, and produces placement / delete / query events
|
|
120
|
+
and the replies to send back. (Two small changes to the vendored jsgotty:
|
|
121
|
+
the export, and later chunks of a transfer whose first chunk named `i=`
|
|
122
|
+
now continue that transfer, as the protocol allows — to be carried back
|
|
123
|
+
to the jsgotty repository.)
|
|
124
|
+
|
|
125
|
+
Around those, `/lib/bunterm/` adds:
|
|
126
|
+
|
|
127
|
+
| File | Does |
|
|
128
|
+
|---|---|
|
|
129
|
+
| `renderer.js` | Paints `term.buffer` cell by cell. Cell size comes from DejaVu Sans Mono; every glyph is looked up in the regular font, then the fallbacks (colour emoji first for emoji-presentation code points, monochrome symbols first otherwise) and centred in its one or two cells; oversized fallback glyphs are scaled to fit. Multi-code-point graphemes are shaped by Skia's `Paragraph` and cached. Only rows whose content hash changed since the last frame, the cursor rows, and rows under moved images are repainted. 16/256/24-bit colour, bold (with bright base colours), italic, dim, underline, strikethrough, inverse, invisible. |
|
|
130
|
+
| `glyphs.js` | Box drawing (U+2500–257F incl. double, dashed, rounded, mixed-weight), block elements and shades (U+2580–259F), Powerline (U+E0A0–E0BF) and legacy computing (U+1FB70–1FB97) drawn as Skia paths, so they meet seamlessly at any size. The shape tables are xterm.js's `CustomGlyphs.ts` (MIT); coordinates snap to pixel centres for crisp 1-px lines. |
|
|
131
|
+
| `images.js` | Kitty placements: decodes PNG (`f=100`) with Skia or raw RGB/RGBA (`f=24/32`), with `Bun.Image` as a transcoder for other encodings; anchors each placement to an xterm marker so it scrolls with its line and disappears with it (on the alternate screen, where xterm.js issues no markers, to a fixed row that is dropped when that screen ends); sizes in cells (`c,r`) or from pixel size; crops (`x,y,w,h`), cell offsets (`X,Y`), `p=` placement ids, `a=d` deletion scopes, and the cursor move after a placement. |
|
|
132
|
+
| `input.js` | Raw mode on the console (`TCGETS`/`TCSETS` through the shared libc binding) and translation of the kernel's "linux" key sequences to xterm's, honouring DECCKM. |
|
|
133
|
+
| `terminal.js` | `createSession()` wires PTY → parser → emulator → renderer with a coalesced ~60 Hz frame timer and a serialized output queue, so a kitty packet always sees the cursor position left by the text before it. `runTerminal()` adds `runGraphics()` and the keyboard. |
|
|
134
|
+
|
|
135
|
+
Manual: `bunterm --help` / `initramfs/usr/share/doc/buninu-linux/bunterm.md`.
|
|
136
|
+
|
|
137
|
+
## Data flow of one frame
|
|
138
|
+
|
|
139
|
+
1. The program writes to the PTY; Bun delivers the bytes to `BunPtyBackend`'s
|
|
140
|
+
`data` callback.
|
|
141
|
+
2. `KittyGraphicsParser.consume()` returns plain-text runs and kitty packets
|
|
142
|
+
in order. Plain runs go to `term.write()` (awaited, so the buffer is
|
|
143
|
+
current); each packet is parsed with the cursor position at that point,
|
|
144
|
+
handed to `ImageStore`, and acknowledged back to the PTY if the client
|
|
145
|
+
asked.
|
|
146
|
+
3. A frame is requested. Sixteen milliseconds later `Renderer.render()`
|
|
147
|
+
hashes each visible row, repaints the changed ones (background rect,
|
|
148
|
+
glyph or vector, underline), draws the cursor block, and re-draws the
|
|
149
|
+
parts of image placements that intersect the repainted rows.
|
|
150
|
+
4. `screen.flush()` finishes Skia's work and copies the wasm-heap frame into
|
|
151
|
+
the `/dev/fb0` mapping.
|
|
152
|
+
|
|
153
|
+
Keyboard bytes travel the other way: console → `input.js` → PTY. Terminal
|
|
154
|
+
replies (cursor position, device attributes, kitty acks) go from the
|
|
155
|
+
emulator straight to the PTY.
|
|
156
|
+
|
|
157
|
+
## Sizes
|
|
158
|
+
|
|
159
|
+
| Component | Raw | In the gzip initramfs |
|
|
160
|
+
|---|---|---|
|
|
161
|
+
| CanvasKit wasm + js | 7.3 MB | ~2.7 MB |
|
|
162
|
+
| xterm headless + graphemes addon | 0.2 MB | ~0.05 MB |
|
|
163
|
+
| Fonts | 39.9 MB | ~24 MB |
|
|
164
|
+
| Total added | ~47 MB | ~27 MB |
|
|
165
|
+
|
|
166
|
+
The initramfs grew from 44.7 MB to 71.8 MB compressed; the UKI is 84.5 MB and
|
|
167
|
+
the 127 MB EFI system partition keeps 46 MB free. The initramfs is unpacked
|
|
168
|
+
into RAM, and CanvasKit copies the fonts it uses into its heap, so the guest
|
|
169
|
+
needs about 1 GB.
|
|
170
|
+
|
|
171
|
+
## Trying it
|
|
172
|
+
|
|
173
|
+
The framebuffer needs a kernel that provides one. Alpine's `linux-lts` has
|
|
174
|
+
`CONFIG_FB`, `CONFIG_FB_EFI` and `CONFIG_DRM_SIMPLEDRM` built in; the default
|
|
175
|
+
`linux-virt` builds them as modules, and the image ships only the network,
|
|
176
|
+
storage, USB and HID modules, so there `/dev/fb0` never appears. Build with
|
|
177
|
+
`./index.js -b --linux-lts` (or `--real`); under QEMU the lts kernel gets a
|
|
178
|
+
1280×800 `simpledrm` framebuffer from the UEFI GOP even with `-display none`,
|
|
179
|
+
and the monitor's `screendump` shows it. From a virtual console in the guest:
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
bunterm # /bin/sh on this console
|
|
183
|
+
bunterm /dev/tty1 --font-size 20 # from a serial console, use VT 1
|
|
184
|
+
bunterm -e bun /buninu/apps/jsmdcui/src/index.js --demo
|
|
185
|
+
bun /lib/fbdev.js # the plain-framebuffer triangle
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
To render off-screen on the build host (no framebuffer), give `openCanvas()`
|
|
189
|
+
a plain object with `width`, `height`, `stride`, `bitsPerPixel`, `fields` and
|
|
190
|
+
a `pixels` `Uint8Array`, replace `screen.flush`, and snapshot the surface —
|
|
191
|
+
that is how the renderer and the kitty pipeline were tested during
|
|
192
|
+
development (`BUNINU_LIBC=/lib/aarch64-linux-gnu/libc.so.6` lets `dlopen.js`
|
|
193
|
+
load the host libc).
|
|
194
|
+
|
|
195
|
+
Verified in QEMU (lts kernel, `-vga std`, 1 GB): the attribute/CJK/emoji
|
|
196
|
+
sample, a kitty PNG placement, an interactive bunmsh with keys sent through
|
|
197
|
+
the console, and the jsmdcui editor demo all render as on the host;
|
|
198
|
+
`bunterm /dev/tty2` from the serial REPL switches the display to tty2 and
|
|
199
|
+
back to tty1 on exit, and Ctrl-Alt-F2 / Ctrl-Alt-F1 during a session
|
|
200
|
+
switch away and repaint on return. On the
|
|
201
|
+
host, `jsmdcui --tui` on a Markdown file with a JPEG (bunterm sets
|
|
202
|
+
`JSMDCUI_KITTY_MODE=extended` for the program it runs) places the image
|
|
203
|
+
through its transmit / `a=p` / `a=d` sequence exactly as in the browser.
|
|
204
|
+
|
|
205
|
+
## Not done yet
|
|
206
|
+
|
|
207
|
+
- Mouse, selection and scrollback viewing in `bunterm`.
|
|
208
|
+
- Kitty `z < 0` (images behind text), animation frames, Unicode
|
|
209
|
+
placeholders, and shared-memory transmission.
|
|
210
|
+
- Text run shaping with ligatures for single-code-point cells (each cell is
|
|
211
|
+
one glyph; Paragraph shaping is only used for grapheme clusters).
|
|
212
|
+
- Non-terminal UI on `canvas.js` (the `ui` font set and Roboto are there for
|
|
213
|
+
it).
|