pick icon indicating copy to clipboard operation
pick copied to clipboard

Build problem on OpenBSD

Open drduh opened this issue 6 years ago • 18 comments

 ~/git/pick make
*** Warning in /home/drduh/git/pick: '$(shell  cd $(GOVENDOR) ;  rm -rf src ;  find . -mindepth 2 -maxdepth 2 -path ./src
 -prune -o -type d -print |  sed -e 's/.\///' |  xargs -I{} sh -c '  mkdir -p "src/`dirname {}`" ;  ln -sfn "../../{}"
"src/{}" ;  '  )' expands to '' while building dependencies (Makefile:38)
mkdir -p
usage: mkdir [-p] [-m mode] directory ...
*** Error 1 in /home/drduh/git/pick (Makefile:39 'dependencies')


~/git/pick/vendor rm -rf src
~/git/pick/vendor find . -mindepth 2 -maxdepth 2 -path ./src -prune -o -type d -print | sed -e 's/.\///' | xargs -I{} sh -c '  mkdir -p "src/`dirname {}`" ;  ln -sfn "../../{}" "src/{}" '
ln: src/./.: Operation not permitted
mkdir: src/github.com: File exists
ln: src/github.com/atotto: No such file or directory
mkdir: src/github.com: File exists
ln: src/github.com/aws: No such file or directory
mkdir: src/github.com: File exists
ln: src/github.com/fsnotify: No such file
...

~/git/pick/vendor rm -rf src; find . -mindepth 2 -maxdepth 2 -path ./src -prune -o -type d -print | sed -e 's/.\///' | xargs file
.:                                 directory
github.com:                        directory
github.com/atotto:                 directory
github.com/aws:                    directory
github.com/fsnotify:               directory
github.com/go-ini:                 directory
github.com/hashicorp:              directory
github.com/inconshreveable:        directory
github.com/jmespath:               directory
...

 ~/git/pick/vendor find . -mindepth 2 -maxdepth 2 -path ./src -prune -o -type d -print | sed -e 's/.\///' | xargs -I{} sh -c '  echo "src/`dirname {}`" ;  echo "../../{}" "src/{}" '
src/.
../../. src/.
src/.
../../github.com src/github.com
src/github.com
../../github.com/atotto src/github.com/atotto
src/github.com
../../github.com/aws src/github.com/aws
src/github.com
../../github.com/fsnotify src/github.com/fsnotify
src/github.com
...

~/git/pick/vendor uname -a
OpenBSD bsd.whatever 6.4 GENERIC.MP#385 amd64

drduh avatar Oct 24 '18 23:10 drduh

Looks like -mindepth 2 is not honored in your version of find. find . -mindepth 2 should not return the CWD (.). Please try the following patch:

diff --git a/Makefile b/Makefile
index c26b9fd..67ee833 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ dependencies:
 	@$(shell \
 		cd $(GOVENDOR) ; \
 		rm -rf src ; \
-		find . -mindepth 2 -maxdepth 2 -path ./src -prune -o -type d -print | \
+		find . -mindepth 2 -maxdepth 2 -path ./src -prune -o ! -path . -type d -print | \
 		sed -e 's/.\///' | \
 		xargs -I{} sh -c ' \
 			mkdir -p "src/`dirname {}`" ; \

@bndw what do you think about (finally) removing the Makefile-hack now that Go modules are a thing?

leonklingele avatar Oct 27 '18 00:10 leonklingele

I don't think BSD make supports the shell directive:

$ cat Makefile
GOVENDOR=vendor
GOPKG=foobar
all:
        echo $(GOVENDOR)/src/$(GOPKG)
        echo $(shell dirname $(GOVENDOR)/src/$(GOPKG))

$ uname -rv
6.4 GENERIC.MP#385

$ make
echo vendor/src/foobar
vendor/src/foobar
echo

$ uname -rv
3.16.0-7-amd64 #1 SMP Debian 3.16.59-1 (2018-10-03)

$ make
echo vendor/src/foobar
vendor/src/foobar
echo vendor/src
vendor/src

drduh avatar Oct 27 '18 15:10 drduh

@leonklingele I'd almost forgotten, that's a great idea.

bndw avatar Oct 29 '18 02:10 bndw

Regarding Go modules-- @leonklingele correct me if I'm wrong but would this mean we cannot support < Go 1.11?

bndw avatar Oct 31 '18 01:10 bndw

With Go modules (and without the Makefile hack), the project can only be build from GOPATH when using a Go version < 1.11.

leonklingele avatar Oct 31 '18 01:10 leonklingele

If using go modules still requires the project to live in the GOPATH, then I am not sure the benefit.

At this stage I'd be OK with removing the Makefile hack and updating the README with a requirement to clone into the GOPATH. While it's nice to be able to build from any directory, it seems like it's more trouble than it's worth. We provide pre-build binaries of every release for folks that don't want to setup a "proper" Go environment.

bndw avatar Nov 02 '18 20:11 bndw

@drduh I'm working on a repo, just got an environment setup

bsd# uname -a
OpenBSD bsd.whatever 6.4 GENERIC#349 amd64

bsd# go version
go version go1.11 openbsd/amd64

bndw avatar Nov 02 '18 20:11 bndw

Aside from the find discrepancies, it appears that a couple of our Go dependencies may not build on openbsd

bsd# pwd
/root/go/src/github.com/bndw/pick

bsd# go build -o bin/pick .
# github.com/bndw/pick/vendor/github.com/marcsauter/single
vendor/github.com/marcsauter/single/single.go:31:13: s.CheckLock undefined (type *Single has no field or method CheckLock)
vendor/github.com/marcsauter/single/single.go:38:13: s.TryUnlock undefined (type *Single has no field or method TryUnlock)
# github.com/bndw/pick/vendor/github.com/pkg/term/termios
vendor/github.com/pkg/term/termios/pty_bsd.go:13:31: undefined: syscall.SYS_POSIX_OPENPT
vendor/github.com/pkg/term/termios/pty_bsd.go:27:19: undefined: syscall.TIOCGPTN
vendor/github.com/pkg/term/termios/pty_bsd.go:36:19: undefined: syscall.TIOCGPTN

bndw avatar Nov 02 '18 20:11 bndw

If using go modules still requires the project to live in the GOPATH, then I am not sure the benefit.

See my updated comment above: With Go modules (and without the Makefile hack), the project can only be build from GOPATH when using a Go version < 1.11.

it appears that a couple of our Go dependencies may not build on openbsd

github.com/bndw/pick/vendor/github.com/marcsauter/single

@bndw can you please check if the following patch fixes the issue?

diff --git a/vendor/github.com/marcsauter/single/single_unix.go b/vendor/github.com/marcsauter/single/single_unix.go
index 1f9990d..f716eb6 100644
--- a/vendor/github.com/marcsauter/single/single_unix.go
+++ b/vendor/github.com/marcsauter/single/single_unix.go
@@ -1,4 +1,4 @@
-// +build linux solaris darwin freebsd
+// +build linux solaris darwin freebsd openbsd netbsd
 
 package single
 

github.com/bndw/pick/vendor/github.com/pkg/term/termios

There's an open issue @ upstream: https://github.com/pkg/term/issues/25. A fix is available too: https://github.com/pkg/term/pull/30.

leonklingele avatar Nov 02 '18 21:11 leonklingele

@leonklingele applied the patch

diff --git a/vendor/github.com/marcsauter/single/single_unix.go b/vendor/github.com/marcsauter/single/single_unix.go
index 1f9990d..f716eb6 100644
--- a/vendor/github.com/marcsauter/single/single_unix.go
+++ b/vendor/github.com/marcsauter/single/single_unix.go
@@ -1,4 +1,4 @@
-// +build linux solaris darwin freebsd
+// +build linux solaris darwin freebsd openbsd
 
 package single

And ran the build

go build -o bin/pick .

# github.com/bndw/pick/vendor/github.com/marcsauter/single
vendor/github.com/marcsauter/single/single_unix.go:15:25: s.Filename undefined (type *Single has no field or method Filename)
vendor/github.com/marcsauter/single/single_unix.go:46:23: s.Filename undefined (type *Single has no field or method Filename)

bndw avatar Nov 03 '18 04:11 bndw

https://github.com/pkg/term/pull/30 has been merged. A fix for github.com/marcsauter/single is available here: https://github.com/marcsauter/single/pull/11.

leonklingele avatar Nov 03 '18 08:11 leonklingele

Once that single PR lands, I'll give it another spin 🤞

bndw avatar Nov 04 '18 00:11 bndw

@bndw apply this patch:

diff --git a/Gopkg.toml b/Gopkg.toml
index 3010027..cf920e1 100644
--- a/Gopkg.toml
+++ b/Gopkg.toml
@@ -23,7 +23,7 @@
 
 [[constraint]]
   name = "github.com/atotto/clipboard"
-  revision = "bb272b845f1112e10117e3e45ce39f690c0001ad"
+  version = "v0.1.1"
 
 [[constraint]]
   name = "github.com/aws/aws-sdk-go"
@@ -33,13 +33,17 @@
   name = "github.com/leonklingele/randomstring"
   version = "1.0.0"
 
+[[constraint]]
+  name = "github.com/marcsauter/single"
+  revision = "f8bf46f26ec011cb275d59dbb51d1fae0a0a18a6"
+
 [[constraint]]
   name = "github.com/mitchellh/go-homedir"
   revision = "b8bc1bf767474819792c23f32d8286a45736f1c6"
 
 [[constraint]]
   name = "github.com/pkg/term"
-  revision = "b1f72af2d63057363398bec5873d16a98b453312"
+  revision = "93e6c91493094ff99a036fea0040802a1e0a4f69"
 
 [[constraint]]
   name = "github.com/spf13/cobra"

Followed by dep ensure. This adds support for OpenBSD, NetBSD and DragonFlyBSD (inside GOPATH and using go build, the Makefile-hack still needs to be cleared up). I verified a build on all 3 OS'.

leonklingele avatar Nov 04 '18 10:11 leonklingele

@leonklingele confirmed myself on OpenBSD, thanks! 🎉

bndw avatar Nov 05 '18 02:11 bndw

PR that applies the above diff on dependencies: https://github.com/bndw/pick/pull/185

bndw avatar Nov 05 '18 02:11 bndw

  • [x] Go code is now building on OpenBSD, NetBSD, and DragonFlyBSD
  • [ ] Resolve the Makefile compatibility issues, find, shell, et al

bndw avatar Nov 06 '18 17:11 bndw

Looking good on develop :+1: - thanks for the updates!

drduh avatar Nov 07 '18 03:11 drduh

Reference for what install could look like with Go modules: https://github.com/gohugoio/hugo#fetch-from-github

bndw avatar Nov 30 '18 05:11 bndw