Skip to content

Instantly share code, notes, and snippets.

@koobs
Last active November 12, 2022 02:06
Show Gist options
  • Save koobs/0b909fd093695df0f633874313b5efd7 to your computer and use it in GitHub Desktop.
Save koobs/0b909fd093695df0f633874313b5efd7 to your computer and use it in GitHub Desktop.
CoderHQ FreeBSD Support PoC v1 Notes

Reprod Geoffreys CoderHQ Env/Issue

Install deps from ports

This gets us in front of / testing a next step: ports/package build from source

Note: Minus hs-pandoc, lets see what happens

sudo portmaster --force-config misc/getopt devel/shfmt www/node archivers/nfpm 
x11/pixman graphics/cairo x11-toolkits/pango
===>  Configuring for pango-1.50.9
pango-1.50.9: Needs cairo with GLIB (GObject) support enabled.

Rebuild cairo with OPTIONS_SET=GLIB

Update godbus dependency

From v5.1.0 -> latest (4b691ce883d5). 4b691ce883d5 is post #332 PR pmerge

go119 get github.com/godbus/dbus/v5@master
go: downloading github.com/godbus/dbus/v5 v5.1.1-0.20221029134443-4b691ce883d5
go: downloading golang.org/x/sys v0.1.0
go: upgraded github.com/godbus/dbus/v5 v5.1.0 => v5.1.1-0.20221029134443-4b691ce883d5

Allow GETOPT, MAKE and GO to be passed via the env

FreeBSD go packages provide goXYZ as binary names (with no go -> symlink)

See: https://koobs.io/www/patches/coder-freebsd-support-poc-v1.diff

Build

GO=go119 MAKE=/usr/local/bin/gmake  GETOPT=/usr/local/bin/getopt ./scripts/build_go.sh --os freebsd --arch amd64 --agpl
go: downloading cdr.dev/slog v1.4.2-0.20220525200111-18dce5c2cd5f
go: downloading cloud.google.com/go/compute/metadata v0.2.1
go: downloading github.com/kylecarbs/spinner v1.18.2-0.20220329160715-20702b5af89e
go: downloading cloud.google.com/go/compute v1.12.1
go: downloading github.com/charmbracelet/lipgloss v0.6.0
go: downloading github.com/cli/safeexec v1.0.0
go: downloading github.com/coder/retry v1.3.0
go: downloading github.com/coreos/go-oidc/v3 v3.4.0
go: downloading github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
go: downloading github.com/fatih/color v1.13.0
go: downloading github.com/kylecarbs/embedded-postgres v1.17.1-0.20220615202325-461532cecd3a
go: downloading github.com/gen2brain/beeep v0.0.0-20220402123239-6a3042f4b71a
go: downloading github.com/go-playground/validator/v10 v10.11.0
go: downloading github.com/gofrs/flock v0.8.1
go: downloading github.com/google/go-github/v43 v43.0.1-0.20220414155304-00e42332e405
go: downloading github.com/google/uuid v1.3.0
go: downloading github.com/jedib0t/go-pretty/v6 v6.4.0
go: downloading github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
go: downloading github.com/mattn/go-isatty v0.0.16
go: downloading github.com/mafredri/udp v0.1.2-0.20220805105907-b2872e92e98d
go: downloading github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
go: downloading github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e
go: downloading github.com/prometheus/client_golang v1.13.0
go: downloading github.com/spf13/afero v1.9.2
go: downloading github.com/spf13/cobra v1.6.1
go: downloading github.com/spf13/viper v1.13.0
go: downloading go.opentelemetry.io/otel/trace v1.11.1
go: downloading golang.org/x/crypto v0.1.0
go: downloading go.opentelemetry.io/otel v1.11.1
go: downloading golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
go: downloading golang.org/x/mod v0.6.0
go: downloading golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
go: downloading golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0
go: downloading golang.org/x/term v0.1.0
go: downloading golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
go: downloading google.golang.org/api v0.100.0
go: downloading gopkg.in/natefinch/lumberjack.v2 v2.0.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/coder/tailscale v1.1.1-0.20221104170440-ef53dca69a41
go: downloading github.com/AlecAivazis/survey/v2 v2.3.5
go: downloading github.com/bgentry/speakeasy v0.1.0
go: downloading github.com/charmbracelet/charm v0.12.1
go: downloading github.com/fatih/structtag v1.2.0
go: downloading github.com/kylecarbs/opencensus-go v0.23.1-0.20220307014935-4d0325a68f8b
go: downloading github.com/mattn/go-runewidth v0.0.13
go: downloading github.com/muesli/reflow v0.3.0
go: downloading github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739
go: downloading github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2
go: downloading github.com/coder/ssh v0.0.0-20220811105153-fcea99919338
go: downloading github.com/go-chi/chi v1.5.4
go: downloading github.com/pkg/sftp v1.13.6-0.20221018182125-7da137aa03f0
go: downloading go.uber.org/atomic v1.10.0
go: downloading github.com/hashicorp/go-reap v0.0.0-20170704170343-bf58d8a43e7b
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/andybalholm/brotli v1.0.4
go: downloading github.com/go-chi/chi/v5 v5.0.7
go: downloading github.com/go-chi/render v1.0.1
go: downloading github.com/klauspost/compress v1.15.9
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading github.com/moby/moby v20.10.21+incompatible
go: downloading github.com/tabbed/pqtype v0.1.1
go: downloading gopkg.in/square/go-jose.v2 v2.6.0
go: downloading nhooyr.io/websocket v1.8.7
go: downloading storj.io/drpc v0.0.33-0.20220622181519-9206537a4db7
go: downloading github.com/robfig/cron/v3 v3.0.1
go: downloading github.com/jmoiron/sqlx v1.3.5
go: downloading github.com/lib/pq v1.10.6
go: downloading github.com/golang-migrate/migrate/v4 v4.15.2
go: downloading github.com/go-ping/ping v1.1.0
go: downloading golang.zx2c4.com/wireguard v0.0.0-20220920152132-bb719d3a6e2c
go: downloading golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b
go: downloading github.com/adrg/xdg v0.4.0
go: downloading github.com/go-chi/httprate v0.7.0
go: downloading github.com/justinas/nosurf v1.1.1
go: downloading github.com/elastic/go-sysinfo v1.8.1
go: downloading github.com/go-logr/logr v1.2.3
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading go.nhat.io/otelsql v0.7.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.1
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.1
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.11.1
go: downloading go.opentelemetry.io/otel/sdk v1.11.1
go: downloading google.golang.org/grpc v1.50.1
go: downloading github.com/gohugoio/hugo v0.105.0
go: downloading google.golang.org/protobuf v1.28.1
go: downloading github.com/awalterschulze/gographviz v2.0.3+incompatible
go: downloading github.com/hashicorp/go-version v1.6.0
go: downloading github.com/hashicorp/hc-install v0.4.1-0.20220912074615-4487b02cbcbb
go: downloading github.com/hashicorp/terraform-json v0.14.0
go: downloading github.com/kylecarbs/terraform-config-inspect v0.0.0-20211215004401-bbc517866b88
go: downloading github.com/mitchellh/go-wordwrap v1.0.1
go: downloading github.com/hashicorp/yamux v0.0.0-20220718163420-dd80a7ee44ce
go: downloading go4.org/netipx v0.0.0-20220725152314-7e7bdc8411bf
go: downloading gvisor.dev/gvisor v0.0.0-20220817001344-846276b3dbc5
go: downloading github.com/mattn/go-colorable v0.1.12
go: downloading github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8
go: downloading github.com/go-playground/universal-translator v0.18.0
go: downloading github.com/leodido/go-urn v1.2.1
go: downloading golang.org/x/text v0.4.0
go: downloading github.com/google/go-querystring v1.1.0
go: downloading github.com/pion/transport v0.13.1
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/common v0.37.0
go: downloading github.com/prometheus/procfs v0.8.0
go: downloading github.com/fsnotify/fsnotify v1.6.0
go: downloading github.com/spf13/cast v1.5.0
go: downloading github.com/spf13/jwalterweatherman v1.1.0
go: downloading go4.org/mem v0.0.0-20210711025021-927187094b94
go: downloading github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
go: downloading github.com/hashicorp/hcl/v2 v2.14.0
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/charmbracelet/bubbles v0.10.3
go: downloading github.com/alecthomas/chroma v0.10.0
go: downloading github.com/rivo/uniseg v0.2.0
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/creack/pty v1.1.18
go: downloading github.com/u-root/u-root v0.10.0
go: downloading github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be
go: downloading github.com/kr/fs v0.1.0
go: downloading go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1
go: downloading github.com/open-policy-agent/opa v0.44.0
go: downloading github.com/unrolled/secure v1.13.0
go: downloading github.com/zeebo/errs v1.3.0
go: downloading golang.org/x/time v0.0.0-20220224211638-0e9765cccd65
go: downloading golang.org/x/net v0.1.0
go: downloading github.com/hashicorp/errwrap v1.1.0
go: downloading go.opentelemetry.io/proto/otlp v0.19.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.1
go: downloading google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e
go: downloading go.opentelemetry.io/otel/metric v0.33.0
go: downloading github.com/yuin/goldmark v1.5.2
go: downloading github.com/zclconf/go-cty v1.10.0
go: downloading github.com/go-playground/locales v0.14.0
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369
go: downloading github.com/subosito/gotenv v1.4.1
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/magiconair/properties v1.8.6
go: downloading github.com/pelletier/go-toml/v2 v2.0.5
go: downloading github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
go: downloading github.com/pelletier/go-toml v1.9.5
go: downloading github.com/agext/levenshtein v1.2.3
go: downloading github.com/apparentlymart/go-textseg/v13 v13.0.0
go: downloading github.com/charmbracelet/bubbletea v0.20.0
go: downloading github.com/dlclark/regexp2 v1.4.0
go: downloading github.com/OneOfOne/xxhash v1.2.8
go: downloading github.com/pkg/errors v0.9.1
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/google/btree v1.0.1
go: downloading howett.net/plist v1.0.0
go: downloading github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901
go: downloading github.com/go-logr/stdr v1.2.2
go: downloading github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0
go: downloading github.com/cenkalti/backoff/v4 v4.1.3
go: downloading github.com/clbanning/mxj/v2 v2.5.6
go: downloading github.com/niklasfasching/go-org v1.6.5
go: downloading github.com/fxamacker/cbor/v2 v2.4.0
go: downloading github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3
go: downloading github.com/kylecarbs/go-httpstat v0.0.0-20220831233600-c91452099472
go: downloading github.com/tailscale/goupnp v1.0.1-0.20210804011211-c64d0f06ea05
go: downloading github.com/kortschak/wol v0.0.0-20200729010619-da482cc4850a
go: downloading github.com/googleapis/enterprise-certificate-proxy v0.2.0
go: downloading github.com/containerd/console v1.0.3
go: downloading github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70
go: downloading github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
go: downloading github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0
go: downloading github.com/ghodss/yaml v1.0.0
go: downloading github.com/gobwas/glob v0.2.3
go: downloading github.com/tchap/go-patricia/v2 v2.3.1
go: downloading github.com/yashtewari/glob-intersection v0.1.0
go: downloading github.com/mitchellh/go-ps v1.0.0
go: downloading github.com/bep/godartsass v0.14.0
go: downloading github.com/bep/golibsass v1.1.0
go: downloading github.com/tdewolff/parse/v2 v2.6.4
go: downloading github.com/hashicorp/go-cleanhttp v0.5.2
go: downloading github.com/google/go-cmp v0.5.9
go: downloading github.com/x448/float16 v0.8.4
go: downloading filippo.io/edwards25519 v1.0.0-rc.1
go: downloading github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb
go: downloading github.com/agnivade/levenshtein v1.1.1
# github.com/u-root/u-root/pkg/termios
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/sgtty_unix.go:13:20: undefined: unix.TCGETS
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/sgtty_unix.go:14:20: undefined: unix.TCSETS
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:33:10: undefined: TTYIO
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:39:9: undefined: MakeRaw
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:48:10: undefined: TTYIO
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:71:10: undefined: TTYIO
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:75:10: undefined: TTYIO
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/var_unix.go:42:38: undefined: syscall.IUTF8
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/var_unix.go:50:37: undefined: syscall.OFILL
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/var_unix.go:51:37: undefined: syscall.OFDEL
/home/koobs/go/pkg/mod/github.com/u-root/u-root@v0.10.0/pkg/termios/termios.go:39:9: too many errors

FIN

WIN??

Check binary

  # Unless overridden via --output, the built binary will be dropped in
  # "$repo_root/build/coder_$version_$os_$arch" (with a ".exe" suffix for windows
  
  cmd_path="./enterprise/cmd/coder"
if [[ "$agpl" == 1 ]]; then
        cmd_path="./cmd/coder"
fi
[koobs@140-CURRENT-amd64-564d:/usr/home/koobs/repos/coder/build] ls -la
total 3
drwxr-xr-x   2 koobs  koobs   2 Nov 11 21:44 ./
drwxr-xr-x  28 koobs  koobs  48 Nov 11 21:44 ../

Mmmm... Binary not created because termios errors?

termios isolation

FreeBSD Support added ... 8 days ago (we're livin on the edge!)

Update termios dependency to 18fd0ce368

This is in github.com/u-root/u-root dependency

go119 get github.com/u-root/u-root@18fd0ce368
go: downloading github.com/u-root/u-root v0.9.1-0.20221104004445-18fd0ce36891
...
go: downgraded github.com/u-root/u-root v0.10.0 => v0.9.1-0.20221104004445-18fd0ce36891
# github.com/coder/coder/cli
cli/schedule.go:223:19: undefined: tz.TimezoneIANA
cli/schedule.go:254:17: undefined: tz.TimezoneIANA
cli/util.go:116:17: undefined: tz.TimezoneIANA

Isolate: undefined: tz.TimezoneIANA

  • "github.com/coder/coder/coderd/util/tz"
  • no tz_freebsd.go
# cp tz_linux.go tz_freebsd.go (+ gobuild header change)

WIN!

$ ls build
/usr/home/koobs/repos/coder/build/coder_0.12.5-devel+4b7c7107_freebsd_amd64

BINARY! (+6)

$ ./build/coder_0.12.5-devel+4b7c7107_freebsd_amd64
Coder v0.12.5-devel+4b7c7107 — A tool for provisioning self-hosted development environments with Terraform.

Usage:
  coder [flags]

  coder [command]
...
./build/coder_0.12.5-devel+4b7c7107_freebsd_amd64 server
Coder v0.12.5-devel+4b7c7107 - Remote development on your infrastucture
Using built-in PostgreSQL (/home/koobs/.config/coderv2/postgres)
Failed to start built-in PostgreSQL.
 ./build/coder_0.12.5-devel+4b7c7107_freebsd_amd64 --verbose server
Coder v0.12.5-devel+4b7c7107 - Remote development on your infrastucture
Using built-in PostgreSQL (/home/koobs/.config/coderv2/postgres)
Failed to start built-in PostgreSQL. Optionally, specify an external deployment with `--postgres-url`: no version found matching 13.7.0
Run 'coder server --help' for usage.

Trying to fetch from maven.

Install postgresql local

$ sudo portmaster databases/postgresql15-server (no LLVM/JIT: do later)

Server running

[koobs@140-CURRENT-amd64-564d:/usr/home/koobs/repos/coder] ./build/coder_0.12.5-devel+4b7c7107_freebsd_amd64 --verbose server --postgres-url="postgres://coder@127.0.0.1:5432/coder?sslmode=disable"
Coder v0.12.5-devel+4b7c7107 - Remote development on your infrastucture

Opening tunnel so workspaces can connect to your deployment. For production scenarios, specify an external access URL

...

View the Web UI: https://fccaa30990535aaa18e73f870ff8510b.pit-1.try.coder.app

client login

[koobs@140-CURRENT-amd64-564d:/usr/home/koobs/repos/coder] ./build/coder_0.12.5-devel+4b7c7107_freebsd_amd64 login https://fccaa30990535aaa18e73f870ff8510b.pit-1.try.coder.app                                                                                                                                                
> Your Coder deployment hasn't been set up!                                                                                                                    
> Would you like to create the first user? (yes/no) yes                                                                                                        
> What  username  would you like? (koobs) koobs                                                                                                               
> What's your  email ? dont-need@this.tld                                                                                                                     
> Enter a  password :
> Confirm  password : 

  Welcome to Coder, koobs! You're authenticated.

  Get started by creating a template:  coder templates init

Notes

  • Add some success output exit: 0 for lib version.sh etc (currently null output)
  • Output build dir / binary path
  • improve postgres fetch error: no version found matching 13.7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment