Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail helpfully when running on mac #173

Merged
merged 1 commit into from
Dec 19, 2023
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
5 changes: 5 additions & 0 deletions pkg/leeway/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ func Build(pkg *Package, opts ...BuildOption) (err error) {
return err
}

err = checkForCpCompatibility()
if err != nil {
return err
}

requirements := pkg.GetTransitiveDependencies()
allpkg := append(requirements, pkg)

Expand Down
21 changes: 21 additions & 0 deletions pkg/leeway/build_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,29 @@ package leeway

import (
"fmt"
"os/exec"
"strings"

log "github.com/sirupsen/logrus"
)

func checkForCpCompatibility() error {
out, err := exec.Command("cp", "--help").CombinedOutput()
if err != nil && !strings.Contains(err.Error(), "exit") {
log.WithError(err).Debug("cannot check if cp is compatible")
// if cp is not compatible we'll fail later in the build,
// but maybe it is and we don't want to fail here for no good reason.
return nil
}

if strings.Contains(string(out), "--parents") {
// we're good
return nil
}

return fmt.Errorf("leeway requires a GNU-compatible cp. Please install using `brew install coreutils`; make sure you update your PATH after installing.")
}

func executeCommandsForPackageSafe(buildctx *buildContext, p *Package, wd string, commands [][]string) error {
return fmt.Errorf("not implemented")
}
5 changes: 5 additions & 0 deletions pkg/leeway/build_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import (
log "github.com/sirupsen/logrus"
)

func checkForCpCompatibility() error {
// we're on linux - just assume it's GNU cp
return nil
}

func executeCommandsForPackageSafe(buildctx *buildContext, p *Package, wd string, commands [][]string) error {
tmpdir, err := os.MkdirTemp("", "leeway-*")
if err != nil {
Expand Down
Loading