Skip to content

Commit da7d606

Browse files
committed
Fail helpfully when running on mac
1 parent 3e29cfd commit da7d606

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

pkg/leeway/build.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,11 @@ func Build(pkg *Package, opts ...BuildOption) (err error) {
396396
return err
397397
}
398398

399+
err = checkForCpCompatibility()
400+
if err != nil {
401+
return err
402+
}
403+
399404
requirements := pkg.GetTransitiveDependencies()
400405
allpkg := append(requirements, pkg)
401406

pkg/leeway/build_darwin.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,29 @@ package leeway
22

33
import (
44
"fmt"
5+
"os/exec"
6+
"strings"
7+
8+
log "github.com/sirupsen/logrus"
59
)
610

11+
func checkForCpCompatibility() error {
12+
out, err := exec.Command("cp", "--help").CombinedOutput()
13+
if err != nil && !strings.Contains(err.Error(), "exit") {
14+
log.WithError(err).Debug("cannot check if cp is compatible")
15+
// if cp is not compatible we'll fail later in the build,
16+
// but maybe it is and we don't want to fail here for no good reason.
17+
return nil
18+
}
19+
20+
if strings.Contains(string(out), "--parents") {
21+
// we're good
22+
return nil
23+
}
24+
25+
return fmt.Errorf("leeway requires a GNU-compatible cp. Please install using `brew install coreutils`; make sure you update your PATH after installing.")
26+
}
27+
728
func executeCommandsForPackageSafe(buildctx *buildContext, p *Package, wd string, commands [][]string) error {
829
return fmt.Errorf("not implemented")
930
}

pkg/leeway/build_linux.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ import (
1414
log "github.com/sirupsen/logrus"
1515
)
1616

17+
func checkForCpCompatibility() error {
18+
// we're on linux - just assume it's GNU cp
19+
return nil
20+
}
21+
1722
func executeCommandsForPackageSafe(buildctx *buildContext, p *Package, wd string, commands [][]string) error {
1823
tmpdir, err := os.MkdirTemp("", "leeway-*")
1924
if err != nil {

0 commit comments

Comments
 (0)