summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-02 16:25:19 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-02 16:36:12 +0200
commita050431f2660d73e191ab8100d2f0934c8aedbf9 (patch)
tree5e6f4802e9fddec1f1bbade4079f16b2e78e3002
parent0c976003c8690506915dab0003138283307a8089 (diff)
Makefile: export PWD for OpenBSD's ksh(1)
Interestingly, ksh(1) on OpenBSD does not export PWD by default, and it also has a notion of the "logical cwd" vs the "physical cwd", with the latter being passed to chdir, but the former being stored in the non-exported PWD and displayed to the user. This means that if you `cd` into a directory that's comprised of symlinks, exec'd processes will see the physical path. Observe: # ksh # mkdir a # ln -s a b # cd b # pwd /root/b # ksh -c pwd /root/a The fact of separating physical and logical paths is not too uncommon for shells (bash does it too), but not exporting PWD is very odd. Since this is common behavior for many shells, libraries that return the working directory will do something strange: they `stat(".")` and then `stat(getenv("PWD"))`, and if these point to the same inode, they roll with the value of `getenv("PWD")`, or otherwise fallback to asking the kernel for the cwd. Since PWD was not exported by ksh(1), Go's dep utility did not understand it was operating inside of our faked GOPATH and became upset. This patch works around the whole situation by simply exporting PWD before executing dep.
-rw-r--r--Makefile2
1 files changed, 1 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index bd282fd..af2f542 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ version.go:
vendor/.created: Gopkg.toml Gopkg.lock | .gopath/.created
command -v dep >/dev/null || go get -v github.com/golang/dep/cmd/dep
- cd .gopath/src/$(GO_IMPORT_PATH) && dep ensure -vendor-only -v
+ export PWD; cd .gopath/src/$(GO_IMPORT_PATH) && dep ensure -vendor-only -v
touch $@
wireguard-go: $(wildcard *.go) $(wildcard */*.go) .gopath/.created vendor/.created version.go