Bake mise into default VM images

New VMs should have mise available without a per-VM bootstrap step, and the activation needs to work in the default root bash workflow.

Install a pinned mise binary during both the Go-native image build path and the customize.sh rootfs rebuild path, then enable bash activation through /etc/profile.d for login shells and /etc/bash.bashrc for interactive shells.

Add a regression around the generated provisioning script and validate with bash -n customize.sh, go test ./..., and make build. Rebuilding the default rootfs is still required before future default-image VMs pick up the change.
This commit is contained in:
Thales Maciel 2026-03-18 13:13:11 -03:00
parent 7b7f7e676c
commit ff8482b841
No known key found for this signature in database
GPG key ID: 33112E6833C34679
3 changed files with 64 additions and 0 deletions

View file

@ -0,0 +1,23 @@
package daemon
import (
"strings"
"testing"
)
func TestBuildProvisionScriptInstallsAndActivatesMise(t *testing.T) {
t.Parallel()
script := buildProvisionScript("devbox", "1.1.1.1", []string{"git", "curl"}, false)
for _, snippet := range []string{
"curl -fsSL https://mise.run | MISE_INSTALL_PATH='/usr/local/bin/mise' MISE_VERSION='v2025.12.0' sh",
"cat > /etc/profile.d/mise.sh <<'EOF'",
"if [ -n \"${BASH_VERSION:-}\" ] && [ -x '/usr/local/bin/mise' ]; then",
`eval "$(/usr/local/bin/mise activate bash)"`,
`if ! grep -Fqx 'eval "$(/usr/local/bin/mise activate bash)"' '/etc/bash.bashrc'; then`,
} {
if !strings.Contains(script, snippet) {
t.Fatalf("buildProvisionScript missing snippet %q\nscript:\n%s", snippet, script)
}
}
}