Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion .github/workflows/nightly-copr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,57 @@ on:
schedule:
- cron: "0 1 * * *"
workflow_dispatch:
inputs:
copr-repo-name:
description: COPR repository name
default: "@microshift-io/microshift-nightly"
type: string

env:
COPR_REPO_NAME: "@microshift-io/microshift-nightly"
COPR_REPO_NAME: ${{ github.event.inputs.copr-repo-name || '@microshift-io/microshift-nightly' }}

jobs:
build-dependencies-rpm:
if: github.event_name != 'schedule' || github.repository == 'microshift-io/microshift'
runs-on: ubuntu-24.04
steps:
- name: Check out MicroShift upstream repository
uses: actions/checkout@v4

- name: Detect OKD version tag
id: detect-okd-version
uses: ./.github/actions/okd-version

- name: Build dependencies RPM
shell: bash
env:
COPR_CONFIG: |
${{ secrets.COPR_CONFIG }}
run: |
set -euo pipefail
cd ${GITHUB_WORKSPACE}/
echo "${COPR_CONFIG}" > /tmp/copr-config

make copr-dependencies \
OKD_VERSION_TAG=${{ steps.detect-okd-version.outputs.okd-version-tag }} \
COPR_REPO_NAME=${{ env.COPR_REPO_NAME }} \
COPR_CONFIG=/tmp/copr-config

- name: Build CNI plugins RPM
shell: bash
env:
COPR_CONFIG: |
${{ secrets.COPR_CONFIG }}
run: |
set -euo pipefail
cd ${GITHUB_WORKSPACE}/
echo "${COPR_CONFIG}" > /tmp/copr-config

make copr-cni \
COPR_REPO_NAME=${{ env.COPR_REPO_NAME }} \
COPR_CONFIG=/tmp/copr-config


build-rpms:
if: github.event_name != 'schedule' || github.repository == 'microshift-io/microshift'
runs-on: ubuntu-24.04
Expand Down
12 changes: 3 additions & 9 deletions docs/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,13 @@ sudo ./src/rpm/create_repos.sh -delete
#### RPMs from the COPR

Run the following commands to install MicroShift nightly RPM packages from the COPR.
Before installing MicroShift, RHOCP beta mirror must be enabled to provide dependencies.

> Note: By skipping `create_repos.sh -delete` users can keep the RPM repositories configuration
> and use `dnf update` to update MicroShift and its dependencies (withing single Major.Minor release
> when new MicroShift minor version is released, rerunning the `create_repos.sh -rhocp-mirror` might be necessary
> to enable newer dependency repository).

```bash
sudo dnf copr enable -y @microshift-io/microshift-nightly
sudo ./src/rpm/create_repos.sh -rhocp-mirror
# microshift-io-dependencies must be installed
# before microshift in order to setup dependencies repositories.
sudo dnf install -y microshift-io-dependencies-repo
sudo dnf install -y microshift microshift-kindnet
Comment on lines +44 to 47
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, check the current state of docs/run.md around lines 44-47
head -n 50 docs/run.md | tail -n 20

Repository: microshift-io/microshift

Length of output: 680


🏁 Script executed:

# Search for microshift-io-dependencies references across the codebase
rg "microshift-io-dependencies" -n --max-count=20

Repository: microshift-io/microshift

Length of output: 565


🏁 Script executed:

# Check quickrpm.sh for the package name being installed
rg -A 5 -B 5 "microshift-io-dependencies" src/quickrpm.sh

Repository: microshift-io/microshift

Length of output: 288


🏁 Script executed:

# Look for any -repo suffix variants
rg "microshift-io-dependencies-repo" -n

Repository: microshift-io/microshift

Length of output: 134


Fix package name in installation command.

Line 46 references microshift-io-dependencies-repo, but the actual package is microshift-io-dependencies (as defined in the spec and used in quickrpm.sh line 101).

Change required
-sudo dnf install -y microshift-io-dependencies-repo
+sudo dnf install -y microshift-io-dependencies
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# microshift-io-dependencies must be installed
# before microshift in order to setup dependencies repositories.
sudo dnf install -y microshift-io-dependencies-repo
sudo dnf install -y microshift microshift-kindnet
# microshift-io-dependencies must be installed
# before microshift in order to setup dependencies repositories.
sudo dnf install -y microshift-io-dependencies
sudo dnf install -y microshift microshift-kindnet
🤖 Prompt for AI Agents
In `@docs/run.md` around lines 44 - 47, Replace the incorrect package name
"microshift-io-dependencies-repo" in the installation command with the correct
package "microshift-io-dependencies" so the docs match the spec and quickrpm.sh
usage; update the line that currently runs sudo dnf install -y
microshift-io-dependencies-repo to sudo dnf install -y
microshift-io-dependencies in docs/run.md.

# Optionally run the following command to remove the configured MicroShift COPR and dependencies repositories.
# sudo ./src/rpm/create_repos.sh -delete
```

### Start MicroShift Service
Expand Down
81 changes: 81 additions & 0 deletions src/copr/cni/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash

set -euo pipefail

_package_name="containernetworking-plugins"
_scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

if [ $# -ne 1 ]; then
echo "Usage: $(basename "$0") <copr-repo-name>"
exit 1
fi

COPR_REPO_NAME="$1"

[ -z "${COPR_REPO_NAME}" ] && echo "ERROR: COPR_REPO_NAME is not set" && exit 1
echo "COPR_REPO_NAME: '${COPR_REPO_NAME}'"

latest_tag=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/containernetworking/plugins/releases/latest | jq -r '.tag_name')

echo "### containernetworking/plugins latest tag: '${latest_tag}'"
version="${latest_tag#v}"

echo "### Checking if package ${_package_name} ${version} already exists in the COPR repository"
cni_pkg="$(copr-cli list-packages "${COPR_REPO_NAME}" | jq -r '.[] | select(.name == "'${_package_name}'")')"
if [ -n "${cni_pkg}" ]; then
existing_package_version=$(copr-cli get-package \
--name "${_package_name}" \
--with-latest-succeeded-build \
"${COPR_REPO_NAME}" \
| jq -r '.latest_succeeded_build.source_package.version')

if [[ "${existing_package_version}" == "1:${version}-1" ]]; then
echo "### Package ${_package_name} ${version} already exists in the COPR repository"
exit 0
fi
fi

temp_dir="$(mktemp -d "/tmp/containernetworking-plugins-${version}.XXXXXX")"
cp "${_scriptdir}/containernetworking-plugins.spec" "${temp_dir}/"

pushd "${temp_dir}" >/dev/null

echo "### Downloading the CNI plugins x86_64 and aarch64 releases for ${version}"
curl -L -o amd64.tgz "https://github.com/containernetworking/plugins/releases/download/v${version}/cni-plugins-linux-amd64-v${version}.tgz"
curl -L -o arm64.tgz "https://github.com/containernetworking/plugins/releases/download/v${version}/cni-plugins-linux-arm64-v${version}.tgz"

mkdir -p containernetworking-plugins-${version}/{x86_64,aarch64}

tar xf amd64.tgz -C containernetworking-plugins-${version}/x86_64
tar xf arm64.tgz -C containernetworking-plugins-${version}/aarch64
cp containernetworking-plugins-${version}/x86_64/LICENSE containernetworking-plugins-${version}/x86_64/README.md containernetworking-plugins-${version}/

tar czf containernetworking-plugins-${version}.tar.gz -C containernetworking-plugins-${version} .

mkdir -p buildroot/{RPMS,SRPMS,SOURCES,SPECS,BUILD}
mv containernetworking-plugins-${version}.tar.gz buildroot/SOURCES/
Comment on lines +50 to +59
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Quote ${version} to fix SC2086 shellcheck warnings.

Multiple unquoted uses of ${version} in path constructions.

Proposed fix
-mkdir -p containernetworking-plugins-${version}/{x86_64,aarch64}
+mkdir -p "containernetworking-plugins-${version}"/{x86_64,aarch64}
 
-tar xf amd64.tgz -C containernetworking-plugins-${version}/x86_64
-tar xf arm64.tgz -C containernetworking-plugins-${version}/aarch64
-cp containernetworking-plugins-${version}/x86_64/LICENSE containernetworking-plugins-${version}/x86_64/README.md containernetworking-plugins-${version}/
+tar xf amd64.tgz -C "containernetworking-plugins-${version}/x86_64"
+tar xf arm64.tgz -C "containernetworking-plugins-${version}/aarch64"
+cp "containernetworking-plugins-${version}/x86_64/LICENSE" "containernetworking-plugins-${version}/x86_64/README.md" "containernetworking-plugins-${version}/"
 
-tar czf containernetworking-plugins-${version}.tar.gz -C containernetworking-plugins-${version} .
+tar czf "containernetworking-plugins-${version}.tar.gz" -C "containernetworking-plugins-${version}" .
 
 mkdir -p buildroot/{RPMS,SRPMS,SOURCES,SPECS,BUILD}
-mv containernetworking-plugins-${version}.tar.gz buildroot/SOURCES/
+mv "containernetworking-plugins-${version}.tar.gz" buildroot/SOURCES/

As per coding guidelines, shell scripts should pass linting with shellcheck.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mkdir -p containernetworking-plugins-${version}/{x86_64,aarch64}
tar xf amd64.tgz -C containernetworking-plugins-${version}/x86_64
tar xf arm64.tgz -C containernetworking-plugins-${version}/aarch64
cp containernetworking-plugins-${version}/x86_64/LICENSE containernetworking-plugins-${version}/x86_64/README.md containernetworking-plugins-${version}/
tar czf containernetworking-plugins-${version}.tar.gz -C containernetworking-plugins-${version} .
mkdir -p buildroot/{RPMS,SRPMS,SOURCES,SPECS,BUILD}
mv containernetworking-plugins-${version}.tar.gz buildroot/SOURCES/
mkdir -p "containernetworking-plugins-${version}"/{x86_64,aarch64}
tar xf amd64.tgz -C "containernetworking-plugins-${version}/x86_64"
tar xf arm64.tgz -C "containernetworking-plugins-${version}/aarch64"
cp "containernetworking-plugins-${version}/x86_64/LICENSE" "containernetworking-plugins-${version}/x86_64/README.md" "containernetworking-plugins-${version}/"
tar czf "containernetworking-plugins-${version}.tar.gz" -C "containernetworking-plugins-${version}" .
mkdir -p buildroot/{RPMS,SRPMS,SOURCES,SPECS,BUILD}
mv "containernetworking-plugins-${version}.tar.gz" buildroot/SOURCES/
🧰 Tools
🪛 GitHub Actions: linters

[warning] 50-50: SC2086: Double quote to prevent globbing and word splitting.


[warning] 52-52: SC2086: Double quote to prevent globbing and word splitting.


[warning] 53-53: SC2086: Double quote to prevent globbing and word splitting.


[warning] 54-54: SC2086: Double quote to prevent globbing and word splitting.


[warning] 54-54: SC2086: Double quote to prevent globbing and word splitting.


[warning] 56-56: SC2086: Double quote to prevent globbing and word splitting.


[warning] 56-56: SC2086: Double quote to prevent globbing and word splitting.


[warning] 59-59: SC2086: Double quote to prevent globbing and word splitting.

🤖 Prompt for AI Agents
In `@src/copr/cni/build.sh` around lines 50 - 59, The unquoted ${version} variable
is used in several path constructions (mkdir, tar -C, cp, tar czf, mv) in
build.sh and triggers shellcheck SC2086; update every occurrence to use quoted
expansions like "${version}" (e.g.,
containernetworking-plugins-"${version}"/x86_64) so paths with spaces or glob
chars are safe, and ensure all related commands (mkdir, tar -C, cp, tar czf, mv)
reference the quoted form consistently.


cat > buildroot/SPECS/containernetworking-plugins.spec <<EOF
%global ver ${version}

EOF
cat containernetworking-plugins.spec >> buildroot/SPECS/containernetworking-plugins.spec

echo "### Building the SRPM"
rpmbuild -bs --define "_topdir ./buildroot" ./buildroot/SPECS/containernetworking-plugins.spec

echo "### Pushing the SRPM to COPR (${COPR_REPO_NAME}) and waiting for the build"
# Just epel-10 chroots because of the obsolesence of the original package in the CentOS Stream 10.
if copr-cli build "${COPR_REPO_NAME}" \
--chroot epel-10-aarch64 --chroot epel-10-x86_64 \
"${temp_dir}/buildroot/SRPMS/containernetworking-plugins-${version}-1.src.rpm"; then
copr-cli regenerate-repos "${COPR_REPO_NAME}"
else
exit 1
fi

popd >/dev/null
rm -rf "${temp_dir}"
43 changes: 43 additions & 0 deletions src/copr/cni/containernetworking-plugins.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
%global debug_package %{nil}

Name: containernetworking-plugins
# Setting epoch to workaround containers-common's Obsolete of 'containernetworking-plugins < 2'
Epoch: 1
Version: %{ver}
Release: 1
Summary: Binaries required to provision kubernetes container networking

Packager: MicroShift team
License: Apache-2.0
URL: https://microshift.io
Source0: %{name}-%{version}.tar.gz

%description
%{summary}.

%prep
%setup -q -c

%build
# Nothing to build

%install
# Detect host arch
KUBE_ARCH="$(uname -m)"

# Install files
mkdir -p %{buildroot}/usr/libexec/cni/
mkdir -p %{buildroot}%{_sysconfdir}/cni/net.d/

cp -a ${KUBE_ARCH}/* %{buildroot}/usr/libexec/cni/

%files
/usr/libexec/cni/
%dir %{_sysconfdir}/cni
%dir %{_sysconfdir}/cni/net.d
%license LICENSE
%doc README.md

%changelog
* Fri Feb 13 2026 Patryk Matuszak <pmatusza@redhat.com> 0.0.0
- Init specfile based on https://download.opensuse.org/repositories/isv:/kubernetes:/core:/prerelease:/v1.36/rpm/src/kubernetes-cni-1.8.0-150500.1.1.src.rpm
9 changes: 8 additions & 1 deletion src/copr/copr-cli.Containerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
FROM quay.io/fedora/fedora:latest

RUN dnf install -y copr-cli && dnf clean all
RUN dnf install \
--setopt=install_weak_deps=False \
-y \
copr-cli jq rpmbuild \
&& dnf clean all
Comment on lines +3 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

Fedora dnf package rpmbuild rpm-build

💡 Result:

On Fedora, the rpmbuild command is provided by the rpm-build package. [1]

sudo dnf install rpm-build

To confirm on your system:

dnf provides '*/rpmbuild'

Use rpm-build instead of rpmbuild.

On Fedora, the rpmbuild binary is provided by the rpm-build package. dnf install rpmbuild will fail.

Proposed fix
 RUN dnf install \
         --setopt=install_weak_deps=False \
         -y \
-        copr-cli jq rpmbuild \
+        copr-cli jq rpm-build \
     && dnf clean all
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN dnf install \
--setopt=install_weak_deps=False \
-y \
copr-cli jq rpmbuild \
&& dnf clean all
RUN dnf install \
--setopt=install_weak_deps=False \
-y \
copr-cli jq rpm-build \
&& dnf clean all
🤖 Prompt for AI Agents
In `@src/copr/copr-cli.Containerfile` around lines 3 - 7, The RUN installation
line installs the wrong package name "rpmbuild"; replace it with the correct
Fedora package "rpm-build" in the RUN command that installs "copr-cli jq
rpmbuild" (so the token "rpmbuild" in that RUN should be changed to "rpm-build")
and keep the rest of the flags and cleanup unchanged.


COPY create-build.sh microshift-io-dependencies.sh cni/containernetworking-plugins.spec /
COPY cni/build.sh cni/containernetworking-plugins.spec /cni/
29 changes: 22 additions & 7 deletions src/copr/copr.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,25 @@ copr-cli:
@echo "Building the COPR CLI container"
sudo podman build \
--tag "${COPR_CLI_IMAGE}" \
--file src/copr/copr-cli.Containerfile .
--file src/copr/copr-cli.Containerfile src/copr/

.PHONY: copr-delete-build
copr-delete-build: copr-cfg-ensure-podman-secret copr-cli
@echo "Deleting the COPR build ${COPR_BUILD_ID}"
sudo podman run \
--rm \
--secret ${COPR_SECRET_NAME} \
--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
"${COPR_CLI_IMAGE}" \
bash -c "copr-cli --config /run/secrets/${COPR_SECRET_NAME} delete-build ${COPR_BUILD_ID}"
bash -c "copr-cli delete-build ${COPR_BUILD_ID}"

.PHONY: copr-regenerate-repos
copr-regenerate-repos: copr-cfg-ensure-podman-secret copr-cli
@echo "Regenerating the COPR repository"
sudo podman run \
--rm \
--secret ${COPR_SECRET_NAME} \
--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
"${COPR_CLI_IMAGE}" \
bash -c "copr-cli --config /run/secrets/${COPR_SECRET_NAME} regenerate-repos ${COPR_REPO_NAME}"
bash -c "copr-cli regenerate-repos ${COPR_REPO_NAME}"

.PHONY: copr-create-build
copr-create-build: copr-cfg-ensure-podman-secret copr-cli
Expand All @@ -94,10 +94,9 @@ copr-create-build: copr-cfg-ensure-podman-secret copr-cli
fi
sudo podman run \
--rm \
--secret ${COPR_SECRET_NAME} \
--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
--env COPR_REPO_NAME="${COPR_REPO_NAME}" \
--volume "${SRPM_WORKDIR}:/srpms:Z" \
--volume "./src/copr/create-build.sh:/create-build.sh:Z" \
"${COPR_CLI_IMAGE}" \
bash -c "bash -x /create-build.sh"

Expand All @@ -109,3 +108,19 @@ copr-watch-build: copr-cli
--volume "${SRPM_WORKDIR}:/srpms:Z" \
"${COPR_CLI_IMAGE}" \
bash -c "copr-cli watch-build ${COPR_BUILD_ID}"

copr-dependencies: copr-cfg-ensure-podman-secret copr-cli
@echo "Building RPM with MicroShift dependencies repositories configuration"
sudo podman run \
--rm -ti \
--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
"${COPR_CLI_IMAGE}" \
/microshift-io-dependencies.sh "${OKD_VERSION_TAG}" "${COPR_REPO_NAME}"
Comment on lines +112 to +118
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Missing .PHONY and -ti will break in CI.

  1. Add .PHONY: copr-dependencies — every other target in this file declares it.
  2. -ti allocates a TTY + interactive stdin. GitHub Actions runners have no TTY, so this will fail or emit warnings. The other targets in this file use only --rm. Drop -ti (or use -t only if truly needed for colored output, gated on [ -t 0 ]).
  3. OKD_VERSION_TAG is undocumented in the help target and has no default — consider adding it to the variables section.
Proposed fix
+.PHONY: copr-dependencies
 copr-dependencies: copr-cfg-ensure-podman-secret copr-cli
 	`@echo` "Building RPM with MicroShift dependencies repositories configuration"
 	sudo podman run \
-		--rm -ti \
+		--rm \
 		--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
 		"${COPR_CLI_IMAGE}" \
 		/microshift-io-dependencies.sh "${OKD_VERSION_TAG}" "${COPR_REPO_NAME}"
🤖 Prompt for AI Agents
In `@src/copr/copr.mk` around lines 112 - 118, Add a .PHONY declaration for the
copr-dependencies target, remove the interactive TTY flags (-ti) from the podman
run invocation (use --rm only, or gate -t behind a tty check if colored output
is needed), and document or provide a default for OKD_VERSION_TAG in the
Makefile variables/help section so the copr-dependencies target has a defined
value; update references to COPR_SECRET_NAME and COPR_CLI_IMAGE only as needed
to match the existing variable names.


copr-cni: copr-cfg-ensure-podman-secret copr-cli
@echo "Building RPM with CNI plugins"
sudo podman run \
--rm -ti \
--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
"${COPR_CLI_IMAGE}" \
/cni/build.sh "${COPR_REPO_NAME}"
Comment on lines +120 to +126
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Same issues: missing .PHONY and -ti; also no trailing newline.

Same fixes as copr-dependencies above. Additionally, the file lacks a final newline which can cause POSIX tools to misbehave.

Proposed fix
+.PHONY: copr-cni
 copr-cni: copr-cfg-ensure-podman-secret copr-cli
 	`@echo` "Building RPM with CNI plugins"
 	sudo podman run \
-		--rm -ti \
+		--rm \
 		--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
 		"${COPR_CLI_IMAGE}" \
 		/cni/build.sh "${COPR_REPO_NAME}"
+
🤖 Prompt for AI Agents
In `@src/copr/copr.mk` around lines 120 - 126, The copr-cni make target is missing
a .PHONY declaration, uses the interactive -ti flags in the podman run, and the
file lacks a final newline; update the Makefile to add copr-cni to the .PHONY
list (alongside other phony targets), remove the -ti flags from the podman run
invocation in the copr-cni recipe so it runs non-interactively, and ensure the
file ends with a trailing newline character so POSIX tools behave correctly.

2 changes: 1 addition & 1 deletion src/copr/create-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [[ -z "${COPR_REPO_NAME:-}" ]]; then
exit 1
fi

out="$(copr-cli --config /run/secrets/copr-cfg build --nowait "${COPR_REPO_NAME}" /srpms/microshift*.src.rpm)"
out="$(copr-cli build --nowait "${COPR_REPO_NAME}" /srpms/microshift*.src.rpm)"
echo "${out}"
build=$(echo "${out}" | grep "Created builds" | cut -d: -f2 | xargs)
if [[ -z "${build}" ]]; then
Expand Down
92 changes: 92 additions & 0 deletions src/copr/microshift-io-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env bash
set -euo pipefail

_package_name="microshift-io-dependencies"
_minor_version_start=18

if [ $# -ne 2 ]; then
echo "Usage: $(basename "$0") <okd-version-tag> <copr-repo-name>"
exit 1
fi

OKD_VERSION_TAG="$1"
COPR_REPO_NAME="$2"

echo "OKD_VERSION_TAG: '${OKD_VERSION_TAG}'"
echo "COPR_REPO_NAME: '${COPR_REPO_NAME}'"

[ -z "${OKD_VERSION_TAG}" ] && echo "ERROR: OKD_VERSION_TAG is not set" && exit 1
[ -z "${COPR_REPO_NAME}" ] && echo "ERROR: COPR_REPO_NAME is not set" && exit 1

major=$(echo "${OKD_VERSION_TAG}" | cut -d. -f1)
minor=$(echo "${OKD_VERSION_TAG}" | cut -d. -f2)
pkg_version="${major}.${minor}"
echo "New package version: '${pkg_version}'"

if $(copr-cli list-packages "${COPR_REPO_NAME}" | jq -r '.[].name' | grep -q "${_package_name}"); then
existing_package_version=$(copr-cli get-package \
--name "${_package_name}" \
--with-latest-succeeded-build \
"${COPR_REPO_NAME}" \
| jq -r '.latest_succeeded_build.source_package.version')

if [[ "${existing_package_version}" == "${pkg_version}-1" ]]; then
echo "Package ${_package_name} ${pkg_version} already exists in the COPR repository"
exit 0
fi
fi
Comment on lines +26 to +37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Bug: if $(...) always evaluates to true (SC2091).

The $() captures stdout (empty from grep -q) and tries to execute it as a command. An empty command succeeds, so this if is always true — the version-existence check never gates anything.

Remove the $() wrapper so if tests the pipeline's exit code directly:

Proposed fix
-if $(copr-cli list-packages "${COPR_REPO_NAME}" | jq -r '.[].name' | grep -q "${_package_name}"); then
+if copr-cli list-packages "${COPR_REPO_NAME}" | jq -r '.[].name' | grep -q "${_package_name}"; then

As per coding guidelines, shell scripts should pass linting with shellcheck.

🧰 Tools
🪛 GitHub Actions: linters

[warning] 26-26: SC2091: Remove surrounding $() to avoid executing output (or use eval if intentional).

🤖 Prompt for AI Agents
In `@src/copr/microshift-io-dependencies.sh` around lines 26 - 37, The if
condition incorrectly uses command substitution causing SC2091 (if $(...)
executes stdout rather than the pipeline exit status); change the condition to
test the pipeline directly—invoke the pipeline starting with copr-cli
list-packages "${COPR_REPO_NAME}" | jq -r '.[].name' | grep -q
"${_package_name}" in the if statement (without $()), so the exit code controls
the branch; keep the inner logic that sets existing_package_version (from
copr-cli get-package ... | jq -r
'.latest_succeeded_build.source_package.version') and compares it to
"${pkg_version}-1" as before.


rhocp_versions=""
for min in $(seq "${_minor_version_start}" "${minor}") ; do
rhocp_versions+="${major}.${min} "
done

echo "RHOCP versions to create .repo files for: '${rhocp_versions}'"

dest=$(mktemp -d "/tmp/${_package_name}.XXXXXX")
cat > "${dest}/${_package_name}.spec" <<EOF
%global rhocp_versions ${rhocp_versions}
%global version ${pkg_version}

Name: ${_package_name}
Version: %{version}
Release: 1%{?dist}
Summary: RPM repository configurations for MicroShift dependencies

License: Apache-2.0
URL: https://github.com/microshift-io/microshift-io
BuildArch: noarch

%description
This package installs RPM repository configuration files required
for installing MicroShift dependencies from the OpenShift beta mirror repository.

%install
install -d %{buildroot}%{_sysconfdir}/yum.repos.d

for v in %{rhocp_versions}; do
cat >> %{buildroot}%{_sysconfdir}/yum.repos.d/openshift-mirror-beta.repo <<EOF2
[openshift-mirror-\${v}-beta]
name=OpenShift \${v} Mirror Beta Repository
baseurl=https://mirror.openshift.com/pub/openshift-v4/\\\$basearch/dependencies/rpms/\${v}-el9-beta/
enabled=1
gpgcheck=0
skip_if_unavailable=0

EOF2
done

%files
%config(noreplace) %{_sysconfdir}/yum.repos.d/openshift-mirror-beta.repo

EOF

echo "--------------- SPEC FILE ---------------"
cat "${dest}/${_package_name}.spec"
echo "-----------------------------------------"

if copr-cli build "${COPR_REPO_NAME}" "${dest}/${_package_name}.spec"; then
copr-cli regenerate-repos "${COPR_REPO_NAME}"
else
exit 1
Comment on lines +88 to +91
Copy link

@coderabbitai coderabbitai bot Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

copr-cli build .spec file SRPM input format documentation

💡 Result:

copr-cli build primarily takes an SRPM as its input (either a local file path or an HTTP(S) URL): copr-cli build <project> <path-or-url-to>.src.rpm. [1]

For a .spec file, COPR supports it as a build source too:

  • URL to a .spec file: you can pass a public HTTPS URL to a .spec; COPR will then download the referenced sources (from public HTTPS locations) and build an SRPM first, then build RPMs from that SRPM. [2]
  • Direct upload of a local .spec: COPR also supports uploading a local .spec (or SRPM) via copr-cli / web UI (“Direct Upload” source type). [2]

If what you actually have is a Git repo with the spec+sources, use the SCM source type (build from Git/SVN/DistGit and have COPR generate the SRPM using rpkg/tito/make srpm). [2]

Docs to read (most relevant sections):

  • Fedora Developer Portal “Copr command line interface” (shows copr-cli build with SRPM path/URL). [1]
  • COPR “User Documentation → Build Source Types” (URLs / Direct Upload / SCM; includes .spec via URL and local .spec upload). [2]

Sources: [1] [2]


🏁 Script executed:

# Check the context around line 88-91 in the file
sed -n '80,100p' src/copr/microshift-io-dependencies.sh

Repository: microshift-io/microshift

Length of output: 426


🏁 Script executed:

# Check if there's any SRPM generation earlier in the script
head -n 87 src/copr/microshift-io-dependencies.sh | tail -n 20

Repository: microshift-io/microshift

Length of output: 602


copr-cli build cannot accept a local .spec file directly.

According to COPR documentation, copr-cli build expects an SRPM (local path or HTTP(S) URL), not a raw .spec file. Passing a local .spec file path will fail at runtime. Either build an SRPM first and pass that, or provide a URL to the .spec file so COPR can download sources and generate the SRPM itself.

🤖 Prompt for AI Agents
In `@src/copr/microshift-io-dependencies.sh` around lines 88 - 91, The script
currently calls copr-cli build with a local .spec path (copr-cli build
"${COPR_REPO_NAME}" "${dest}/${_package_name}.spec"), but copr-cli expects an
SRPM or URL; change the flow to create an SRPM from the spec (e.g., run rpmbuild
-ba /path/to/"${_package_name}.spec" or the project's SRPM build command to
produce an .src.rpm) and then call copr-cli build with that SRPM path (copr-cli
build "${COPR_REPO_NAME}" "/path/to/${_package_name}-*.src.rpm"); keep the
subsequent copr-cli regenerate-repos call the same. Ensure variables
(COPR_REPO_NAME, dest, _package_name) are used to locate the produced SRPM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please...

# copr-cli build -h
usage: copr build [-h] [--timeout TIMEOUT] [--nowait] [-r CHROOT] [--exclude-chroot CHROOT] [--background] [--isolation {simple,nspawn,default}] [--enable-net {on,off}] [--bootstrap {unchanged,default,on,off,image}]
                  [--after-build-id BUILD_ID | --with-build-id BUILD_ID]
                  copr_repo pkgs [pkgs ...]

positional arguments:
  copr_repo             The copr repo to build the package in. Can be just name of project or even in format username/project or @groupname/project. It can also be in the form project:<tag>, which will put the build into a side repository
                        with the user-chosen tag in its name.
  pkgs                  List of filenames or URLs for SRPMs or SPEC files to build packages
                                                               ^^^^^^^^^^

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmtk, you're absolutely right—I apologize for the incorrect review comment. The copr-cli build command does indeed accept SPEC files directly, as shown in the help output you provided. The code is correct as written. Thank you for the correction!


🧠 Learnings used
Learnt from: pmtk
Repo: microshift-io/microshift PR: 151
File: docs/workflows.md:74-76
Timestamp: 2025-12-04T13:35:05.230Z
Learning: The COPR group microshift-io/microshift exists at https://copr.fedorainfracloud.org/coprs/g/microshift-io/microshift/ and is used for publishing MicroShift RPM packages in the microshift-io/microshift repository.

Learnt from: CR
Repo: microshift-io/microshift PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T11:22:03.985Z
Learning: Applies to packaging/Containerfile* : SRPM build container must clone MicroShift from upstream repository at `USHIFT_GITREF` and replace component images with OKD references via `src/image/prebuild.sh`

Learnt from: ggiguash
Repo: microshift-io/microshift PR: 137
File: src/quickrpm.sh:83-98
Timestamp: 2025-11-26T06:46:33.353Z
Learning: In the microshift-io/microshift repository, the quickrpm.sh script only supports RHEL 9 or above (and equivalent CentOS/Fedora versions), where util-linux includes the `--nooverlap` flag for losetup.

Learnt from: ggiguash
Repo: microshift-io/microshift PR: 57
File: .github/workflows/builders.yaml:75-84
Timestamp: 2025-10-17T10:53:08.461Z
Learning: In the microshift repository, the RPM-to-Debian conversion workflow follows this pattern: `convert.sh` receives an RPM directory as input and outputs .deb files to a `deb/` subdirectory within that directory. The `install.sh` script expects to receive the parent RPM directory (not the deb subdirectory) and uses recursive `find` commands to locate the .deb files in subdirectories.

Learnt from: ggiguash
Repo: microshift-io/microshift PR: 194
File: .github/workflows/builders.yaml:67-69
Timestamp: 2026-02-03T07:55:19.478Z
Learning: In the microshift-io/microshift repository, bootc-image-tag values like `stream9`, `stream10`, and `latest` are rolling tags that track the latest images from CentOS 9, CentOS 10, and Fedora bootc streams respectively, not fixed version pins.

Learnt from: CR
Repo: microshift-io/microshift PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T11:22:03.985Z
Learning: Applies to src/image/prebuild.sh : Replace component images with OKD references during SRPM build stage

Learnt from: ggiguash
Repo: microshift-io/microshift PR: 57
File: src/debian/install.sh:12-0
Timestamp: 2025-10-17T10:31:57.408Z
Learning: In the MicroShift project, the Ubuntu version in src/debian/install.sh is intentionally hardcoded to "xUbuntu_20.04" because CRI-O builds are not available for all the latest Ubuntu versions. This should not be changed to dynamic detection.

Learnt from: pmtk
Repo: microshift-io/microshift PR: 161
File: .github/actions/build/action.yaml:51-53
Timestamp: 2026-01-27T09:05:17.450Z
Learning: In `.github/actions/build/action.yaml`, the `build` input supports flexible workflows: use `build=all` to build both RPMs and bootc-image in one step, or build RPMs externally (e.g., via COPR) and then call the action with `build=bootc-image` to build only the container image. The Makefile validates RPM availability and provides helpful error messages.

Learnt from: CR
Repo: microshift-io/microshift PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T11:22:03.985Z
Learning: Applies to packaging/Containerfile* : RPM build container requires SRPM image from previous stage and outputs to `RPM_OUTDIR`

fi
4 changes: 1 addition & 3 deletions src/quickrpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ function install_microshift_packages() {
function install_rpms_copr() {
dnf copr enable -y "${COPR_REPO}"

"${WORKDIR}/create_repos.sh" -rhocp-mirror
dnf install -y microshift-io-dependencies
install_microshift_packages
# Keep the repos, so the `dnf update` works for updated MicroShift RPMs and
# updated dependencies.
}

function install_rpms() {
Expand Down
Loading