vouch/vouch-proxy

Building on FreeBSD

YetAnotherBugHunter opened this issue · 3 comments

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}" .
}

@YetAnotherBugHunter interesting!

Would you care to submit a PR for your changes? It would be most welcome!

I'd also suggest adding an OS field to this list and passing the OS as a param to the build.
https://github.com/vouch/vouch-proxy/blob/master/main.go#L51-L68

This block should also be modified to report the OS.
https://github.com/vouch/vouch-proxy/blob/master/main.go#L121-L130

Cheers!

I submitted a PR for the two changes I made. Note that I created a new function, Hostname(), to hide the details since how to query for the FQDN can vary from OS to OS.

I'm assuming that the suggested changes to main.go were intended for someone else since I have not yet to passed GO nor collected ... :)