From 3701c2ac0e4a69c6ba56526838c9c37ae5b9fe8b Mon Sep 17 00:00:00 2001 From: Joe Beda Date: Wed, 15 Oct 2014 16:50:17 -0700 Subject: [PATCH] Add kubectl to build/release scripts. Also Refactor build helpers into client/cross and server/linux. This make it easier to tell users what to build to get just the client binaries. --- build/README.md | 4 +-- build/build-image/common.sh | 29 +++++++++++-------- .../{make-cross.sh => make-client.sh} | 17 ++++++----- .../{make-binaries.sh => make-server.sh} | 7 ++++- build/common.sh | 1 + build/{make-cross.sh => make-client.sh} | 4 +-- build/{make-binaries.sh => make-server.sh} | 4 +-- build/release.sh | 4 +-- cluster/kubecfg.sh | 2 +- 9 files changed, 43 insertions(+), 29 deletions(-) rename build/build-image/{make-cross.sh => make-client.sh} (76%) rename build/build-image/{make-binaries.sh => make-server.sh} (86%) rename build/{make-cross.sh => make-client.sh} (86%) rename build/{make-binaries.sh => make-server.sh} (88%) diff --git a/build/README.md b/build/README.md index 49a5d0dd9db..78debda65c3 100644 --- a/build/README.md +++ b/build/README.md @@ -18,10 +18,10 @@ There is also early support for building Docker "run" containers ## Key scripts -* `make-binaries.sh`: This will compile all of the Kubernetes binaries +* `make-server.sh`: This will compile all of the Kubernetes server binaries for linux/amd64 +* `make-client.sh`: This will make all cross-compiled client binaries * `run-tests.sh`: This will run the Kubernetes unit tests * `run-integration.sh`: This will build and run the integration test -* `make-cross.sh`: This will make all cross-compiled binaries (currently just `kubecfg`) * `copy-output.sh`: This will copy the contents of `_output/build` from any remote Docker container to the local `_output/build`. Right now this is only necessary on Mac OS X with `boot2docker`. * `make-clean.sh`: Clean out the contents of `_output/build` and remove any local built container images. * `shell.sh`: Drop into a `bash` shell in a build container with a snapshot of the current repo code. diff --git a/build/build-image/common.sh b/build/build-image/common.sh index 5982b706cda..6abd6cbf064 100644 --- a/build/build-image/common.sh +++ b/build/build-image/common.sh @@ -23,6 +23,19 @@ cd "${KUBE_ROOT}" readonly KUBE_TARGET="${KUBE_ROOT}/_output/build" readonly KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes +server_targets=( + cmd/proxy + cmd/apiserver + cmd/controller-manager + cmd/kubelet + plugin/cmd/scheduler +) + +client_targets=( + cmd/kubecfg + cmd/kubectl +) + mkdir -p "${KUBE_TARGET}" if [[ ! -f "/kube-build-image" ]]; then @@ -46,19 +59,11 @@ function kube::build::make_binary() { } function kube::build::make_binaries() { - local -a targets=( - cmd/proxy - cmd/apiserver - cmd/controller-manager - cmd/kubelet - cmd/kubecfg - plugin/cmd/scheduler - ) - - if [[ -n "${1-}" ]]; then - targets=("$1") - fi + [[ $# -gt 0 ]] || { + echo "!!! Internal error. kube::build::make_binaries called with no targets." + } + local -a targets=("$@") local -a binaries=() local target for target in "${targets[@]}"; do diff --git a/build/build-image/make-cross.sh b/build/build-image/make-client.sh similarity index 76% rename from build/build-image/make-cross.sh rename to build/build-image/make-client.sh index 74a48c7dffd..6a77abd4316 100755 --- a/build/build-image/make-cross.sh +++ b/build/build-image/make-client.sh @@ -21,16 +21,19 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. source "${KUBE_ROOT}/build/build-image/common.sh" -readonly CROSS_BINARIES=( - ./cmd/kubecfg - ) +platforms=(linux/amd64 $KUBE_CROSSPLATFORMS) +targets=("${client_targets[@]}") -for platform in ${KUBE_CROSSPLATFORMS}; do +if [[ $# -gt 0 ]]; then + targets=("$@") +fi + +for platform in "${platforms[@]}"; do ( + # Subshell to contain these exports export GOOS=${platform%/*} export GOARCH=${platform##*/} - for binary in "${CROSS_BINARIES[@]}"; do - kube::build::make_binaries "${binary}" - done + + kube::build::make_binaries "${targets[@]}" ) done diff --git a/build/build-image/make-binaries.sh b/build/build-image/make-server.sh similarity index 86% rename from build/build-image/make-binaries.sh rename to build/build-image/make-server.sh index 20a9890f268..5e71fd35e95 100755 --- a/build/build-image/make-binaries.sh +++ b/build/build-image/make-server.sh @@ -21,4 +21,9 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. source "${KUBE_ROOT}/build/build-image/common.sh" -kube::build::make_binaries "$@" +targets=("${server_targets[@]}") +if [[ $# -gt 0 ]]; then + targets=("$@") +fi + +kube::build::make_binaries "${targets[@]}" diff --git a/build/common.sh b/build/common.sh index 42348d43ed6..6acc77d5663 100644 --- a/build/common.sh +++ b/build/common.sh @@ -63,6 +63,7 @@ readonly DOCKER_MOUNT_ARGS=(--volume "${LOCAL_OUTPUT_BUILD}:${REMOTE_OUTPUT_DIR} readonly KUBE_CLIENT_BINARIES=( kubecfg + kubectl ) readonly KUBE_SERVER_BINARIES=( diff --git a/build/make-cross.sh b/build/make-client.sh similarity index 86% rename from build/make-cross.sh rename to build/make-client.sh index 730df7521fa..2678b592afa 100755 --- a/build/make-cross.sh +++ b/build/make-client.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Make all of the Kubernetes binaries for cross compile targets +# Make all of the client Kubernetes binaries for cross compile targets # # This makes the docker build image, builds the cross binaries and copies them # out of the docker container. @@ -28,5 +28,5 @@ source "$KUBE_ROOT/build/common.sh" kube::build::verify_prereqs kube::build::build_image -kube::build::run_build_command build/build-image/make-cross.sh +kube::build::run_build_command build/build-image/make-client.sh "$@" kube::build::copy_output diff --git a/build/make-binaries.sh b/build/make-server.sh similarity index 88% rename from build/make-binaries.sh rename to build/make-server.sh index 7df9d121649..6ef84dbac33 100755 --- a/build/make-binaries.sh +++ b/build/make-server.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Make all of the Kubernetes binaries. +# Make all of the Kubernetes server binaries. # # This makes the docker build image, builds the binaries and copies them out # of the docker container. @@ -27,5 +27,5 @@ source "$KUBE_ROOT/build/common.sh" kube::build::verify_prereqs kube::build::build_image -kube::build::run_build_command build/build-image/make-binaries.sh "$@" +kube::build::run_build_command build/build-image/make-server.sh "$@" kube::build::copy_output diff --git a/build/release.sh b/build/release.sh index db0c9b90293..5ab7ae2db53 100755 --- a/build/release.sh +++ b/build/release.sh @@ -29,8 +29,8 @@ KUBE_RELEASE_RUN_TESTS=${KUBE_RELEASE_RUN_TESTS-y} kube::build::verify_prereqs kube::build::build_image -kube::build::run_build_command build/build-image/make-binaries.sh -kube::build::run_build_command build/build-image/make-cross.sh +kube::build::run_build_command build/build-image/make-client.sh +kube::build::run_build_command build/build-image/make-server.sh if [[ $KUBE_RELEASE_RUN_TESTS =~ ^[yY]$ ]]; then kube::build::run_build_command build/build-image/run-tests.sh diff --git a/cluster/kubecfg.sh b/cluster/kubecfg.sh index aed47ae0341..f286a7040a5 100755 --- a/cluster/kubecfg.sh +++ b/cluster/kubecfg.sh @@ -68,7 +68,7 @@ if [[ ! -x "$kubecfg" ]]; then echo "It looks as if you don't have a compiled kubecfg binary." echo echo "If you are running from a clone of the git repo, please run" - echo "'./build/make-cross.sh'. Note that this requires having Docker installed." + echo "'./build/make-client.sh'. Note that this requires having Docker installed." echo echo "If you are running from a binary release tarball, something is wrong. " echo "Look at http://kubernetes.io/ for information on how to contact the "