|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# This script sets up a go workspace locally and builds all go components. |
| 4 | +# You can 'source' this file if you want to set up GOPATH in your local shell. |
| 5 | + |
| 6 | +if [ "$(which go)" == "" ]; then |
| 7 | + echo "Can't find 'go' in PATH, please fix and retry." |
| 8 | + echo "See http://golang.org/doc/install for installation instructions." |
| 9 | + exit 1 |
| 10 | +fi |
| 11 | + |
| 12 | +# Travis continuous build uses a head go release that doesn't report |
| 13 | +# a version number, so we skip this check on Travis. Its unnecessary |
| 14 | +# there anyway. |
| 15 | +if [ "${TRAVIS}" != "true" ]; then |
| 16 | + GO_VERSION=($(go version)) |
| 17 | + |
| 18 | + if [ ${GO_VERSION[2]} \< "go1.2" ]; then |
| 19 | + echo "Detected go version: ${GO_VERSION}." |
| 20 | + echo "OpenShift requires go version 1.2 or greater." |
| 21 | + echo "Please install Go version 1.2 or later" |
| 22 | + exit 1 |
| 23 | + fi |
| 24 | +fi |
| 25 | + |
| 26 | +pushd $(dirname "${BASH_SOURCE}")/.. >/dev/null |
| 27 | +OS_REPO_ROOT="${PWD}" |
| 28 | +OS_TARGET="${OS_REPO_ROOT}/output/go" |
| 29 | +popd >/dev/null |
| 30 | + |
| 31 | +mkdir -p "${OS_TARGET}" |
| 32 | + |
| 33 | +OLD_GOPATH="${GOPATH}" |
| 34 | +export GOPATH="${OS_TARGET}" |
| 35 | + |
| 36 | +OS_GO_PACKAGE="github.com/openshift/origin" |
| 37 | +OS_GO_PACKAGE_DIR="${GOPATH}/src/${OS_GO_PACKAGE}" |
| 38 | + |
| 39 | +ETCD_GO_PACKAGE="github.com/coreos/etcd" |
| 40 | +ETCD_GO_PACKAGE_DIR="${GOPATH}/src/${ETCD_GO_PACKAGE}" |
| 41 | +if [ ! -d "${OLD_GOPATH}/src/${ETCD_GO_PACKAGE}" ]; then |
| 42 | + echo "You must go get ${ETCD_GO_PACKAGE}" |
| 43 | +fi |
| 44 | + |
| 45 | +( |
| 46 | + PACKAGE_BASE=$(dirname "${OS_GO_PACKAGE_DIR}") |
| 47 | + if [ ! -d "${PACKAGE_BASE}" ]; then |
| 48 | + mkdir -p "${PACKAGE_BASE}" |
| 49 | + fi |
| 50 | + rm "${OS_GO_PACKAGE_DIR}" >/dev/null 2>&1 || true |
| 51 | + ln -s "${OS_REPO_ROOT}" "${OS_GO_PACKAGE_DIR}" |
| 52 | + |
| 53 | + PACKAGE_BASE=$(dirname "${ETCD_GO_PACKAGE_DIR}") |
| 54 | + if [ ! -d "${PACKAGE_BASE}" ]; then |
| 55 | + mkdir -p "${PACKAGE_BASE}" |
| 56 | + fi |
| 57 | + rm "${ETCD_GO_PACKAGE_DIR}" >/dev/null 2>&1 || true |
| 58 | + ln -s "${OLD_GOPATH}/src/${ETCD_GO_PACKAGE}" "${ETCD_GO_PACKAGE_DIR}" |
| 59 | + |
| 60 | + |
| 61 | + if [[ "$OS_KUBE_PATH" != "" ]]; then |
| 62 | + echo "Using Kubernetes from source $OS_KUBE_PATH" |
| 63 | + OS_GO_KUBE_PACKAGE_DIR="${OS_TARGET}/src/github.com/GoogleCloudPlatform/kubernetes" |
| 64 | + KUBE_PACKAGE_BASE=$(dirname "${OS_GO_KUBE_PACKAGE_DIR}") |
| 65 | + if [ ! -d "${KUBE_PACKAGE_BASE}" ]; then |
| 66 | + mkdir -p "${KUBE_PACKAGE_BASE}" |
| 67 | + fi |
| 68 | + rm "${OS_GO_KUBE_PACKAGE_DIR}" >/dev/null 2>&1 || true |
| 69 | + ln -s "${OS_KUBE_PATH}" "${OS_GO_KUBE_PACKAGE_DIR}" |
| 70 | + fi |
| 71 | +) |
| 72 | +export GOPATH="${OS_TARGET}:${OS_REPO_ROOT}/third_party/src/github.com/GoogleCloudPlatform/kubernetes/third_party:${OS_REPO_ROOT}/third_party" |
0 commit comments