mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
Linux build VMs' ssh ports were Lima's own pick, outside the claims lock, so another VM's forwarder could take one before Lima bound it. Lima's start now gets every build VM's port from ports.Allocator.Build on macOS and Linux alike, and sets it with its one edit. - start.go: the l.OS == "darwin" condition goes. - build.go, tools.go: cloneEdits goes; a build VM's start always edits its new ssh port, so the configure step is always counted. - ports.Allocator.Build holds a file lock on run/build-ports/<name> (platform.LockFile) until release, so the kernel lets go of it when devvm ends, killed or not. free, under the claims lock, first deletes (clearStale) the records no process holds that are over 15 minutes old (staleAfter: longer than Lima's 10 minutes of waiting for ssh, which a killed devvm's limactl start may still spend binding it). Tests: TestBuild (a stale record kept while young, then cleared; a held one kept however old), TestStartBuildSSHPort on darwin and linux, TestStartConfined's Linux builds, TestBuildImageLayer, TestBuildTools; TestCloneEdits goes. build.txtar checks the build's port edit and that its record is gone; tools.txtar's steps are one count on both systems; layout.txtar lists run/build-ports on Linux. The limactl stub needed no change: it applies .ssh.localPort on every host, and the contract's scenario already starts builds with a port. Docs: internals/design (reserved ports; the build VM's ssh port lead is now confirmed, fixed), internals/overview, using/space. Co-Authored-By: Claude Opus 5.5 <[email protected]>
81 lines
2.9 KiB
Plaintext
81 lines
2.9 KiB
Plaintext
# Base image features: devvm's own, chosen the first time anything is
|
|
# built (without a terminal, every one), saved in settings.json unless
|
|
# config.toml chooses them, and run in base after base.sh, in the order
|
|
# chosen. A script in ~/.config/devvm/features isn't a feature: your own
|
|
# extras are layers.
|
|
env CHOSEN=$DATA/settings.json
|
|
rm $CHOSEN
|
|
mkdir $XDG_CONFIG_HOME/devvm/features
|
|
cp mine.sh $XDG_CONFIG_HOME/devvm/features/mine.sh
|
|
mkdir $XDG_CONFIG_HOME/devvm/layers
|
|
cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
|
|
|
|
exec devvm build base
|
|
! stderr .
|
|
! stdout features_help
|
|
stdout '^==> base_features features=cli-tools fzf omb$'
|
|
grep '^ "features": \[\n "cli-tools",\n "fzf",\n "omb"\n \]$' $CHOSEN
|
|
cmp $STUB_DIR/scripts ran-all
|
|
catg $DATA/logs/runs/*.log
|
|
stdout '^# \[4/10\] running_script script=apt\.sh vm=devvm-img-'
|
|
stdout '^# \[5/10\] running_script script=base\.sh vm=devvm-img-'
|
|
stdout '^# \[6/10\] running_script script=cli-tools\.sh vm=devvm-img-'
|
|
stdout '^# \[9/10\] running_script script=apt\.sh vm=devvm-img-'
|
|
stdout '^# \[10/10\] stopping vm=devvm-img-'
|
|
|
|
# Chosen once: the next build keeps the choice, and base. The script in
|
|
# ~/.config/devvm/features is in no image's key.
|
|
exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/features/mine.sh"'
|
|
exec devvm build base
|
|
! stdout 'base_features|building_image'
|
|
|
|
# A chosen feature without a script is skipped, with a warning, mine
|
|
# among them; the steps count only what runs. A layer runs only its own
|
|
# script. config.toml's features win over settings.json's.
|
|
cp some.toml $CFG/config.toml
|
|
exec sh -c ': > "$STUB_DIR/scripts"'
|
|
exec devvm build foo
|
|
stderr '^devvm: unknown_feature feature=nope$'
|
|
stderr '^devvm: unknown_feature feature=mine$'
|
|
! stdout base_features
|
|
cmp $STUB_DIR/scripts ran-some
|
|
exec sh -c 'cat "$XDG_DATA_HOME"/devvm/logs/runs/*.log'
|
|
stdout '^# \[5/9\] running_script script=base\.sh vm=devvm-img-'
|
|
stdout '^# \[6/9\] running_script script=fzf\.sh vm=devvm-img-'
|
|
stdout '^# \[7/9\] running_script script=omb\.sh vm=devvm-img-'
|
|
stdout '^# \[9/9\] stopping vm=devvm-img-'
|
|
stdout '^# \[5/6\] running_script script=foo\.sh vm=devvm-img-'
|
|
! stdout '\[10/9\]|\[7/6\]'
|
|
|
|
# None chosen: base runs only base.sh.
|
|
cp none.toml $CFG/config.toml
|
|
exec sh -c ': > "$STUB_DIR/scripts"'
|
|
exec devvm build base
|
|
! stderr .
|
|
cmp $STUB_DIR/scripts ran-none
|
|
grep '"omb"' $CHOSEN
|
|
|
|
-- some.toml --
|
|
features = ["fzf", "omb", "nope", "mine"]
|
|
-- none.toml --
|
|
features = []
|
|
|
|
-- mine.sh --
|
|
#!/bin/bash
|
|
# my tools
|
|
-- foo.sh --
|
|
#!/bin/bash
|
|
echo foo
|
|
-- ran-all --
|
|
# Essentials, and mise for the shared tools (shared-tools/).
|
|
# CLI tools: bat, fd, eza, zoxide (z), btop, tree, tldr
|
|
# fzf: fuzzy Ctrl-R history and Ctrl-T file search
|
|
# oh-my-bash: themed prompt, completions, aliases
|
|
-- ran-some --
|
|
# Essentials, and mise for the shared tools (shared-tools/).
|
|
# fzf: fuzzy Ctrl-R history and Ctrl-T file search
|
|
# oh-my-bash: themed prompt, completions, aliases
|
|
echo foo
|
|
-- ran-none --
|
|
# Essentials, and mise for the shared tools (shared-tools/).
|