Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on FreeBSD #368

Closed
YetAnotherBugHunter opened this issue Feb 20, 2021 · 3 comments
Closed

Building on FreeBSD #368

YetAnotherBugHunter opened this issue Feb 20, 2021 · 3 comments

Comments

@YetAnotherBugHunter
Copy link

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

@bnfinet
Copy link
Member

bnfinet commented Feb 20, 2021

@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!

@YetAnotherBugHunter
Copy link
Author

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 ... :)

@bnfinet
Copy link
Member

bnfinet commented Feb 21, 2021

@YetAnotherBugHunter thanks much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants