From 33869ab644b4c023727016543c7b073b3ee8e6df Mon Sep 17 00:00:00 2001 From: Joe Beda Date: Thu, 30 Oct 2014 10:49:44 -0700 Subject: [PATCH] Don't include '.' in release tars. Also make ownership, by default, be root. This won't work on systems that don't have GNU tar so we warn. Fixes: #1902 --- build/common.sh | 32 ++++++++++++++++--- docs/getting-started-guides/binary_release.md | 2 +- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/build/common.sh b/build/common.sh index 975a6a1a8ce1e..fdaf3db10f9f0 100644 --- a/build/common.sh +++ b/build/common.sh @@ -464,7 +464,7 @@ function kube::release::package_client_tarballs() { "${release_stage}/client/bin/" local package_name="${RELEASE_DIR}/kubernetes-client-${platform_tag}.tar.gz" - tar czf "${package_name}" -C "${release_stage}/.." . + kube::release::create_tarball "${package_name}" "${release_stage}/.." done } @@ -486,7 +486,7 @@ function kube::release::package_server_tarballs() { "${release_stage}/server/bin/" local package_name="${RELEASE_DIR}/kubernetes-server-${platform_tag}.tar.gz" - tar czf "${package_name}" -C "${release_stage}/.." . + kube::release::create_tarball "${package_name}" "${release_stage}/.." done } @@ -502,7 +502,7 @@ function kube::release::package_salt_tarball() { cp -R "${KUBE_ROOT}/cluster/saltbase" "${release_stage}/" local package_name="${RELEASE_DIR}/kubernetes-salt.tar.gz" - tar czf "${package_name}" -C "${release_stage}/.." . + kube::release::create_tarball "${package_name}" "${release_stage}/.." } # This is all the stuff you need to run/install kubernetes. This includes: @@ -537,9 +537,33 @@ function kube::release::package_full_tarball() { cp "${KUBE_ROOT}/Vagrantfile" "${release_stage}/" local package_name="${RELEASE_DIR}/kubernetes.tar.gz" - tar czf "${package_name}" -C "${release_stage}/.." . + kube::release::create_tarball "${package_name}" "${release_stage}/.." } +# Build a release tarball. $1 is the output tar name. $2 is the base directory +# of the files to be packaged. This assumes that ${2}/kubernetes is what is +# being packaged. +function kube::release::create_tarball() { + local tarfile=$1 + local stagingdir=$2 + + # Find gnu tar if it is available + local tar=tar + if which gtar > /dev/null; then + tar=gtar + fi + + local tar_cmd=("$tar" "czf" "${tarfile}" "-C" "${stagingdir}" "kubernetes") + if "$tar" --version | grep -q GNU; then + tar_cmd=("${tar_cmd[@]}" "--owner=0" "--group=0") + else + echo " !!! GNU tar not available. User names will be embedded in output and" + echo " release tars are not official. Build on Linux or install GNU tar" + echo " on Mac OS X (brew install gnu-tar)" + fi + + "${tar_cmd[@]}" +} # --------------------------------------------------------------------------- # GCS Release diff --git a/docs/getting-started-guides/binary_release.md b/docs/getting-started-guides/binary_release.md index c234f805601b6..df17a9eec22c5 100644 --- a/docs/getting-started-guides/binary_release.md +++ b/docs/getting-started-guides/binary_release.md @@ -6,7 +6,7 @@ You can either build a release from sources or download a pre-built release. If Soon, we will have a list of numbered and nightly releases. Until then, you can download a development release/snapshot from [here](http://storage.googleapis.com/kubernetes-releases-56726/devel/kubernetes.tar.gz). -Unpack this tar file on Linux or OS X. Most guides assume you are in the `kubernetes/` directory. +Unpack this tar file on Linux or OS X. Unpack this tar file on Linux or OS X, cd to the created `kubernetes/` directory, and then follow the getting started guide for your cloud. ### Building from source