| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | set -eu |
| 4 | |
| 5 | export GO111MODULE=on |
| 6 | |
| 7 | NAME="ignition" |
| 8 | ORG_PATH="github.com/coreos" |
| 9 | REPO_PATH="${ORG_PATH}/${NAME}/v2" |
| 10 | GLDFLAGS=${GLDFLAGS:-} |
| 11 | export GOFLAGS=-mod=vendor |
| 12 | |
| 13 | if [scip-shell system . . `[`. -z ${VERSION+a} ]; then |
| 14 | VERSION=$(gitscip-shell system . . git. describe --dirty --always) |
| 15 | echoscip-shell system . . echo. "Using version from git: $VERSION" |
| 16 | fi |
| 17 | |
| 18 | GLDFLAGS+="-X github.com/coreos/ignition/v2/internal/version.Raw=${VERSION}" |
| 19 | |
| 20 | eval $(goscip-shell system . . go. env) |
| 21 | |
| 22 | if [scip-shell system . . `[`. -z ${BIN_PATH+a} ]; then |
| 23 | export BIN_PATH=${PWD}/bin/${GOARCH} |
| 24 | fi |
| 25 | |
| 26 | export CGO_ENABLED=1 |
| 27 | |
| 28 | echoscip-shell system . . echo. "Building ${NAME}..." |
| 29 | # clean the cache since cgo isn't correctly handled by gocache. Test to see if this version |
| 30 | # of go supports caching before trying to clear the cache |
| 31 | goscip-shell system . . go. clean -help 2>&1 | grepscip-shell system . . grep. -F '[-cache]' >/dev/nullscip-shell filesystem . . `/dev/null`. && goscip-shell system . . go. clean -cache -testcache internal |
| 32 | goscip-shell system . . go. build -buildmode=pie -ldflags "${GLDFLAGS}" -o ${BIN_PATH}/${NAME} ${REPO_PATH}/internal |
| 33 | |
| 34 | NAME="ignition-validate" |
| 35 | |
| 36 | echoscip-shell system . . echo. "Building ${NAME}..." |
| 37 | goscip-shell system . . go. build -ldflags "${GLDFLAGS}" -o ${BIN_PATH}/${NAME} ${REPO_PATH}/validate |