Fix mock: use custom config with extra repos instead of --shell injection

The --init/--shell/--no-clean approach caused a corrupted RPM database
in the chroot. Instead, generate a custom mock config that includes
both the Forgejo package registry and the xlibre Copr repos directly
in config_opts['yum.conf'] before the chroot is created. This is the
standard, reliable way to add extra repositories to mock.
This commit is contained in:
Anders da Silva Rytter Hansen 2026-05-27 13:14:52 -03:00
commit d357aae360

View file

@ -50,18 +50,29 @@ jobs:
- name: Build RPM with mock
run: |
cat > /tmp/mock-custom.cfg <<'MOCKEOF'
include('/etc/mock/alma+epel-10-x86_64.cfg')
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 alma+epel-10-x86_64 \
--init
FORGEJO_REPO=$(curl -fsSL https://pc-rytteren.dk/forge/api/packages/anders/rpm.repo)
COPR_REPO=$(curl -fsSL "https://copr.fedorainfracloud.org/coprs/g/xlibre/xlibre-xserver/repo/rhel+epel-10/group_xlibre-xlibre-xserver-rhel+epel-10.repo")
mock \
--root alma+epel-10-x86_64 \
--shell "mkdir -p /etc/yum.repos.d && echo '${FORGEJO_REPO}' > /etc/yum.repos.d/sonicde.repo && echo '${COPR_REPO}' > /etc/yum.repos.d/xlibre-xserver.repo"
mock \
--root alma+epel-10-x86_64 \
-r /tmp/mock-custom.cfg \
--resultdir "${HOME}/mock-results" \
--no-clean \
--rebuild "${{ env.SRPM_PATH }}"
- name: Upload RPMs to Forgejo Package Registry