Skip to content

Building on FreeBSD #368

@YetAnotherBugHunter

Description

@YetAnotherBugHunter

Ran into 2 minor issue with the do.sh script on FreeBSD.

uname -a
FreeBSD syslogserver.cidercreekranch.net 12.2-RELEASE-p2 FreeBSD 12.2-RELEASE-p2 663e6b09467(HEAD) TRUENAS  amd64
  1. The do.sh script uses a shebang of #!/bin/bash, but on FreeBSD bash is found at /usr/local/bin/bash. To get around this problem I change the shebang to:

$!/usr/bin/env bash

  1. The hostname command on FreeBSD does not support the -fqdn switch. The same results can be achieved by simply calling hostname without switches.

I added an OS test in the build function which allowed the build to complete.

 build () {
  local VERSION=$(git describe --always --long)
  local DT=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # ISO-8601

  #-- Added OS test for FreeBSD
  if [ $(uname) = "FreeBSD" ]; then
    local FQDN=$(hostname)
  else
    local FQDN=$(hostname --fqdn)
  fi

  local SEMVER=$(git tag --list --sort="v:refname" | tail -n -1)
  local BRANCH=$(git rev-parse --abbrev-ref HEAD)
  go build -i -v -ldflags=" -X main.version=${VERSION} -X main.builddt=${DT} -X main.host=${FQDN} -X main.semver=${SEMVER} -X main.branch=${BRANCH}" .
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions