2
2
3
3
# This script builds a single Go binary of Coder with the given parameters.
4
4
#
5
- # Usage: ./build_go.sh [--version 1.2.3-devel+abcdef] [--os linux] [--arch amd64] [--output path/to/output] [--slim]
5
+ # Usage: ./build_go.sh [--version 1.2.3-devel+abcdef] [--os linux] [--arch amd64] [--output path/to/output] [--slim] [--agpl]
6
6
#
7
7
# Defaults to linux:amd64 with slim disabled, but can be controlled with GOOS,
8
8
# GOARCH and CODER_SLIM_BUILD=1. If no version is specified, defaults to the
19
19
# If the --sign-darwin parameter is specified and the OS is darwin, binaries
20
20
# will be signed using the `codesign` utility. $AC_APPLICATION_IDENTITY must be
21
21
# set and the signing certificate must be imported for this to work.
22
+ #
23
+ # If the --agpl parameter is specified, builds only the AGPL-licensed code (no
24
+ # Coder enterprise features).
22
25
23
26
set -euo pipefail
24
27
# shellcheck source=scripts/lib.sh
@@ -31,8 +34,9 @@ arch="${GOARCH:-amd64}"
31
34
slim=" ${CODER_SLIM_BUILD:- 0} "
32
35
sign_darwin=0
33
36
output_path=" "
37
+ agpl=" ${CODER_BUILD_AGPL:- 0} "
34
38
35
- args=" $( getopt -o " " -l version:,os:,arch:,output:,slim,sign-darwin -- " $@ " ) "
39
+ args=" $( getopt -o " " -l version:,os:,arch:,output:,slim,agpl, sign-darwin -- " $@ " ) "
36
40
eval set -- " $args "
37
41
while true ; do
38
42
case " $1 " in
@@ -56,6 +60,10 @@ while true; do
56
60
slim=1
57
61
shift
58
62
;;
63
+ --agpl)
64
+ agpl=1
65
+ shift
66
+ ;;
59
67
--sign-darwin)
60
68
if [[ " ${AC_APPLICATION_IDENTITY:- } " == " " ]]; then
61
69
error " AC_APPLICATION_IDENTITY must be set when --sign-darwin is supplied"
@@ -115,9 +123,13 @@ elif [[ "$arch" == "armv"* ]] || [[ "$arch" == "arm64v"* ]]; then
115
123
arch=" ${arch// v*/ } "
116
124
fi
117
125
126
+ cmd_path=" ./enterprise/cmd/coder"
127
+ if [[ " $agpl " == 1 ]]; then
128
+ cmd_path=" ./cmd/coder"
129
+ fi
118
130
CGO_ENABLED=0 GOOS=" $os " GOARCH=" $arch " GOARM=" $arm_version " go build \
119
131
" ${build_args[@]} " \
120
- ./cmd/coder 1>&2
132
+ " $cmd_path " 1>&2
121
133
122
134
if [[ " $sign_darwin " == 1 ]] && [[ " $os " == " darwin" ]]; then
123
135
codesign -s " $AC_APPLICATION_IDENTITY " -f -v --timestamp --options runtime " $output_path "
0 commit comments