build: remove obsolete cross build container

The cross build container is not used anymore since the conversion
to github actions. Now the obsolete scripts and makefiles are
cleaned up to remove some confusing leftovers from the
cross container.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit 738a300827)
This commit is contained in:
Travis Nielsen authored and mergify-bot committed 2022-04-07 20:43:06 +00:00
1 parent 585f295655
commit 2f07c19aa8
13 files changed
+5 -538

No files matched your search

-75
View File
@@ -14,11 +14,8 @@ set -u
# See the License for the specific language governing permissions and
# limitations under the License.
BUILD_HOST=$(hostname)
BUILD_REPO=github.com/rook/rook
BUILD_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd -P)
SHA256CMD=${SHA256CMD:-shasum -a 256}
BUILD_REGISTRY=build-$(echo "${BUILD_HOST}"-"${BUILD_ROOT}" | ${SHA256CMD} | cut -c1-8)
DOCKERCMD=${DOCKERCMD:-docker}
@@ -28,10 +25,6 @@ export OUTPUT_DIR=${BUILD_ROOT}/_output
export WORK_DIR=${BUILD_ROOT}/.work
export CACHE_DIR=${BUILD_ROOT}/.cache
CROSS_IMAGE=${BUILD_REGISTRY}/cross-amd64
CROSS_IMAGE_VOLUME=cross-volume
CROSS_RSYNC_PORT=10873
function ver() {
local full_ver maj min bug build
full_ver="$1" # functions should name input params for easier understanding
@@ -54,71 +47,3 @@ function check_git() {
echo WARN: submodule paths. Please consider upgrading to 2.8.3 or later
fi
}
function start_rsync_container() {
${DOCKERCMD} run \
-d \
-e OWNER=root \
-e GROUP=root \
-e MKDIRS="/volume/go/src/${BUILD_REPO}" \
-p ${CROSS_RSYNC_PORT}:873 \
-v ${CROSS_IMAGE_VOLUME}:/volume \
--entrypoint "/tini" \
"${CROSS_IMAGE}" \
-- /build/rsyncd.sh
}
function wait_for_rsync() {
# wait for rsync to come up
local tries=100
while (( tries > 0 )); do
if rsync "rsync://localhost:${CROSS_RSYNC_PORT}/" &> /dev/null ; then
return 0
fi
(( tries-- ))
sleep 0.1
done
echo ERROR: rsyncd did not come up >&2
exit 1
}
function stop_rsync_container() {
local id=$1
${DOCKERCMD} stop "${id}" &> /dev/null || true
${DOCKERCMD} rm "${id}" &> /dev/null || true
}
function run_rsync() {
local src=$1
shift
local dst=$1
shift
# run the container as an rsyncd daemon so that we can copy the
# source tree to the container volume.
local id
id=$(start_rsync_container)
# wait for rsync to come up
wait_for_rsync || { stop_rsync_container "${id}"; return 1; }
# NOTE: add --progress to show files being syncd
rsync \
--archive \
--delete \
--prune-empty-dirs \
"$@" \
"$src" "$dst" || { stop_rsync_container "${id}"; return 1; }
stop_rsync_container "${id}"
}
function rsync_host_to_container() {
run_rsync "${scriptdir}"/.. rsync://localhost:${CROSS_RSYNC_PORT}/volume/go/src/${BUILD_REPO} "$@"
}
function rsync_container_to_host() {
run_rsync rsync://localhost:${CROSS_RSYNC_PORT}/volume/go/src/${BUILD_REPO}/ "${scriptdir}"/.. "$@"
}
-26
View File
@@ -40,18 +40,6 @@ endif
ALL_PLATFORMS ?= darwin_amd64 windows_amd64 linux_amd64 linux_arm64
ifeq ($(PLATFORM),linux_amd64)
CROSS_TRIPLE = x86_64-linux-gnu
endif
ifeq ($(PLATFORM),linux_arm64)
CROSS_TRIPLE = aarch64-linux-gnu
endif
ifeq ($(PLATFORM),darwin_amd64)
CROSS_TRIPLE=x86_64-apple-darwin15
endif
ifeq ($(PLATFORM),windows_amd64)
CROSS_TRIPLE=x86_64-w64-mingw32
endif
export GOARM
# force the build of a linux binary when running on MacOS
@@ -59,20 +47,6 @@ GOHOSTOS=linux
GOHOSTARCH := $(shell go env GOHOSTARCH)
HOST_PLATFORM := $(GOHOSTOS)_$(GOHOSTARCH)
ifneq ($(PLATFORM),$(HOST_PLATFORM))
ifeq (,$(shell go env CC))
CC := $(CROSS_TRIPLE)-gcc
else
CC := $(shell go env CC)
endif
ifeq (,$(shell go env CXX))
CXX := $(CROSS_TRIPLE)-gcc
else
CXX := $(shell go env CXX)
endif
export CC CXX
endif
# REAL_HOST_PLATFORM is used to determine the correct url to download the various binary tools from and it does not use
# HOST_PLATFORM which is used to build the program.
REAL_HOST_PLATFORM=$(shell go env GOHOSTOS)_$(GOHOSTARCH)
-12
View File
@@ -16,15 +16,3 @@
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${scriptdir}/common.sh"
# this should only clean up leaked containers during rsync
for c in $(docker ps -a -q --filter=ancestor=${CROSS_IMAGE}); do
echo removing container ${c}
docker stop ${c}
docker rm ${c}
done
if [[ $(docker volume ls | grep ${CROSS_IMAGE_VOLUME}) ]]; then
echo removing volume ${CROSS_IMAGE_VOLUME}
docker volume rm ${CROSS_IMAGE_VOLUME}
fi
-165
View File
@@ -1,165 +0,0 @@
#!/bin/bash -e
set -e
set -x
# Copyright 2016 The Rook Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${scriptdir}/common.sh"
check_git
# build the the container if we've not done so already
if [ "`uname -m`" != "x86_64" ]; then
echo ERROR: we only support the cross container build on amd64 host.
exit 1
fi
echo ==== building the cross container \(this could take minutes the first time\)
make_cmd="make --no-print-directory -C ${scriptdir}/../images cross PULL=0 DOCKERCMD=${DOCKERCMD}"
make_output=$($make_cmd 2>&1) || {
cat <<EOF >&2
=== cross build image failed for ${CROSS_IMAGE}
${make_output}
EOF
exit 1
}
# run the container with the same uid and gid of the user to avoid
# permissions issues when sharing volumes with the host
USER_ARGS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g )"
BUILDER_HOME=/home/rook
KUBE_ARGS=""
# setup kubectl from the host if available
if [ -d ${HOME}/.kube ]; then
KUBE_ARGS="-v ${HOME}/.kube:${BUILDER_HOME}/.kube"
fi
if [ "`uname -s`" != "Linux" ]; then
# On non-linux hosts, its is EXTREMELY slow to mount the source
# tree inside the container. As such we use rsync to copy the source
# tree to a new docker volumer on each run. The first rsync take a
# little bit of time, but subsequent ones go by fast. This approach
# is MUCH faster than using osxfs, NFS or other approaches.
# create a new volume to hold our go workspace. NOTE: while concurrent
# runs of the build container are supported they will share the same volume
# and we will be rsyncing to it at different times. This could lead to
# undefined behavior but this should be a rare case on non-linux envs.
if [[ ! $(${DOCKERCMD} volume ls | grep ${CROSS_IMAGE_VOLUME}) ]]; then
echo ==== Creating docker volume "${CROSS_IMAGE_VOLUME}" and syncing sources
echo ==== for first time. This could take a few seconds.
${DOCKERCMD} volume create --name ${CROSS_IMAGE_VOLUME} &> /dev/null
fi
# On non-linux the layout is as follows:
#
# /var/run/docker.sock (bind mounted to host /var/run/docker.sock)
# /${BUILDER_HOME} (bind mounted to an independent docker volume)
# /.netrc (bind mounted to host ${HOME}/.netrc)
# /.aws (bind mounted to host ${HOME}/.aws)
# /.docker (bind mounted to host ${HOME}/.docker)
# /.cache (bind mounted to host ${CACHE_DIR} if set)
# /go/src/github.com/rook/rook (rsync'd from host <source>)
# now copy the source tree to the container volume. Note this also
# copies the .git directory but not the index.lock files which
# change frequently and sometimes cause rsync to fail.
rsync_host_to_container \
--filter="- /.work/" \
--filter="- /.cache/" \
--filter="- /.vscode/" \
--filter="- index.lock"
MOUNT_OPTS="-v ${CROSS_IMAGE_VOLUME}:${BUILDER_HOME}"
else
# On linux bind mounts are cheap so we dont need to rsync
# the layout is as follows:
#
# /var/run/docker.sock (bind mounted to host /var/run/docker.sock)
# /${BUILDER_HOME}
# /.netrc (bind mounted to host ${HOME}/.netrc)
# /.aws (bind mounted to host ${HOME}/.aws)
# /.docker (bind mounted to host ${HOME}/.docker)
# /go
# /pkg (bind mounted to <source>/.work/cross_pkg)
# /src/github.com/rook/rook (bind mounted to <source>)
MOUNT_OPTS="\
-v ${scriptdir}/../.work/cross_pkg:${BUILDER_HOME}/go/pkg
-v ${scriptdir}/..:${BUILDER_HOME}/go/src/${BUILD_REPO}"
fi
# if CACHE_DIR is not set bind mount it
if [[ -n "${CACHE_DIR}" ]]; then
mkdir -p ${CACHE_DIR}
DOWNLOAD_ARGS="-e CACHE_DIR=${BUILDER_HOME}/go/src/${BUILD_REPO}/.cache \
-v ${CACHE_DIR}:${BUILDER_HOME}/go/src/${BUILD_REPO}/.cache"
fi
tty -s && TTY_ARGS=-ti || TTY_ARGS=
DISABLE_NESTED_DOCKER=""
DOCKER_NESTED_ARGS=""
# BUGBUG: new docker clients switch to using OSX keychain. how do we copy creds?
# sometimes we run docker inside docker. bind the docker config and socket
if [ -z "${DISABLE_NESTED_DOCKER}" ]; then
DOCKER_NESTED_ARGS="\
-v ${HOME}/.docker:${BUILDER_HOME}/.docker \
-v /var/run/docker.sock:/var/run/docker.sock"
fi
# set AWS creds
AWS_ARGS="\
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_DEFAULT_REGION \
-v ${HOME}/.aws:${BUILDER_HOME}/.aws"
rsync_back() {
if [ "`uname -s`" != "Linux" ]; then
# rsync generated files back to the host. IMPORTANT: we never rsync the .git directory back
# since the host's version might have changed.
rsync_container_to_host \
--filter="+ /_output/" \
--filter="- /*"
fi
}
${DOCKERCMD} run \
--rm \
-h ${BUILD_HOST} \
-e BUILD_REGISTRY=${BUILD_REGISTRY} \
-e GOPATH="${BUILDER_HOME}/go" \
-e GO_PKG_DIR="" \
-e GITHUB_TOKEN \
-e VERSION \
-e CHANNEL \
-v ${PWD}/_output:${BUILDER_HOME}/go/bin \
${TTY_ARGS} \
${KUBE_ARGS} \
${DOWNLOAD_ARGS} \
${AWS_ARGS} \
${USER_ARGS} \
${DOCKER_NESTED_ARGS} \
${MOUNT_OPTS} \
-w ${BUILDER_HOME}/go/src/${BUILD_REPO} \
${CROSS_IMAGE} \
"$@" || { rsync_back; exit 1; }
rsync_back