diff --git a/.tito/lib/origin/common.py b/.tito/lib/origin/common.py index 5e9823f4f886..addfd5ba3c48 100644 --- a/.tito/lib/origin/common.py +++ b/.tito/lib/origin/common.py @@ -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 diff --git a/Makefile b/Makefile index 489109cb5a49..fab48679c985 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/hack/build-cross.sh b/hack/build-cross.sh index 649a7bdaef17..5694dee946c6 100755 --- a/hack/build-cross.sh +++ b/hack/build-cross.sh @@ -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 diff --git a/hack/build-go.sh b/hack/build-go.sh index 33290fc30931..b99392c19315 100755 --- a/hack/build-go.sh +++ b/hack/build-go.sh @@ -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[@]}" diff --git a/hack/build-images.sh b/hack/build-images.sh index a47a48c34f69..c45ebc5884f1 100755 --- a/hack/build-images.sh +++ b/hack/build-images.sh @@ -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 \ No newline at end of file diff --git a/hack/build-rpm-release.sh b/hack/build-rpm-release.sh deleted file mode 100755 index f4da77370f67..000000000000 --- a/hack/build-rpm-release.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/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 - -os::util::ensure::system_binary_exists tito -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 - -os::log::info 'Building Origin release RPMs with tito...' -os::build::rpm::get_nvra_vars -tito tag --use-version="${OS_RPM_VERSION}" \ - --use-release="${OS_RPM_RELEASE}" \ - --no-auto-changelog --offline -tito_tmp_dir="${BASETMPDIR}/tito" -mkdir -p "${tito_tmp_dir}" -tito build --offline --srpm --rpmbuild-options="--define 'dist .el7'" --output="${tito_tmp_dir}" -tito build --output="${tito_tmp_dir}" --rpm --no-cleanup --quiet --offline \ - --rpmbuild-options="--define 'make_redistributable ${make_redistributable}' ${RPM_BUILD_OPTS:-}" -tito tag --undo --offline - -os::log::info 'Unpacking tito artifacts for reuse...' -output_directories=( $( find "${tito_tmp_dir}" -type d -name "rpmbuild-${OS_RPM_NAME}*" ) ) -if [[ "${#output_directories[@]}" -eq 0 ]]; then - os::log::fatal 'After the tito build, no rpmbuild directory was found!' -elif [[ "${#output_directories[@]}" -gt 1 ]]; then - # find the newest directory in the list - output_directory="${output_directories[0]}" - for directory in "${output_directories[@]}"; do - if [[ "${directory}" -nt "${output_directory}" ]]; then - output_directory="${directory}" - fi - done - os::log::warning "After the tito build, more than one rpmbuild directory was found! -This script will unpack the most recently modified directory: ${output_directory}" -else - output_directory="${output_directories[0]}" -fi - -tito_output_directory="$( find "${output_directory}" -type d -path "*/BUILD/${OS_RPM_NAME}-${OS_RPM_VERSION}/_output/local" )" -if [[ -z "${tito_output_directory}" ]]; then - os::log::fatal 'No _output artifact directory found in tito rpmbuild artifacts!' -fi - -make clean - -# migrate the tito artifacts to the Origin directory -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 "${tito_output_directory}") == $(stat -c %d "${OS_OUTPUT}") ]]; then - mv "${tito_output_directory}"/* "${OS_OUTPUT}" -else - cp -R "${tito_output_directory}"/* "${OS_OUTPUT}" - rm -rf "${tito_output_directory}"/* -fi - -mkdir -p "${OS_OUTPUT_RPMPATH}" -mv -f "${tito_tmp_dir}"/*src.rpm "${OS_OUTPUT_RPMPATH}" -mv -f "${tito_tmp_dir}"/*/*.rpm "${OS_OUTPUT_RPMPATH}" -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 = OpenShift Release from Local Source -enabled = 1 -" > "${repo_path}/${OS_RPM_NAME}-local-release.repo" - -os::log::info "Repository file for \`yum\` or \`dnf\` placed at ${repo_path}/origin-local-release.repo -Install it with: -$ mv '${repo_path}/origin-local-release.repo' '/etc/yum.repos.d" diff --git a/hack/build-rpm-release.sh b/hack/build-rpm-release.sh new file mode 120000 index 000000000000..27d9ba4105f7 --- /dev/null +++ b/hack/build-rpm-release.sh @@ -0,0 +1 @@ +build-rpms.sh \ No newline at end of file diff --git a/hack/build-rpms.sh b/hack/build-rpms.sh new file mode 100755 index 000000000000..86cac9ed08f1 --- /dev/null +++ b/hack/build-rpms.sh @@ -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" diff --git a/hack/deps b/hack/deps index df8858a56b15..d0c549308be3 100755 --- a/hack/deps +++ b/hack/deps @@ -9,10 +9,7 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh" if [[ $# -eq 0 || ! -f "${OS_OUTPUT}/deps" ]]; then echo "Generating dependency graph ..." 1>&2 mkdir -p "${OS_OUTPUT}" - go list -f '{{.ImportPath}}{{.Imports}}' ./pkg/... ./cmd/... | tr '[]' ' ' | - grep -vE '^github.com/openshift/origin/cmd/(service-catalog|cluster-capacity)' | - sed -e 's|github.com/openshift/origin/vendor/||g' | - sed -e 's|github.com/openshift/origin/pkg/build/vendor/||g' > "${OS_OUTPUT}/deps" + os::util::list_go_deps > "${OS_OUTPUT}/deps" fi if [[ $# -eq 0 ]]; then @@ -21,10 +18,10 @@ if [[ $# -eq 0 ]]; then echo "Install digraph with: go get -u golang.org/x/tools/cmd/digraph" echo echo "To see the list of all dependencies of a package: " - echo " hack/deps.sh forward github.com/openshift/origin/cmd/openshift" + echo " hack/deps.sh forward ${OS_GO_PACKAGE}/cmd/openshift" echo echo "To see how a package was included into a binary (one particular way): " - echo " hack/deps.sh somepath github.com/openshift/origin/cmd/openshift FULL_PACKAGE_NAME" + echo " hack/deps.sh somepath ${OS_GO_PACKAGE}/cmd/openshift FULL_PACKAGE_NAME" exit 0 fi diff --git a/hack/lib/build/binaries.sh b/hack/lib/build/binaries.sh index 7efa83aad62a..7387eeb3ff75 100644 --- a/hack/lib/build/binaries.sh +++ b/hack/lib/build/binaries.sh @@ -8,6 +8,9 @@ function os::build::binaries_from_targets() { local target for target; do + if [[ -z "${target}" ]]; then + continue + fi echo "${OS_GO_PACKAGE}/${target}" done } @@ -82,9 +85,9 @@ function os::build::setup_env() { if [[ "${TRAVIS:-}" != "true" ]]; then local go_version go_version=($(go version)) - if [[ "${go_version[2]}" < "go1.8" ]]; then + if [[ "${go_version[2]}" < "${OS_REQUIRED_GO_VERSION}" ]]; then os::log::fatal "Detected Go version: ${go_version[*]}. -Origin builds require Go version 1.8 or greater." +Builds require Go version ${OS_REQUIRED_GO_VERSION} or greater." fi fi # For any tools that expect this to be set (it is default in golang 1.6), @@ -187,9 +190,13 @@ os::build::internal::build_binaries() { os::build::export_targets "$@" + if [[ ! "${targets[@]:+${targets[@]}}" || ! "${binaries[@]:+${binaries[@]}}" ]]; then + return 0 + fi + local -a nonstatics=() local -a tests=() - for binary in "${binaries[@]}"; do + for binary in "${binaries[@]-}"; do if [[ "${binary}" =~ ".test"$ ]]; then tests+=($binary) else @@ -197,6 +204,11 @@ os::build::internal::build_binaries() { fi done + local pkgdir="${OS_OUTPUT_PKGDIR}" + if [[ "${CGO_ENABLED-}" == "0" ]]; then + pkgdir+="/static" + fi + local host_platform=$(os::build::host_platform) local platform for platform in "${platforms[@]+"${platforms[@]}"}"; do @@ -226,7 +238,7 @@ os::build::internal::build_binaries() { if [[ ${#nonstatics[@]} -gt 0 ]]; then GOOS=${platform%/*} GOARCH=${platform##*/} go install \ - -pkgdir "${OS_OUTPUT_PKGDIR}/${platform}" \ + -pkgdir "${pkgdir}/${platform}" \ -tags "${OS_GOFLAGS_TAGS-} ${!platform_gotags_envvar:-}" \ -ldflags="${local_ldflags}" \ "${goflags[@]:+${goflags[@]}}" \ @@ -240,14 +252,14 @@ os::build::internal::build_binaries() { fi if [[ "$platform" == "windows/amd64" ]]; then - rm ${OS_ROOT}/cmd/oc/oc.syso + os::build::clean_windows_versioninfo fi for test in "${tests[@]:+${tests[@]}}"; do local outfile="${OS_OUTPUT_BINPATH}/${platform}/$(basename ${test})" # disabling cgo allows use of delve CGO_ENABLED="${OS_TEST_CGO_ENABLED:-}" GOOS=${platform%/*} GOARCH=${platform##*/} go test \ - -pkgdir "${OS_OUTPUT_PKGDIR}/${platform}" \ + -pkgdir "${pkgdir}/${platform}" \ -tags "${OS_GOFLAGS_TAGS-} ${!platform_gotags_test_envvar:-}" \ -ldflags "${local_ldflags}" \ -i -c -o "${outfile}" \ @@ -258,66 +270,12 @@ os::build::internal::build_binaries() { } readonly -f os::build::build_binaries -# Generates the .syso file used to add compile-time VERSIONINFO metadata to the -# Windows binary. -function os::build::generate_windows_versioninfo() { - os::build::version::get_vars - local major="${OS_GIT_MAJOR}" - local minor="${OS_GIT_MINOR%+}" - local patch="${OS_GIT_PATCH}" - local windows_versioninfo_file=`mktemp --suffix=".versioninfo.json"` - cat <"${windows_versioninfo_file}" -{ - "FixedFileInfo": - { - "FileVersion": { - "Major": ${major}, - "Minor": ${minor}, - "Patch": ${patch} - }, - "ProductVersion": { - "Major": ${major}, - "Minor": ${minor}, - "Patch": ${patch} - }, - "FileFlagsMask": "3f", - "FileFlags ": "00", - "FileOS": "040004", - "FileType": "01", - "FileSubType": "00" - }, - "StringFileInfo": - { - "Comments": "", - "CompanyName": "Red Hat, Inc.", - "InternalName": "openshift client", - "FileVersion": "${OS_GIT_VERSION}", - "InternalName": "oc", - "LegalCopyright": "© Red Hat, Inc. Licensed under the Apache License, Version 2.0", - "LegalTrademarks": "", - "OriginalFilename": "oc.exe", - "PrivateBuild": "", - "ProductName": "OpenShift Client", - "ProductVersion": "${OS_GIT_VERSION}", - "SpecialBuild": "" - }, - "VarFileInfo": - { - "Translation": { - "LangID": "0409", - "CharsetID": "04B0" - } - } -} -EOF - goversioninfo -o ${OS_ROOT}/cmd/oc/oc.syso ${windows_versioninfo_file} -} -readonly -f os::build::generate_windows_versioninfo - # Generates the set of target packages, binaries, and platforms to build for. # Accepts binaries via $@, and platforms via OS_BUILD_PLATFORMS, or defaults to # the current platform. function os::build::export_targets() { + platforms=("${OS_BUILD_PLATFORMS[@]:+${OS_BUILD_PLATFORMS[@]}}") + targets=() local arg for arg; do @@ -325,15 +283,8 @@ function os::build::export_targets() { targets+=("${arg}") fi done - - if [[ ${#targets[@]} -eq 0 ]]; then - echo "No targets to export!" - exit 1 - fi - - binaries=($(os::build::binaries_from_targets "${targets[@]}")) - - platforms=("${OS_BUILD_PLATFORMS[@]:+${OS_BUILD_PLATFORMS[@]}}") + + binaries=($(os::build::binaries_from_targets "${targets[@]-}")) } readonly -f os::build::export_targets @@ -470,68 +421,15 @@ function os::build::make_openshift_binary_symlinks() { } readonly -f os::build::make_openshift_binary_symlinks -# os::build::get_product_vars exports variables that we expect to change -# depending on the distribution of Origin -function os::build::get_product_vars() { - export OS_BUILD_LDFLAGS_IMAGE_PREFIX="${OS_IMAGE_PREFIX:-"openshift/origin"}" - export OS_BUILD_LDFLAGS_DEFAULT_IMAGE_STREAMS="${OS_BUILD_LDFLAGS_DEFAULT_IMAGE_STREAMS:-"centos7"}" - export OS_BUILD_LDFLAGS_FEDERATION_SERVER_IMAGE_NAME="${OS_BUILD_LDFLAGS_FEDERATION_SERVER_IMAGE_NAME:-"${OS_BUILD_LDFLAGS_IMAGE_PREFIX}-federation"}" - export OS_BUILD_LDFLAGS_FEDERATION_ETCD_IMAGE="${OS_BUILD_LDFLAGS_FEDERATION_ETCD_IMAGE:-"quay.io/coreos/etcd:v3.1.7"}" -} - -# golang 1.5 wants `-X key=val`, but golang 1.4- REQUIRES `-X key val` +# DEPRECATED: will be removed function os::build::ldflag() { local key=${1} local val=${2} - GO_VERSION=($(go version)) - if [[ -n $(echo "${GO_VERSION[2]}" | grep -E 'go1.4') ]]; then - echo "-X ${key} ${val}" - else - echo "-X ${key}=${val}" - fi + echo "-X ${key}=${val}" } readonly -f os::build::ldflag -# os::build::ldflags calculates the -ldflags argument for building OpenShift -function os::build::ldflags() { - # Run this in a subshell to prevent settings/variables from leaking. - set -o errexit - set -o nounset - set -o pipefail - - cd "${OS_ROOT}" - - os::build::version::get_vars - os::build::get_product_vars - - local buildDate="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" - - declare -a ldflags=() - - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/oc/bootstrap/docker.defaultImageStreams" "${OS_BUILD_LDFLAGS_DEFAULT_IMAGE_STREAMS}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/cmd/util/variable.DefaultImagePrefix" "${OS_BUILD_LDFLAGS_IMAGE_PREFIX}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/version.majorFromGit" "${OS_GIT_MAJOR}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/version.minorFromGit" "${OS_GIT_MINOR}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/version.versionFromGit" "${OS_GIT_VERSION}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/version.commitFromGit" "${OS_GIT_COMMIT}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/version.buildDate" "${buildDate}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/kubernetes/pkg/version.gitCommit" "${KUBE_GIT_COMMIT}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/kubernetes/pkg/version.gitVersion" "${KUBE_GIT_VERSION}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/kubernetes/pkg/version.buildDate" "${buildDate}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/kubernetes/pkg/version.gitTreeState" "clean")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.gitCommit" "${KUBE_GIT_COMMIT}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.gitVersion" "${KUBE_GIT_VERSION}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.buildDate" "${buildDate}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.gitTreeState" "clean")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/federation/kubefed.serverImageName" "${OS_BUILD_LDFLAGS_FEDERATION_SERVER_IMAGE_NAME}")) - ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/federation/kubefed.defaultEtcdImage" "${OS_BUILD_LDFLAGS_FEDERATION_ETCD_IMAGE}")) - - # The -ldflags parameter takes a single string, so join the output. - echo "${ldflags[*]-}" -} -readonly -f os::build::ldflags - # os::build::require_clean_tree exits if the current Git tree is not clean. function os::build::require_clean_tree() { if ! git diff-index --quiet HEAD -- || test $(git ls-files --exclude-standard --others | wc -l) != 0; then diff --git a/hack/lib/build/constants.sh b/hack/lib/build/constants.sh deleted file mode 100755 index c6f699a87b40..000000000000 --- a/hack/lib/build/constants.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/bash - -# This script provides constants for the Golang binary build process - -readonly OS_BUILD_ENV_GOLANG="${OS_BUILD_ENV_GOLANG:-1.8}" -readonly OS_BUILD_ENV_IMAGE="${OS_BUILD_ENV_IMAGE:-openshift/origin-release:golang-${OS_BUILD_ENV_GOLANG}}" - -readonly OS_OUTPUT_BASEPATH="${OS_OUTPUT_BASEPATH:-_output}" -readonly OS_BASE_OUTPUT="${OS_ROOT}/${OS_OUTPUT_BASEPATH}" -readonly OS_OUTPUT_SCRIPTPATH="${OS_OUTPUT_SCRIPTPATH:-"${OS_BASE_OUTPUT}/scripts"}" - -readonly OS_OUTPUT_SUBPATH="${OS_OUTPUT_SUBPATH:-${OS_OUTPUT_BASEPATH}/local}" -readonly OS_OUTPUT="${OS_ROOT}/${OS_OUTPUT_SUBPATH}" -readonly OS_OUTPUT_RELEASEPATH="${OS_OUTPUT}/releases" -readonly OS_OUTPUT_RPMPATH="${OS_OUTPUT_RELEASEPATH}/rpms" -readonly OS_OUTPUT_BINPATH="${OS_OUTPUT}/bin" -readonly OS_OUTPUT_PKGDIR="${OS_OUTPUT}/pkgdir" - -readonly OS_GO_PACKAGE=github.com/openshift/origin - -readonly OS_SDN_COMPILE_TARGETS_LINUX=( - pkg/network/sdn-cni-plugin - vendor/github.com/containernetworking/cni/plugins/ipam/host-local - vendor/github.com/containernetworking/cni/plugins/main/loopback -) -readonly OS_IMAGE_COMPILE_TARGETS_LINUX=( - cmd/dockerregistry - cmd/gitserver - vendor/k8s.io/kubernetes/cmd/hyperkube - "${OS_SDN_COMPILE_TARGETS_LINUX[@]}" -) -readonly OS_SCRATCH_IMAGE_COMPILE_TARGETS_LINUX=( - images/pod - examples/hello-openshift -) -readonly OS_IMAGE_COMPILE_BINARIES=("${OS_SCRATCH_IMAGE_COMPILE_TARGETS_LINUX[@]##*/}" "${OS_IMAGE_COMPILE_TARGETS_LINUX[@]##*/}") - -readonly OS_CROSS_COMPILE_TARGETS=( - cmd/openshift - cmd/oc - cmd/kubefed - cmd/template-service-broker -) -readonly OS_CROSS_COMPILE_BINARIES=("${OS_CROSS_COMPILE_TARGETS[@]##*/}") - -readonly OS_TEST_TARGETS=( - test/extended/extended.test -) - -#If you update this list, be sure to get the images/origin/Dockerfile -readonly OPENSHIFT_BINARY_SYMLINKS=( - openshift-router - openshift-deploy - openshift-recycle - openshift-sti-build - openshift-docker-build - openshift-git-clone - openshift-manage-dockerfile - openshift-extract-image-content - origin - osc - oadm - osadm - kubectl - kubernetes - kubelet - kube-proxy - kube-apiserver - kube-controller-manager - kube-scheduler -) -readonly OPENSHIFT_BINARY_COPY=( - oadm - kubelet - kube-proxy - kube-apiserver - kube-controller-manager - kube-scheduler -) -readonly OC_BINARY_COPY=( - kubectl -) -readonly OS_BINARY_RELEASE_CLIENT_WINDOWS=( - oc.exe - README.md - ./LICENSE -) -readonly OS_BINARY_RELEASE_CLIENT_MAC=( - oc - README.md - ./LICENSE -) -readonly OS_BINARY_RELEASE_CLIENT_LINUX=( - ./oc - ./README.md - ./LICENSE -) -readonly OS_BINARY_RELEASE_SERVER_LINUX=( - './*' -) -readonly OS_BINARY_RELEASE_CLIENT_EXTRA=( - ${OS_ROOT}/README.md - ${OS_ROOT}/LICENSE -) diff --git a/hack/lib/build/environment.sh b/hack/lib/build/environment.sh index e07cd8ac6fcd..70e2e09a3b37 100644 --- a/hack/lib/build/environment.sh +++ b/hack/lib/build/environment.sh @@ -10,14 +10,17 @@ function os::build::environment::create() { set -o errexit local release_image="${OS_BUILD_ENV_IMAGE}" local additional_context="${OS_BUILD_ENV_DOCKER_ARGS:-}" + + local workingdir + workingdir=$( os::build::environment::release::workingdir ) + additional_context+=" -w ${workingdir}" + if [[ "${OS_BUILD_ENV_USE_DOCKER:-y}" == "y" ]]; then additional_context+=" --privileged -v /var/run/docker.sock:/var/run/docker.sock" if [[ "${OS_BUILD_ENV_LOCAL_DOCKER:-n}" == "y" ]]; then # if OS_BUILD_ENV_LOCAL_DOCKER==y, add the local OS_ROOT as the bind mount to the working dir # and set the running user to the current user - local workingdir - workingdir=$( os::build::environment::release::workingdir ) additional_context+=" -v ${OS_ROOT}:${workingdir} -u $(id -u)" elif [[ -n "${OS_BUILD_ENV_VOLUME:-}" ]]; then if docker volume inspect "${OS_BUILD_ENV_VOLUME}" >/dev/null 2>&1; then @@ -40,9 +43,6 @@ function os::build::environment::create() { fi additional_context+=" -v ${OS_BUILD_ENV_TMP_VOLUME}:/tmp" fi - - local workingdir - workingdir=$( os::build::environment::release::workingdir ) additional_context+=" -v ${OS_BUILD_ENV_VOLUME}:${workingdir}" fi fi @@ -89,6 +89,10 @@ readonly -f os::build::environment::create # os::build::environment::release::workingdir calculates the working directory for the current # release image. function os::build::environment::release::workingdir() { + if [[ -n "${OS_BUILD_ENV_WORKINGDIR-}" ]]; then + echo "${OS_BUILD_ENV_WORKINGDIR}" + return 0 + fi set -o errexit # get working directory local container @@ -185,7 +189,7 @@ function os::build::environment::withsource() { if [[ -n "${OS_BUILD_ENV_FROM_ARCHIVE-}" ]]; then # Generate version definitions. Tree state is clean because we are pulling from git directly. OS_GIT_TREE_STATE=clean os::build::version::get_vars - os::build::version::save_vars "/tmp/os-version-defs" + os::build::version::save_vars > "/tmp/os-version-defs" os::log::debug "Generating source code archive" tar -cf - -C /tmp/ os-version-defs | docker cp - "${container}:/tmp" diff --git a/hack/lib/build/rpm.sh b/hack/lib/build/rpm.sh index bc41236aa308..babd198309b4 100644 --- a/hack/lib/build/rpm.sh +++ b/hack/lib/build/rpm.sh @@ -10,13 +10,11 @@ # Arguments: # - None # Exports: -# - OS_RPM_NAME # - OS_RPM_VERSION # - OS_RPM_RELEASE # - OS_RPM_ARCHITECTURE function os::build::rpm::get_nvra_vars() { # the package name can be overwritten but is normally 'origin' - OS_RPM_NAME="${OS_RPM_NAME:-"origin"}" OS_RPM_ARCHITECTURE="$(uname -i)" # we can extract the pacakge version from the build version @@ -66,7 +64,9 @@ function os::build::rpm::get_nvra_vars() { os::log::fatal "Malformed git version metadata: ${metadata}" fi - export OS_RPM_NAME OS_RPM_VERSION OS_RPM_RELEASE OS_RPM_ARCHITECTURE + OS_RPM_GIT_VARS=$( os::build::version::save_vars | tr '\n' ' ' ) + + export OS_RPM_VERSION OS_RPM_RELEASE OS_RPM_ARCHITECTURE OS_RPM_GIT_VARS } @@ -83,9 +83,13 @@ function os::build::rpm::get_nvra_vars() { # Returns: # None function os::build::rpm::format_nvra() { - if [[ -z "${OS_RPM_NAME:-}" || -z "${OS_RPM_VERSION:-}" || -z "${OS_RPM_RELEASE:-}" ]]; then + if [[ -z "${OS_RPM_VERSION:-}" || -z "${OS_RPM_RELEASE:-}" ]]; then os::build::rpm::get_nvra_vars fi + if [[ -z "${OS_RPM_NAME-}" ]]; then + OS_RPM_SPECFILE="$( find "${OS_ROOT}" -name *.spec )" + OS_RPM_NAME="$( rpmspec -q --qf '%{name}\n' "${OS_RPM_SPECFILE}" | head -1 )" + fi echo "${OS_RPM_NAME}-${OS_RPM_VERSION}-${OS_RPM_RELEASE}.${OS_RPM_ARCHITECTURE}" } diff --git a/hack/lib/build/version.sh b/hack/lib/build/version.sh index 9472d312188a..837b76aa375f 100644 --- a/hack/lib/build/version.sh +++ b/hack/lib/build/version.sh @@ -16,14 +16,19 @@ function os::build::version::get_vars() { fi os::log::warning "No version file at ${OS_VERSION_FILE}, falling back to git versions" fi - os::build::version::openshift_vars - os::build::version::kubernetes_vars - os::build::version::etcd_vars + os::build::version::git_vars } readonly -f os::build::version::get_vars -# os::build::version::openshift_vars looks up the current Git vars -function os::build::version::openshift_vars() { +# os::build::version::git_vars looks up the current Git vars if they have not been calculated. +function os::build::version::git_vars() { + if [[ -n "${OS_GIT_VERSION-}" ]]; then + return 0 + fi + + os::build::version::kubernetes_vars + os::build::version::etcd_vars + local git=(git --work-tree "${OS_ROOT}") if [[ -z "${OS_GIT_CATALOG_VERSION:-}" ]]; then @@ -79,7 +84,7 @@ function os::build::version::openshift_vars() { fi fi } -readonly -f os::build::version::openshift_vars +readonly -f os::build::version::git_vars function os::build::version::etcd_vars() { ETCD_GIT_VERSION=$(go run "${OS_ROOT}/tools/godepversion/godepversion.go" "${OS_ROOT}/Godeps/Godeps.json" "github.com/coreos/etcd/etcdserver" "comment") @@ -116,12 +121,7 @@ readonly -f os::build::version::kubernetes_vars # Saves the environment flags to $1 function os::build::version::save_vars() { - local version_file=${1-} - if [[ -z ${version_file} ]]; then - os::log::fatal "No file specified as an argument to os::build::version::save_vars" - fi - - cat <"${version_file}" + cat <"${windows_versioninfo_file}" +{ + "FixedFileInfo": + { + "FileVersion": { + "Major": ${major}, + "Minor": ${minor}, + "Patch": ${patch} + }, + "ProductVersion": { + "Major": ${major}, + "Minor": ${minor}, + "Patch": ${patch} + }, + "FileFlagsMask": "3f", + "FileFlags ": "00", + "FileOS": "040004", + "FileType": "01", + "FileSubType": "00" + }, + "StringFileInfo": + { + "Comments": "", + "CompanyName": "Red Hat, Inc.", + "InternalName": "openshift client", + "FileVersion": "${OS_GIT_VERSION}", + "InternalName": "oc", + "LegalCopyright": "© Red Hat, Inc. Licensed under the Apache License, Version 2.0", + "LegalTrademarks": "", + "OriginalFilename": "oc.exe", + "PrivateBuild": "", + "ProductName": "OpenShift Client", + "ProductVersion": "${OS_GIT_VERSION}", + "SpecialBuild": "" + }, + "VarFileInfo": + { + "Translation": { + "LangID": "0409", + "CharsetID": "04B0" + } + } +} +EOF + goversioninfo -o ${OS_ROOT}/cmd/oc/oc.syso ${windows_versioninfo_file} +} +readonly -f os::build::generate_windows_versioninfo + +# Removes the .syso file used to add compile-time VERSIONINFO metadata to the +# Windows binary. +function os::build::clean_windows_versioninfo() { + rm ${OS_ROOT}/cmd/oc/oc.syso +} +readonly -f os::build::clean_windows_versioninfo + +# OS_ALL_IMAGES is the list of images built by os::build::images. +readonly OS_ALL_IMAGES=( + openshift/origin + openshift/origin-base + openshift/origin-pod + openshift/origin-deployer + openshift/origin-docker-builder + openshift/origin-docker-registry + openshift/origin-keepalived-ipfailover + openshift/origin-sti-builder + openshift/origin-haproxy-router + openshift/origin-f5-router + openshift/origin-egress-router + openshift/origin-egress-http-proxy + openshift/origin-recycler + openshift/origin-gitserver + openshift/origin-cluster-capacity + openshift/origin-service-catalog + openshift/origin-template-service-broker + openshift/hello-openshift + openshift/openvswitch + openshift/node +) + +# os::build::images builds all images in this repo. +function os::build::images() { + # 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 +} +readonly -f os::build::images \ No newline at end of file diff --git a/hack/lib/util/golang.sh b/hack/lib/util/golang.sh index 9c46e1c7724b..3bbb1ebf48b0 100644 --- a/hack/lib/util/golang.sh +++ b/hack/lib/util/golang.sh @@ -11,10 +11,10 @@ function os::golang::verify_go_version() { if [[ "${go_version[2]}" != go1.8* ]]; then os::log::info "Detected go version: ${go_version[*]}." if [[ -z "${PERMISSIVE_GO:-}" ]]; then - os::log::fatal "Please install Go version 1.8 or use PERMISSIVE_GO=y to bypass this check." + os::log::fatal "Please install Go version ${OS_REQUIRED_GO_VERSION} or use PERMISSIVE_GO=y to bypass this check." else - os::log::warning "Detected golang version doesn't match preferred Go version for Origin." - os::log::warning "This version mismatch could lead to differences in execution between this run and the Origin CI systems." + os::log::warning "Detected golang version doesn't match required Go version." + os::log::warning "This version mismatch could lead to differences in execution between this run and the CI systems." return 0 fi fi diff --git a/hack/lib/util/misc.sh b/hack/lib/util/misc.sh index 6046fa59aa2d..96b88316b4d6 100644 --- a/hack/lib/util/misc.sh +++ b/hack/lib/util/misc.sh @@ -189,48 +189,3 @@ function os::util::curl_etcd() { --cert "${etcd_client_cert}" --key "${etcd_client_key}" "${full_url}" fi } - -# os::util::list_go_src_files lists files we consider part of our project -# source code, useful for tools that iterate over source to provide vet- -# ting or linting, etc. -# -# Globals: -# None -# Arguments: -# None -# Returns: -# None -function os::util::list_go_src_files() { - find . -not \( \ - \( \ - -wholename './_output' \ - -o -wholename './.*' \ - -o -wholename './pkg/assets/bindata.go' \ - -o -wholename './pkg/assets/*/bindata.go' \ - -o -wholename './pkg/oc/bootstrap/bindata.go' \ - -o -wholename './openshift.local.*' \ - -o -wholename './test/extended/testdata/bindata.go' \ - -o -wholename '*/vendor/*' \ - -o -wholename './cmd/service-catalog/*' \ - -o -wholename './cmd/cluster-capacity/*' \ - -o -wholename './assets/bower_components/*' \ - \) -prune \ - \) -name '*.go' | sort -u -} -readonly -f os::util::list_go_src_files - -# os::util::list_go_src_dirs lists dirs in origin/ and cmd/ dirs excluding -# cmd/cluster-capacity and cmd/service-catalog and doc.go useful for tools that -# iterate over source to provide vetting or linting, or for godep-save etc. -# -# Globals: -# None -# Arguments: -# None -# Returns: -# None -function os::util::list_go_src_dirs() { - os::util::list_go_src_files | cut -d '/' -f 1-2 | grep -v ".go$" | grep -v "^./cmd" | LC_ALL=C sort -u - os::util::list_go_src_files | grep "^./cmd/"| cut -d '/' -f 1-3 | grep -v ".go$" | LC_ALL=C sort -u -} -readonly -f os::util::list_go_src_dirs diff --git a/hack/push-release.sh b/hack/push-release.sh index 2ca409c9f60e..435aa8c0a0e8 100755 --- a/hack/push-release.sh +++ b/hack/push-release.sh @@ -34,28 +34,7 @@ if [[ -z "${source_tag}" ]]; then fi fi -images=( - openshift/origin - openshift/origin-base - openshift/origin-pod - openshift/origin-deployer - openshift/origin-docker-builder - openshift/origin-docker-registry - openshift/origin-keepalived-ipfailover - openshift/origin-sti-builder - openshift/origin-haproxy-router - openshift/origin-f5-router - openshift/origin-egress-router - openshift/origin-egress-http-proxy - openshift/origin-recycler - openshift/origin-gitserver - openshift/origin-cluster-capacity - openshift/origin-service-catalog - openshift/origin-template-service-broker - openshift/hello-openshift - openshift/openvswitch - openshift/node -) +images="${OS_ALL_IMAGES}" PUSH_OPTS="" if docker push --help | grep -q force; then diff --git a/hack/test-go.sh b/hack/test-go.sh index ebd51e7318db..8c58f112ca0b 100755 --- a/hack/test-go.sh +++ b/hack/test-go.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# This script runs Go language unit tests for the Origin repository. Arguments to this script +# This script runs Go language unit tests for the repository. Arguments to this script # are parsed as a list of packages to test until the first argument starting with '-' or '--' is # found. That argument and all following arguments are interpreted as flags to be passed directly # to `go test`. If no arguments are given, then "all" packages are tested. @@ -41,7 +41,6 @@ os::cleanup::tmpdir # Internalize environment variables we consume and default if they're not set dry_run="${DRY_RUN:-}" -test_kube="${TEST_KUBE:-}" test_timeout="${TIMEOUT:-120s}" detect_races="${DETECT_RACES:-true}" coverage_output_dir="${COVERAGE_OUTPUT_DIR:-}" @@ -85,28 +84,6 @@ if [[ -n "${test_timeout}" ]]; then gotest_flags+=" -timeout ${test_timeout}" fi -# list_test_packages_under lists all packages containing Golang test files that we want to run as unit tests -# under the given base dir in the OpenShift Origin tree -function list_test_packages_under() { - local basedir=$* - - # we do not quote ${basedir} to allow for multiple arguments to be passed in as well as to allow for - # arguments that use expansion, e.g. paths containing brace expansion or wildcards - find ${basedir} -not \( \ - \( \ - -path 'vendor' \ - -o -path '*_output' \ - -o -path '*.git' \ - -o -path '*openshift.local.*' \ - -o -path '*vendor/*' \ - -o -path '*assets/node_modules' \ - -o -path '*test/*' \ - -o -path '*cmd/cluster-capacity' \ - -o -path '*cmd/service-catalog' \ - -o -path '*pkg/proxy' \ - \) -prune \ - \) -name '*_test.go' | xargs -n1 dirname | sort -u | xargs -n1 printf "${OS_GO_PACKAGE}/%s\n" -} # Break up the positional arguments into packages that need to be tested and arguments that need to be passed to `go test` package_args= @@ -136,29 +113,7 @@ if [[ -n "${package_args}" ]]; then done else # If no packages are given to test, we need to generate a list of all packages with unit tests - openshift_test_packages="$(list_test_packages_under '*')" - test_packages="${openshift_test_packages}" - - kubernetes_path="vendor/k8s.io/kubernetes" - - if [[ -n "${test_kube}" ]]; then - # we need to find all of the kubernetes test suites, excluding those we directly whitelisted before, the end-to-end suite, and - # the go2idl tests which we currently do not support - # etcd3 isn't supported yet and that test flakes upstream - optional_kubernetes_packages="$(find -L vendor/k8s.io/{apimachinery,apiserver,client-go,kube-aggregator,kubernetes} -not \( \ - \( \ - -path "${kubernetes_path}/staging" \ - -o -path "${kubernetes_path}/test" \ - -o -path "${kubernetes_path}/cmd/libs/go2idl/client-gen/testoutput/testgroup/unversioned" \ - -o -path "${kubernetes_path}/pkg/storage/etcd3" \ - -o -path "${kubernetes_path}/third_party/golang/go/build" \ - \) -prune \ - \) -name '*_test.go' | cut -f 2- -d / | xargs -n1 dirname | sort -u | xargs -n1 printf "./vendor/%s\n")" - - test_packages="${test_packages} ${optional_kubernetes_packages}" - else - test_packages="${test_packages} ./vendor/k8s.io/kubernetes/pkg/api/... ./vendor/k8s.io/kubernetes/pkg/apis/..." - fi + test_packages="$(os::util::list_test_packages_under '*')" fi if [[ -n "${dry_run}" ]]; then diff --git a/hack/verify-govet.sh b/hack/verify-govet.sh index bf5904cb590b..c8cee8e9be51 100755 --- a/hack/verify-govet.sh +++ b/hack/verify-govet.sh @@ -10,17 +10,11 @@ trap "cleanup" EXIT os::golang::verify_go_version -govet_blacklist=( - "pkg/.*/client/clientset_generated/internalclientset/fake/clientset_generated.go:[0-9]+: literal copies lock value from fakePtr: github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/client/testing/core.Fake" - "pkg/.*/client/clientset_generated/release_v1_./fake/clientset_generated.go:[0-9]+: literal copies lock value from fakePtr: github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/client/testing/core.Fake" - "pkg/.*/clientset/internalclientset/fake/clientset_generated.go:[0-9]+: literal copies lock value from fakePtr: github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/client/testing/core.Fake" - "pkg/.*/clientset/release_v3_./fake/clientset_generated.go:[0-9]+: literal copies lock value from fakePtr: github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/client/testing/core.Fake" - "cmd/cluster-capacity/.*" -) +govet_blacklist=( "${OS_GOVET_BLACKLIST[@]-}" ) function govet_blacklist_contains() { local text=$1 - for blacklist_entry in "${govet_blacklist[@]}"; do + for blacklist_entry in "${govet_blacklist[@]-}"; do if grep -Eqx "${blacklist_entry}" <<<"${text}"; then # the text we got matches this blacklist entry return 0 diff --git a/origin.spec b/origin.spec index ed49440aa609..15045b2df948 100644 --- a/origin.spec +++ b/origin.spec @@ -34,6 +34,16 @@ %else %global do_build 1 %endif +%if 0%{?skip_prep} +%global do_prep 0 +%else +%global do_prep 1 +%endif +%if 0%{?skip_dist} +%global package_dist %{nil} +%else +%global package_dist %{dist} +%endif %if 0%{?fedora} || 0%{?epel} %global need_redistributable_set 0 @@ -55,11 +65,12 @@ %global product_name Origin %endif +%{!?version: %global version 0.0.1} +%{!?release: %global release 1} + Name: %{package_name} -# Version is not kept up to date and is intended to be set by tito custom -# builders provided in the .tito/lib directory of this project -Version: 0.0.1 -Release: 0%{?dist} +Version: %{version} +Release: %{release}%{package_dist} Summary: Open Source Container Management by Red Hat License: ASL 2.0 URL: https://%{import_path} @@ -234,13 +245,15 @@ of docker. Exclude those versions of docker. %{name}-docker-excluder unexclude - docker packages can be updated %prep +%if 0%{do_prep} %setup -q +%endif %build %if 0%{do_build} %if 0%{make_redistributable} # Create Binaries for all supported arches -%{os_git_vars} OS_BUILD_RELEASE_ARCHIVES=n hack/build-cross.sh +%{os_git_vars} OS_BUILD_RELEASE_ARCHIVES=n make build-cross %{os_git_vars} hack/build-go.sh vendor/github.com/onsi/ginkgo/ginkgo %{os_git_vars} unset GOPATH; cmd/service-catalog/go/src/github.com/kubernetes-incubator/service-catalog/hack/build-cross.sh %{os_git_vars} unset GOPATH; cmd/cluster-capacity/go/src/github.com/kubernetes-incubator/cluster-capacity/hack/build-cross.sh @@ -261,7 +274,7 @@ of docker. Exclude those versions of docker. %ifarch s390x BUILD_PLATFORM="linux/s390x" %endif -OS_ONLY_BUILD_PLATFORMS="${BUILD_PLATFORM}" %{os_git_vars} OS_BUILD_RELEASE_ARCHIVES=n hack/build-cross.sh +OS_ONLY_BUILD_PLATFORMS="${BUILD_PLATFORM}" %{os_git_vars} OS_BUILD_RELEASE_ARCHIVES=n make build-cross OS_ONLY_BUILD_PLATFORMS="${BUILD_PLATFORM}" %{os_git_vars} hack/build-go.sh vendor/github.com/onsi/ginkgo/ginkgo OS_ONLY_BUILD_PLATFORMS="${BUILD_PLATFORM}" %{os_git_vars} unset GOPATH; cmd/service-catalog/go/src/github.com/kubernetes-incubator/service-catalog/hack/build-cross.sh OS_ONLY_BUILD_PLATFORMS="${BUILD_PLATFORM}" %{os_git_vars} unset GOPATH; cmd/cluster-capacity/go/src/github.com/kubernetes-incubator/cluster-capacity/hack/build-cross.sh