The AlmaLinux 10 mock base config does not create the mockbuild user inside the chroot, causing 'Failed to resolve user mockbuild' during SRPM installation. Add explicit user creation via mock --chroot after --init, and use --scrub=all + --no-clean to prevent stale state from interfering.
99 lines
3.1 KiB
YAML
99 lines
3.1 KiB
YAML
name: Build RPMs
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- "**.spec"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: almalinux-10
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
spec:
|
|
- sonic-interface-libraries.spec
|
|
- sonic-win.spec
|
|
- sonic-workspace.spec
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install build tools
|
|
run: |
|
|
dnf install -y \
|
|
rpm-build \
|
|
rpmdevtools \
|
|
mock \
|
|
curl
|
|
|
|
- name: Add runner user to mock group
|
|
run: usermod -aG mock $(whoami) || true
|
|
|
|
- name: Setup RPM build tree
|
|
run: rpmdev-setuptree
|
|
|
|
- name: Download sources for ${{ matrix.spec }}
|
|
run: |
|
|
spectool -g -C ~/rpmbuild/SOURCES/ ${{ matrix.spec }}
|
|
|
|
- name: Build SRPM from ${{ matrix.spec }}
|
|
run: |
|
|
rpmbuild -bs \
|
|
--define "_topdir ${HOME}/rpmbuild" \
|
|
--define "_disable_source_fetch 0" \
|
|
${{ matrix.spec }}
|
|
PKGNAME=$(rpmspec -q --srpm --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.src.rpm" ${{ matrix.spec }})
|
|
echo "SRPM_PATH=${HOME}/rpmbuild/SRPMS/${PKGNAME}" >> "$GITHUB_ENV"
|
|
|
|
- name: Build RPM with mock
|
|
run: |
|
|
cat > /etc/mock/custom.cfg <<'MOCKEOF'
|
|
include('/etc/mock/alma+epel-10-x86_64.cfg')
|
|
config_opts['root'] = 'custom'
|
|
config_opts['yum.conf'] += """
|
|
[sonicde-rpm]
|
|
name=SonicDE RPM
|
|
baseurl=https://pc-rytteren.dk/forge/api/packages/anders/rpm
|
|
enabled=1
|
|
gpgcheck=0
|
|
|
|
[xlibre-xserver]
|
|
name=Copr xlibre-xserver
|
|
baseurl=https://download.copr.fedorainfracloud.org/results/@xlibre/xlibre-xserver/rhel+epel-10-$basearch/
|
|
type=rpm-md
|
|
skip_if_unavailable=True
|
|
gpgcheck=1
|
|
gpgkey=https://download.copr.fedorainfracloud.org/results/@xlibre/xlibre-xserver/pubkey.gpg
|
|
repo_gpgcheck=0
|
|
enabled=1
|
|
"""
|
|
MOCKEOF
|
|
|
|
mock --root custom --scrub=all || true
|
|
mock --root custom --init
|
|
mock --root custom --chroot 'groupadd -g 135 mock 2>/dev/null || true; useradd -u 135 -g 135 -d /builddir -s /bin/bash mockbuild 2>/dev/null || true'
|
|
mock --root custom --resultdir "${HOME}/mock-results" --no-clean --rebuild "${{ env.SRPM_PATH }}"
|
|
|
|
- name: Upload RPMs to Forgejo Package Registry
|
|
run: |
|
|
FORGEJO_URL="${{ github.server_url }}"
|
|
OWNER="${{ github.repository_owner }}"
|
|
TOKEN="${{ secrets.PACKAGE_TOKEN }}"
|
|
|
|
find "${HOME}/mock-results" -name "*.rpm" ! -name "*.src.rpm" | while read rpm; do
|
|
FILENAME=$(basename "$rpm")
|
|
echo "Uploading $FILENAME ..."
|
|
curl --fail-with-body \
|
|
--user "${OWNER}:${TOKEN}" \
|
|
--upload-file "$rpm" \
|
|
"${FORGEJO_URL}/api/packages/${OWNER}/rpm/upload"
|
|
done
|
|
|
|
- name: Clean up build artifacts
|
|
if: always()
|
|
run: |
|
|
rm -rf "${HOME}/mock-results"
|
|
rm -rf "${HOME}/rpmbuild/SRPMS"
|