Skip to content

Commit

Permalink
Bump origin spec files to be consistent with shared code
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Nov 9, 2017
1 parent 985a79b commit 1a8b960
Show file tree
Hide file tree
Showing 20 changed files with 641 additions and 571 deletions.
2 changes: 1 addition & 1 deletion .tito/lib/origin/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_os_git_vars():
for var in ["COMMIT", "VERSION", "MAJOR", "MINOR", "CATALOG_VERSION"]:
var_name = "OS_GIT_{}".format(var)
git_vars[var_name] = run_command(
"bash -c 'source ./hack/lib/init.sh; os::build::version::openshift_vars; echo ${}'".format(var_name)
"bash -c 'source ./hack/lib/init.sh; os::build::version::git_vars; echo ${}'".format(var_name)
)

# we hard-code this to a clean state as tito will have dirtied up the tree
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ install-travis:
# Example:
# make build-rpms
build-rpms:
OS_ONLY_BUILD_PLATFORMS='linux/amd64' hack/build-rpm-release.sh
OS_ONLY_BUILD_PLATFORMS='linux/amd64' hack/build-rpms.sh
.PHONY: build-rpms

# Build RPMs for all architectures
Expand All @@ -286,7 +286,7 @@ build-rpms:
# Example:
# make build-rpms-redistributable
build-rpms-redistributable:
hack/build-rpm-release.sh
hack/build-rpms.sh
.PHONY: build-rpms-redistributable

# Build images from the official RPMs
Expand Down
4 changes: 0 additions & 4 deletions hack/build-cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"

host_platform="$(os::build::host_platform)"

# Set build tags for these binaries
readonly OS_GOFLAGS_TAGS="include_gcs include_oss containers_image_openpgp"
readonly OS_GOFLAGS_TAGS_$(os::build::platform_arch)="gssapi"

# by default, build for these platforms
platforms=(
linux/amd64
Expand Down
22 changes: 2 additions & 20 deletions hack/build-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,17 @@ function cleanup() {
}
trap "cleanup" EXIT

build_targets=("$@")
platform="$(os::build::host_platform)"

# Set build tags for these binaries
readonly OS_GOFLAGS_TAGS="include_gcs include_oss containers_image_openpgp"

# only works on Linux for now, all other platforms must build binaries themselves
build_targets=("$@")
if [[ -z "$@" ]]; then
if [[ "${OS_RELEASE:-}" != "n" ]] && \
os::build::archive::detect_local_release_tars $(os::build::host_platform_friendly) >/dev/null; then
echo "++ Using release artifacts from ${OS_RELEASE_COMMIT} for ${platform} instead of building"
mkdir -p "${OS_OUTPUT_BINPATH}/${platform}"
os::build::archive::extract_tar "${OS_PRIMARY_RELEASE_TAR}" "${OS_OUTPUT_BINPATH}/${platform}"
os::build::archive::extract_tar "${OS_CLIENT_RELEASE_TAR}" "${OS_OUTPUT_BINPATH}/${platform}"
os::build::archive::extract_tar "${OS_IMAGE_RELEASE_TAR}" "${OS_OUTPUT_BINPATH}/${platform}"

os::build::make_openshift_binary_symlinks

exit
fi

build_targets=("${OS_CROSS_COMPILE_TARGETS[@]}")
build_targets=("${OS_CROSS_COMPILE_TARGETS[@]}")
# Also build SDN components on Linux by default
if [[ "${platform}" == linux/* ]]; then
build_targets=("${build_targets[@]}" "${OS_SDN_COMPILE_TARGETS_LINUX[@]}")
fi
fi


OS_BUILD_PLATFORMS=("${OS_BUILD_PLATFORMS[@]:-${platform}}")
os::build::build_binaries "${build_targets[@]}"
os::build::place_bins "${build_targets[@]}"
Expand Down
57 changes: 1 addition & 56 deletions hack/build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,59 +22,4 @@ os::build::release::check_for_rpms
# we need to mount RPMs into the container builds for installation
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 {
local src_file=$1
local dst_dir=$2
if os::build::archive::internal::is_hardlink_supported "${dst_dir}" ; then
ln -f "${src_file}" "${dst_dir}"
else
cp -pf "${src_file}" "${dst_dir}"
fi
}

# Link or copy image binaries to the appropriate locations.
ln_or_cp "${OS_OUTPUT_BINPATH}/linux/amd64/hello-openshift" examples/hello-openshift/bin
ln_or_cp "${OS_OUTPUT_BINPATH}/linux/amd64/gitserver" examples/gitserver/bin

# determine the correct tag prefix
tag_prefix="${OS_IMAGE_PREFIX:-"openshift/origin"}"

# images that depend on "${tag_prefix}-source"
( os::build::image "${tag_prefix}-pod" images/pod ) &
( os::build::image "${tag_prefix}-cluster-capacity" images/cluster-capacity ) &
( os::build::image "${tag_prefix}-service-catalog" images/service-catalog ) &
( os::build::image "${tag_prefix}-template-service-broker" images/template-service-broker ) &


for i in `jobs -p`; do wait $i; done

# images that depend on "${tag_prefix}-base"
( os::build::image "${tag_prefix}" images/origin ) &
( os::build::image "${tag_prefix}-docker-registry" images/dockerregistry ) &
( os::build::image "${tag_prefix}-egress-router" images/egress/router ) &
( os::build::image "${tag_prefix}-egress-http-proxy" images/egress/http-proxy ) &
( os::build::image "${tag_prefix}-federation" images/federation ) &

for i in `jobs -p`; do wait $i; done

# images that depend on "${tag_prefix}
( os::build::image "${tag_prefix}-haproxy-router" images/router/haproxy ) &
( os::build::image "${tag_prefix}-keepalived-ipfailover" images/ipfailover/keepalived ) &
( os::build::image "${tag_prefix}-gitserver" examples/gitserver ) &
( os::build::image "${tag_prefix}-deployer" images/deployer ) &
( os::build::image "${tag_prefix}-recycler" images/recycler ) &
( os::build::image "${tag_prefix}-docker-builder" images/builder/docker/docker-builder ) &
( os::build::image "${tag_prefix}-sti-builder" images/builder/docker/sti-builder ) &
( os::build::image "${tag_prefix}-f5-router" images/router/f5 ) &
( os::build::image "openshift/node" images/node ) &

for i in `jobs -p`; do wait $i; done

# images that depend on "openshift/node"
( os::build::image "openshift/openvswitch" images/openvswitch ) &

# extra images (not part of infrastructure)
( os::build::image "openshift/hello-openshift" examples/hello-openshift ) &

for i in `jobs -p`; do wait $i; done
os::build::images
99 changes: 0 additions & 99 deletions hack/build-rpm-release.sh

This file was deleted.

1 change: 1 addition & 0 deletions hack/build-rpm-release.sh
134 changes: 134 additions & 0 deletions hack/build-rpms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/bin/bash

# This script generates release zips and RPMs into _output/releases.
# tito and other build dependencies are required on the host. We will
# be running `hack/build-cross.sh` under the covers, so we transitively
# consume all of the relevant envars.
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"

function cleanup() {
return_code=$?
os::util::describe_return_code "${return_code}"
exit "${return_code}"
}
trap "cleanup" EXIT

# check whether we are in a clean output state
dirty="$( if [[ -d "${OS_OUTPUT}" ]]; then echo '1'; fi )"

os::util::ensure::system_binary_exists rpmbuild
os::util::ensure::system_binary_exists createrepo
os::build::setup_env

if [[ "${OS_ONLY_BUILD_PLATFORMS:-}" == 'linux/amd64' ]]; then
# when the user is asking for only Linux binaries, we will
# furthermore not build cross-platform clients in tito
make_redistributable=0
else
make_redistributable=1
fi
if [[ -n "${OS_BUILD_SRPM-}" ]]; then
srpm="a"
else
srpm="b"
fi


os::build::rpm::get_nvra_vars

OS_RPM_SPECFILE="$( find "${OS_ROOT}" -name *.spec )"
OS_RPM_NAME="$( rpmspec -q --qf '%{name}\n' "${OS_RPM_SPECFILE}" | head -1 )"

os::log::info "Building release RPMs for ${OS_RPM_SPECFILE} ..."

rpm_tmp_dir="${BASETMPDIR}/rpm"

# RPM requires the spec file be owned by the invoking user
chown "$(id -u):$(id -g)" "${OS_RPM_SPECFILE}" || true

if [[ -n "${dirty}" && "${OS_GIT_TREE_STATE}" == "dirty" ]]; then
os::log::warning "Repository is not clean, performing fast build and reusing _output"

# build and output from source to destination
mkdir -p "${rpm_tmp_dir}"
ln -fs "${OS_ROOT}" "${rpm_tmp_dir}/SOURCES"
ln -fs "${OS_ROOT}" "${rpm_tmp_dir}/BUILD"

rpmbuild -bb "${OS_RPM_SPECFILE}" \
--define "_sourcedir ${rpm_tmp_dir}/SOURCES" \
--define "_builddir ${rpm_tmp_dir}/BUILD" \
--define "skip_prep 1" \
--define "skip_dist 1" \
--define "make_redistributable ${make_redistributable}" \
--define "version ${OS_RPM_VERSION}" --define "release ${OS_RPM_RELEASE}" \
--define "commit ${OS_GIT_COMMIT}" \
--define "os_git_vars ${OS_RPM_GIT_VARS}" \
--define 'dist .el7' --define "_topdir ${rpm_tmp_dir}"

mkdir -p "${OS_OUTPUT_RPMPATH}"
mv -f "${rpm_tmp_dir}"/RPMS/*/*.rpm "${OS_OUTPUT_RPMPATH}"

else
mkdir -p "${rpm_tmp_dir}/SOURCES"
tar czf "${rpm_tmp_dir}/SOURCES/${OS_RPM_NAME}-${OS_RPM_VERSION}.tar.gz" \
--owner=0 --group=0 \
--exclude=_output --exclude=.git --transform "s|^|${OS_RPM_NAME}-${OS_RPM_VERSION}/|rSH" \
.

rpmbuild -b${srpm} "${OS_RPM_SPECFILE}" \
--define "skip_dist 1" \
--define "make_redistributable ${make_redistributable}" \
--define "version ${OS_RPM_VERSION}" --define "release ${OS_RPM_RELEASE}" \
--define "commit ${OS_GIT_COMMIT}" \
--define "os_git_vars ${OS_RPM_GIT_VARS}" \
--define 'dist .el7' --define "_topdir ${rpm_tmp_dir}"

output_directory="$( find "${rpm_tmp_dir}" -type d -path "*/BUILD/${OS_RPM_NAME}-${OS_RPM_VERSION}/_output/local" )"
if [[ -z "${output_directory}" ]]; then
os::log::fatal 'No _output artifact directory found in rpmbuild artifacts!'
fi

# migrate the rpm artifacts to the output directory, must be clean or move will fail
make clean
mkdir -p "${OS_OUTPUT}"

# mv exits prematurely with status 1 in the following scenario: running as root,
# attempting to move a [directory tree containing a] symlink to a destination on
# an NFS volume exported with root_squash set. This can occur when running this
# script on a Vagrant box. The error shown is "mv: failed to preserve ownership
# for $FILE: Operation not permitted". As a workaround, if
# ${tito_output_directory} and ${OS_OUTPUT} are on different devices, use cp and
# rm instead.
if [[ $(stat -c %d "${output_directory}") == $(stat -c %d "${OS_OUTPUT}") ]]; then
mv "${output_directory}"/* "${OS_OUTPUT}"
else
cp -R "${output_directory}"/* "${OS_OUTPUT}"
rm -rf "${output_directory}"/*
fi

mkdir -p "${OS_OUTPUT_RPMPATH}"
if [[ -n "${OS_BUILD_SRPM-}" ]]; then
mv -f "${rpm_tmp_dir}"/SRPMS/*src.rpm "${OS_OUTPUT_RPMPATH}"
fi
mv -f "${rpm_tmp_dir}"/RPMS/*/*.rpm "${OS_OUTPUT_RPMPATH}"
fi

mkdir -p "${OS_OUTPUT_RELEASEPATH}"
echo "${OS_GIT_COMMIT}" > "${OS_OUTPUT_RELEASEPATH}/.commit"

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

echo "[${OS_RPM_NAME}-local-release]
baseurl = file://${repo_path}
gpgcheck = 0
name = Release from Local Source for ${OS_RPM_NAME}
enabled = 1
" > "${repo_path}/local-release.repo"

# DEPRECATED: preserve until jobs migrate to using local-release.repo
cp "${repo_path}/local-release.repo" "${repo_path}/origin-local-release.repo"

os::log::info "Repository file for \`yum\` or \`dnf\` placed at ${repo_path}/local-release.repo
Install it with:
$ mv '${repo_path}/local-release.repo' '/etc/yum.repos.d"
Loading

0 comments on commit 1a8b960

Please sign in to comment.