diff --git a/internal/provider/install.go b/internal/provider/install.go index f622217e9..0bdfad9cb 100644 --- a/internal/provider/install.go +++ b/internal/provider/install.go @@ -145,19 +145,18 @@ func runUntilInstalled(ctx context.Context, cmd *exec.Cmd, c agentCLI) ([]byte, } // shellInstallerRuns is whether a vendor's `curl … | bash` can run here: -// bash, and curl or wget for it to download with. magpie's Docker image -// (distroless) has none of them, and the install failed there with "exec: -// bash: not found". A var so tests can say there is none. +// bash, and curl, which every one-liner (and the scripts behind them) +// downloads with. magpie's Docker image had none of them, and the install +// failed there with "exec: bash: not found". Since 7bfe3137 it has bash and +// busybox's wget but still no curl, and the one-liner failed there too. A +// var so tests can say there is none. var shellInstallerRuns = func() bool { - if _, err := exec.LookPath("bash"); err != nil { - return false - } - for _, d := range []string{"curl", "wget"} { - if _, err := exec.LookPath(d); err == nil { - return true + for _, p := range []string{"bash", "curl"} { + if _, err := exec.LookPath(p); err != nil { + return false } } - return false + return true } // installCLI installs c with its vendor's installer and makes sure magpie diff --git a/internal/provider/install_test.go b/internal/provider/install_test.go index d6e9c99e8..4330c7796 100644 --- a/internal/provider/install_test.go +++ b/internal/provider/install_test.go @@ -186,3 +186,23 @@ func waitPast(t *testing.T, id, state string) SignInState { t.Fatalf("still %s", state) return SignInState{} } + +// magpie's Docker image has bash and busybox's wget but no curl, which every +// vendor's one-liner downloads with: there the native installer is used +func TestShellInstallerNeedsCurl(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("the shell installer is for macOS and Linux") + } + bin := t.TempDir() + for _, p := range []string{"bash", "wget"} { + testenv.Program(t, filepath.Join(bin, p), "#!/bin/sh\n") + } + t.Setenv("PATH", bin) + if shellInstallerRuns() { + t.Fatal("the shell installer runs with bash and wget, without curl") + } + testenv.Program(t, filepath.Join(bin, "curl"), "#!/bin/sh\n") + if !shellInstallerRuns() { + t.Fatal("the shell installer doesn't run with bash and curl") + } +}