diff --git a/bin/check_go_path b/bin/check_go_path index 589696466389..7f2692cc94e8 100755 --- a/bin/check_go_path +++ b/bin/check_go_path @@ -1,19 +1,18 @@ #!/bin/sh -PWD=$1 +set -e -if [ -z "$PWD" ]; then - echo "must pass in your current working directory" - exit 1 -fi +PKG="$1" -while [ ${#} -gt 1 ]; do - if [ "$PWD" = "$2" ]; then - exit 0 - fi - shift +PWD="$(realpath "$(pwd)")" +GOPATH="$(go env GOPATH)" + +for p in IFS=: "${GOPATH}"; do + if [ "$PWD" = "$(realpath "$p")/src/$PKG" ]; then + exit 0 + fi done echo "go-ipfs must be built from within your \$GOPATH directory." -echo "expected within '$(go env GOPATH)' but got '$PWD'" +echo "expected within '$GOPATH' but got '$PWD'" exit 1 diff --git a/mk/golang.mk b/mk/golang.mk index 87e5ea3aa691..aa2da8e96215 100644 --- a/mk/golang.mk +++ b/mk/golang.mk @@ -66,7 +66,7 @@ check_go_version: DEPS_GO += check_go_version check_go_path: - bin/check_go_path $(realpath $(shell pwd)) $(realpath $(addsuffix /src/github.com/ipfs/go-ipfs,$(subst $(PATH_SEP),$(space),$(GOPATH)))) + GOPATH="$(GOPATH)" bin/check_go_path github.com/ipfs/go-ipfs .PHONY: check_go_path DEPS_GO += check_go_path