bndw / pick

A secure and easy-to-use CLI password manager for macOS and Linux
MIT License
370 stars 29 forks source link

Build problem on OpenBSD #178

Open drduh opened 6 years ago

drduh commented 6 years ago
 ~/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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

bndw commented 6 years ago

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

leonklingele commented 6 years ago

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

bndw commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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.

bndw commented 6 years ago

@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 commented 6 years ago

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.

bndw commented 6 years ago

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

leonklingele commented 6 years ago

@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 commented 6 years ago

@leonklingele confirmed myself on OpenBSD, thanks! 🎉

bndw commented 6 years ago

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

bndw commented 6 years ago
drduh commented 6 years ago

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

bndw commented 5 years ago

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