From 430b018aa96a0f792d7bc3bdea3f49a9b6d0c394 Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Fri, 29 May 2026 18:09:30 -0500 Subject: [PATCH] fixes for bashtop removal --- coverage2_test.go | 50 ----------------------------------------------- pkgmgr.go | 19 ------------------ system.go | 5 ++++- system_test.go | 25 ------------------------ 4 files changed, 4 insertions(+), 95 deletions(-) diff --git a/coverage2_test.go b/coverage2_test.go index fb5d30b..0e5a347 100644 --- a/coverage2_test.go +++ b/coverage2_test.go @@ -610,57 +610,7 @@ func TestSetupVivaldiRepoExisting(t *testing.T) { // ── special installer branches ────────────────────────────────────────── -func TestInstallBashtopExistingClone(t *testing.T) { - defer resetMocks() - osStat = func(_ string) (os.FileInfo, error) { return nil, nil } - runCmd = func(_ []string, _ CmdOpts) CmdResult { return CmdResult{ExitCode: 0} } - installBashtop("/tmp") -} -func TestInstallBashtopPullFails(t *testing.T) { - defer resetMocks() - osStat = func(_ string) (os.FileInfo, error) { return nil, nil } - runCmd = func(argv []string, _ CmdOpts) CmdResult { - if len(argv) > 1 && argv[1] == "-C" { - return CmdResult{ExitCode: 1} - } - return CmdResult{ExitCode: 0} - } - installBashtop("/tmp") - if !hasIssueContaining("bashtop git pull failed") { - t.Error("expected pull failure error") - } -} - -func TestInstallBashtopCloneFails(t *testing.T) { - defer resetMocks() - osStat = func(_ string) (os.FileInfo, error) { return nil, os.ErrNotExist } - runCmd = func(argv []string, _ CmdOpts) CmdResult { - if argv[0] == "git" && argv[1] == "clone" { - return CmdResult{ExitCode: 1} - } - return CmdResult{ExitCode: 0} - } - installBashtop("/tmp") - if !hasIssueContaining("bashtop git clone failed") { - t.Error("expected clone failure error") - } -} - -func TestInstallBashtopMakeFails(t *testing.T) { - defer resetMocks() - osStat = func(_ string) (os.FileInfo, error) { return nil, os.ErrNotExist } - runCmd = func(argv []string, _ CmdOpts) CmdResult { - if argv[0] == "make" { - return CmdResult{ExitCode: 1} - } - return CmdResult{ExitCode: 0} - } - installBashtop("/tmp") - if !hasIssueContaining("make install") { - t.Error("expected make install failure error") - } -} func TestInstallPulumiNoVersion(t *testing.T) { defer resetMocks() diff --git a/pkgmgr.go b/pkgmgr.go index 6f4fcb2..ff26072 100644 --- a/pkgmgr.go +++ b/pkgmgr.go @@ -223,25 +223,6 @@ func resolveSystemPkgs(names []string) ([]string, []string) { return resolved, skipped } -func installSystemPackages(pkgs []string, special []string) { - if len(special) > 0 { - tmp, err := os.MkdirTemp("", "bootstrap-special-") - if err != nil { - errLog(fmt.Sprintf("could not create temp dir for special packages: %v", err)) - return - } - defer osRemoveAll(tmp) - for _, pkg := range special { - fmt.Printf("\n [SPECIAL] Installing %s ...\n", pkg) - installSpecialPkg(pkg, tmp) - } - } - - if pkgMgr == "apt-get" && hasCmd("fdfind") { - runCmd([]string{"ln", "-sf", "/usr/bin/fdfind", "/usr/local/bin/fd"}, CmdOpts{AsSudo: true}) - } -} - // isSystemPkgInstalled queries the host package manager. func isSystemPkgInstalled(pkg string) bool { switch pkgMgr { diff --git a/system.go b/system.go index 7b2e356..eb5516f 100644 --- a/system.go +++ b/system.go @@ -37,7 +37,6 @@ var guiSystemPkgs = map[string]bool{ } func isSpecialPkgInstalled(pkg string) bool { - home, _ := os.UserHomeDir() exists := func(p string) bool { _, err := osStat(p); return err == nil } switch pkg { case "obsidian": @@ -497,6 +496,10 @@ func installSystemPackages(regular, special []string) { installSpecialPkg(pkg, tmp) } } + + if pkgMgr == "apt-get" && hasCmd("fdfind") { + runCmd([]string{"ln", "-sf", "/usr/bin/fdfind", "/usr/local/bin/fd"}, CmdOpts{AsSudo: true}) + } } // appendProfileLine adds a PATH/env line to a system-wide login-shell profile, diff --git a/system_test.go b/system_test.go index 7bc76c1..fc9b460 100644 --- a/system_test.go +++ b/system_test.go @@ -247,32 +247,7 @@ func TestInstallMinikube(t *testing.T) { } } -func TestInstallBashtop(t *testing.T) { - defer resetMocks() - osStat = func(name string) (os.FileInfo, error) { - return nil, os.ErrNotExist // Not cloned yet - } - - var runCmdCalls [][]string - runCmd = func(argv []string, opts CmdOpts) CmdResult { - runCmdCalls = append(runCmdCalls, argv) - return CmdResult{ExitCode: 0} - } - - installBashtop("/tmp") - - // Git clone and make install should be run - if len(runCmdCalls) < 2 { - t.Fatalf("expected git clone and make install, got calls: %v", runCmdCalls) - } - if runCmdCalls[0][1] != "clone" { - t.Errorf("expected git clone, got %v", runCmdCalls[0]) - } - if runCmdCalls[1][0] != "make" || runCmdCalls[1][1] != "install" { - t.Errorf("expected make install, got %v", runCmdCalls[1]) - } -} func TestInstallPulumi(t *testing.T) { defer resetMocks()