github.com/openshift/installer@v1.4.17/hack/build-node-joiner.sh (about) 1 #!/bin/sh 2 3 set -ex 4 5 # shellcheck disable=SC2068 6 version() { IFS="."; printf "%03d%03d%03d\\n" $@; unset IFS;} 7 8 minimum_go_version=1.22 9 current_go_version=$(go version | cut -d " " -f 3) 10 11 if [ "$(version "${current_go_version#go}")" -lt "$(version "$minimum_go_version")" ]; then 12 echo "Go version should be greater or equal to $minimum_go_version" 13 exit 1 14 fi 15 16 export CGO_ENABLED=0 17 MODE="${MODE:-release}" 18 19 GIT_COMMIT="${SOURCE_GIT_COMMIT:-$(git rev-parse --verify 'HEAD^{commit}')}" 20 GIT_TAG="${BUILD_VERSION:-$(git describe --always --abbrev=40 --dirty)}" 21 DEFAULT_ARCH="${DEFAULT_ARCH:-amd64}" 22 GOFLAGS="${GOFLAGS:--mod=vendor}" 23 GCFLAGS="" 24 LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/version.Raw=${GIT_TAG} -X github.com/openshift/installer/pkg/version.Commit=${GIT_COMMIT} -X github.com/openshift/installer/pkg/version.defaultArch=${DEFAULT_ARCH}" 25 TAGS="${TAGS:-}" 26 OUTPUT="${OUTPUT:-bin/node-joiner}" 27 28 case "${MODE}" in 29 release) 30 LDFLAGS="${LDFLAGS} -s -w" 31 TAGS="${TAGS} release" 32 ;; 33 dev) 34 GCFLAGS="${GCFLAGS} all=-N -l" 35 ;; 36 *) 37 echo "unrecognized mode: ${MODE}" >&2 38 exit 1 39 esac 40 41 if test "${SKIP_GENERATION}" != y 42 then 43 # this step has to be run natively, even when cross-compiling 44 GOOS='' GOARCH='' go generate ./data 45 fi 46 47 if (echo "${TAGS}" | grep -q '\bfipscapable\b') 48 then 49 export CGO_ENABLED=1 50 fi 51 52 echo "building node-joiner" 53 54 # shellcheck disable=SC2086 55 go build ${GOFLAGS} -gcflags "${GCFLAGS}" -ldflags "${LDFLAGS}" -tags "${TAGS}" -o "${OUTPUT}" ./cmd/node-joiner