diff --git a/scripts/build b/scripts/build index 884eaedd27..063c01bf48 100755 --- a/scripts/build +++ b/scripts/build @@ -4,8 +4,20 @@ set -e -x source $(dirname $0)/version.sh cd $(dirname $0)/.. +PKG="github.com/rancher/k3s" +PKG_CONTAINERD="github.com/containerd/containerd" +PKG_RANCHER_CONTAINERD="github.com/rancher/containerd" +PKG_CRICTL="github.com/kubernetes-sigs/cri-tools" + +LDFLAGS=" + -X $PKG/pkg/version.Version=$VERSION + -X $PKG/pkg/version.GitCommit=${COMMIT:0:8} + -X $PKG/vendor/$PKG_CONTAINERD/version.Version=$VERSION_CONTAINERD + -X $PKG/vendor/$PKG_CONTAINERD/version.Package=$PKG_RANCHER_CONTAINERD + -X $PKG/vendor/$PKG_CRICTL/pkg/version.Version=$VERSION_CRICTL + -w -s +" -LDFLAGS="-X github.com/rancher/k3s/pkg/version.Version=$VERSION -X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8} -w -s" STATIC="-extldflags '-static'" STATIC_SQLITE="-extldflags '-static -lm -ldl -lz -lpthread'" TAGS="ctrd apparmor seccomp no_btrfs netgo osusergo" @@ -23,7 +35,18 @@ if [ -z "$GOARM" ] && [ "arm" = "$(go env GOARCH)" ]; then GOARM=7 fi -rm -f bin/k3s-agent bin/hyperkube bin/containerd bin/cni ./bin/runc bin/containerd-shim bin/k3s-server bin/kubectl bin/crictl bin/ctr +rm -f \ + bin/k3s-agent \ + bin/hyperkube \ + bin/containerd \ + bin/cni \ + bin/runc \ + bin/containerd-shim \ + bin/k3s-server \ + bin/kubectl \ + bin/crictl \ + bin/ctr + # echo Building agent # CGO_ENABLED=1 go build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC" -o bin/k3s-agent ./cmd/agent/main.go echo Building server diff --git a/scripts/package-cli b/scripts/package-cli index 421bbd3666..ef658d8497 100755 --- a/scripts/package-cli +++ b/scripts/package-cli @@ -38,6 +38,10 @@ cp -f ./bin/hyperkube dist/artifacts/hyperkube${BIN_SUFFIX} CMD_NAME=dist/artifacts/k3s${BIN_SUFFIX} go generate -LDFLAGS="-X github.com/rancher/k3s/pkg/version.Version=$VERSION -X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8} -w -s" +LDFLAGS=" + -X github.com/rancher/k3s/pkg/version.Version=$VERSION + -X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8} + -w -s +" STATIC="-extldflags '-static'" CGO_ENABLED=0 go build -ldflags "$LDFLAGS $STATIC" -o ${CMD_NAME} ./cmd/k3s/main.go diff --git a/scripts/version.sh b/scripts/version.sh index 6798d78ccb..052c0fdbe2 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -15,3 +15,6 @@ fi ARCH=$(go env GOARCH) SUFFIX="-${ARCH}" + +VERSION_CONTAINERD=$(grep ^github.com/containerd/containerd $(dirname $0)/../vendor.conf | awk '{print $2}') +VERSION_CRICTL=$(grep ^github.com/kubernetes-sigs/cri-tools $(dirname $0)/../vendor.conf | awk '{print $2}')