From f18cd53687023147315db3891a678170cb10a42b Mon Sep 17 00:00:00 2001 From: Joe Beda Date: Sun, 16 Nov 2014 16:29:58 -0800 Subject: [PATCH] Make dockerized build work when golang isn't installed. --- hack/lib/init.sh | 2 +- hack/lib/util.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/hack/lib/init.sh b/hack/lib/init.sh index 054bf4c1d56..514a0954cbc 100644 --- a/hack/lib/init.sh +++ b/hack/lib/init.sh @@ -39,4 +39,4 @@ source "${KUBE_ROOT}/hack/lib/version.sh" source "${KUBE_ROOT}/hack/lib/golang.sh" source "${KUBE_ROOT}/hack/lib/etcd.sh" -KUBE_OUTPUT_HOSTBIN="${KUBE_OUTPUT_BINPATH}/$(kube::golang::host_platform)" +KUBE_OUTPUT_HOSTBIN="${KUBE_OUTPUT_BINPATH}/$(kube::util::host_platform)" diff --git a/hack/lib/util.sh b/hack/lib/util.sh index 40a8347ec01..4364dffc1d7 100644 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -36,3 +36,46 @@ kube::util::wait_for_url() { kube::log::error "Timed out waiting for ${url}" return 1 } + +# This figures out the host platform without relying on golang. We need this as +# we don't want a golang install to be a prerequisite to building yet we need +# this info to figure out where the final binaries are placed. +kube::util::host_platform() { + local host_os + local host_arch + case "$(uname -s)" in + Darwin) + host_os=darwin + ;; + Linux) + host_os=linux + ;; + *) + kube::log::error "Unsupported host OS. Must be Linux or Mac OS X." + exit 1 + ;; + esac + + case "$(uname -m)" in + x86_64*) + host_arch=amd64 + ;; + i?86_64*) + host_arch=amd64 + ;; + amd64*) + host_arch=amd64 + ;; + arm*) + host_arch=arm + ;; + i?86*) + host_arch=x86 + ;; + *) + kube::log::error "Unsupported host arch. Must be x86_64, 386 or arm." + exit 1 + ;; + esac + echo "${host_os}/${host_arch}" +}