From d7396accedb12cea954d8314dce6cf3b55366124 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Wed, 30 Jul 2014 15:29:12 -0700 Subject: [PATCH 1/2] Remove executable permissions of files that do not need it. In particular, .gitignore, *.go, *.sls and etcd.conf are files that should not be marked as executable. Tested: built it with hack/build-go.sh, called all binaries with the -version flag to confirm they work. Signed-off-by: Filipe Brandenburger --- .gitignore | 0 cluster/saltbase/pillar/top.sls | 0 cluster/saltbase/salt/base.sls | 0 cluster/saltbase/salt/cadvisor/init.sls | 0 cluster/saltbase/salt/docker/init.sls | 0 cluster/saltbase/salt/etcd/etcd.conf | 0 cluster/saltbase/salt/etcd/init.sls | 0 cluster/saltbase/salt/golang.sls | 0 cluster/saltbase/salt/top.sls | 0 third_party/src/code.google.com/p/go-uuid/uuid/dce.go | 0 third_party/src/code.google.com/p/go-uuid/uuid/doc.go | 0 third_party/src/code.google.com/p/go-uuid/uuid/node.go | 0 third_party/src/code.google.com/p/go-uuid/uuid/time.go | 0 third_party/src/code.google.com/p/go-uuid/uuid/uuid.go | 0 third_party/src/code.google.com/p/go-uuid/uuid/uuid_test.go | 0 .../src/code.google.com/p/goauth2/oauth/example/oauthreq.go | 0 16 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 .gitignore mode change 100755 => 100644 cluster/saltbase/pillar/top.sls mode change 100755 => 100644 cluster/saltbase/salt/base.sls mode change 100755 => 100644 cluster/saltbase/salt/cadvisor/init.sls mode change 100755 => 100644 cluster/saltbase/salt/docker/init.sls mode change 100755 => 100644 cluster/saltbase/salt/etcd/etcd.conf mode change 100755 => 100644 cluster/saltbase/salt/etcd/init.sls mode change 100755 => 100644 cluster/saltbase/salt/golang.sls mode change 100755 => 100644 cluster/saltbase/salt/top.sls mode change 100755 => 100644 third_party/src/code.google.com/p/go-uuid/uuid/dce.go mode change 100755 => 100644 third_party/src/code.google.com/p/go-uuid/uuid/doc.go mode change 100755 => 100644 third_party/src/code.google.com/p/go-uuid/uuid/node.go mode change 100755 => 100644 third_party/src/code.google.com/p/go-uuid/uuid/time.go mode change 100755 => 100644 third_party/src/code.google.com/p/go-uuid/uuid/uuid.go mode change 100755 => 100644 third_party/src/code.google.com/p/go-uuid/uuid/uuid_test.go mode change 100755 => 100644 third_party/src/code.google.com/p/goauth2/oauth/example/oauthreq.go diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/cluster/saltbase/pillar/top.sls b/cluster/saltbase/pillar/top.sls old mode 100755 new mode 100644 diff --git a/cluster/saltbase/salt/base.sls b/cluster/saltbase/salt/base.sls old mode 100755 new mode 100644 diff --git a/cluster/saltbase/salt/cadvisor/init.sls b/cluster/saltbase/salt/cadvisor/init.sls old mode 100755 new mode 100644 diff --git a/cluster/saltbase/salt/docker/init.sls b/cluster/saltbase/salt/docker/init.sls old mode 100755 new mode 100644 diff --git a/cluster/saltbase/salt/etcd/etcd.conf b/cluster/saltbase/salt/etcd/etcd.conf old mode 100755 new mode 100644 diff --git a/cluster/saltbase/salt/etcd/init.sls b/cluster/saltbase/salt/etcd/init.sls old mode 100755 new mode 100644 diff --git a/cluster/saltbase/salt/golang.sls b/cluster/saltbase/salt/golang.sls old mode 100755 new mode 100644 diff --git a/cluster/saltbase/salt/top.sls b/cluster/saltbase/salt/top.sls old mode 100755 new mode 100644 diff --git a/third_party/src/code.google.com/p/go-uuid/uuid/dce.go b/third_party/src/code.google.com/p/go-uuid/uuid/dce.go old mode 100755 new mode 100644 diff --git a/third_party/src/code.google.com/p/go-uuid/uuid/doc.go b/third_party/src/code.google.com/p/go-uuid/uuid/doc.go old mode 100755 new mode 100644 diff --git a/third_party/src/code.google.com/p/go-uuid/uuid/node.go b/third_party/src/code.google.com/p/go-uuid/uuid/node.go old mode 100755 new mode 100644 diff --git a/third_party/src/code.google.com/p/go-uuid/uuid/time.go b/third_party/src/code.google.com/p/go-uuid/uuid/time.go old mode 100755 new mode 100644 diff --git a/third_party/src/code.google.com/p/go-uuid/uuid/uuid.go b/third_party/src/code.google.com/p/go-uuid/uuid/uuid.go old mode 100755 new mode 100644 diff --git a/third_party/src/code.google.com/p/go-uuid/uuid/uuid_test.go b/third_party/src/code.google.com/p/go-uuid/uuid/uuid_test.go old mode 100755 new mode 100644 diff --git a/third_party/src/code.google.com/p/goauth2/oauth/example/oauthreq.go b/third_party/src/code.google.com/p/goauth2/oauth/example/oauthreq.go old mode 100755 new mode 100644 From d00e08bb5fbe51d67a6e5f53b34f0607411120a6 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Wed, 30 Jul 2014 17:07:28 -0700 Subject: [PATCH 2/2] Fix shell script quoting, clean up build scripts Fix quoting so that it works with arbitrary path names (e.g. containing spaces.) Make hack/config-go.sh non-executable since it is meant for sourcing and not as a standalone. Tested: - Checked out the tree to a directory with spaces, called the build script from outside the tree, confirmed it worked as expected. - Confirmed binaries work by running them with -version. - Ran hack/build-go.sh cmd/kubecfg and confirmed only kubecfg was built. - Ran hack/build-go.sh cmd/integration and confirmed it was built. - Checked it out on a Mac and confirmed that the build script works. - Confirmed that hack/test-go.sh and hack/test-cmd.sh work. Signed-off-by: Filipe Brandenburger --- hack/build-go.sh | 32 ++++++++++++++++++---------- hack/config-go.sh | 53 +++++++++++++++++++++++------------------------ 2 files changed, 47 insertions(+), 38 deletions(-) mode change 100755 => 100644 hack/config-go.sh diff --git a/hack/build-go.sh b/hack/build-go.sh index 36ae7a2d81a..6a5def2016e 100755 --- a/hack/build-go.sh +++ b/hack/build-go.sh @@ -16,19 +16,29 @@ # This script sets up a go workspace locally and builds all go components. -set -e +set -o errexit +set -o nounset +set -o pipefail + +hackdir=$(dirname "$0") + +# Set the environment variables required by the build. +. "${hackdir}/config-go.sh" + +# Go to the top of the tree. +cd "${KUBE_REPO_ROOT}" # Update the version. -$(dirname $0)/version-gen.sh +"${hackdir}/version-gen.sh" -source $(dirname $0)/config-go.sh - -cd "${KUBE_TARGET}" - -BINARIES="cmd/proxy cmd/apiserver cmd/controller-manager cmd/kubelet cmd/kubecfg" - -if [ $# -gt 0 ]; then - BINARIES="$@" +if [[ $# == 0 ]]; then + # Update $@ with the default list of targets to build. + set -- cmd/proxy cmd/apiserver cmd/controller-manager cmd/kubelet cmd/kubecfg fi -go install $(for b in $BINARIES; do echo "${KUBE_GO_PACKAGE}"/${b}; done) +binaries=() +for arg; do + binaries+=("${KUBE_GO_PACKAGE}/${arg}") +done + +go install "${binaries[@]}" diff --git a/hack/config-go.sh b/hack/config-go.sh old mode 100755 new mode 100644 index c96079f59f7..1023b820603 --- a/hack/config-go.sh +++ b/hack/config-go.sh @@ -17,51 +17,50 @@ # This script sets up a go workspace locally and builds all go components. # You can 'source' this file if you want to set up GOPATH in your local shell. -if [[ "$(which go)" == "" ]]; then - echo "Can't find 'go' in PATH, please fix and retry." - echo "See http://golang.org/doc/install for installation instructions." - exit 1 +if [[ -z "$(which go)" ]]; then + echo "Can't find 'go' in PATH, please fix and retry." >&2 + echo "See http://golang.org/doc/install for installation instructions." >&2 + exit 1 fi # Travis continuous build uses a head go release that doesn't report # a version number, so we skip this check on Travis. Its unnecessary # there anyway. -if [ "${TRAVIS}" != "true" ]; then +if [[ "${TRAVIS:-}" != "true" ]]; then GO_VERSION=($(go version)) - - if [[ ${GO_VERSION[2]} < "go1.2" ]]; then - echo "Detected go version: ${GO_VERSION}." - echo "Kubernetes requires go version 1.2 or greater." - echo "Please install Go version 1.2 or later" + if [[ "${GO_VERSION[2]}" < "go1.2" ]]; then + echo "Detected go version: ${GO_VERSION[*]}." >&2 + echo "Kubernetes requires go version 1.2 or greater." >&2 + echo "Please install Go version 1.2 or later" >&2 exit 1 fi fi -if [[ "$OSTYPE" == *darwin* ]]; then - KUBE_REPO_ROOT="${PWD}/$(dirname ${BASH_SOURCE:-$0})/.." +KUBE_REPO_ROOT=$(dirname "${BASH_SOURCE:-$0}")/.. +if [[ "${OSTYPE:-}" == *darwin* ]]; then + # Make the path absolute if it is not. + if [[ "${KUBE_REPO_ROOT}" != /* ]]; then + KUBE_REPO_ROOT=${PWD}/${KUBE_REPO_ROOT} + fi else - KUBE_REPO_REL_ROOT="$(dirname ${BASH_SOURCE:-$0})/.." - KUBE_REPO_ROOT="$(readlink -f ${KUBE_REPO_REL_ROOT})" + # Resolve symlinks. + KUBE_REPO_ROOT=$(readlink -f "${KUBE_REPO_ROOT}") fi KUBE_TARGET="${KUBE_REPO_ROOT}/output/go" - mkdir -p "${KUBE_TARGET}" KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes -export GOPATH="${KUBE_TARGET}" -KUBE_GO_PACKAGE_DIR="${GOPATH}/src/${KUBE_GO_PACKAGE}" +KUBE_GO_PACKAGE_DIR="${KUBE_TARGET}/src/${KUBE_GO_PACKAGE}" -( - PACKAGE_BASE=$(dirname "${KUBE_GO_PACKAGE_DIR}") - if [ ! -d "${PACKAGE_BASE}" ]; then - mkdir -p "${PACKAGE_BASE}" - fi +KUBE_GO_PACKAGE_BASEDIR=$(dirname "${KUBE_GO_PACKAGE_DIR}") +mkdir -p "${KUBE_GO_PACKAGE_BASEDIR}" - rm "${KUBE_GO_PACKAGE_DIR}" >/dev/null 2>&1 || true - ln -s "${KUBE_REPO_ROOT}" "${KUBE_GO_PACKAGE_DIR}" -) +# Create symlink under output/go/src. +ln -snf "${KUBE_REPO_ROOT}" "${KUBE_GO_PACKAGE_DIR}" -# unset GOBIN in case it already exsit in the current session +GOPATH="${KUBE_TARGET}:${KUBE_REPO_ROOT}/third_party" +export GOPATH + +# Unset GOBIN in case it already exsits in the current session. unset GOBIN -export GOPATH="${KUBE_TARGET}:${KUBE_REPO_ROOT}/third_party"