From 29a971d5c08399f577cbdfda08da30ca9255086e Mon Sep 17 00:00:00 2001 From: Patryk Matuszak Date: Thu, 11 Dec 2025 17:20:57 +0100 Subject: [PATCH 1/6] Local build from SRPM --- Makefile | 10 +- packaging/microshift-builder.Containerfile | 106 ++++++--------------- 2 files changed, 34 insertions(+), 82 deletions(-) diff --git a/Makefile b/Makefile index 71447dc9..1124d012 100644 --- a/Makefile +++ b/Makefile @@ -71,13 +71,15 @@ all: .PHONY: rpm rpm: - @echo "Building the MicroShift builder image" + @if ! sudo podman image exists "${SRPM_IMAGE}" ; then \ + echo "ERROR: Run 'make srpm' to build the MicroShift SRPMs" ; \ + exit 1 ; \ + fi + + @echo "Building the MicroShift RPMs image" sudo podman build \ -t "${BUILDER_IMAGE}" \ --ulimit nofile=524288:524288 \ - --build-arg USHIFT_GITREF="${USHIFT_GITREF}" \ - --build-arg OKD_VERSION_TAG="${OKD_VERSION_TAG}" \ - --build-arg OKD_RELEASE_IMAGE="${OKD_RELEASE_IMAGE}" \ -f packaging/microshift-builder.Containerfile . @echo "Extracting the MicroShift RPMs" diff --git a/packaging/microshift-builder.Containerfile b/packaging/microshift-builder.Containerfile index a8d68ee8..5684c25a 100644 --- a/packaging/microshift-builder.Containerfile +++ b/packaging/microshift-builder.Containerfile @@ -1,81 +1,31 @@ -FROM quay.io/centos-bootc/centos-bootc:stream9 +FROM localhost/microshift-okd-srpm:latest AS srpm -# Variables controlling the source of MicroShift components to build -ARG USHIFT_GITREF=main -ARG OKD_RELEASE_IMAGE=quay.io/okd/scos-release -ARG OKD_VERSION_TAG +FROM quay.io/centos/centos:stream9 -ENV OKD_VERSION_TAG=${OKD_VERSION_TAG} -ENV USHIFT_GITREF=${USHIFT_GITREF} - -# Internal variables -ARG USHIFT_GIT_URL=https://github.com/openshift/microshift.git -ENV USER=microshift -ENV HOME=/home/microshift -ARG BUILDER_RPM_REPO_PATH=${HOME}/microshift/_output/rpmbuild/RPMS -ARG USHIFT_PREBUILD_SCRIPT=/tmp/prebuild.sh -ARG USHIFT_POSTBUILD_SCRIPT=/tmp/postbuild.sh -ARG USHIFT_MODIFY_SPEC_SCRIPT=/tmp/modify-spec.py -ARG USHIFT_BUILDRPMS_SCRIPT=/tmp/build-rpms.sh -ARG SPECFILE_KINDNET=/tmp/kindnet.spec -ARG SPECFILE_TOPOLVM=/tmp/topolvm.spec - -# Verify mandatory build arguments -RUN if [ -z "${OKD_VERSION_TAG}" ] ; then \ - echo "ERROR: OKD_VERSION_TAG is not set" ; \ - echo "See ${OKD_RELEASE_IMAGE} for a list of tags" ; \ - exit 1; \ - fi - -# System setup for the build -RUN useradd -m -s /bin/bash "${USER}" && \ - echo "${USER} ALL=(ALL) NOPASSWD: ALL" > "/etc/sudoers.d/${USER}" && \ - chmod 0640 /etc/shadow && \ - dnf install -y \ +RUN dnf install -y \ --setopt=install_weak_deps=False \ - git rpm-build jq python3-pip createrepo && \ - dnf clean all && \ - pip install specfile - -# Set the user and work directory -USER ${USER}:${USER} -WORKDIR ${HOME} - -# Preparing the OS configuration for the build -RUN git clone --branch "${USHIFT_GITREF}" --single-branch "${USHIFT_GIT_URL}" "${HOME}/microshift" && \ - echo '{"auths":{"fake":{"auth":"aWQ6cGFzcwo="}}}' > /tmp/.pull-secret && \ - "${HOME}/microshift/scripts/devenv-builder/configure-vm.sh" --no-build --no-set-release-version --skip-dnf-update /tmp/.pull-secret - -WORKDIR ${HOME}/microshift/ - -COPY --chmod=755 ./src/image/prebuild.sh ${USHIFT_PREBUILD_SCRIPT} -RUN "${USHIFT_PREBUILD_SCRIPT}" --replace "${OKD_RELEASE_IMAGE}" "${OKD_VERSION_TAG}" - -COPY --chown=${USER}:${USER} ./src/kindnet/kindnet.spec "${SPECFILE_KINDNET}" -COPY --chown=${USER}:${USER} ./src/kindnet/assets/ "${HOME}/microshift/assets/optional/" -COPY --chown=${USER}:${USER} ./src/kindnet/dropins/ "${HOME}/microshift/packaging/kindnet/" -COPY --chown=${USER}:${USER} ./src/kindnet/crio.conf.d/ "${HOME}/microshift/packaging/crio.conf.d/" -RUN "${USHIFT_PREBUILD_SCRIPT}" --replace-kindnet "${OKD_RELEASE_IMAGE}" "${OKD_VERSION_TAG}" - -COPY --chown=${USER}:${USER} ./src/topolvm/topolvm.spec "${SPECFILE_TOPOLVM}" -COPY --chown=${USER}:${USER} ./src/topolvm/assets/ "${HOME}/microshift/assets/optional/topolvm/" -COPY --chown=${USER}:${USER} ./src/topolvm/dropins/ "${HOME}/microshift/packaging/microshift/dropins/" -COPY --chown=${USER}:${USER} ./src/topolvm/greenboot/ "${HOME}/microshift/packaging/greenboot/" -COPY --chown=${USER}:${USER} ./src/topolvm/release/ "${HOME}/microshift/assets/optional/topolvm/" - -COPY --chmod=755 ./src/image/modify-spec.py ${USHIFT_MODIFY_SPEC_SCRIPT} -# Modify the microshift.spec: -# - remove packages not yet supported by the upstream -# - merge the kindnet.spec and topolvm.spec into the microshift.spec -# Disable the RPM and SRPM checks in the make-rpm.sh script to not complain about removed packages -RUN "${USHIFT_MODIFY_SPEC_SCRIPT}" ./packaging/rpm/microshift.spec "${SPECFILE_KINDNET}" "${SPECFILE_TOPOLVM}" && \ - sed -i -e 's,CHECK_RPMS="y",,g' -e 's,CHECK_SRPMS="y",,g' ./packaging/rpm/make-rpm.sh - -# Build all MicroShift downstream RPMs and SRPMs -COPY --chmod=755 ./src/image/build-rpms.sh ${USHIFT_BUILDRPMS_SCRIPT} -# hadolint ignore=DL3059 -RUN "${USHIFT_BUILDRPMS_SCRIPT}" all - -# Post-build MicroShift configuration -COPY --chmod=755 ./src/image/postbuild.sh ${USHIFT_POSTBUILD_SCRIPT} -RUN "${USHIFT_POSTBUILD_SCRIPT}" "${BUILDER_RPM_REPO_PATH}" + rpm-build which git cpio createrepo \ + gcc gettext golang jq make policycoreutils selinux-policy selinux-policy-devel systemd && \ + dnf clean all + +COPY --from=srpm /home/microshift/microshift/_output/rpmbuild/SRPMS/ /tmp/ + +ARG BUILDER_RPM_REPO_PATH=/home/microshift/microshift/_output/rpmbuild/ + +WORKDIR /tmp + +# hadolint ignore=DL4006 +RUN \ + echo "# Extract the MicroShift source code into /home/microshift/microshift - bootc builder is reusing file" && \ + rpm2cpio ./microshift-*.src.rpm | cpio -idmv && \ + mkdir -p /home/microshift/microshift && \ + tar xf ./microshift-*.tar.gz -C /home/microshift/microshift --strip-components=1 && \ + \ + echo "# Build the RPMs from the SRPM" && \ + rpmbuild --quiet --rebuild ./microshift-*.src.rpm && \ + \ + echo "# Finally, move the RPMs" && \ + mkdir -p ${BUILDER_RPM_REPO_PATH} && \ + mv /root/rpmbuild/RPMS ${BUILDER_RPM_REPO_PATH}/ && \ + createrepo -v ${BUILDER_RPM_REPO_PATH}/RPMS && \ + rm -rf /root/rpmbuild /tmp/* From 9260c1a0f0d08f42764489fed35e18bdf0db7bee Mon Sep 17 00:00:00 2001 From: Patryk Matuszak Date: Thu, 11 Dec 2025 17:57:55 +0100 Subject: [PATCH 2/6] Update build.md --- docs/build.md | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/docs/build.md b/docs/build.md index 1d1c96d5..fafac657 100644 --- a/docs/build.md +++ b/docs/build.md @@ -16,9 +16,9 @@ Install the software necessary for running the build process: sudo dnf install -y make podman ``` -### Create RPM Packages +### Create SRPM Package -Create the MicroShift RPM packages by running the `make rpm` command. +Create the MicroShift SRPM package by running the `make srpm` command. The following options can be specified in the make command line using the `NAME=VAL` format. @@ -26,12 +26,45 @@ The following options can be specified in the make command line using the `NAME= |-----------------|----------|----------|----------| | USHIFT_GITREF | no | main | [MicroShift repository branches](https://github.com/openshift/microshift/branches) | | OKD_VERSION_TAG | no | latest | [OKD version tags](https://quay.io/repository/okd/scos-release?tab=tags) | -| RPM_OUTDIR | no | /tmp/... | RPM repository output directory | +| SRPM_WORKDIR | no | /tmp/... | SRPM repository output directory | -The `make rpm` command builds MicroShift RPMs based on CentOS Stream 9 operating -system. The `main` MicroShift repository branch and the latest OKD version tag +The `main` MicroShift repository branch and the latest OKD version tag are used by default if unspecified. +```bash +make srpm +``` + +If the build completes successfully, the `microshift-okd-srpm` container image +is created and the MicroShift SRPM and version.txt file is copied to +the `SRPM_WORKDIR` directory on the host. + +``` +... +... +SRPMs are available in '/tmp/microshift-srpms-1tzW3h' +``` + +Notes: +- The MicroShift repository branch and the OKD version tag used to build the + SRPM can be overridden by specifying `USHIFT_GITREF` and `OKD_VERSION_TAG` + make command line arguments. +- The path to the `SRPM_WORKDIR` directory (either temporary or specified in + the `make srpm` command line) is displayed in the end of the build procedure. + +### Create RPM Packages + +Create the MicroShift RPM packages by running the `make rpm` command. + +The `make rpm` command builds MicroShift RPMs for CentOS Stream 9 operating +system. RPMs are build from the SRPM built by running `make srpm`. + +The following options can be specified in the make command line using the `NAME=VAL` format. + +| Name | Required | Default | Comments | +|-----------------|----------|----------|----------| +| RPM_OUTDIR | no | /tmp/... | RPM repository output directory | + ```bash make rpm ``` @@ -49,9 +82,6 @@ RPMs are available in '/tmp/microshift-rpms-EI3IXg' ``` Notes: -- The MicroShift repository branch and the OKD version tag used to build the - packages can be overridden by specifying `USHIFT_GITREF` and `OKD_VERSION_TAG` - make command line arguments. - The path to the `RPM_OUTDIR` directory (either temporary or specified in the `make rpm` command line) is displayed in the end of the build procedure. From 37948559cf41c9951d32bb590fa0168fd4650680 Mon Sep 17 00:00:00 2001 From: Patryk Matuszak Date: Thu, 11 Dec 2025 18:03:43 +0100 Subject: [PATCH 3/6] Rename Containerfiles - microshift-runner -> bootc - microshift-builder -> rpm --- Makefile | 17 +++++++++-------- docs/build.md | 4 ++-- ...runner.Containerfile => bootc.Containerfile} | 2 +- ...-builder.Containerfile => rpm.Containerfile} | 0 4 files changed, 12 insertions(+), 11 deletions(-) rename packaging/{microshift-runner.Containerfile => bootc.Containerfile} (98%) rename packaging/{microshift-builder.Containerfile => rpm.Containerfile} (100%) diff --git a/Makefile b/Makefile index 1124d012..1e86feff 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ else OKD_RELEASE_IMAGE ?= $(OKD_RELEASE_IMAGE_X86_64) endif -BUILDER_IMAGE := microshift-okd-builder +RPM_IMAGE := microshift-okd-rpm USHIFT_IMAGE := microshift-okd SRPM_IMAGE := microshift-okd-srpm LVM_DISK := /var/lib/microshift-okd/lvmdisk.image @@ -78,15 +78,15 @@ rpm: @echo "Building the MicroShift RPMs image" sudo podman build \ - -t "${BUILDER_IMAGE}" \ + -t "${RPM_IMAGE}" \ --ulimit nofile=524288:524288 \ - -f packaging/microshift-builder.Containerfile . + -f packaging/rpm.Containerfile . @echo "Extracting the MicroShift RPMs" outdir="$${RPM_OUTDIR:-$$(mktemp -d /tmp/microshift-rpms-XXXXXX)}" && \ - mntdir="$$(sudo podman image mount "${BUILDER_IMAGE}")" && \ + mntdir="$$(sudo podman image mount "${RPM_IMAGE}")" && \ sudo cp -r "$${mntdir}/home/microshift/microshift/_output/rpmbuild/RPMS/." "$${outdir}" && \ - sudo podman image umount "${BUILDER_IMAGE}" && \ + sudo podman image umount "${RPM_IMAGE}" && \ echo "" && \ echo "Build completed successfully" && \ echo "RPMs are available in '$${outdir}'" @@ -118,7 +118,7 @@ rpm-to-deb: .PHONY: image image: - @if ! sudo podman image exists microshift-okd-builder ; then \ + @if ! sudo podman image exists "${RPM_IMAGE}" ; then \ echo "ERROR: Run 'make rpm' to build the MicroShift RPMs" ; \ exit 1 ; \ fi @@ -135,7 +135,7 @@ image: --env WITH_TOPOLVM="${WITH_TOPOLVM}" \ --env WITH_OLM="${WITH_OLM}" \ --env EMBED_CONTAINER_IMAGES="${EMBED_CONTAINER_IMAGES}" \ - -f packaging/microshift-runner.Containerfile . + -f packaging/bootc.Containerfile . .PHONY: run run: @@ -192,7 +192,8 @@ clean-all: @echo "Performing a full cleanup" $(MAKE) clean sudo podman rmi -f "${USHIFT_IMAGE}" || true - sudo podman rmi -f "${BUILDER_IMAGE}" || true + sudo podman rmi -f "${RPM_IMAGE}" || true + sudo podman rmi -f "${SRPM_IMAGE}" || true .PHONY: check check: _hadolint _shellcheck diff --git a/docs/build.md b/docs/build.md index fafac657..c15343df 100644 --- a/docs/build.md +++ b/docs/build.md @@ -69,7 +69,7 @@ The following options can be specified in the make command line using the `NAME= make rpm ``` -If the build completes successfully, the `microshift-okd-builder` container image +If the build completes successfully, the `microshift-okd-rpm` container image is created and the MicroShift RPM repository is copied to the `RPM_OUTDIR` directory on the host. The packages from this repository can be used to install MicroShift on the supported operating systems. @@ -132,7 +132,7 @@ The following options can be specified in the make command line using the `NAME= The `make image` command builds a MicroShift Bootc image based on CentOS Stream 9 operating system with the default options. The command uses artifacts from the -`microshift-okd-builder` container image created by `make rpm`. +`microshift-okd-rpm` container image created by `make rpm`. ```bash make image diff --git a/packaging/microshift-runner.Containerfile b/packaging/bootc.Containerfile similarity index 98% rename from packaging/microshift-runner.Containerfile rename to packaging/bootc.Containerfile index 3c16b991..fab3ebe0 100644 --- a/packaging/microshift-runner.Containerfile +++ b/packaging/bootc.Containerfile @@ -2,7 +2,7 @@ ARG BOOTC_IMAGE_URL=quay.io/centos-bootc/centos-bootc ARG BOOTC_IMAGE_TAG=stream9 -FROM localhost/microshift-okd-builder:latest AS builder +FROM localhost/microshift-okd-rpm:latest AS builder FROM ${BOOTC_IMAGE_URL}:${BOOTC_IMAGE_TAG} ARG REPO_CONFIG_SCRIPT=/tmp/create_repos.sh diff --git a/packaging/microshift-builder.Containerfile b/packaging/rpm.Containerfile similarity index 100% rename from packaging/microshift-builder.Containerfile rename to packaging/rpm.Containerfile From 0f7d20201b7ad42d5fc4ba8987a09c6a3a964bd6 Mon Sep 17 00:00:00 2001 From: Patryk Matuszak Date: Thu, 11 Dec 2025 18:03:50 +0100 Subject: [PATCH 4/6] Add missed var definition --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 1e86feff..f3f10140 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ else OKD_VERSION_TAG ?= $$(./src/okd/get_version.sh latest-amd64) endif RPM_OUTDIR ?= +SRPM_WORKDIR ?= # Options used in the 'image' target BOOTC_IMAGE_URL ?= quay.io/centos-bootc/centos-bootc From ae610a75b6e1e28c92d7c1cfcb2aae4cd57e9e16 Mon Sep 17 00:00:00 2001 From: Patryk Matuszak Date: Fri, 12 Dec 2025 10:40:29 +0100 Subject: [PATCH 5/6] Update build action --- .github/actions/build-deb/action.yaml | 6 ++++-- .github/actions/build/action.yaml | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/actions/build-deb/action.yaml b/.github/actions/build-deb/action.yaml index d9a8e495..d2b1f217 100644 --- a/.github/actions/build-deb/action.yaml +++ b/.github/actions/build-deb/action.yaml @@ -39,9 +39,11 @@ runs: # Run the RPM build process. cd ${GITHUB_WORKSPACE}/ - make rpm \ + make srpm \ USHIFT_GITREF=${{ inputs.ushift-gitref }} \ - OKD_VERSION_TAG=${{ inputs.okd-version-tag }} \ + 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 bc113db5..4d8e9055 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -50,9 +50,11 @@ runs: # Run the RPM build process. cd ${GITHUB_WORKSPACE}/ - make rpm \ + make srpm \ USHIFT_GITREF="${{ inputs.ushift-gitref }}" \ - OKD_VERSION_TAG="${{ inputs.okd-version-tag }}" \ + OKD_VERSION_TAG="${{ inputs.okd-version-tag }}" + + make rpm \ RPM_OUTDIR=/mnt/rpms - name: Build MicroShift bootc container image From 8c1aca21bcd26c04a242260159884761d3e022a5 Mon Sep 17 00:00:00 2001 From: Patryk Matuszak Date: Fri, 12 Dec 2025 11:08:56 +0100 Subject: [PATCH 6/6] Define microshift_variant explicitly Because downstream make-rpm.sh does not persist it in the specfile, it gets lost when building RPMs from SRPM. --- packaging/rpm.Containerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/rpm.Containerfile b/packaging/rpm.Containerfile index 5684c25a..85e8fd96 100644 --- a/packaging/rpm.Containerfile +++ b/packaging/rpm.Containerfile @@ -22,7 +22,7 @@ RUN \ tar xf ./microshift-*.tar.gz -C /home/microshift/microshift --strip-components=1 && \ \ echo "# Build the RPMs from the SRPM" && \ - rpmbuild --quiet --rebuild ./microshift-*.src.rpm && \ + rpmbuild --quiet --define 'microshift_variant community' --rebuild ./microshift-*.src.rpm && \ \ echo "# Finally, move the RPMs" && \ mkdir -p ${BUILDER_RPM_REPO_PATH} && \