Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenBSD] build.sh: getopt: unknown option -- l #314

Closed
B-Interactive opened this issue Dec 3, 2020 · 4 comments
Closed

[OpenBSD] build.sh: getopt: unknown option -- l #314

B-Interactive opened this issue Dec 3, 2020 · 4 comments
Labels
bug Something isn't working.

Comments

@B-Interactive
Copy link

Describe the bug

On OpenBSD 6.8 amd64, when trying to build from source, immediately fails with error:

bash-5.0# ./build.sh
getopt: unknown option -- l
Unknown option: . See --help.

Steps to reproduce

  1. Fresh install of OpenBSD 6.8 amd64.
  2. Install Go 1.15.2 from packages.
  3. Install Bash shell 5.0.18 from packages.
  4. Downloaded and extracted maddy 0.4.2 release from https://github.com/foxcpp/maddy/releases
  5. In the extracted folder, I run bash ./build.sh
  6. Immediately fails with error:
bash-5.0# ./build.sh
getopt: unknown option -- l
Unknown option: . See --help.
  1. Using the --help argument as suggested, produces the same error:
bash-5.0# ./build.sh --help
getopt: unknown option -- l
Unknown option: . See --help.

Environment information

  • OpenBSD version: 6.8 amd64
  • maddy version: 0.4.2 Release
  • Go version: 1.15.2
  • Bash shell version: 5.0.18
@B-Interactive B-Interactive added the bug Something isn't working. label Dec 3, 2020
@B-Interactive B-Interactive changed the title build.sh: getopt: unknown option -- l [OpenBSD] build.sh: getopt: unknown option -- l Dec 3, 2020
@foxcpp
Copy link
Owner

foxcpp commented Dec 3, 2020

Unfortunately, current version of build script is rather Linux-specific, in particular getopt is assumed to have GNU extensions.

You can still build maddy by directly calling go tool:

go build ./cmd/maddy
go build ./cmd/maddyctl

@B-Interactive
Copy link
Author

B-Interactive commented Dec 3, 2020

Thanks @foxcpp, that provided some more options.

I was able to build it using those two commands you offered. Skimming through build.sh though, it seems there's much more going on than just a build, so if I pursue that option I'll need to nut that all out.

The second thing I tried (again thanks to your pointers), was a version of getopt with GNU extensions.

# pkg_add gnugetopt
quirks-3.440 signed on 2020-12-03T21:39:27Z
gnugetopt-1.1.6p2: ok

That I believe solves the issue I opened here for OpenBSD (might test with FreeBSD too). However, I stumbled across a new issue that may be specific to Go on OpenBSD (still investigating): -buildmode=pie not supported on openbsd/amd64

bash-5.0# ./build.sh
                                _|        _|
_|_|_|  _|_|      _|_|_|    _|_|_|    _|_|_|  _|    _|
_|    _|    _|  _|    _|  _|    _|  _|    _|  _|    _|
_|    _|    _|  _|    _|  _|    _|  _|    _|  _|    _|
_|    _|    _|    _|_|_|    _|_|_|    _|_|_|    _|_|_|
                                                    _|
 All-in-one composable mail server.             _|_|

--- Using system Go toolchain (1.15.2, /usr/local/bin/go).
--- WARNING: Source tree is not a Git repository and no version specified.
--- Downloading dependencies...
go: downloading github.com/foxcpp/go-mockdns v0.0.0-20200531120619-ae750bbf9d73
--- Building main executable...
-buildmode=pie not supported on openbsd/amd64

Opened a new issue: #315

@B-Interactive
Copy link
Author

B-Interactive commented Dec 3, 2020

To resolve this specific issue under OpenBSD, install gnugetopt.

# pkg_add gnugetopt

Then on the line 3 of build.sh, modify the command so getopt becomes gnugetop:

options=$(gnugetopt -o hb:p:d: -l help,builddir:,prefix:,destdir:,systemddir:,configdir:,statedir:,runtimedir:,fail2bandir:,tags:,prefix:,gitversion:,version:,source:,sudo -- "$@")

@foxcpp
Copy link
Owner

foxcpp commented Dec 5, 2020

I just pushed 4ec6eb2 with new (much more simple) build.sh implementation. I would appreciate someone testing it on *BSD to make sure it works there correctly. It should work fine with any POSIX shell, not just Bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants