From 2d2796cbe5a28120aa83cd52d7632fccd8f24fa7 Mon Sep 17 00:00:00 2001 From: Patryk Matuszak Date: Fri, 12 Dec 2025 18:58:12 +0100 Subject: [PATCH 1/2] RPMs build improvements --- .github/actions/build-deb/action.yaml | 4 +--- .github/actions/build/action.yaml | 4 +--- CLAUDE.md | 2 +- Makefile | 27 +++++++++++---------------- packaging/rpm.Containerfile | 7 +++++-- packaging/srpm.Containerfile | 8 +++----- src/image/postbuild.sh | 11 ----------- 7 files changed, 22 insertions(+), 41 deletions(-) delete mode 100644 src/image/postbuild.sh diff --git a/.github/actions/build-deb/action.yaml b/.github/actions/build-deb/action.yaml index d2b1f217..51a00038 100644 --- a/.github/actions/build-deb/action.yaml +++ b/.github/actions/build-deb/action.yaml @@ -39,11 +39,9 @@ runs: # Run the RPM build process. cd ${GITHUB_WORKSPACE}/ - make srpm \ + make rpm \ USHIFT_GITREF=${{ inputs.ushift-gitref }} \ OKD_VERSION_TAG=${{ inputs.okd-version-tag }} - - make rpm \ RPM_OUTDIR=/mnt/rpms - name: Convert the MicroShift RPMs to Debian packages diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index 4d8e9055..a7878968 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -50,11 +50,9 @@ runs: # Run the RPM build process. cd ${GITHUB_WORKSPACE}/ - make srpm \ + make rpm \ USHIFT_GITREF="${{ inputs.ushift-gitref }}" \ OKD_VERSION_TAG="${{ inputs.okd-version-tag }}" - - make rpm \ RPM_OUTDIR=/mnt/rpms - name: Build MicroShift bootc container image diff --git a/CLAUDE.md b/CLAUDE.md index 07afdf0e..2570c1fe 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -115,7 +115,7 @@ make check # Run linters (hadolint + shellcheck) - `packaging/`: Containerfiles for SRPM, RPM, and bootc builds - `src/`: Build scripts and component customizations - - `src/image/`: Image build scripts (prebuild.sh replaces OKD images, postbuild.sh configures) + - `src/image/`: Image build scripts (prebuild.sh replaces OKD images) - `src/okd/`: OKD version detection and ARM builds - `src/kindnet/`: Kindnet CNI assets and spec - `src/topolvm/`: TopoLVM CSI assets and spec diff --git a/Makefile b/Makefile index f3f10140..5f0de145 100644 --- a/Makefile +++ b/Makefile @@ -71,40 +71,35 @@ all: @echo "" .PHONY: rpm -rpm: - @if ! sudo podman image exists "${SRPM_IMAGE}" ; then \ - echo "ERROR: Run 'make srpm' to build the MicroShift SRPMs" ; \ - exit 1 ; \ - fi - +rpm: srpm @echo "Building the MicroShift RPMs image" sudo podman build \ -t "${RPM_IMAGE}" \ --ulimit nofile=524288:524288 \ -f packaging/rpm.Containerfile . - @echo "Extracting the MicroShift RPMs" - outdir="$${RPM_OUTDIR:-$$(mktemp -d /tmp/microshift-rpms-XXXXXX)}" && \ + @outdir="$${RPM_OUTDIR:-$$(mktemp -d /tmp/microshift-rpms-XXXXXX)}" && \ mntdir="$$(sudo podman image mount "${RPM_IMAGE}")" && \ sudo cp -r "$${mntdir}/home/microshift/microshift/_output/rpmbuild/RPMS/." "$${outdir}" && \ - sudo podman image umount "${RPM_IMAGE}" && \ - echo "" && \ - echo "Build completed successfully" && \ - echo "RPMs are available in '$${outdir}'" + sudo podman image umount "${RPM_IMAGE}" >/dev/null && \ + echo -e "\nBuild completed successfully\nRPMs are available in '$${outdir}'" .PHONY: srpm srpm: @echo "Building the MicroShift SRPM image" - outdir="$${SRPM_WORKDIR:-$$(mktemp -d /tmp/microshift-srpms-XXXXXX)}" && \ sudo podman build \ -t "${SRPM_IMAGE}" \ --build-arg USHIFT_GITREF="${USHIFT_GITREF}" \ --build-arg OKD_VERSION_TAG="${OKD_VERSION_TAG}" \ --build-arg OKD_RELEASE_IMAGE_X86_64="${OKD_RELEASE_IMAGE_X86_64}" \ --build-arg OKD_RELEASE_IMAGE_AARCH64="${OKD_RELEASE_IMAGE_AARCH64}" \ - --volume "$${outdir}:/output:Z" \ - -f packaging/srpm.Containerfile . && \ - echo "SRPMs are available in '$${outdir}'" + -f packaging/srpm.Containerfile . + + @outdir="$${SRPM_WORKDIR:-$$(mktemp -d /tmp/microshift-srpms-XXXXXX)}" && \ + mntdir="$$(sudo podman image mount "${SRPM_IMAGE}")" && \ + sudo cp -r "$${mntdir}/home/microshift/microshift/_output/rpmbuild/SRPMS/." "$${outdir}" && \ + sudo podman image umount "${SRPM_IMAGE}" >/dev/null && \ + echo -e "\nBuild completed successfully\nSRPM is available in '$${outdir}'" .PHONY: rpm-to-deb rpm-to-deb: diff --git a/packaging/rpm.Containerfile b/packaging/rpm.Containerfile index 85e8fd96..4475b1df 100644 --- a/packaging/rpm.Containerfile +++ b/packaging/rpm.Containerfile @@ -25,7 +25,10 @@ RUN \ rpmbuild --quiet --define 'microshift_variant community' --rebuild ./microshift-*.src.rpm && \ \ echo "# Finally, move the RPMs" && \ - mkdir -p ${BUILDER_RPM_REPO_PATH} && \ + mkdir -p ${BUILDER_RPM_REPO_PATH}/ && \ mv /root/rpmbuild/RPMS ${BUILDER_RPM_REPO_PATH}/ && \ + mkdir -p ${BUILDER_RPM_REPO_PATH}/RPMS/srpms/ && \ + mv ./microshift-*.src.rpm ${BUILDER_RPM_REPO_PATH}/RPMS/srpms/ && \ + mv ./version.txt ${BUILDER_RPM_REPO_PATH}/RPMS/ && \ createrepo -v ${BUILDER_RPM_REPO_PATH}/RPMS && \ - rm -rf /root/rpmbuild /tmp/* + rm -rf /root/rpmbuild /tmp/* /root/.cache/go-build diff --git a/packaging/srpm.Containerfile b/packaging/srpm.Containerfile index 42b5b158..88861d41 100644 --- a/packaging/srpm.Containerfile +++ b/packaging/srpm.Containerfile @@ -32,9 +32,8 @@ RUN [ "$(uname -m)" = "aarch64" ] && ARCH="-arm64" || ARCH="" ; \ OKD_CLIENT_URL="https://github.com/okd-project/okd/releases/download/${OKD_VERSION_TAG}/openshift-client-linux${ARCH}-${OKD_VERSION_TAG}.tar.gz" && \ echo "OKD_CLIENT_URL: ${OKD_CLIENT_URL}" && \ curl -L --retry 5 -o /tmp/okd-client.tar.gz "${OKD_CLIENT_URL}" && \ - tar -xzf /tmp/okd-client.tar.gz -C /tmp && \ - mv /tmp/oc /usr/local/bin/oc && \ - rm -rf /tmp/okd-client.tar.gz ; + tar -xzf /tmp/okd-client.tar.gz -C /usr/local/bin/ && \ + rm -rf /tmp/okd-client.tar.gz WORKDIR ${HOME} @@ -68,5 +67,4 @@ RUN sed -i -e 's,CHECK_RPMS="y",,g' -e 's,CHECK_SRPMS="y",,g' ./packaging/rpm/ma "${USHIFT_MODIFY_SPEC_SCRIPT}" ./packaging/rpm/microshift.spec "${SPEC_KINDNET}" "${SPEC_TOPOLVM}" COPY --chmod=755 ./src/image/build-rpms.sh ${USHIFT_BUILDRPMS_SCRIPT} -RUN "${USHIFT_BUILDRPMS_SCRIPT}" srpm && \ - cp ./_output/rpmbuild/SRPMS/* /output/ +RUN "${USHIFT_BUILDRPMS_SCRIPT}" srpm diff --git a/src/image/postbuild.sh b/src/image/postbuild.sh deleted file mode 100644 index 64940a7d..00000000 --- a/src/image/postbuild.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -euo pipefail -set -x - -# Variables -BUILDER_RPM_REPO_PATH="$1" - -# Create a local RPM repository and add SRPMs on top of it -mkdir -p "${BUILDER_RPM_REPO_PATH}/srpms" -createrepo -v "${BUILDER_RPM_REPO_PATH}" -cp -r "${BUILDER_RPM_REPO_PATH}/../SRPMS/." "${BUILDER_RPM_REPO_PATH}/srpms/" From 3134b573298ff1bcb8c8959941a03101069b8394 Mon Sep 17 00:00:00 2001 From: Gregory Giguashvili Date: Sat, 13 Dec 2025 12:52:13 +0200 Subject: [PATCH 2/2] Fix AI comments --- .github/actions/build-deb/action.yaml | 2 +- .github/actions/build/action.yaml | 2 +- Makefile | 4 ++-- packaging/rpm.Containerfile | 8 ++++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/actions/build-deb/action.yaml b/.github/actions/build-deb/action.yaml index 51a00038..d9a8e495 100644 --- a/.github/actions/build-deb/action.yaml +++ b/.github/actions/build-deb/action.yaml @@ -41,7 +41,7 @@ runs: cd ${GITHUB_WORKSPACE}/ make rpm \ USHIFT_GITREF=${{ inputs.ushift-gitref }} \ - OKD_VERSION_TAG=${{ inputs.okd-version-tag }} + OKD_VERSION_TAG=${{ inputs.okd-version-tag }} \ RPM_OUTDIR=/mnt/rpms - name: Convert the MicroShift RPMs to Debian packages diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index a7878968..bc113db5 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -52,7 +52,7 @@ runs: cd ${GITHUB_WORKSPACE}/ make rpm \ USHIFT_GITREF="${{ inputs.ushift-gitref }}" \ - OKD_VERSION_TAG="${{ inputs.okd-version-tag }}" + OKD_VERSION_TAG="${{ inputs.okd-version-tag }}" \ RPM_OUTDIR=/mnt/rpms - name: Build MicroShift bootc container image diff --git a/Makefile b/Makefile index 5f0de145..3b31759e 100644 --- a/Makefile +++ b/Makefile @@ -80,8 +80,8 @@ rpm: srpm @outdir="$${RPM_OUTDIR:-$$(mktemp -d /tmp/microshift-rpms-XXXXXX)}" && \ mntdir="$$(sudo podman image mount "${RPM_IMAGE}")" && \ + trap "sudo podman image umount '${RPM_IMAGE}' >/dev/null" EXIT && \ sudo cp -r "$${mntdir}/home/microshift/microshift/_output/rpmbuild/RPMS/." "$${outdir}" && \ - sudo podman image umount "${RPM_IMAGE}" >/dev/null && \ echo -e "\nBuild completed successfully\nRPMs are available in '$${outdir}'" .PHONY: srpm @@ -97,8 +97,8 @@ srpm: @outdir="$${SRPM_WORKDIR:-$$(mktemp -d /tmp/microshift-srpms-XXXXXX)}" && \ mntdir="$$(sudo podman image mount "${SRPM_IMAGE}")" && \ + trap "sudo podman image umount '${SRPM_IMAGE}' >/dev/null" EXIT && \ sudo cp -r "$${mntdir}/home/microshift/microshift/_output/rpmbuild/SRPMS/." "$${outdir}" && \ - sudo podman image umount "${SRPM_IMAGE}" >/dev/null && \ echo -e "\nBuild completed successfully\nSRPM is available in '$${outdir}'" .PHONY: rpm-to-deb diff --git a/packaging/rpm.Containerfile b/packaging/rpm.Containerfile index 4475b1df..b1b28c80 100644 --- a/packaging/rpm.Containerfile +++ b/packaging/rpm.Containerfile @@ -16,7 +16,8 @@ WORKDIR /tmp # hadolint ignore=DL4006 RUN \ - echo "# Extract the MicroShift source code into /home/microshift/microshift - bootc builder is reusing file" && \ + echo "# Extract the MicroShift source code into /home/microshift/microshift" && \ + echo "# Note: Bootc builder is reusing the source archive" && \ rpm2cpio ./microshift-*.src.rpm | cpio -idmv && \ mkdir -p /home/microshift/microshift && \ tar xf ./microshift-*.tar.gz -C /home/microshift/microshift --strip-components=1 && \ @@ -24,11 +25,14 @@ RUN \ echo "# Build the RPMs from the SRPM" && \ rpmbuild --quiet --define 'microshift_variant community' --rebuild ./microshift-*.src.rpm && \ \ - echo "# Finally, move the RPMs" && \ + echo "# Move the RPMs" && \ mkdir -p ${BUILDER_RPM_REPO_PATH}/ && \ + rm -rf ${BUILDER_RPM_REPO_PATH}/RPMS && \ mv /root/rpmbuild/RPMS ${BUILDER_RPM_REPO_PATH}/ && \ mkdir -p ${BUILDER_RPM_REPO_PATH}/RPMS/srpms/ && \ mv ./microshift-*.src.rpm ${BUILDER_RPM_REPO_PATH}/RPMS/srpms/ && \ mv ./version.txt ${BUILDER_RPM_REPO_PATH}/RPMS/ && \ + \ + echo "# Create the repository and cleanup" && \ createrepo -v ${BUILDER_RPM_REPO_PATH}/RPMS && \ rm -rf /root/rpmbuild /tmp/* /root/.cache/go-build