Skip to content

Commit

Permalink
build: remove obsolete cross build container
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
travisn committed Apr 7, 2022
1 parent 4e8536a commit 738a300
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 538 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/shellcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ jobs:
severity: warning
check_together: 'yes'
disable_matcher: false
additional_files: build/run build/reset build/sed-in-place
additional_files: build/reset build/sed-in-place
ignore: olm
format: gcc
73 changes: 1 addition & 72 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ The following tools are need on the host:
* git
* make
* golang
* rsync (if you're using the build container on mac)
* helm

## Build
Expand All @@ -27,15 +26,7 @@ You can build the Rook binaries and all container images for the host platform b
command below. Building in parallel with the `-j` option is recommended.

```console
make -j4
```

Developers may often wish to make only images for a particular backend in their testing. This can
be done by specifying the `IMAGES` environment variable with `make` as exemplified below. Possible
values for are as defined by sub-directory names in the `/rook/images/` dir. Multiple images can be separated by a space.

```console
make -j4 IMAGES='ceph' build
make -j4 build
```

Run `make help` for more options.
Expand All @@ -56,65 +47,3 @@ You can also run the build for all supported platforms:
```console
make -j4 build.all
```

Or from the cross container:

```console
build/run make -j4 build.all
```

Currently, only `amd64` platform supports this kind of 'cross' build. In order to make `build.all`
succeed, we need to follow the steps specified by the below section `Building for other platforms`
first.

We suggest to use native `build` to create the binaries and container images on `arm{32,64}`
platform, but if you do want to build those `arm{32,64}` binaries and images on `amd64` platform
with `build.all` command, please make sure the multi-arch feature is supported. To test run the
following:

```console
> docker run --rm -ti arm32v7/ubuntu uname -a
Linux bad621a75757 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 armv7l armv7l armv7l GNU/Linux

> docker run --rm -ti arm64v8/ubuntu uname -a
Linux f51ea93e76a2 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 aarch64 aarch64 aarch64 GNU/Linux
```

In order to build container images for these platforms we rely on cross-compilers and QEMU. Cross compiling is much faster than QEMU and so we lean heavily on it.

In order for QEMU to work inside docker containers you need to do a few things on
the linux host. If you are using a recent Docker for Mac build you can skip this section, since they added support for binfmt and multi-arch docker builds.

On an Ubuntu machine with a 4.8+ kernel you need to run install the following:

```console
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
binfmt-support
qemu-user-static
```

You also need to run the following on every boot:

```console
docker run --rm --privileged hypriot/qemu-register
```

you can install a systemd unit to help with this if you'd like, for example:

```console
cat <<EOF > /etc/systemd/system/update-binfmt.service
[Unit]
After=docker.service

[Service]
Type=oneshot
ExecStartPre=/usr/bin/docker pull hypriot/qemu-register
ExecStart=/usr/bin/docker run --rm --privileged hypriot/qemu-register
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

systemctl enable update-binfmt.service
```
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ build: csv-clean build.common ## Only build for linux platform
@$(MAKE) go.build PLATFORM=linux_$(GOHOSTARCH)
@$(MAKE) -C images PLATFORM=linux_$(GOHOSTARCH)

build.all: build.common ## Build source code for all platforms. Best done in the cross build container due to cross compiler dependencies.
build.all: build.common ## Build source code for all platforms.
ifneq ($(GOHOSTARCH),amd64)
$(error cross platform image build only supported on amd64 host currently)
endif
Expand Down Expand Up @@ -195,7 +195,7 @@ gen-rbac: $(HELM) $(YQ) ## generate RBAC from Helm charts
@# output only stdout to the file; stderr for debugging should keep going to stderr
HELM=$(HELM) ./build/rbac/gen-common.sh

.PHONY: all build.common cross.build.parallel
.PHONY: all build.common
.PHONY: build build.all install test check vet fmt codegen mod.check clean distclean prune

# ====================================================================================
Expand Down
1 change: 1 addition & 0 deletions PendingReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Prometheus rules are installed by the Helm chart. If you were relying on the cephcluster setting
`monitoring.enabled` to create the prometheus rules, they now need to be enabled by setting
`monitoring.createPrometheusRules` in the Helm chart values.
* Remove the obsolete cross build container, now unused by the CI

## Features

Expand Down
75 changes: 0 additions & 75 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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
Expand All @@ -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 changes: 0 additions & 26 deletions build/makelib/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,39 +40,13 @@ 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
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)
Expand Down
12 changes: 0 additions & 12 deletions build/reset
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit 738a300

Please sign in to comment.