From 2b04a66df7796afff59abd8c4d940d7576285b83 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Wed, 22 Nov 2017 12:19:38 -0800 Subject: [PATCH 1/2] Rename tree state from 'git archive' to 'archive' --- hack/lib/version.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hack/lib/version.sh b/hack/lib/version.sh index 3dab71052af..0df161e37c6 100644 --- a/hack/lib/version.sh +++ b/hack/lib/version.sh @@ -22,6 +22,7 @@ # source code. # KUBE_GIT_TREE_STATE - "clean" indicates no changes since the git commit id # "dirty" indicates source code changes after the git commit id +# "archive" indicates the tree was produced by 'git archive' # KUBE_GIT_VERSION - "vX.Y" used to indicate the last release version. # KUBE_GIT_MAJOR - The major part of the version # KUBE_GIT_MINOR - The minor component of the version @@ -40,7 +41,7 @@ kube::version::get_version_vars() { # we likely don't have a git tree, but these magic values may be filled in. if [[ '$Format:%%$' == "%" ]]; then KUBE_GIT_COMMIT='$Format:%H$' - KUBE_GIT_TREE_STATE="git archive" + KUBE_GIT_TREE_STATE="archive" # When a 'git archive' is exported, the '$Format:%D$' below will look # something like 'HEAD -> release-1.8, tag: v1.8.3' where then 'tag: ' # can be extracted from it. From 96e2da2992900a2f9f60b11898ffc50b3a6bd6f8 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Wed, 22 Nov 2017 12:29:29 -0800 Subject: [PATCH 2/2] Use git archive to produce kubernetes-src.tar.gz when possible --- build/lib/release.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/build/lib/release.sh b/build/lib/release.sh index 85a1d784f56..afacffbdce9 100644 --- a/build/lib/release.sh +++ b/build/lib/release.sh @@ -98,18 +98,23 @@ function kube::release::package_tarballs() { # Package the source code we built, for compliance/licensing/audit/yadda. function kube::release::package_src_tarball() { + local -r src_tarball="${RELEASE_TARS}/kubernetes-src.tar.gz" kube::log::status "Building tarball: src" - local source_files=( - $(cd "${KUBE_ROOT}" && find . -mindepth 1 -maxdepth 1 \ - -not \( \ - \( -path ./_\* -o \ - -path ./.git\* -o \ - -path ./.config\* -o \ - -path ./.gsutil\* \ - \) -prune \ - \)) - ) - "${TAR}" czf "${RELEASE_TARS}/kubernetes-src.tar.gz" -C "${KUBE_ROOT}" "${source_files[@]}" + if [[ "${KUBE_GIT_TREE_STATE-}" == "clean" ]]; then + git archive -o "${src_tarball}" HEAD + else + local source_files=( + $(cd "${KUBE_ROOT}" && find . -mindepth 1 -maxdepth 1 \ + -not \( \ + \( -path ./_\* -o \ + -path ./.git\* -o \ + -path ./.config\* -o \ + -path ./.gsutil\* \ + \) -prune \ + \)) + ) + "${TAR}" czf "${src_tarball}" -C "${KUBE_ROOT}" "${source_files[@]}" + fi } # Package up all of the cross compiled clients. Over time this should grow into