Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/guest/bundled/arch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ seed_packages = []

[pkg]
setup = "pacman -Sy --noconfirm"
install = ["pacman", "-S", "--noconfirm"]
install = ["pacman", "-S", "--noconfirm", "--needed"]
scaffold_setup = "pacman -Sy --noconfirm\n"
scaffold_install = "pacman -S --noconfirm "
scaffold_install = "pacman -S --noconfirm --needed "
# Arch names its Python 3 package "python".
runtime_packages = { python3 = "python" }

Expand Down
17 changes: 17 additions & 0 deletions internal/guest/prelude_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"
"os/exec"
"path/filepath"
"slices"
"strings"
"testing"
)
Expand Down Expand Up @@ -171,3 +172,19 @@ func TestWithPreludeKeepsShebangFirst(t *testing.T) {
t.Errorf("no-shebang case: %q", got)
}
}

// pacman reinstalls a package it already has unless --needed is passed.
// devtools and build-deps both install base-devel on Arch, so a VM that
// selects both would download the whole group twice.
func TestArchInstallSkipsSatisfiedPackages(t *testing.T) {
o, ok := Lookup("arch")
if !ok {
t.Fatal("bundled arch missing")
}
if !slices.Contains(o.Pkg.Install, "--needed") {
t.Errorf("arch install = %v, want --needed", o.Pkg.Install)
}
if !strings.Contains(o.Pkg.ScaffoldInstall, "--needed") {
t.Errorf("arch scaffold_install = %q, want --needed", o.Pkg.ScaffoldInstall)
}
}
2 changes: 1 addition & 1 deletion internal/guest/testdata/prelude/arch.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
stoat_pkg_setup() { pacman -Sy --noconfirm; }
stoat_pkg_install() { 'pacman' '-S' '--noconfirm' "$@"; }
stoat_pkg_install() { 'pacman' '-S' '--noconfirm' '--needed' "$@"; }
stoat_svc_enable() { systemctl enable "$1"; }
stoat_svc_start() { systemctl start "$1"; }
stoat_svc_stop() { systemctl stop "$1"; }
Expand Down
Loading