mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Address couple of issue on image build for ARM arch
- `GOARM` should not be hardcoded - `GOARM` needn't be set when the `ARCH` is not `arm` - make it also possible to build binary within `agnhost` dir as well - fix image build failure when the user is root Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
parent
5f83eb721b
commit
c60181317e
@ -53,7 +53,7 @@ MANIFEST_IMAGE := $(PUSH_REGISTRY)/etcd
|
||||
export DOCKER_CLI_EXPERIMENTAL := enabled
|
||||
# golang version should match the golang version from https://github.com/coreos/etcd/releases for the current ETCD_VERSION.
|
||||
GOLANG_VERSION?=1.10.4
|
||||
GOARM=7
|
||||
GOARM?=7
|
||||
TEMP_DIR:=$(shell mktemp -d)
|
||||
|
||||
ifeq ($(ARCH),amd64)
|
||||
@ -97,13 +97,18 @@ else
|
||||
|
||||
# Download etcd in a golang container and cross-compile it statically
|
||||
# For each release create a tmp dir 'etcd_release_tmp_dir' and unpack the release tar there.
|
||||
arch_prefix=""
|
||||
ifeq ($(ARCH),arm)
|
||||
arch_prefix="GOARM=$(GOARM)"
|
||||
endif
|
||||
|
||||
for version in $(BUNDLED_ETCD_VERSIONS); do \
|
||||
etcd_release_tmp_dir=$(shell mktemp -d); \
|
||||
docker run --interactive -v $${etcd_release_tmp_dir}:/etcdbin golang:$(GOLANG_VERSION) /bin/bash -c \
|
||||
"git clone https://github.com/coreos/etcd /go/src/github.com/coreos/etcd \
|
||||
&& cd /go/src/github.com/coreos/etcd \
|
||||
&& git checkout v$${version} \
|
||||
&& GOARM=$(GOARM) GOARCH=$(ARCH) ./build \
|
||||
&& $(arch_prefix) GOARCH=$(ARCH) ./build \
|
||||
&& cp -f bin/$(ARCH)/etcd* bin/etcd* /etcdbin; echo 'done'"; \
|
||||
cp $$etcd_release_tmp_dir/etcd $$etcd_release_tmp_dir/etcdctl $(TEMP_DIR)/; \
|
||||
cp $(TEMP_DIR)/etcd $(TEMP_DIR)/etcd-$$version; \
|
||||
|
@ -15,7 +15,7 @@
|
||||
include ../../hack/make-rules/Makefile.manifest
|
||||
|
||||
REGISTRY ?= gcr.io/kubernetes-e2e-test-images
|
||||
GOARM=7
|
||||
GOARM ?= 7
|
||||
QEMUVERSION=v2.9.1
|
||||
GOLANG_VERSION=1.12.6
|
||||
export
|
||||
|
@ -88,7 +88,7 @@ build() {
|
||||
if [[ $(id -u) != 0 ]]; then
|
||||
sudo=sudo
|
||||
fi
|
||||
"${sudo}" "${KUBE_ROOT}/third_party/multiarch/qemu-user-static/register/register.sh" --reset
|
||||
${sudo} "${KUBE_ROOT}/third_party/multiarch/qemu-user-static/register/register.sh" --reset
|
||||
curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/"${QEMUVERSION}"/x86_64_qemu-"${QEMUARCHS[$arch]}"-static.tar.gz | tar -xz -C "${temp_dir}"
|
||||
# Ensure we don't get surprised by umask settings
|
||||
chmod 0755 "${temp_dir}/qemu-${QEMUARCHS[$arch]}-static"
|
||||
@ -140,13 +140,17 @@ push() {
|
||||
|
||||
# This function is for building the go code
|
||||
bin() {
|
||||
local arch_prefix=""
|
||||
if [[ "${ARCH}" == "arm" ]]; then
|
||||
arch_prefix="GOARM=${GOARM:-7}"
|
||||
fi
|
||||
for SRC in $@;
|
||||
do
|
||||
docker run --rm -it -v "${TARGET}:${TARGET}:Z" -v "${KUBE_ROOT}":/go/src/k8s.io/kubernetes:Z \
|
||||
golang:"${GOLANG_VERSION}" \
|
||||
/bin/bash -c "\
|
||||
cd /go/src/k8s.io/kubernetes/test/images/${SRC_DIR} && \
|
||||
CGO_ENABLED=0 GOARM=${GOARM} GOARCH=${ARCH} go build -a -installsuffix cgo --ldflags '-w' -o ${TARGET}/${SRC} ./$(dirname "${SRC}")"
|
||||
CGO_ENABLED=0 ${arch_prefix} GOARCH=${ARCH} go build -a -installsuffix cgo --ldflags '-w' -o ${TARGET}/${SRC} ./$(dirname "${SRC}")"
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
SRCS=regression-issue-74839
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOARM = 7
|
||||
GOARM ?= 7
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user