From e4482b0282998db9492eb087634ee9027cc9d20c Mon Sep 17 00:00:00 2001 From: Lapo Luchini Date: Thu, 12 Oct 2023 14:46:27 +0200 Subject: [PATCH 1/2] Add support for building on FreeBSD. --- build.sh | 2 +- internal/service/handler.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 7702532..dd481cd 100755 --- a/build.sh +++ b/build.sh @@ -22,7 +22,7 @@ LDFLAGS="-s -X github.com/prometheus/common/version.Version=${GITVERSION} \ -X github.com/prometheus/common/version.BuildUser=${GITHUB_ACTOR} \ -X github.com/prometheus/common/version.BuildDate=${TIME}" -for OS in "darwin" "linux" "windows"; do +for OS in "darwin" "linux" "windows" "freebsd"; do for ARCH in "amd64" "386"; do echo "Building ${OS}/${ARCH} with version: ${GITVERSION}, revision: ${GITREVISION}, buildUser: ${GITHUB_ACTOR}" if [[ $OS == "windows" ]]; then diff --git a/internal/service/handler.go b/internal/service/handler.go index 951fe16..0bedb6f 100644 --- a/internal/service/handler.go +++ b/internal/service/handler.go @@ -1,4 +1,4 @@ -// +build linux darwin +//go:build linux || darwin || freebsd package service From 813ba230960ba5d687de199ebf87139de66a2aca Mon Sep 17 00:00:00 2001 From: Lapo Luchini Date: Thu, 12 Oct 2023 14:50:02 +0200 Subject: [PATCH 2/2] Make compatbile with `sh` instead of ` bash`. (another option would have been to use `#! /usr/bin/env bash` I guess) --- build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index dd481cd..516c0ce 100755 --- a/build.sh +++ b/build.sh @@ -1,13 +1,13 @@ -#!/bin/bash +#!/bin/sh set -e -if [[ -z "$GITHUB_WORKSPACE" ]]; then +if [ -z "$GITHUB_WORKSPACE" ]; then GITHUB_WORKSPACE=$(pwd) echo "Setting up GITHUB_WORKSPACE to current directory: ${GITHUB_WORKSPACE}" fi -if [[ -z "$GITHUB_ACTOR" ]]; then +if [ -z "$GITHUB_ACTOR" ]; then GITHUB_ACTOR=$(whoami) echo "Setting up GITHUB_ACTOR to current user: ${GITHUB_ACTOR}" fi @@ -25,7 +25,7 @@ LDFLAGS="-s -X github.com/prometheus/common/version.Version=${GITVERSION} \ for OS in "darwin" "linux" "windows" "freebsd"; do for ARCH in "amd64" "386"; do echo "Building ${OS}/${ARCH} with version: ${GITVERSION}, revision: ${GITREVISION}, buildUser: ${GITHUB_ACTOR}" - if [[ $OS == "windows" ]]; then + if [ $OS == "windows" ]; then GO111MODULE=on CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags "${LDFLAGS}" -tags 'netgo static_build' -a -o ".build/${OS}-${ARCH}/beat-exporter.exe" else GO111MODULE=on CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags "${LDFLAGS}" -tags 'netgo static_build' -a -o ".build/${OS}-${ARCH}/beat-exporter"