Skip to content

Commit

Permalink
Merge pull request #786 from klihub/build/cross-tarball
Browse files Browse the repository at this point in the history
build: add target for cross-building binary tarballs using a CentOS-7 container.
  • Loading branch information
klihub authored Mar 15, 2022
2 parents d4e516e + 9892874 commit 538e52d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ DOCKER_RPM_BUILD := \
done && \
cp -v $$(rpm --eval %{_rpmdir}/%{_arch})/*.rpm /output

# Docker boilerplate/commands to build binary tarballs.
DOCKER_TAR_BUILD := \
cd ~ && \
$(GZIP_DC) /build/input/cri-resource-manager-$(TAR_VERSION).tar$(GZ_EXT) | \
$(TAR) -xf - && \
cd cri-resource-manager-$(TAR_VERSION) && \
$(MAKE) OUTPUT=/output/ binary-dist

# Docker boilerplate/commands to build binaries.
DOCKER_BIN_BUILD := \
mkdir ~/build && cd ~/build && \
Expand Down Expand Up @@ -498,7 +506,7 @@ vendored-dist: dist
rm -fr $$tardir

binary-dist: build
$(Q)tarball=cri-resource-manager-$(TAR_VERSION).$$(uname -m).tar; \
$(Q)tarball=$(OUTPUT)cri-resource-manager-$(TAR_VERSION).$$(uname -m).tar; \
echo "Creating binary dist tarball $$tarball..."; \
tardir=binary-dist; \
rm -fr $$tarball* $$tardir && \
Expand Down Expand Up @@ -600,6 +608,20 @@ cross-bin.%: docker/cross-build/% dist
$$distro-build /bin/bash -c '$(DOCKER_BIN_BUILD)' && \
rm -fr $$builddir

cross-tar cross-tarball: dist docker/cross-build/centos-7
$(Q)distro=tarball; \
builddir=$(BUILD_DIR)/docker/$$distro; \
outdir=$(PACKAGES_DIR)/$$distro; \
echo "Docker cross-building $$distro packages..."; \
mkdir -p $$outdir && \
rm -fr $$builddir && mkdir -p $$builddir/{input,build} && \
cp cri-resource-manager-$(TAR_VERSION).tar$(GZEXT) $$builddir/input && \
$(DOCKER) run --rm -ti $(DOCKER_OPTIONS) --user $(shell echo $$USER) \
--env USER_NAME="$(USER_NAME)" --env USER_EMAIL=$(USER_EMAIL) \
-v $$(pwd)/$$builddir:/build \
-v $$(pwd)/$$outdir:/output \
centos-7-build /bin/bash -c '$(DOCKER_TAR_BUILD)' && \
rm -fr $$builddir

# Build a docker image (for distro cross-building).
docker/cross-build/%: dockerfiles/cross-build/Dockerfile.%
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/cross-build/Dockerfile.centos-7
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ARG CREATE_USER="build"
ARG USER_OPTIONS=""
ENV PATH /go/bin:/usr/local/go/bin:$PATH

RUN yum install -y rpm-build \
RUN yum install -y --nogpgcheck rpm-build \
kernel-devel clang gcc \
curl-devel zlib-devel openssl-devel expat-devel \
make wget
Expand Down

0 comments on commit 538e52d

Please sign in to comment.