Extend the default image provisioning path so opencode is installed through mise as part of both the Go-native image builder and the shell-based rootfs customization flow. That keeps new images consistent regardless of which build path produced them. The change reuses the existing mise activation setup instead of adding a second tool bootstrap path, and adds a provisioning-script assertion so the generated guest setup includes the opencode install step. Verified with bash -n customize.sh and go test ./....
24 lines
819 B
Go
24 lines
819 B
Go
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",
|
|
"'/usr/local/bin/mise' use -g 'github:anomalyco/opencode'",
|
|
"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)
|
|
}
|
|
}
|
|
}
|