How to build and install Mattermost plugins on FreeBSD

FreeBSD Jan 30, 2021

I was unpleasantly surprised to find that all plugins published on Mattermost plugin marketplace are not working on installed server on FreeBSD. They all are failing to start - it doesn't matter did  you enabled linux64 emulation inside the OS.

After some research I have found that the problematic area is easy visible from file packages.json - as example here I'm givin a snippet from mattermost-plugin-jitsi:

{
"id": "jitsi",
"name": "Jitsi",
"description": "Jitsi audio and video conferencing plugin for Mattermost.",
"homepage_url": "https://github.com/mattermost/mattermost-plugin-jitsi",
"support_url": "https://github.com/mattermost/mattermost-plugin-jitsi/issues",
"release_notes_url": "https://github.com/mattermost/mattermost-plugin-jitsi/releases/tag/v2.0.0",
"icon_path": "assets/icon.svg",
"version": "2.0.0",
"min_server_version": "5.2.0",
"server": {
"executables": {
"linux-amd64": "server/dist/plugin-linux-amd64",
"darwin-amd64": "server/dist/plugin-darwin-amd64",
"windows-amd64": "server/dist/plugin-windows-amd64.exe"
}
},

It's easy visible and clear that the source must be build for FreeBSD too. The good news is that GO language has excelent cross compiling features.

$GOOS $GOARCH
aix ppc64
android 386
android amd64
android arm
android arm64
darwin 386
darwin amd64
darwin arm
darwin arm64
dragonfly amd64
freebsd 386
freebsd amd64
freebsd arm
illumos amd64
js wasm
linux 386
linux amd64
linux arm
linux arm64
linux ppc64
linux ppc64le
linux mips
linux mipsle
linux mips64
linux mips64le
linux s390x
netbsd 386
netbsd amd64
netbsd arm
openbsd 386
openbsd amd64
openbsd arm
openbsd arm64
plan9 386
plan9 amd64
plan9 arm
solaris amd64
windows 386
windows amd64

Edit the Makefile in this way:

cd server && env GOOS=linux GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -o dist/plugin-linux-amd64;
cd server && env GOOS=freebsd GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -o dist/plugin-freebsd-amd64;
cd server && env GOOS=darwin GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -o dist/plugin-darwin-amd64;
cd server && env GOOS=windows GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -o dist/plugin-windows-amd64.exe;

Change the packages.json and server/manifest.go files to include new supported architecture:

"server": {
    "executables": {
        "linux-amd64": "server/dist/plugin-linux-amd64",
        "freebsd-amd64": "server/dist/plugin-freebsd-amd64",           
        "darwin-amd64": "server/dist/plugin-darwin-amd64",
        "windows-amd64": "server/dist/plugin-windows-amd64.exe"
    }
},

If there are failures when building package, replace whole "server" section with:

"server": {
    "executable": "server/dist/plugin-freebsd-amd64"
},

Then build package using "gmake dist" to generate distribution into "dist/*.gz". You can grab generated file and upload it to your mattermost instance running on FreeBSD.

Tags

Jordan Ostreff

2G/3G/4G/NSA-5G/SA-5G Mobile Packet Core, Telco Clouds, Ericsson CEE, OpenStack, NFV, Orchestration, SDN, Containerisation, Networking IPv4/IPv6, Industrial Computer Networks, Mathematics, Engineering

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Share with Me via Nextcloud