Skip to content
This repository has been archived by the owner on Nov 9, 2019. It is now read-only.

Build problem on OpenBSD #178

Open
drduh opened this issue Oct 24, 2018 · 18 comments
Open

Build problem on OpenBSD #178

drduh opened this issue Oct 24, 2018 · 18 comments
Assignees

Comments

@drduh
Copy link

drduh commented Oct 24, 2018

 ~/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
@leonklingele
Copy link
Collaborator

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?

@drduh
Copy link
Author

drduh commented Oct 27, 2018

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

@bndw
Copy link
Owner

bndw commented Oct 29, 2018

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

@bndw
Copy link
Owner

bndw commented Oct 31, 2018

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

@leonklingele
Copy link
Collaborator

leonklingele commented Oct 31, 2018

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

@bndw
Copy link
Owner

bndw commented Nov 2, 2018

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 bndw self-assigned this Nov 2, 2018
@bndw
Copy link
Owner

bndw commented Nov 2, 2018

@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
Copy link
Owner

bndw commented Nov 2, 2018

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

@leonklingele
Copy link
Collaborator

leonklingele commented Nov 2, 2018

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: pkg/term#25. A fix is available too: pkg/term#30.

@bndw
Copy link
Owner

bndw commented Nov 3, 2018

@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)

@leonklingele
Copy link
Collaborator

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

@bndw
Copy link
Owner

bndw commented Nov 4, 2018

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

@leonklingele
Copy link
Collaborator

leonklingele commented Nov 4, 2018

@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'.

@bndw
Copy link
Owner

bndw commented Nov 5, 2018

@leonklingele confirmed myself on OpenBSD, thanks! 🎉

@bndw
Copy link
Owner

bndw commented Nov 5, 2018

PR that applies the above diff on dependencies: #185

bndw added a commit that referenced this issue Nov 6, 2018
@bndw
Copy link
Owner

bndw commented Nov 6, 2018

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

@drduh
Copy link
Author

drduh commented Nov 7, 2018

Looking good on develop 👍 - thanks for the updates!

@bndw
Copy link
Owner

bndw commented Nov 30, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants