From 82402c7d31f38671c67785a03ab9c9b2046d778d Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Tue, 16 Aug 2016 12:31:02 -0400 Subject: [PATCH] Make it easier to extract content from hack/env OS_BUILD_ENV_PRESERVE=_output/local/releases hack/env make release Allows content to be extracted back to the working dir (relative) after a build. --- .travis.yml | 2 +- hack/build-release.sh | 4 +--- hack/common.sh | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a70acb12bc7..c378c19aaed2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: go go: - 1.6 - - tip + - 1.7 install: - export PATH=$GOPATH/bin:./_output/tools/etcd/bin:$PATH diff --git a/hack/build-release.sh b/hack/build-release.sh index 0bb2d72f84ac..c60b1f5f1f18 100755 --- a/hack/build-release.sh +++ b/hack/build-release.sh @@ -24,9 +24,7 @@ trap "os::build::environment::cleanup ${container}" EXIT os::build::get_version_vars echo "++ Building release ${OS_GIT_VERSION}" ) -os::build::environment::withsource "${container}" "${OS_GIT_COMMIT:-HEAD}" -# Get the command output -docker cp "${container}:/go/src/github.com/openshift/origin/_output/local/releases" "${OS_OUTPUT}" +OS_BUILD_ENV_PRESERVE=_output/local/releases os::build::environment::withsource "${container}" "${OS_GIT_COMMIT:-HEAD}" echo "${OS_GIT_COMMIT}" > "${OS_LOCAL_RELEASEPATH}/.commit" ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret" diff --git a/hack/common.sh b/hack/common.sh index 8110b2cdd0fe..ecf420f565e1 100755 --- a/hack/common.sh +++ b/hack/common.sh @@ -1066,6 +1066,21 @@ function os::build::environment::withsource() { docker start "${container}" > /dev/null docker logs -f "${container}" + + # extract content from the image + if [[ -n "${OS_BUILD_ENV_PRESERVE-}" ]]; then + local workingdir + workingdir="$(docker inspect -f '{{ index . "Config" "WorkingDir" }}' "${container}")" + local oldIFS="${IFS}" + IFS=: + for path in ${OS_BUILD_ENV_PRESERVE}; do + local parent + parent="$( dirname ${path} )" + mkdir -p "${parent}" + docker cp "${container}:${workingdir}/${path}" "${parent}" + done + IFS="${oldIFS}" + fi } readonly -f os::build::environment::withsource