Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default directories to the $OS_BUILD_ENV_PRESERVE path #14324

Merged
merged 2 commits into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hack/build-cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ os::build::release_sha
if [[ "${OS_GIT_TREE_STATE:-dirty}" == "clean" ]]; then
# only when we are building from a clean state can we claim to
# have created a valid set of binaries that can resemble a release
echo "${OS_GIT_COMMIT}" > "${OS_LOCAL_RELEASEPATH}/.commit"
echo "${OS_GIT_COMMIT}" > "${OS_OUTPUT_RELEASEPATH}/.commit"
fi

ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"
2 changes: 1 addition & 1 deletion hack/build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ os::build::detect_local_release_tars $(os::build::host_platform_friendly)
readonly OS_GOFLAGS_TAGS="include_gcs include_oss"

# we need to mount RPMs into the container builds for installation
OS_BUILD_IMAGE_ARGS="${OS_BUILD_IMAGE_ARGS:-} -mount ${OS_LOCAL_RPMPATH}/:/srv/origin-local-release/"
OS_BUILD_IMAGE_ARGS="${OS_BUILD_IMAGE_ARGS:-} -mount ${OS_OUTPUT_RPMPATH}/:/srv/origin-local-release/"

# Create link to file if the FS supports hardlinks, otherwise copy the file
function ln_or_cp {
Expand Down
4 changes: 2 additions & 2 deletions hack/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export OS_BUILD_ENV_PRESERVE=_output/local
context="${OS_ROOT}/_output/buildenv-context"

# Clean existing output.
rm -rf "${OS_LOCAL_RELEASEPATH}"
rm -rf "${OS_OUTPUT_RELEASEPATH}"
rm -rf "${context}"
mkdir -p "${context}"
mkdir -p "${OS_OUTPUT}"
Expand All @@ -28,6 +28,6 @@ trap "os::build::environment::cleanup ${container}" EXIT
echo "++ Building release ${OS_GIT_VERSION}"
)
os::build::environment::withsource "${container}" "${OS_GIT_COMMIT:-HEAD}"
echo "${OS_GIT_COMMIT}" > "${OS_LOCAL_RELEASEPATH}/.commit"
echo "${OS_GIT_COMMIT}" > "${OS_OUTPUT_RELEASEPATH}/.commit"

ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"
8 changes: 4 additions & 4 deletions hack/build-rpm-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ make clean
# migrate the tito artifacts to the Origin directory
mkdir -p "${OS_OUTPUT}"
mv "${tito_output_directory}"/* "${OS_OUTPUT}"
mkdir -p "${OS_LOCAL_RPMPATH}"
mv "${tito_tmp_dir}"/*src.rpm "${OS_LOCAL_RPMPATH}"
mv "${tito_tmp_dir}"/*/*.rpm "${OS_LOCAL_RPMPATH}"
mkdir -p "${OS_OUTPUT_RPMPATH}"
mv "${tito_tmp_dir}"/*src.rpm "${OS_OUTPUT_RPMPATH}"
mv "${tito_tmp_dir}"/*/*.rpm "${OS_OUTPUT_RPMPATH}"

repo_path="$( os::util::absolute_path "${OS_LOCAL_RPMPATH}" )"
repo_path="$( os::util::absolute_path "${OS_OUTPUT_RPMPATH}" )"
createrepo "${repo_path}"

echo "[${OS_RPM_NAME}-local-release]
Expand Down
34 changes: 17 additions & 17 deletions hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function os::build::place_bins() {

if [[ "${OS_RELEASE_ARCHIVE-}" != "" ]]; then
os::build::get_version_vars
mkdir -p "${OS_LOCAL_RELEASEPATH}"
mkdir -p "${OS_OUTPUT_RELEASEPATH}"
fi

os::build::export_targets "$@"
Expand Down Expand Up @@ -398,7 +398,7 @@ function os::build::archive_zip() {
pushd "${release_binpath}" &> /dev/null
sha256sum "${file}"
popd &>/dev/null
zip "${OS_LOCAL_RELEASEPATH}/${archive_name}" -qj "${release_binpath}/${file}"
zip "${OS_OUTPUT_RELEASEPATH}/${archive_name}" -qj "${release_binpath}/${file}"
done
}
readonly -f os::build::archive_zip
Expand All @@ -412,9 +412,9 @@ function os::build::archive_tar() {
pushd "${release_binpath}" &> /dev/null
find . -type f -exec sha256sum {} \;
if [[ -n "$(which bsdtar)" ]]; then
bsdtar -czf "${OS_LOCAL_RELEASEPATH}/${archive_name}" -s ",^\.,${base_name}," $@
bsdtar -czf "${OS_OUTPUT_RELEASEPATH}/${archive_name}" -s ",^\.,${base_name}," $@
else
tar -czf --xattrs-exclude='LIBARCHIVE.xattr.security.selinux' "${OS_LOCAL_RELEASEPATH}/${archive_name}" --transform="s,^\.,${base_name}," $@
tar -czf --xattrs-exclude='LIBARCHIVE.xattr.security.selinux' "${OS_OUTPUT_RELEASEPATH}/${archive_name}" --transform="s,^\.,${base_name}," $@
fi
popd &>/dev/null
}
Expand Down Expand Up @@ -484,7 +484,7 @@ readonly -f os::build::extract_tar
# os::build::release_sha calculates a SHA256 checksum over the contents of the
# built release directory.
function os::build::release_sha() {
pushd "${OS_LOCAL_RELEASEPATH}" &> /dev/null
pushd "${OS_OUTPUT_RELEASEPATH}" &> /dev/null
sha256sum * > CHECKSUM
popd &> /dev/null
}
Expand All @@ -503,7 +503,7 @@ function os::build::make_openshift_binary_symlinks() {
readonly -f os::build::make_openshift_binary_symlinks

# os::build::detect_local_release_tars verifies there is only one primary and one
# image binaries release tar in OS_LOCAL_RELEASEPATH for the given platform specified by
# image binaries release tar in OS_OUTPUT_RELEASEPATH for the given platform specified by
# argument 1, exiting if more than one of either is found.
#
# If the tars are discovered, their full paths are exported to the following env vars:
Expand All @@ -513,36 +513,36 @@ readonly -f os::build::make_openshift_binary_symlinks
function os::build::detect_local_release_tars() {
local platform="$1"

if [[ ! -d "${OS_LOCAL_RELEASEPATH}" ]]; then
echo "There are no release artifacts in ${OS_LOCAL_RELEASEPATH}"
if [[ ! -d "${OS_OUTPUT_RELEASEPATH}" ]]; then
echo "There are no release artifacts in ${OS_OUTPUT_RELEASEPATH}"
return 2
fi
if [[ ! -f "${OS_LOCAL_RELEASEPATH}/.commit" ]]; then
echo "There is no release .commit identifier ${OS_LOCAL_RELEASEPATH}"
if [[ ! -f "${OS_OUTPUT_RELEASEPATH}/.commit" ]]; then
echo "There is no release .commit identifier ${OS_OUTPUT_RELEASEPATH}"
return 2
fi
local primary=$(find ${OS_LOCAL_RELEASEPATH} -maxdepth 1 -type f -name openshift-origin-server-*-${platform}* \( -name *.tar.gz -or -name *.zip \))
local primary=$(find ${OS_OUTPUT_RELEASEPATH} -maxdepth 1 -type f -name openshift-origin-server-*-${platform}* \( -name *.tar.gz -or -name *.zip \))
if [[ $(echo "${primary}" | wc -l) -ne 1 || -z "${primary}" ]]; then
echo "There should be exactly one ${platform} server tar in $OS_LOCAL_RELEASEPATH"
echo "There should be exactly one ${platform} server tar in $OS_OUTPUT_RELEASEPATH"
[[ -z "${WARN-}" ]] && return 2
fi

local client=$(find ${OS_LOCAL_RELEASEPATH} -maxdepth 1 -type f -name openshift-origin-client-tools-*-${platform}* \( -name *.tar.gz -or -name *.zip \))
local client=$(find ${OS_OUTPUT_RELEASEPATH} -maxdepth 1 -type f -name openshift-origin-client-tools-*-${platform}* \( -name *.tar.gz -or -name *.zip \))
if [[ $(echo "${client}" | wc -l) -ne 1 || -z "${client}" ]]; then
echo "There should be exactly one ${platform} client tar in $OS_LOCAL_RELEASEPATH"
echo "There should be exactly one ${platform} client tar in $OS_OUTPUT_RELEASEPATH"
[[ -n "${WARN-}" ]] || return 2
fi

local image=$(find ${OS_LOCAL_RELEASEPATH} -maxdepth 1 -type f -name openshift-origin-image*-${platform}* \( -name *.tar.gz -or -name *.zip \))
local image=$(find ${OS_OUTPUT_RELEASEPATH} -maxdepth 1 -type f -name openshift-origin-image*-${platform}* \( -name *.tar.gz -or -name *.zip \))
if [[ $(echo "${image}" | wc -l) -ne 1 || -z "${image}" ]]; then
echo "There should be exactly one ${platform} image tar in $OS_LOCAL_RELEASEPATH"
echo "There should be exactly one ${platform} image tar in $OS_OUTPUT_RELEASEPATH"
[[ -n "${WARN-}" ]] || return 2
fi

export OS_PRIMARY_RELEASE_TAR="${primary}"
export OS_IMAGE_RELEASE_TAR="${image}"
export OS_CLIENT_RELEASE_TAR="${client}"
export OS_RELEASE_COMMIT="$(cat ${OS_LOCAL_RELEASEPATH}/.commit)"
export OS_RELEASE_COMMIT="$(cat ${OS_OUTPUT_RELEASEPATH}/.commit)"
}
readonly -f os::build::detect_local_release_tars

Expand Down
6 changes: 6 additions & 0 deletions hack/env
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@
# NOTE: only committed code is built.
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"

relative_bin_path="$( os::util::repository_relative_path "${OS_OUTPUT_BINPATH}" )"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember this is now going to download 1GB everytime you exit a container, so just be sure you want that pain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

99% sure we do ... realistically people are using this to do builds locally pretty much 99.99999% of the time, they're not running other stuff as much.

relative_release_path="$( os::util::repository_relative_path "${OS_OUTPUT_RELEASEPATH}" )"
relative_script_path="$( os::util::repository_relative_path "${OS_OUTPUT_SCRIPTPATH}" )"
default_preserve_paths="${relative_bin_path}:${relative_release_path}:${relative_script_path}"
export OS_BUILD_ENV_PRESERVE="${OS_BUILD_ENV_PRESERVE:-"${default_preserve_paths}"}"

os::build::environment::run "$@"
5 changes: 3 additions & 2 deletions hack/lib/build/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ readonly OS_BUILD_ENV_IMAGE="${OS_BUILD_ENV_IMAGE:-openshift/origin-release:gola

readonly OS_OUTPUT_SUBPATH="${OS_OUTPUT_SUBPATH:-_output/local}"
readonly OS_OUTPUT="${OS_ROOT}/${OS_OUTPUT_SUBPATH}"
readonly OS_LOCAL_RELEASEPATH="${OS_OUTPUT}/releases"
readonly OS_LOCAL_RPMPATH="${OS_LOCAL_RELEASEPATH}/rpms"
readonly OS_OUTPUT_RELEASEPATH="${OS_OUTPUT}/releases"
readonly OS_OUTPUT_RPMPATH="${OS_OUTPUT_RELEASEPATH}/rpms"
readonly OS_OUTPUT_SCRIPTPATH="${OS_OUTPUT}/scripts"
readonly OS_OUTPUT_BINPATH="${OS_OUTPUT}/bin"
readonly OS_OUTPUT_PKGDIR="${OS_OUTPUT}/pkgdir"

Expand Down
4 changes: 2 additions & 2 deletions hack/lib/build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

# os::build::release::check_for_rpms checks that an RPM release has been built
function os::build::release::check_for_rpms() {
if [[ ! -d "${OS_LOCAL_RPMPATH}" || ! -s "${OS_LOCAL_RELEASEPATH}/CHECKSUM" ]]; then
relative_release_path="$( os::util::repository_relative_path "${OS_LOCAL_RELEASEPATH}" )"
if [[ ! -d "${OS_OUTPUT_RPMPATH}" || ! -s "${OS_OUTPUT_RELEASEPATH}/CHECKSUM" ]]; then
relative_release_path="$( os::util::repository_relative_path "${OS_OUTPUT_RELEASEPATH}" )"
relative_bin_path="$( os::util::repository_relative_path "${OS_OUTPUT_BINPATH}" )"
os::log::fatal "No release RPMs have been built! RPMs are necessary to build container images.
Build them with:
Expand Down
2 changes: 1 addition & 1 deletion hack/lib/util/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function os::util::environment::setup_tmpdir_vars() {
VOLUME_DIR="${BASETMPDIR}/volumes"
export VOLUME_DIR

BASEOUTDIR="${OS_ROOT}/_output/scripts/${sub_dir}"
BASEOUTDIR="${OS_OUTPUT_SCRIPTPATH}/${sub_dir}"
export BASEOUTDIR
LOG_DIR="${LOG_DIR:-${BASEOUTDIR}/logs}"
export LOG_DIR
Expand Down