From 32960345f74676c2c35b76206baf042251dbeceb Mon Sep 17 00:00:00 2001 From: Huamin Chen Date: Tue, 14 Mar 2023 14:48:31 -0400 Subject: [PATCH] rpm: use containerized rpm build (#582) --- .github/workflows/release.yml | 4 ++-- Makefile | 10 ++++++++++ build/Dockerfile.builder | 2 +- packaging/rpm/kepler.spec | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bcad91e606..4f06fd00a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -87,10 +87,10 @@ jobs: _VERSION_ : ${{ github.event.inputs.rpm_version }} _RELEASE_: ${{ github.event.inputs.rpm_release }} _COMMITTER_: ${{ github.event.inputs.committer }} - _TIMESTAMP_: ${{ steps.date.outputs.date }} _CHANGELOG_: ${{ github.event.inputs.changelog }} _ARCH_: ${{ github.event.inputs.arch }} - run: make build_rpm + run: | + make build_rpm - if: startsWith(github.event.ref, 'refs/tags/') name: Release diff --git a/Makefile b/Makefile index 75722ad6a2..44c7e780d6 100644 --- a/Makefile +++ b/Makefile @@ -146,6 +146,16 @@ container_build: tidy-vendor format build_rpm: rpmbuild packaging/rpm/kepler.spec --build-in-place -bb +containerized_build_rpm: + @mkdir -p "/root/rpmbuild" + $(CTR_CMD) run --rm \ + -v $(base_dir):/kepler:Z -w /kepler -v /root/rpmbuild:/root/rpmbuild \ + -e _VERSION_=${_VERSION_} -e _RELEASE_=${_RELEASE_} -e _ARCH_=${_ARCH_} \ + -e _TIMESTAMP_="$(shell date)" -e _COMMITTER_=${_COMMITTER_} -e _CHANGELOG_=${_CHANGELOG_} \ + -e GOROOT=/usr/local/go -e PATH=$(PATH):/usr/local/go/bin \ + $(BUILDER_IMAGE) \ + make build_rpm + clean_build_local: rm -rf $(CROSS_BUILD_BINDIR) diff --git a/build/Dockerfile.builder b/build/Dockerfile.builder index 697e9d4eaa..4abde5e264 100644 --- a/build/Dockerfile.builder +++ b/build/Dockerfile.builder @@ -4,7 +4,7 @@ FROM quay.io/sustainable_computing_io/kepler_base:ubi-8.6-bcc-0.24 as builder LABEL name=kepler-builder -RUN yum install -y kernel-devel make git gcc && \ +RUN yum install -y kernel-devel make git gcc rpm-build systemd && \ yum clean all -y RUN curl -LO https://go.dev/dl/go1.18.1.linux-amd64.tar.gz; mkdir -p /usr/local; tar -C /usr/local -xvzf go1.18.1.linux-amd64.tar.gz; rm -f go1.18.1.linux-amd64.tar.gz diff --git a/packaging/rpm/kepler.spec b/packaging/rpm/kepler.spec index 348923af9b..4d47a358c2 100644 --- a/packaging/rpm/kepler.spec +++ b/packaging/rpm/kepler.spec @@ -33,7 +33,7 @@ CROSS_BUILD_BINDIR=_output/bin GOARCH=amd64 %endif -make container_build GOOS=${GOOS} GOARCH=${GOARCH} +make _build_local GOOS=${GOOS} GOARCH=${GOARCH} cp ./${CROSS_BUILD_BINDIR}/${GOOS}_${GOARCH}/kepler ./_output/kepler