zalando / go-keyring

Cross-platform keyring interface for Go
MIT License
846 stars 84 forks source link

Feature request: add FreeBSD support via GNOME keyring #67

Closed torculus closed 2 years ago

torculus commented 2 years ago

Considering that FreeBSD has go 1.17.5, libsecret, gnome-keyring, and dbus-daemon, please consider adding support for FreeBSD

szuecs commented 2 years ago

@torculus can you test it? Do you think we just need to create a build target?

torculus commented 2 years ago

Yeah, I'm willing to test it. I'm not much of a go programmer, but I think the Linux target should work well as a template

szuecs commented 2 years ago

@torculus can you try to build https://github.com/zalando/go-keyring/pull/68 on your system? I just checked https://github.com/vmactions/freebsd-vm and it's a bit weird to run a VM inside macos and then I have to figure what ports I need to install (maybe you want to create a PR for the GH actions?).

szuecs commented 2 years ago

@torculus we merged the change and it should built also on *BSD.

torculus commented 2 years ago

So, I attempted to build on my machine and it's complaining about u_int and uintptr_t being invalid types

Long story short, upsteam godbus had an issue with compiling on FreeBSD that was fixed back in 2020 (godbus version 5.0.4). Unfortunately, go-keyring is pulling godbus version 5.0.3, which is unpatched

I don't know if the requirement could be updated, but that would fix this issue

mikkeloscar commented 2 years ago

@torculus Could you try with this PR? https://github.com/zalando/go-keyring/pull/70

torculus commented 2 years ago

@mikkeloscar yes! It compiles perfectly without error!

I tried building the example module (on the README), but unfortunately my proficiency with Go is too limited to get it working as a local module. If it gets merged into master and released (go-keyring v0.1.2), I will re-test it

twpayne commented 2 years ago

Note that github.com/godbus/dbus currently does not compile on freebsd/386. See https://github.com/godbus/dbus/issues/315.

twpayne commented 2 years ago

Ah, so the problem is in fact that godbus/gobus relies on cgo and cgo is not easily available when cross-compiling. This may be tricky.

mikkeloscar commented 2 years ago

@torculus We have released version v0.2.0 with the update you can try!

mikkeloscar commented 2 years ago

@twpayne From where do you cross-compile? Does it not work to compile directly on the target?

We were able to add a CI step running in freebsd VM which works: #71 (I don't know too many details about *BSD so maybe it's different from what you mean?)

twpayne commented 2 years ago

It does work when you compile directly, but I'm cross-compiling as I'm using GoReleaser to build chezmoi's release binaries. The GoReleaser job runs on Linux (on GitHub Actions) and cross-compiles binaries for other operating systems and doesn't support cgo.

In practice I think zalando/go-keyring has done all that it's possible to reasonably do here. In chezmoi, I've used build tags to activate the GNOME Keyring functionality when it is available. https://github.com/twpayne/chezmoi/pull/1919 contains the gory details if you're interested.

mikkeloscar commented 2 years ago

Thanks for the information.

I will close this issue as it seems like we have done what we could from go-keyring side and support FreeBSD under the right conditions